Gator/Arduino Compatible PLC (Part I) (Programmable Logic Controller)
A customer/contractor wanted a "Internet Controlled Water Sprinkler Valve Controller."
By having the Internet to automatically predict "local" weather projections and by using local rain guage sensors,
water consumption and usage could be greatly reduced. ($$$$)
We decided build a "generic" programmable logic controller using an Arduino compatible microcontroller. (See design specs. - below)
The isolated input / output interface board for the PLC (microcontroller - Arduino/Gator/Gator+) uses the Parallax Digital I/O Board Kit.
PLC Generic Design Specs.
Version: 1.0b
Date: 3/1/2010
Author: ArduinoAndy
#1. +12 VDC single supply voltage operation.
#2. 8 opto isolated digital inputs - +12 VDC inputs. <Parallax Digital I/O Board Kit (Parallax.com)>
#3. 8 relay outputs - 4 solid state for AC loads (8 amp) and/or 4 mechanical for AC/DC loads (12 amp). (can be mixed and matched - 8 total) <Parallax Digital I/O Board Kit (Parallax.com)>
#4. Accurate real time clock with battery backup. +- 1 minute per year @ room temperature. <I2C Real Time Clock - ChronoDot (Macetech.com)>
#5. LCD Display with software controlled backlight/contrast for PLC status and data. <New Haven 4 x 20 LCD serial Display (newhavendisplay.com)>
#6. I/O Status LEDs on all digital inputs and outputs. <Parallax Digital I/O Board Kit (Parallax.com)>
#7. All PLC sub modules are standoff mountable for easy repair and maintenance.
#8. RGB LED status annunciator. <BlinkM RGB I2C LED Annunciator (Sparkfun.com)>
#9. Modular analog and digital interface. <Electronic Bricks by Seeed Depot (seeedstudio.com)(compatible modules by Phidigets.com>)
#10. All modules and parts easily purchased via Internet for quick construction. (Except for Watchdog timer / 12 VDC Bus board, 5 VDC Distribution / I2C Bus Protoboard, which has to be constructed)
#11. PLC intended use (inside) for home automation, security, envir. control. <---- Not for use in an industrial or medical (life) applications!!!!
#12. PLC Watchdog Timer for output control safety and protection. <Still under design/construction/testing.> <----<<<< This Watchdog board is a design requirement.
#13. Rugged microcontroller inputs and outputs which are protected from ESD, shorts and overvoltage. <Gator/Gator+ (RuggedCircuits.com) [Also, can use the standard Arduino?]
#14. PLC controlled and polled via serial port by the Internet. <IOBridge with serial output module (IOBridge.com)> (Rugged Circuits Gator has two serial ports for easy external uploading and serial I/O)
Note: The IOBridge needs no PC but needs an Ethernet / Internet connection to function.
(Part I)
Parallax Digital I/O Board Kit
General
The main digital input/output "isolated" interface board is the Digital I/O Board KIT from Parallax. The Parallax Digital I/O Board Kit enables your microcontroller to interface to high voltage circuits allowing you to read up to 8 optically isolated inputs and control up to 8 isolated outputs. Inputs can be a voltage from 5-30VDC (AC compatible) and outputs can be either mechanical (AC/DC loads) or solid state relays (AC load only) that can switch up to 12A loads, such as cooling fans, solenoids, heating elements and more.
The Parallax Digital I/O Board Kit has the following features:
Mechanical and or Solid State Relay output
Configurable Input Voltage range
Serial or parallel interface to inputs/outputs
LED indication of power and input/output status
Hints & Tips
To use the Parallax I/O interface, 8 inputs and 8 outputs pins are needed - 16 I/O pins total. Since we are using the Gator/Gator+ with 28 I/O this was not an issue. We used this interface for easy I/O bit troubleshooting. For users with Arduino boards, the I/O requirement can be greatly reduced to 4 I/O pins by using the serial shifting in and out and using the built-in serial interface.
The cost of the board is fairly expensive but is well engineered ($50 USD) but it does not include the optional (extra) output mechanical or solid state relays. (User application requirement determined) For those, who are good at bread boarding, the cost can be greatly reduced by just buying the components needed and constructing a perf board. The schematic and instruction PDFs can be obtained at the Parallax.com website.
The Parallax I/O board needs two sources of power. The input 12 VDC "relay power" which supplies the control voltage for the mechanical and solid state relays. The "logic power" is a +5 VDC power for the opto isolator logic on the board. Both supplies will be needed and "sized" for the high current to the control to the circuits.
Since, the 8 amp solid state relay (AC loads only) and 12 amp mechanical relays (AC/DC loads only) have high amperage outputs, then only thru soldering can the relays be attached to the board.
There are no easy to use plug-in pin sockets due to the high amperage outputs. So, by chosing what type (Solid state or mechanical) and how many relays are critical due to the fact that
all outputs relays will have to be soldered on the board. Note: The relays can be mixed and/or matched.
The Parallax Digital I/O board has current limiting resistors (resistor pack) to limit excessive output current from the microcontroller. Since the Gator/Gator+ plus has 510 ohm resistors built-in, then we jumpered the resistors out on the digital I/O board. Using a standard Arduino, these resistors will save your board in case of excessive current draws or short circuits.
The I/O connections to the I/O board are done via ribbon headers. We used 22 guage wire in the header holes for a better reliable connection(s) to the microcontroller. There is also an option that uses the input +12 VDC "supply power" for the "relay power" VDD that goes to the microcontroller to supply the 12 VDC to the microcontroller board input regulator and then feeds back +5 VDC from the microcontroller supply to the I/O board for "logic power". Proper power supply "sizing" is required.
We installed 1.0K input resistors for 12 VDC photo isolated inputs instead of the 1.5K inputs resistors (default) for 15 VDC isolator inputs, which came with the kit.
Note: Different voltage photo isolated levels can be designed per user requirements.
Watchdog - Digital I/O Board
Safety and protection is always designed into a PLC and having an external Watchdog is a standard PLC design requirement. (This is NOT optional!)
Fault #1 What happens if the microcontroller fails or becomes "bricked"? (Device failure?)
Fault #2 What happens if you lose the 5 VDC "logic power" on the digital I/O board? (Device failure?)
Fault #3 What happens if the I2C bus hangs or halts the microcontroller instruction execution? (This does happens with the 2 wire.h library!) (Software or device failure?)
Fault #4 What happens if the local 5 VDC power supply is shorted / overheats or fails? (Device failure?)
Fault #5 What happens if the microcontroller has faulty, buggy software (sketch or rev.) that causes the microcontroller execution to hang, to loop forever or to halt? (Software?)
Fault #6 What happens if a microcontroller critical component like the RTC fails? (Device failure?)
Fault #7 What happens if a microcontroller, during a "fixed timed scan sequence", times out or overruns? (Software?)
You guess it !!! --> The control digital outputs could be activated and stay on all the time without the microcontroller! This loss of control is a severe safety and protection failure that can be easily preventable by proper system design. An external Watchdog will, in most cases (above), will disconnect the control output "relay power" when there is a fault, failure or error. This would stop all control outputs from functioning until the fault, failure or error is fixed or repaired.
By using one output from a microcontroller, which pulses a "missing pulse detector" watchdog relay. This watchdog relay is activated (ON) all the time, which supplies power to the digital I/O board. On any failure event, which causes the output pulse to stop, the watchdog relay will drop and the control output voltage is removed from the control output relays. The watchdog has a timed R/C 2.2 second time out delay, a manual reset and an optional "auto reset" on restart input (dry contact NO).
Note 1: By losing the "input supply" +12 VDC to the digital I/O board, all control voltage is removed from the digital I/O board. All control outputs are turned off.
(Warning ...Do not use the NC contacts on the mechanical relays!)