Go to Post make your robot so it's not a problem and it won't be a problem - pfreivald [more]
Home
Go Back   Chief Delphi > Technical > Technical Discussion
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Spotlight this post!  
Unread 16-01-2002, 20:26
Joe Johnson's Avatar Unsung FIRST Hero
Joe Johnson Joe Johnson is offline
Engineer at Medrobotics
AKA: Dr. Joe
FRC #0088 (TJ2)
Team Role: Engineer
 
Join Date: May 2001
Rookie Year: 1996
Location: Raynham, MA
Posts: 2,648
Joe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond repute
This is easily done...

Suppose you have a switch called p1_trig.

Suppose that you have 2 variables called Left_wheels and Right_wheels that are bytes that you output to the appropriate PWM channel to make the wheels go round.

Then the following code turns your joysticks around (in a sense) in that what used to make your robot go forward will now make it go backward.

Just Prior to the output statement put:
.
.
.
If p1_trig = 0 then DoNothing
Left_wheels = 254 - (Left_wheels MAX 254)
Right_wheels = 254 - (Right_wheels MAX 254)
DoNothing:
.
.
.

Joe J.

P.S. The MAX 254 takes care of the case when you may have (foolishly) set a PWM value to 255. This may cause trouble for the master CPU if you actual DO set a value of a PWM to 255, but that is only a possibility. It is a certainty that a value of 255 will cause the transformation above to make an error if you don't have the MAX 254 bit. Why? Well, thing about it. 255 probably was intended to make the machine go as fast as possible FORWARD. So, in the transformed case you want the robot to go as fast as possible REARWARD. Now, if you stuff in 255 without the MAX 254 stuff, the value of 255 will yield -1 which using the magic of 16 bit unsigned math will transform to 255 -- so... the robot will go Full FORWARD -- not the drive intended because they intended the machine to be going Full REVERSE. I am not sure I made that very clear but it will have to do for now. JJ.

P.P.S Don't try using this
Left_wheel = 254 - Left_wheel MIN 0
Trust me, this will not yield the desired result. JJ
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
how do i control a piston with a joystick Ryan Foley Programming 2 27-05-2003 17:13
Fried program slots? Jeff Waegelin Programming 18 19-03-2003 18:08
question about one joystick drive programing james700 Programming 13 29-01-2003 14:49
robot goes haywire with the one joystick default code Miles Programming 7 24-01-2003 14:58
joystick problem archiver 2000 12 23-06-2002 23:08


All times are GMT -5. The time now is 05:35.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi