Posted by Josh at 1/13/2001 6:14 PM EST
Student on team #158, Cobras, from Live Oaks and SDRC.
In Reply to: Single Joystick Tank Steering
Posted by Josh on 1/12/2001 7:20 PM EST:
The version I currently have of the program comes from
http://www.innovationfirst.com
I was creating my own version of this until I found out about this one. I stopped working on my own version because it was a lot longer. Right now, I can send you the one from Innovation First, but not mine because I did not get good test result from using it. The difference between the versions is this: Innovation First's is less code, but it calculates in a way that goes beyond PWM limits. This was fixed using Min and Max commands. My version would be more accurate and true to the position the joystick is in. It would basically have smoother transitions from full forward to forward and right. The calculations would not need Min and Max commands because they would not exceed the boundaries.
Here is the code from Innovation First.
1) Start with a FIRST default program from this year. Previous versions of the program may also work.
2) Declare these variables in the DECLARE VARIABLES section.
PWM1 VAR byte 'define variable for left wheel PWM
PWM2 VAR byte 'define variable for right wheel PWM
3) Add this to the CUSTOM CODE section
PWM1 = (((2000 + p1_y - p1_x + 127) Min 2000 Max 2254) - 2000)
PWM2 = (((2000 + p1_y + p1_x - 127) Min 2000 Max 2254) - 2000)
4) If necessary, change the SEROUT command so that PWM1 and PWM2 are in the correct places.
That's it, you're done.
If you would like my code, email me in about a week and I should be done with it. When I did my testing, the controls were very touchy going forward, but normal going backward. This was the same for both versions of the SJTS system. This is an indication of a bad potentiometer in the joystick. More testing to come.