jbrandes
Hey All,

I just started with OpenPLC and I hooked up my Arduino UNO as a slave to Runtime. Now that everything is working I am looking for beginner project ideas. If anyone has any suggestions please send them my way. Now that I have this tool I really want to use to learn more about PLCs.
Quote 0 0
tim292stro
Some simple projects to get started:

1) Push a button, turn on a status light, release the button, turn off status light (basic IO)
2) Push a button to turn on a status light, push a different button to turn off same status light (basic IO + basic set/reset logic)
3) Push a button, toggle a status light on/off (basic IO + more complicated set/reset logic)
4) Push a button, turn on a status light for 5 seconds, then turn off the status light (basic IO + sequential timing logic)
5) Push a button, if switch is on status light turns on (basic IO + conditional logic)
6) Push a button, if an analog knob (potentiometer) is above a certain setting, turn on status light (slightly more advanced IO + conditional logic)

Various combinations of these simple projects should get you running with more advanced stuff later, as everything becomes a combination of the above.  There are different "functional blocks" one can substitute in for conditions, and you will be able to see that the output of one block can be chained as the conditional input to another control loop.

For example - #1 shows that some is or isn't, this can be anything, like a float switch at a certain level in a tank, a beam-break sensor on a garage door, etc...
#2 can be a run/stop circuit for a machine motor
#3 can be the motor of a fan (push once to turn on, push again to stop)


Complex chains can be built as well once you have the basics down, using the garage door opener as an example,

One can have several basic inputs using #1:
1) Beam break switch
2) Door edge contact switch
3) Door Closed limit switch
4) Door Opened limit switch
5) Inside garage opener button
6) Remote control opener momentary input (like an electronic button)

And a few outputs:
1) Motor forwards relay
2) Motor reverse relay
3) Opener light relay

You can build up to filling in the blanks on how to chain this all together:
  • Either the remote OR the inside button should begin a "door action" event.
  • The beam break sensor should only trigger an event if the door is open.
  • Any time an "event" is triggered, a reset of a 2 minute count-down timer should turn on the garage door opener light until the timer expires (turning off the light).
  • The door should not begin closing if either the beam break sensor or the sense edge is tripped.
  • The condition of the door should be determined by limit switches (either it's opened, closed, or mid-travel).
  • Build a sequential "state machine" for the door travel for "stop1", "closing", "stop2", "opening" - every door action should increment the state one step - so pushing either control button should get you these actions.  Power On of the system should begin in a stopped state (if door is "not open" goto stop2, else goto/stay-at stop1)
  • The sense edge and beam break sensor to stop then reverse (open) the door if it is closing only (it should increment two steps in the state machine).
  • Limit switches should increment one step in the state machine only when in the appropriate state (i.e. opening + door open limit = 1 step, closing + door closed limit = 1 step)
An extra output tied to the status of the door closed limit switch can be sent to an alarm system to indicate that the door is closed - or if inverted "is not closed" (i.e. at least partially if not completely open).  More logic can be written to mechanically lock the door after is is fully closed for a second or two (Stop2 + Door closed = start 1 second timer then fire "lock" event), and unlock it before the door is allowed to open (when Open state is valid, fire "unlock" event delay one second, then continue to reverse relay start) - this can be improved by adding an unlocked sense input to bypass the delay and unlock event to go straight to opening.  You can expand on this as much as you want with full control of the logic.  But also take care to understand that certain conditions can create states you should avoid (the reason I encourage the use of a state machine) - for example, if one turns on both the open and close relay outputs... what will happen?  It's good to get in the habit of thinking about what happens in the physical world and design that system to be "fail safe" as you may forget some interaction in software and not realize you are doing something that can break something or injure someone.

For example - an Emergency Stop should have an effect on the real-physical world and not be reliant on software, and it should allow for failures in the wiring and controls to end up in a safe state.  The forwards/reverse relays should be wired in an interlock so that if one is active, the other cannot be activated (this would need at least a DPDT relay for both forwards/reverse).  These two can be chained together in wiring by switching the high side of the relay with the PLC and having the low side go through a normally closed circuit of the opposite relay then to the upper side of the normally-closed E-stop switch, then to ground.  In this way, if the E-Stop is triggered/pressed the relays no longer can be powered so the motor stops, and neither relay can be activated unless the other relay is inactive.  If the wires to the E-stop break, the circuit is broken and the motor will again not run so it's failing to a safe state.

If you feel brave, you can use an absolute position input (like potentiometer) to determine where the door is in its travel and build software limit switches for open and closed greater than some value equals "open limit" less than some value equals "closed limit".  With a current sensor on the motor you can build some routines to figure out where these limits are by watching for the current to spike when it reaches the mechanical limit of the mechanism (you'd want to stop it anyway at that point...).

With that you're pretty much at where the most advanced/expensive garage door openers are today.

Good luck!
Quote 0 0
thiagoralves
Nice ideas tim! Also, I would suggest Factory IO if you're looking at a virtual platform to test your code. Factory IO offers a 3D environment with conveyor belts, gates and some other machinery so you can "physically" implement the garage door opener tim was talking about =)

Just search for Factory IO on the forum. There are some posts here that will help you get started.
Quote 0 0