CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

PWM 16f877a

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
farouk_baya



Joined: 18 Jun 2010
Posts: 27

View user's profile Send private message

PWM 16f877a
PostPosted: Wed Aug 25, 2010 3:55 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Aug 27, 2010 1:59 am     Reply with quote

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.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group