i’m trying to use a pot to limit a motor to turning only 90 drgrees. I need to know what the value that is stored in the sensor variable represents and how to prevent the motor from turning ( the motor will likely be run through a victor). also, is their a way that i can have the program slow down the motor as it approaches the end of a 90 degree turn?
one way to do it is just to turn your motors off at 90 degrees and to limit them to a lower amount at some lesser amount.
Try the following (as always, off the top of my head, untested but probably not too far from correct)
’ assume right joystick movement turns motor right, left turns it left.
’ assume steering motor is wired such that PWM1 > 127 moves steering left
’ assume pot is wired such that Sensor1 >127 means steering is pointed left
’ assume pot is adjusted such that Sensor1 = 127 means straight
'assume you enter the code below with p1_x as your variable that holds the joystick value that you what to use to steer
'assume that the output statement uses p1_x as the output to PWM1
Sensor1FullLeft CON 127 + 100 ’ approx value, yours may vary
Sensor1SlowRight CON 127 + 50
Sensor1SlowLeft CON 127 - 50
Sensor1FullRight CON 127 - 100
PWMSlowRight CON 127 - 50 ’ adjust to suit
PWMSlowLeft CON 127 + 50 ’ adjust to suit
If sensor1 < Sensor1FullRight StopSteerMotor
If sensor1 < Sensor1SlowRight SlowRightSteerMotor
If sensor1 > Sensor1FullLeft StopSteerMotor
If sensor1 > Sensor1SlowRight SlowLeftSteerMotor
p1_x = 127
p1_x = PWMSlowRight
p1_x = PWMSlowleft
Hope this helps.
If I get a chance, I will post a better way later.