Hi,
I run the BLDC well in anti-clockwise with the help of AN4704.
But when I try to run the motor in clockwise,it failed.
How can i run the motor in both direction?
Can anyone give me a tip to modify the source code?
It maybe be an easy work.
The key is MaskVal[6], OutCtl[6], BemfPhase[6].
Hi,
For clockwise direction, please do following modifications:
For motor, please, keep this phase wires connection:
Connector J24, PHASE 1: blue
Connector J24, PHASE 2: white
Connector J24, PHASE 0: green
For Hall sensor, please, keep this wires connection:
Connector J11-1: red
Connector J11-2: black
Connector J11-3: white
Connector J11-4: green
Connector J11-5: blue
Then, please modify MaskVal[6], OutCtl[6], BemfPhase[6] in software example:
const char MaskVal[2][6] = {{0x34, 0x1c, 0x13, 0x31, 0x0d, 0x07}, {0x31, 0x13, 0x1c, 0x34, 0x07, 0x0d}};
const char OutCtl[2][6] = {{0x0c, 0x30, 0x30, 0x03, 0x03, 0x0c}, {0x03, 0x30, 0x30, 0x0c, 0x0c, 0x03}};
const char BemfPhase[2][6] = {{0x03, 0x02, 0x01, 0x03, 0x02, 0x01}, {0x03, 0x01, 0x02, 0x03, 0x01, 0x02}};
const uint8_t BLDCPatternBasedOnHall[2][7] = {{0, 4, 0, 5, 2, 3, 1},{0, 2, 0, 1, 4, 3, 5}};
Use variable "direction" to select CW or CCW and apply BLDCPatternBasedOnHall in function:
INTERRUPT void TIMchan1_ISR(void)
{
...
ActualCmtSector = BLDCPatternBasedOnHall[direction][hallPattern];
...
}
void AppAlignmentToStart(void)
{
...
ActualCmtSector = BLDCPatternBasedOnHall[direction][hallPattern];
...
}
Last and very IMPORTANT step:
Please, open Jumper J9 otherwise it will affect Hall signal
Regards,
Marek