Action to be Initiated and Stopped with Different Inputs

I want an action to be initiated when a certain set of inputs are provided, and I want it to stop once a different set of inputs are provided. The idea is that after the action has begun, it will ignore any changes to the set of inputs that initiated it until after the action has been stopped.

I know this is the "programming questions" thread, so this is just a "what type of statement or loop, etc will work best" question. I'm not asking for specific project guidance, but to give some context, this is being used on an accumulating conveyor. The logic is as follows: If the sensor for zone 1 is blocked and the sensor for zone 2 is clear, motor 1 and motor 2 will run until the sensor for zone 2 is blocked. Somewhere during that transition, while the product is in the middle of the two zones, the sensors for both zones will be clear, thus changing the set of initiating inputs before the action has been "completed," i.e. the sensor for zone 2 becomes blocked. Because of this, I'm having trouble finding an appropriate statement.

Any help is greatly appreciated, and if I am missing any information or details, or if this is not the best section to post this in, please let me know.

I'm using an Arduino-compatible PLC (linked below) and I would describe my expertise level as beginner-intermediate. I've had success with a few small projects and I've had a couple of classes of formal education covering C++ and Arduino.

https://www.automationdirect.com/adc/shopping/catalog/programmable_controllers/open_source_controllers_(arduino-compatible)/productivityopen_(arduino-compatible)/controllers_-a-_shields/p1am-100

Do a search for "Arduino state machine tutorial". I think that a state machine type program is what you need.

here is a quite brief but still understandable tuorial
finite state machine statemachine stae-machine

best regards Stefan

tmjone20:
I want an action to be initiated when a certain set of inputs are provided, and I want it to stop once a different set of inputs are provided.The idea is that after the action has begun, it will ignore any changes to the set of inputs that initiated it until after the action has been stopped.

I’m confused.

  • “I want an action to be initiated when a certain set of inputs are provided”
  • “I want it to stop once a different set of inputs are provided.”
  • “after the action has begun, it will ignore any changes to the set of inputs”

These three statements seem to be somewhat contradictory. How are we to ignore any change in the input until the action has stopped while stopping the action only when the inputs are changed?!?

tmjone20:
The logic is as follows: If the sensor for zone 1 is blocked and the sensor for zone 2 is clear, motor 1 and motor 2 will run until the sensor for zone 2 is blocked.

Is the gist of it: if our PE is clear, run motor. If downstream permissive is OFF and our PE is blocked stop motor, else run our motor?

Pseudo code:

if(zone2 is_blocked)
  stop_motor;
else if(zone1 is_blocked or motor_is_running)
  run_motor;

Is it only to be 2 zones? Or, should this end up something that can handle N zones?

-jim lee

You can write a SET RESET Equation as follow:
Q(t+1) = S + Not(R) *Q(t)
S = inputs combination for set condition
R = inputs combinations for reset condition

Q = S | (!R&&Q)
If you have only one input for SET condition and another for RESET, you can try using the interrupts input.
Thanks