Stamps coding, FIRST robotics motor control question
I am a STAMPS newbie working on a FIRST robotics problem and running out of
time.
The challenge is to use the code to match the speeds of two different motors.
For starters, we assume that the motors will respond in a linear way to PWM
pulse width, both with and without load. Comments welcomed.
We have a tachometer. The formula below does slow the motor, but not by the
predicted amount.
At this point in the program, the joysticks produce a number from 1-255, 1-126
is forward, 127 is stop, 128-255 is reverse.
I have three questions:
1. will the attached code snippet work? (I'm aware that it could be more
compact)
2. why do the debug statements pass the syntax check and then go on to cause
Basic Runtime errors on the robot (now commented out)?
3. Any comments on my thinking about controlling the motor speeds?
p1_y (byte) is the signal derived from a joystick and being sent to the Victor
883 blue connected to the 12v Bosch drill motor driving the right rear wheel.
(4 amps draw at no load, 280 watts rated at full load)
p3_y is the right front, driven by a motor from a 12v Fisher Price Jeep.
(2 amps draw at no load, 200 watts rated full load)
The gear ratios dictate a requirement that the Bosch motor be slowed to
approximately 2/3 of the speed of the Fisher Price motors. The motors are
coupled only buy their wheel contact with the playing surface.
' STAMPS II code
' Set Fisher Price Motors to be the same as Drill motors
p3_y=p1_y
p4_y=p2_y
' Adjustment to slow drill motors to match speed of Fisher Price Motors
' Right hand wheels
' debug dec " input value p1_y ",p1_y
' pause 1000
' debug cls
IF p1_y >= 127 THEN gopast10 ' use this code when P1_y is < 127
p1_y = 127 - p1_y ' gives fwd speed
p1_y = 127 - p1_y + (p1_y / 3) ' reduces fwd speed by 1/3 and recenters
' debug dec p1_y ," fwd result right hand wheels "
' pause 1000
' debug cls
gopast10
IF p1_y <= 127 THEN gopast11 ' use this code when P1_y is > 127
p1_y = p1_y - 127
p1_y = p1_y - (p1_y / 3) + 127
' debug dec p1_y ," bkwd result right hand wheels "
' pause 1000
' debug cls
gopast11
Thanks,
Charlie Affel, team 487, caffel@a...
time.
The challenge is to use the code to match the speeds of two different motors.
For starters, we assume that the motors will respond in a linear way to PWM
pulse width, both with and without load. Comments welcomed.
We have a tachometer. The formula below does slow the motor, but not by the
predicted amount.
At this point in the program, the joysticks produce a number from 1-255, 1-126
is forward, 127 is stop, 128-255 is reverse.
I have three questions:
1. will the attached code snippet work? (I'm aware that it could be more
compact)
2. why do the debug statements pass the syntax check and then go on to cause
Basic Runtime errors on the robot (now commented out)?
3. Any comments on my thinking about controlling the motor speeds?
p1_y (byte) is the signal derived from a joystick and being sent to the Victor
883 blue connected to the 12v Bosch drill motor driving the right rear wheel.
(4 amps draw at no load, 280 watts rated at full load)
p3_y is the right front, driven by a motor from a 12v Fisher Price Jeep.
(2 amps draw at no load, 200 watts rated full load)
The gear ratios dictate a requirement that the Bosch motor be slowed to
approximately 2/3 of the speed of the Fisher Price motors. The motors are
coupled only buy their wheel contact with the playing surface.
' STAMPS II code
' Set Fisher Price Motors to be the same as Drill motors
p3_y=p1_y
p4_y=p2_y
' Adjustment to slow drill motors to match speed of Fisher Price Motors
' Right hand wheels
' debug dec " input value p1_y ",p1_y
' pause 1000
' debug cls
IF p1_y >= 127 THEN gopast10 ' use this code when P1_y is < 127
p1_y = 127 - p1_y ' gives fwd speed
p1_y = 127 - p1_y + (p1_y / 3) ' reduces fwd speed by 1/3 and recenters
' debug dec p1_y ," fwd result right hand wheels "
' pause 1000
' debug cls
gopast10
IF p1_y <= 127 THEN gopast11 ' use this code when P1_y is > 127
p1_y = p1_y - 127
p1_y = p1_y - (p1_y / 3) + 127
' debug dec p1_y ," bkwd result right hand wheels "
' pause 1000
' debug cls
gopast11
Thanks,
Charlie Affel, team 487, caffel@a...