View Single Post
  #12   Spotlight this post!  
Unread 22-09-2005, 18:44
RIgnazio RIgnazio is offline
Registered User
no team
Team Role: Webmaster
 
Join Date: Jan 2005
Rookie Year: 2004
Location: .
Posts: 45
RIgnazio will become famous soon enough
Exclamation Re: Autonomous Code trouble

Even though the comment says that it is a 26.2ms Loop area (I think it was 26.2?) it is in fact 40ms. The autonomous loop runs in 26.2ms space, but your code actually runs in 40ms space.

What I do to keep from getting confused is this:
Quote:
#define second 40
#define tenth_second 4

//IFI code goes here
unsigned int autonomous_clock;

if (autonomous_clock < ((2*second) + (4*tenth_second))
{
pwm01 = 254;
pwm02 = 254;
}
else
{
pwm01 = 127;
pwm02 = 127;
}

++autonomous_clock; //adds 1 to the autonomous_clock count
I forget if the default code uses pwm_max, pwm_min, or pwm_neutral, but my code did. I merely use pwm_max as 254, pwm_neutral as 127, and pwm_min as 0

Hope this helps.