The below simple script can control a lift motor in Speed mode. Digital input 1 will be used for down movement and Digital input 2 will be used for up movenet. To have an up or down movement, only one of the two inputs must be pressed at a time. The up and down speeds are hardcoded on the script. 

 Limit switches can be configured through Roborun+ Utility, so the script implementation is not required.



The code follows: 


 

option explicit 'undeclared variables cannot be used. Useful for detecting typos

 

' --------- MODIFY TO PARAMETRIZE SCRIPT ---------------

 

#define DOWN_SW 'Digital input to be used for down movement 

#define UP_SW 'Digital input to be used for down movement 

#define UP_SPEED 300 'Value of up speed in RPM

#define DOWN_SPEED 300 'Value of down speed in RPM

#define CC ' the channel that the lift motor is connected

#define CYCLE_TIME 'The script period in ms

 

' ----------- SCRIPT CODE. DO NOT MODIFY ---------------

 

dim up as integer

dim down as integer

 

start:

 

up getvalue(_DI,UP_SW)

down getvalue(_DI,DOWN_SW)

 

if up and not down

 

    setcommand(_S,CC,UP_SPEED)    

 

end if

 

if down and not up

 

    setcommand(_S,CC,DOWN_SPEED)    

 

end if 

 

wait(CYCLE_TIME)

 

goto start