Hi,
I am using KV58 to control BLDC with hall sensors. Could you tell me if there is any demo application?
Now, I only have the senseless sample and I want to figure out commutation table for hall sensor based?
Thanks,
Christie
Hi Christie,
There is no official BLDC with hall sensors example. You can refer to the following application note which uses TWR-56F8257 and TWR-MC-LV3PH Boards.
BLDC Motor Control with Hall Sensors Driven by DSC
You can download the code from the following link.
https://www.nxp.com/docs/en/application-note-software/AN4413SW.zip
Aldo, I would recommend you to check the following community post where gives more tips about how to set this example to a TWR-KV58F board.
https://community.nxp.com/thread/456465
Hope it helps!
Have a great day,
Felipe
-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!
- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------
Hi Felipe,
I can use phase A(U), B(V), C(W) to drive my DC motor. And I am using FTM1_Ch0/1 and FTM2_Ch0 to read three hall sensor status like: 4-->6-->2-->3-->1-->5. Then I converted to 0~~5 in order to use the table in sample project:
/* Commutation table */
const uint16_t bldcCommutationTableComp[16] = {
/* mask, swap */
0x0440, 0x0040, /* [0] - sector 0 */
0x0220, 0x0400, /* [1] - sector 1 */
0x0110, 0x0400, /* [2] - sector 2 */
0x0440, 0x0004, /* [3] - sector 3 */
0x0220, 0x0004, /* [4] - sector 4 */
0x0110, 0x0040, /* [5] - sector 5 */
0x0000, 0x0440, /* [6] - alignment vector (combination of sectors 0 & 1) */
0x0770, 0x0000 /* [7] - PWM off */
};
To get mask and swap. Then call the function in sample:
bool_t MCDRV_FtmSetPwmOutput(mcdrv_ftm_pwm3ph_t *this, int16_t i16Sector)
{
s_statusPass = TRUE;
this->pui32PwmBase->INVCTRL = *((this->pcBldcTable) + (2 * i16Sector + 1));
this->pui32PwmBase->OUTMASK = *((this->pcBldcTable) + (2 * i16Sector));
this->pui32PwmBase->SYNC |= (FTM_SYNC_SWSYNC_MASK);
return (s_statusPass);
}
But, my BLDC motor is not running.
Could you tell me where the possible reason is? It is related to PWMA initialization?
Do you have sample code for PWMA initialization for BLDC motor by using API?
Thanks,
Christie
Hi Christie,
For PWMA initialization you can refer to the InitPWMA0(); function in MC_BLDC example from de SDK.
Best regards,
Felipe
Hi Felipe,
Do you have any BLDC initialization sample by using your SDK PWM API?
Thanks,
Christie
Hi Christie,
Have you checked MC_BLDC example? This example use InitPWMA0() API. This function is called by M1_MCDRV_PWM_PERIPH_INIT(); in mcdrv_twrkv58f220m.c file.
You can download Motor Control Examples from the following page.
https://mcuxpresso.nxp.com/en/welcome
Regards,
Felipe
Hi Felipe,
Thank you for your information. Now, I can run my BLDC motor. But I have the following questions:
Based on commutation table in sample:
const uint16_t bldcCommutationTableComp[16] =
{
0x0440, 0x0040, // [0] - sector 0(Hall Sensor=100)---MASK A2 & B2(Phase C), Swap Phase B
0x0220, 0x0400, // [1] - sector 1(Hall Sensor=110)---MASK A1 & B1(Phase B), Swap Phase C
0x0110, 0x0400, // [2] - sector 2(Hall Sensor=010)---MASK A0 & B0(Phase A), Swap Phase C
0x0440, 0x0004, // [3] - sector 3(Hall Sensor=011)---MASK A2 & B2(Phase C), Swap Phase A
0x0220, 0x0004, // [4] - sector 4(Hall Sensor=001)---MASK A1 & B1(Phase B), Swap Phase A
0x0110, 0x0040, // [5] - sector 5(Hall Sensor=101)---MASK A0 & B0(Phase A), Swap Phase B
0x0000, 0x0440, // [6] - alignment vector (combination of sectors 0 & 1)---No MASK, Swap Phase B&C
0x0770, 0x0000 // [7] - PWM off------MASK A2&A1&A0 & B2&B1&B0(Phase A&B&C), No Swap
};
1) If I want to switch the direction, can I just change the sequence?
2) I need to switch the voltage from + to '-' in order to switch the direction because I saw this in your BLDC controller application?
If I just switch the sequence of commutation table, it won't work? I have to switch voltage?
ex: 0x0440, 0x0040, // [0] - sector 0(Hall Sensor=100)---MASK A2 & B2(Phase C), Swap Phase B---For CW
0x0440, 0x0004, // [0] - sector 0(Hall Sensor=100)---MASK A2 & B2(Phase C), Swap Phase A---For CCW
What is the better way to do the direction switching?
Thanks,
Christie
Hi Felipe,
I have the following problem during my BLDC testing:
I tried to do commutation first, then set duty of PWM, I am always going the opposite direction first for short time, then go back to the right direction. Is there any way to avoid this? Any idea, why?
Thanks,
Christie
Hi Christie,
I am sorry for my late reply.
Could you please verify if the hall sensors are reading correctly during the time the motor goes to the opposite direction?
Also, please double check the position of the sensors as they must be placed at 120 degrees apart around the rotor.
Best regards,
Felipe
Hi Felipe,
I apply the 90% PWM for CW direction and 100%-90% = 10% PWM for CCW to three phase based on the same commutation sample and works fine for now.
One more question: When I move the motor in CW and CCW with the same PWM duty, I can see CCW direction is much slower than CW direction...
Could you tell me if you experience the same issue and how to fix it?
Thanks,
Christie
Hi Christie,
You shouldn’t have this behavior when changing to CWW direction.
Could you please explain how are you setting the table for CCW direction? Are you reversing the polarity of the phases? Please take a look to the following video to see an explanation on how to make commutation table for CW and CCW direction.
I hope it helps!
Best regards,
Felipe
Hi Felipe,
I am using the same commutation table and change the PWM duty for V+ or V-.
Ex. For CW, I am using 90% of PWM duty to apply to 3 phases and SWAP or MASK based on table.
For CCW, I am using 10% of PWM duty to apply to 3 phases and SWAP or MASK based on table.
It works fine for both directions. Only problem is now that CCW speed is much slower than CW when I applied 90% of PWM. It is getting closer when I applied 50% of PWM.
I am not sure what the reason is? Maybe, it is related to hall sensor alignment?
Thanks,
Christie
Hi Christie,
That may be one reason. Please double check the position of the sensors as they must be placed at 120 degrees apart around the rotor.
Regards,
Felipe
Hi Felipe,
I got lots of noise from hall sensor to cause the commutation issue.
Is there any way to filter the noise on hall sensor from MCU or signal?
Thanks,
Christie
Hi Christie,
You could try with a bypass capacitor or a RC Low Pass Filter and see how it works. I recommend you to check your sensor's specifications.
Best regards,
Felipe
Hi Felipe,
After adding some filtering on hall sensors, it works fine. Thanks.
I had the following issue now:
1) I am trying to use the ramp control to add the power slowly and causes the motor start-up problem. Sometime, I can't start motor even with full power applied on it. When it is the low power, motor keeps bouncing back and force...
2) If I applied full power, no ramp control, it works fine...
Do you experience the similar issue and how to fix it?
Thanks,
Christie
Hi Christie,
As this question is different from the original question of this post. Could you help me creating another community thread for this question?
Best regards,
Felipe
No problem.