In this project I am using a baby-O to control the motor rpm of a brushless FAN motor.
The motor has 4 magnets and 4 coils, there is a HALL sensor which detects the position of the magnets, as soon as the HALL is interrupted we look into the direction of the field and decide to change the direction of the “motor”
I used the Pololu LV168 Demo3 example and the motor outputs to control 4 FET’s in a H-bridge. The avg routine where it sets the motor rpm was moved to the interrupt routine and the if where the motor direction is decided was modified to readout the value of PDD2 (INT0)
Appnote AVR 442 was very useful in setting up the FAN control with the Hall sensor
Appnote AVR 221 supplied me the needed PID controlling function
The FAN is running at 1700 rpm on 7,6V supply and reacting very well on PID settings for Kp, Ki and Kd.
In this example I have used the same number of coils as magnets so the motor does not start from itself. This increases the ability to change motor rpm a lot, in a normal motor spooling down can take some time, this one is very fast.
The next version will incorporate a Pololu motor driver, this setup was to prove the concept.
I have not quite understood the setting up of the pwm, when I need full throttle I have to set pwm to a maximum value of 511, in the comment it says /2 which is ok as w use an 8 bit timer, in the code I do not see the division. Can anyone explain me where this division takes place?
Original code in the demo3 software:
M1_FORWARD((511 - avg) >> 1); // M1 speed = (511 - avg) / 2
PID 4_8V fan.pdf (408 KB)