View Full Version : help programming
aZnXsa1Nt
17-12-2002, 01:11
hey this is Mark from the rookie Mission San Jose Team 1045.
I was wondering how I could go about programming the edubot- for example, in our current setup we have it running off one joystick. How would i use 2, one to control each motor? Where would i find the code?
Thanks for any assistance.
Lloyd Burns
17-12-2002, 07:57
Last night, our "EduBot" group played with the Kit for the first time. I had one joystick from a previous year, and started with that. With no computer handy to program the beast and with one joystick, in Port 1, we had p1_y (which controls PWM1 and PWM3 on the ISAAC robot controller, and p1_x, which controls PWM5. These assignments are in the IFI manual.
We had one motor facing east, one west. the East facing motor was connected to PWM1, the West facing to PWM5. Then the fun began : with the joystick at 45 degrees, a push forward into a "corner" gave forward motion with both wheels turning in the same direction, and aft motion came from pulling back to the opposite corner. turning was done in the alternate corners, but you had to push the stick the way the back of the robot was to go while it was turning (relative to the far side of the bot. This was all pretty IFI (iffy :-)).
You _can_ use two sticks to steer your bot, with the stock program, else you _must_ program. The following is the "fix" suggested in the 1998 manual, modified for motors you can't reverse by wiring :
In the SEROUT statement in the mini-RC, program the PWM1 variable with
(((2000 + p1_y - p1_x + 127) Min 2000 Max 2254) - 2000)
and the PWM5 with
(((2000 + p1_y + p1_x -127) Min 2000 Max 2254) - 2000)
[The minus in front of the p1_y and the + 127 should correct the reversed direction on one side.]
If it isn't right, change which motor goes to which pwm connection. I just made the correction up, so I'm not sure it'll work, but its a point of departure.
seanwitte
17-12-2002, 09:02
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
Lloyd Burns
17-12-2002, 09:21
I just noticed in the manual, that PWM1 gives CCW rotation of the moter, while PWM5 gives CW rotation, so I edited my previous post back to the original 1988 suggestion.:eek:
BTW, seanwitte, to reverse a joystick direction in PBASIC, use
p1_y = 254 - p1_y
because
if p1_y is 254, it becomes 000,
if p1_y is 127, it remains 127,
if p1_y is 000, it becomes 254.
The OI programming will not allow sending an analog value greater than 254 because 255 is used as a syncing signal (Serin starts with 255,255, waiting for two $FF = x00FF = 255d bits before starting to accept data for its following parameters.
LATEST NEWS
Even better - download the pdf re default program guide from www.innovationfirst.com and see what they have to say about switch input SW5 on ISAAC.
It gives you one-stick drive. checkit out !!!
Originally posted by Lloyd Burns
LATEST NEWS
Even better - download the pdf re default program guide from www.innovationfirst.com and see what they have to say about switch input SW5 on ISAAC.
It gives you one-stick drive. checkit out !!! [/B]
Not only that, using SW 8 you have pre-programmed limit switches. I think it's 6 that reverses all inputs and 7 does something else useful, but I forget what.
Never hurts to read the manual.
Jeremy_Mc
17-12-2002, 15:00
It's SW 1, 6, 5, and 8.
If anyone needs help programming, feel free to e-mail me or PM me and I'll do my best to help.
vBulletin® v3.6.4, Copyright ©2000-2017, Jelsoft Enterprises Ltd.