Control script for test rig

5 years 11 months ago #29529928 by SimonPayne
Hi, well I got the motor running ok and yes when the moving part of the rig hits the upper limit switch, the motor reverses direction as intended. All fine so far. However as the rig comes back down again, the limit switch is released (it has a return spring of course) and you guessed it, it changes the state back and reverses the motor again!

Any ideas how we could get it to ignore the second input and keep on going down until it hits the lower switch? (which will have the same problem of course!)

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

5 years 11 months ago #29529929 by TechSupport
You can try setting up some flags into the script that tell the script where the motor went, and then a change in behavior to after releasing the switch that it inverts direction instead.

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

5 years 11 months ago #29529932 by SimonPayne
Hi, not being a programmer I am not sure exactly what you mean by setting "flags" in the script to mark the motor position. Would it be similar to a label,in that it creates a point in the script that can be jumped to using the GOTO command?

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

5 years 11 months ago #29529933 by TechSupport
It means you have like it says a flag. When nothing occurs, the flag is not raised. When something happoens, you raise a flag.

Simply put you could do something like this.

dim action as integer

top
if d1 = 1 then
action = 1 ' means you have set the action variable to say it has something so you can use it later.
else
action = 0

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

Time to create page: 0.169 seconds