When using PIC to control DC
motor, the motion of motor such as forward, reverse,and speed of
rotation can be programmed. If the motion of motor only required forward
and reverse without considering the speed of rotation, motor can be
control through relay module. the are two example of relay module which
can be use by PIC to control DC motor. First figure is to control only
On and OFF of motor which also compatible to other devices that are
using switch. Second figure can be used to control forward and reverse
motion of DC motor.
By
using relay module, it is very easy to control the motion of motor. The
programming part only require ON and OFF of output PORT.
Example of simple forward reverse motor control using 2 switches connected to RD0 and RD1:
main()
{
while (1)
{
TRISD = 0b00000011;
PORTB = 0b00000000;
TRISB = 0b00000000;
PORTB = 0b00000000;
if (PORTDbits.RD0 == 1 && PORTDbits.RD1 == 0)
PORTB = 0b00000010;
if (PORTDbits.RD0 == 0 && PORTDbits.RD1 == 1)
PORTB = 0b00000010;
else
PORTB = 0b00000000;
}
}
When
DC motor require speed control, the speed of DC motor can be control by
various techniques including Pulse Width Modulation (PWM), power
transistor, driver IC etc. The diagram below is example of DC motor
controlled by transistor and PWM.
Whenever
there is input voltage supplied to Base pin of the transistor, the
transistor will turned ON and let the current flow through. with
different speed of PWM provided, the speed of motor can be adjusted. The
faster the PWM signal, the faster the motor will rotate.
No comments:
Post a Comment