View Single Post
  #3   Spotlight this post!  
Unread 17-12-2002, 09:02
seanwitte seanwitte is offline
Registered User
None #0116
Team Role: Engineer
 
Join Date: Nov 2002
Location: Herndon, VA
Posts: 378
seanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant future
Send a message via AIM to seanwitte
trick to account for motor orientation

When you build a robot with the EDURobotics kit, the motors will probably not be mounted with the same orientation. Say you define the following variables and constants:

vDriveRight VAR BYTE 'value passed to right-hand motor
vDriveLeft VAR BYTE 'value passed to left-hand motor
cForward CON 200 'PWM value to go forward
cNeutral CON 127 'PWM value to stop moving

If you set both of the motors to cForward, the robot will rotate in place because they'll be moving in opposite directions. Its easier to write the code assuming they move in the same direction, so just adjust the one that in reverse right before pass the values to SEROUT. That way if you set them both to go forward, the robot will go forward.

--> Edited
I stand corrected, per the reply. To adjust the motor thats mounted in the reverse direction, subtract its value from 254 before you pass it to the SEROUT command instead of taking the bitwise ~ of it.

vDriveRight = 254 - vDriveRight
SEROUT USERCPU, OUTBAUD, [255,255,vDriveLeft,0,vDriveRight

Last edited by seanwitte : 17-12-2002 at 10:57.