farouk_baya
Joined: 18 Jun 2010 Posts: 27
|
PWM 16f877a |
Posted: Wed Aug 25, 2010 3:55 pm |
|
|
I use L298 + 16f877a.
When I tested the L298 it works fine. I put 5v to input Enables to test it.
Code: |
#include "16F877.h"
#fuses XT,PUT, NOWDT, NOPROTECT, BROWNOUT, NOLVP
#use delay(clock = 4M)
main()
{
int8 x=0;
output_low(PIN_C2);
setup_ccp1(CCP_PWM);
setup_timer_2(T2_DIV_BY_4,249, 1); // 1000 Hz
set_pwm1_duty(62);
while(1)
{
if (x==249)
{
x=0;
}
else
{
x=x+10;
}
set_pwm1_duty(x);
delay_ms(2000);
}
} |
The problem that I hear a sound from the motors but nothing is happening.
thanks for help. |
|
nilsener
Joined: 06 Dec 2005 Posts: 59
|
|
Posted: Fri Aug 27, 2010 1:59 am |
|
|
as you increment x by 10 (x=x+10;), x will never be 249 and your
Code: |
if (x==249)
{
x=0;
}
|
will never be entered. Try
Code: |
if (x > 249)
{
x=0;
}
|
or something similar.
I think this is not the reason why your motor is not running, but worth to check. |
|