Designing a MCU-driven permanent magnet BLDC motor controller: Part 3
Before continuing with the explanation started in Part 2 of the switched-mode operation, the timer and timing system for the ST7MC motor control cell needs explanation. All motor timing is driven by one central up-timer/counter clocked via a pre-scaler.The pre-scaler value is determined by a 2n+1 factor, with n being the pre-scale register value. Therefore, a pre-scaler register value of 4 will select a pre-scale value of "divide by 32" (24+1) of the peripheral clock.
Once the timer is started, the mechanism to change the pre-scaler value is limited to a single increment/decrement at the time the timer is reset and cannot be directly written by software. This is an important point when discussing the method used to blindly step the motor during the switched-mode.
The central timer is not simply a free running timer. This timer is reset to zero at certain points depending upon the mode of operation: switched mode or auto-switched mode.
During switched mode there are no reliable zero crossing events so the rotor position is not known. As a result the timer is based on and reset by the commutation event interrupt.
Once the rotor is spinning and reliable zero crossing events are occurring the commutation timing is transferred to auto-switched mode. During auto-switched mode the timer is based on and reset by the Z-event controller interrupt
When changing from switched mode to auto-switched mode, special considerations must be made as the timer's reset point will change between the two modes.
Each of the three events (Commutation, Demagnetization, and Zero Crossing) has a corresponding timing register. These registers are not actual timer/counters but rather contain time values that are related to the central timer.
The timing registers are called timers in the sense that they set or measure a length of time based on the time base of the central timer. The Commutation timer sets a time when the controller should step to the next phase.
When the central timer matches the time value in the Commutation timer, a commutation event occurs. The Demagnetization timer sets a time value when the controller should expect the current in the unused phase to have decayed after a commutation event.
When the central timer matches the time value in the Demagnetization timer, a demagnetization event occurs. The Zero Crossing timer measures a time value when the controller detects a zero crossing event. When a zero crossing event occurs, the value of the central timer when the event occurred is stored in the Zero Crossing timer register.
At start-up, the motor will begin spinning by controlling the active phase and time duration "manually" for each step. A commutation event will occur when the programmed step time has elapsed.
At that point the central timer is reset and a new value is loaded into the commutation timer register. The Demagnetization event will then occur based on the time loaded into the demagnetization timer.
The demagnetization timer will simply be loaded with one-forth of the time value used for commutation which should be more than adequate for most applications. The interrupt service routine:
@interrupt void MTC_C_D_IT(void)
manages both the Commuation and Demagnetization Events.
Two tables are used to determine which phase outputs are active and how long each step will take:
const UInt8
PHASE_CONFIG[ PHASE_CONFIG_SIZE ]
and
const Step_s
RAMP[ STEP_RAMP_SIZE ].
The PHASE configuration table contains six steps. Each step defines which two phases are driven and which phase is used to sense BEMF. The order of the elements in the PHASE_CONFIG table are reversed to make the motor spin in reverse.
The second table, RAMP, contains the "stepping blind" parameters.
This table contains an array of structures. The step's structure is
used to contain the step time and its associated pre-scaler.


Loading comments... Write a comment