View Single Post
  #9   Spotlight this post!  
Unread 01-01-2004, 21:46
EricS-Team180's Avatar
EricS-Team180 EricS-Team180 is offline
SPAM, the lunchmeat of superheroes!
AKA: Eric Schreffler
FRC #0180 (SPAM)
Team Role: Engineer
 
Join Date: Apr 2002
Rookie Year: 2001
Location: Stuart, Florida
Posts: 561
EricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond repute
Re: hey need some help with writing a code please help me here

...painful experience has taught me that if you are going to reverse the motor in software, first, limit the pwm from 1 to 254. Then subtract that value from 255.

so in c...
/*
** Max the PWM ...see p 51. in Kernighan and Richie :"the c programming
** language"
*/
pwm02 = (pwm02 <= 254) ? pwm02 : 254 ;
/* Min the PWM*/
pwm02 = (pwm02 >= 1 ) ? pwm02 : 1 ;
/* reverse it in software */
pwm02 = 255 - pwm02 ;

...or with if's

if ( pwm02 > 254)
{
pwm02 = 254 ;
}
else if (pwm02 < 1)
{
pwm02 = 1 ;
}
pwm02 = 255 - pwm02 ;

Or, we've also reversed the wiring on the motor


But, we prefer to reverse it in software.

Really though, since Anthony and echos code hardwires the values, you know that you don't have to protect for a rollover and can get away with
pwm02 = 254 - pwm02.


Thanks,
Eric
__________________

Don't PANIC!
S. P. A. M.