Overide analog input from joystick with script and then return command to joysti

5 years 11 months ago #29532977 by stanles78
Using a joystick to move an arm. Two axis of motion- CW/CCW and up/down. I cant have it run into a fixed object, so when it gets near the object its location will be given by a certain voltage no an analog input. I then need to override the joystick command and stop one axis of motion and allow the other to remain functional and move above the object until its clear and then reenable both axis. Is this possible. Is there a command to enable/disable a motor if an input is in a certain range. thanks

Please Log in or Create an account to join the conversation.

5 years 11 months ago #29532988 by blake
Yes this is absolutely possible using a simple MicroBasic script. You will simply need to disable the analog input that is controlling the motor that is giving the arm it's vertical motion. You can queue this to happen when the sensor you are using is within a specific voltage range. The command to disable/enable an analog input is setconfig(_AMOD, cc, nn), see page 292 of our User Manual for further details of this command.
The following user(s) said Thank You: stanles78

Please Log in or Create an account to join the conversation.

5 years 11 months ago #29532998 by stanles78
thanks, that works pretty well. I was stuck thinking about disabling the motor rather than the input that controls the motor. But when I run the motor with the joystick and change the analog3 input to cross the 2500mV threshold set in the code, the motor command locks at whatever value its at then. The motor just runs on its own until analog3 drops back below 2500.

Please Log in or Create an account to join the conversation.

5 years 11 months ago #29532999 by stanles78
top:
analog3=getvalue(_AI,3)
If analog3>2500 Then
setconfig(_AMOD,1,0)
Else
setconfig(_AMOD,1,2)
End If
GoTo top

Please Log in or Create an account to join the conversation.

4 years 3 months ago #29534536 by Davidetwinp98
Try this:

TOP:

analog3 = getvalue(_AI,3)

if(analog3>2500)then
do until analog3 <=2500
setconfig(_AMOD,1,0)
analog3 = getvalue(_AI,3)
loop
else
setconfig(_AMOD,1,2)
end if


GOTO TOP

Please Log in or Create an account to join the conversation.

Time to create page: 0.079 seconds