How to use the same input to start and stop?

Questions about using the MCL scripting language.
Post Reply
boston
Posts: 3
Joined: Mon Mar 15, 2021 6:40 pm

How to use the same input to start and stop?

Post by boston » Mon Jun 21, 2021 6:37 am

I’m using a MCP233 to open/close a car scissor door via a momentary rocker switch. One position will open the door and the other position will close it. Pressing either while the door is in motion will stop the door. This type of control logic is also used for car windows, garage door openers, etc.

I can use a max action to stop the motor. However, the desired logic depends on the state of the motor. When I've done this type of thing before I've used an interrupt and placed the logic there - a simple if/else clause. It seems like the actions are basically interrupts that you can only hardwire to one of a set of operations. I considered monitoring the input in the script, but I can’t figure out how to do that. Please advise.

User avatar
Basicmicro Support
Posts: 1554
Joined: Thu Feb 26, 2015 9:45 pm

Re: How to use the same input to start and stop?

Post by Basicmicro Support » Wed Jun 30, 2021 7:01 pm

For that you will need to write a small MCL script. The actions can only be used for a single action per I/O.

In the script you will need to keep track of the last state. You will probably need to have a startup routine as well that will determine what the state of the door is.

Post Reply