atom06
Newbie level 3
l6203 dc motor
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=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.
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=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.