Skip to content

File syn_bldc_6step.c

FileList > motor > syn_bldc_6step.c

Go to the source code of this file

Zero-Heap 6-Step (Trapezoidal) BLDC Motor Commutation Driver Implementation.

  • #include "syntropic/motor/syn_bldc_6step.h"

Classes

Type Name
struct PhaseGatePattern
3-phase gate driving state pattern per commutation step.

Public Static Attributes

Type Name
const PhaseGatePattern s_step_table_ccw = /* multi line expression */
const PhaseGatePattern s_step_table_cw = /* multi line expression */

Public Functions

Type Name
SYN_Status syn_bldc_6step_get_phase_outputs (const SYN_BLDC_6Step * bldc, SYN_BLDC_PhaseOutputs * out)
Retrieve current 3-phase gate output states.
SYN_Status syn_bldc_6step_init (SYN_BLDC_6Step * bldc, const SYN_BLDC_Config * cfg)
Initialize 6-Step BLDC driver instance.
SYN_Status syn_bldc_6step_set_direction (SYN_BLDC_6Step * bldc, SYN_BLDC_Direction dir)
Set motor rotation direction.
SYN_Status syn_bldc_6step_set_duty (SYN_BLDC_6Step * bldc, uint16_t duty_0_to_1000)
Set PWM duty cycle for motor speed control.
SYN_Status syn_bldc_6step_set_hall (SYN_BLDC_6Step * bldc, uint8_t hall_state, SYN_BLDC_PhaseOutputs * out)
Process 3-bit Hall sensor reading and update 6-step phase commutation gates.
SYN_Status syn_bldc_6step_start (SYN_BLDC_6Step * bldc)
Start motor driver (enable gate commutation).
SYN_Status syn_bldc_6step_stop (SYN_BLDC_6Step * bldc, SYN_BLDC_PhaseOutputs * out)
Stop motor driver (turn OFF all 6 gates).
uint32_t syn_bldc_6step_update_speed (SYN_BLDC_6Step * bldc, uint32_t now_ms, uint32_t target_rpm)
Update Hall-based speed calculation (RPM) and speed PID loop.

Public Static Attributes Documentation

variable s_step_table_ccw

const PhaseGatePattern s_step_table_ccw[7];

Counter-clockwise commutation step table


variable s_step_table_cw

const PhaseGatePattern s_step_table_cw[7];

Clockwise commutation step table


Public Functions Documentation

function syn_bldc_6step_get_phase_outputs

Retrieve current 3-phase gate output states.

SYN_Status syn_bldc_6step_get_phase_outputs (
    const SYN_BLDC_6Step * bldc,
    SYN_BLDC_PhaseOutputs * out
) 

Parameters:

  • bldc Pointer to driver struct.
  • out Pointer to destination output struct.

Returns:

SYN_OK on success.


function syn_bldc_6step_init

Initialize 6-Step BLDC driver instance.

SYN_Status syn_bldc_6step_init (
    SYN_BLDC_6Step * bldc,
    const SYN_BLDC_Config * cfg
) 

Parameters:

  • bldc Pointer to driver struct.
  • cfg Configuration parameters (or NULL for defaults: 4 pole pairs).

Returns:

SYN_OK on success, SYN_ERR_INVALID_PARAM if bldc is NULL.


function syn_bldc_6step_set_direction

Set motor rotation direction.

SYN_Status syn_bldc_6step_set_direction (
    SYN_BLDC_6Step * bldc,
    SYN_BLDC_Direction dir
) 

Parameters:

  • bldc Pointer to driver struct.
  • dir SYN_BLDC_DIR_CW or SYN_BLDC_DIR_CCW.

Returns:

SYN_OK on success.


function syn_bldc_6step_set_duty

Set PWM duty cycle for motor speed control.

SYN_Status syn_bldc_6step_set_duty (
    SYN_BLDC_6Step * bldc,
    uint16_t duty_0_to_1000
) 

Parameters:

  • bldc Pointer to driver struct.
  • duty_0_to_1000 PWM duty cycle clamped to range 0..1000.

Returns:

SYN_OK on success.


function syn_bldc_6step_set_hall

Process 3-bit Hall sensor reading and update 6-step phase commutation gates.

SYN_Status syn_bldc_6step_set_hall (
    SYN_BLDC_6Step * bldc,
    uint8_t hall_state,
    SYN_BLDC_PhaseOutputs * out
) 

Call this from Hall sensor EXTI GPIO interrupts or input sampling loops.

Parameters:

  • bldc Pointer to driver struct.
  • hall_state 3-bit Hall sensor state (bits [2:0] = H3, H2, H1). Valid: 1..6.
  • out Pointer to output struct to receive new 3-phase gate states.

Returns:

SYN_OK on valid commutation step, SYN_ERR_FAULT if hall_state is 0b000 or 0b111.


function syn_bldc_6step_start

Start motor driver (enable gate commutation).

SYN_Status syn_bldc_6step_start (
    SYN_BLDC_6Step * bldc
) 

Parameters:

  • bldc Pointer to driver struct.

Returns:

SYN_OK on success.


function syn_bldc_6step_stop

Stop motor driver (turn OFF all 6 gates).

SYN_Status syn_bldc_6step_stop (
    SYN_BLDC_6Step * bldc,
    SYN_BLDC_PhaseOutputs * out
) 

Parameters:

  • bldc Pointer to driver struct.
  • out Optional pointer to receive updated OFF gate states.

Returns:

SYN_OK on success.


function syn_bldc_6step_update_speed

Update Hall-based speed calculation (RPM) and speed PID loop.

uint32_t syn_bldc_6step_update_speed (
    SYN_BLDC_6Step * bldc,
    uint32_t now_ms,
    uint32_t target_rpm
) 

Call periodically (e.g. every 10ms or 100ms).

Parameters:

  • bldc Pointer to driver struct.
  • now_ms Current system tick in milliseconds.
  • target_rpm Target motor speed in RPM (used if speed PID is active).

Returns:

Calculated current RPM.



The documentation for this class was generated from the following file src/syntropic/motor/syn_bldc_6step.c