View Single Post
  #3   Spotlight this post!  
Unread 04-02-2003, 01:33
FotoPlasma FotoPlasma is offline
\: |
no team
 
Join Date: Jul 2001
Rookie Year: 2001
Location: San Jose
Posts: 1,900
FotoPlasma has a reputation beyond reputeFotoPlasma has a reputation beyond reputeFotoPlasma has a reputation beyond reputeFotoPlasma has a reputation beyond reputeFotoPlasma has a reputation beyond reputeFotoPlasma has a reputation beyond reputeFotoPlasma has a reputation beyond reputeFotoPlasma has a reputation beyond reputeFotoPlasma has a reputation beyond reputeFotoPlasma has a reputation beyond reputeFotoPlasma has a reputation beyond repute
Send a message via AIM to FotoPlasma
If you're really planning on changing the orientation of the robot, forwards to backwards, you also have to swap the values of the PWM outputs, switching left for right, and vice versa, or else you'll be sending signals meant for the left side of the robot to the right, and signals meant for the right to the left.

I did this operation last year, for our roller/claw robot, first by doing what gwross already pointed out, which is inverting the PWM value around 127, then by XORing the values with eachother to swap them, without going through a third temp variable.

Code:
PWM1 = PWM1 ^ PWM2
PWM2 = PWM1 ^ PWM2
PWM1 = PWM1 ^ PWM2
or

Code:
drive_L = drive_L ^ drive_R
drive_R = drive_L ^ drive_R
drive_L = drive_L ^ drive_R
It worked like a dream, and was fun to implement.
__________________
I played hacky sack with Andy Baker.

2001-2004: Team 258, The Sea Dawgs
2005: Team 1693, The Robo Lobos