| Author |
Message |
atom06
Joined: 02 May 2006 Posts: 3
|
17 Jan 2008 0:07 L6203 DC MOTOR CONTROL PROBLEM |
|
|
|
Hi,
I want to control a 4A DC motor in a bidirectional way with PIC16F877A however,I do not figure out the input pins 5,7 and 11.In some net sites it is stated that input for pin5 and pin 7 must be pwm, however, the square wave for these pins should be inverted form.(see that attachment) In datasheet, I can not see this explanation.
I wrote following program however,it does not work.
The PWM inversion can be done by following schematic however, I do not want to use logic gates.
-------------------------------------------------------------------
#include <16F877.h>
#include <math.h>
#FUSES NOWDT,NOWRT,NOPUT,NOBROWNOUT,NOLVP,NODEBUG
//#FUSES HS //High speed Osc (> 4mhz)
#FUSES NOPROTECT //Code not protected from reading
//#FUSES NOCPD //No EE protection
#use delay(clock=20000000)
#use rs232(baud=57600,parity=N,xmit=PIN_C6,rcv=PIN_C7)
byte input[3];
int i;
void main()
{
while(true)
{
for(i=0;i<3;i++)
{
input[i]=getc();
}
setup_ccp1(CCP_PWM);
setup_timer_2(T2_DIV_BY_16, input[2], 1);
if (input[0]==1)
{
set_pwm1_duty(input[1]);
output_low(PIN_D2);
output_high(PIN_C4);
}
else if (input[0]==0)
{
set_pwm1_duty(input[1]);
output_high(PIN_D2);
output_LOW(PIN_C4);
}
}
}
------------------------------------------------------------------------
The PWM inversion can be done by following schematic however, I do not want to use logic gates.
|
|
| Back to top |
|
 |
laktronics
Joined: 06 Jan 2007 Posts: 832 Helped: 137
|
05 Feb 2008 16:25 Re: L6203 DC MOTOR CONTROL PROBLEM |
|
|
|
Hi,
I think you can control the motor either way. In the data sheet, you drive one input with PWM, keeping the other input at zero and when you want to reverse, the input signals are simply reversed just by changing the direction control signal level; all the time keeping enable high. You can simulate this condition by using two PWM outputs ( a costly alternative) of the micro, keeping one of them at zero state at a time, or use an equivalent logic shown in the data sheet.
In the case of Data sheet circuit, you get full range of PWM for speed control. In the case of the approach shown at the sites, by applying an inverted PWM to one of the inputs, you are driving the motor in push-pull mode and the direction is changed at 50% duty cycle of the PWM, no need to have a separate bit for direction control, but your range of control is reduced to half.
Regards,
Laktronics
|
|
| Back to top |
|
 |
Ngel
Joined: 18 Mar 2008 Posts: 16
|
18 Mar 2008 23:55 L6203 DC MOTOR CONTROL PROBLEM |
|
|
|
Hm, i got an problam that i use a battery mcu dc motor and L6203, when i start the motors the mcu restarts it because that the high current that the motor need and doint a power down on the mcu.
check out that you use two diffrent supply for motor and another for mcu, or just use a big battery.
|
|
| Back to top |
|
 |