dis/enable motor outputs on digital input

7 years 8 months ago #29530965 by nightline
Gents,
I want to disable the motor outputs of a SDC2160 controller when Din 1 is high.
To perform this I've set the action on Din 1 in the configuration tab to "run script"
The normal motor functions are closed loop tracking.
This is the script which I wrote:

'this program runs when DIN1 is high and disables both motor channels

top:

DisableInput = getvalue(_DIN, 1)

if (DisableInput = 1 )then

setcommand(_GO, 1, 0) ' Apply the command
setcommand(_GO, 2, 0) ' Apply the command

else
terminate

end if

wait(10)
goto top ' Repeat indefinitely every 10ms

My questions are:
Will this program disable any motor action when Din 1 is high, and will the controller resume the normal function when Din 1 is low?

Thanks in advance!

Jack

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

7 years 8 months ago #29530966 by roboteq
Replied by roboteq on topic dis/enable motor outputs on digital input
First, it is best that you have the script run continuously (ie not started by changes in Dinput)

Then, your script will send a command to the motors to go to 0. That will stop them.

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

7 years 8 months ago #29530967 by nightline
Well actually I want to stop the motors.
The controller is in use for an electric vehicle steering. When there is no driving command for more than 3 sec. I send a digital signal to this steering controller to stop steering.
First I used the Safety Stop function, but this needs specific commands from the joystick signal to stop this function.
That's why I'll try it this way.

Why should this program run continuously?

Jack

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

7 years 8 months ago #29530973 by TechSupport
This terminate function means that the script terminates. That means when the script stops running, then the Digital input 1 no longer does what is called in the script. So when the script stops and you engage D1, then nothing will happen, except that the input will just go high with no functionality.

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

7 years 8 months ago #29530974 by nightline
But the function of Din 1 in the configuration Tab is set to "run script", so this should enable the script program again isn't?

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

7 years 8 months ago #29530975 by TechSupport
Your script tells it to disable the motor output by sending the commands to 0.

So when your script terminates, you have to re-enable the script again which you are doing via digital input 1 again. That would also likely trigger the motor output to stop again at the same time it is being pressed.

By having the script constantly running, there would be no reason to re-enable your script to have the motor commands be sent back to 0.

If at all anything in closed loop mode for sending the motors to stop, it would be better to send the controller to open loop mode.

Then send the commands to 0.

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

7 years 8 months ago - 7 years 8 months ago #29530976 by TechSupport
top:

DisableInput = getvalue(_DIN, 1)

if (DisableInput = 1 )then

'Ensure motors will stop
setconfig(_MMOD, 1, 0) ' sets motor 1 to open loop mode
setconfig(_MMOD, 2, 0) ' sets motor 2 to open loop mode
setcommand(_GO, 1, 0) ' Apply the command
setcommand(_GO, 2, 0) ' Apply the command

else

Switch back to closed loop mode
setconfig(_MMOD, 1, nn)
setconfig(_MMOD, 2, nn)

end if

wait(10)
goto top ' Repeat indefinitely every 10ms

You will need to replace the nn with the actual mode.
1 - speed
2 - position relative
3 - count position
4 - position tracking
5 - torque
6 - speed position

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

7 years 8 months ago #29530979 by nightline
I'll try this program, see how it works out.

Thanks!

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

7 years 8 months ago #29530980 by nightline
Today I downloaded the script to the controller, and it's working fine! Thanks!

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

Time to create page: 0.069 seconds