Where:
RPM = Desired motor shaft speed
Pole Pairs = Number of motor
poles divided by 2
The code says we need to spin
the BLY171S-24V-4000 motor shaft
at 305 RPM:
tmr5val = 60 / 305 4 6 = 8.2
milliseconds
We can't readily load the raw
8. 3 ms into our PIC18F2431 TMR5
registers. So, we'll have to do a bit
of conversion. We simply need to
convert 8. 3 ms into TMR5 ticks.
Here's what we need to load into
the PR5 registers:
tmr5val = 8.2 ms (FOSC / 4) =
8.2 5000000 = 40984h =
0xA018
The stage is now set to run this
code:
SCREENSHOT 1: This CleverScope capture was taken from the PHASE_C tap.
This trapezoidal pattern is what we ultimately want to see when the BLDC motor
is running at speed. We'll have to ramp up and spin a bit faster to get enough
BEMF for the PIC18F2431's analog-to-digital converter module.
//**********************************************
//* START MODE
//**********************************************
case STARTMODE:
if(voltage < 570)
{
++voltage;
PDC0H = make8(voltage,1);
PDC0L = make8(voltage,0);
PDC1H = make8(voltage,1);
PDC1L = make8(voltage,0);
PDC2H = make8(voltage,1);
PDC2L = make8(voltage,0);
}
break;
Again, I used physical touch coupled with a minimal
current draw to come up with the 570 PWM voltage value.
Right now, all I want to do is smoothly spin the BLDC motor
shaft. So, I dialed in the PWM voltage value for optimal
symmetry of the waveform you see in Screenshot 1. The
initial START mode voltage ramp is controlled by the
tmr5val as the STARTMODE function is called with every
TMR5 interrupt. The rotational speed is very slow and there
isn't enough BEMF being generated to be recognized above
the noise by the PIC18F2431' A-to-D module. However, my
CleverScope picked up the beginnings of the trademark
BLDC motor trapezoidal commutation waveform in
Screenshot 1.
Spinning Out
The BLDC motor controller hardware is verified and the
BLDC motor driver firmware is well along the way to being
viable. The next step is to transition from the START mode
to the RUN mode. I think you have enough BLDC motor
theory in your battery compartment to follow along in the
complete version of the BLDC motor controller code that I'll
put in the download package on the SERVO website (www.
servomagazine.com) along with the ExpressPCB file. SV
Fred Eady can be reached via email at fred@edtp.com.
SOURCES
CleverScope
Saelig
www.saelig.com
A Microchip ICD3 was employed as the
debugging device.
ICD3 Programmer/Debugger
PIC18F2431
MCP6002
MCP6542
TC4428
Microchip
www.microchip.com
NDS9952A
Fairchild Semiconductor
www.fairchildsemi.com
BLY171S-24V-4000 BLDC Motor
Anaheim Automation
www.anaheimautomation.com
The code for the BLDC motor driver is compiled
using HI-TECH PRO for the PIC18 Family.
HI-TECH Software
www.htsoft.com
SERVO 02.2009
51