I am currently working on a small Project for David at Wine Technologies (vinwizard.us) to replace an older proprietary temperature control PLC. David decided he would like to use a Raspberry Pi due to the fact it is very powerful, low cost and has extensive documentation and support as well as a ready built network and USB stack for communications.
The problem really was would you really want to use a Raspberry Pi in such an industrial application?
The main concerns are the complexity. PLC’s and industrial controllers normally run very simple firmware for very good reasons, that being it is much more testable and therefore very reliable. The RPi to be useful needs to run an operating system such as Linux and while reliable can crash due to numerous reasons. David wanted the system to be at least as reliable as the system he was replacing which meant building a custom motherboard for it with a few additional safeguards. The whole board also had to fit into the existing metal case.
The specification for the motherboard is detailed below:
- The RPi would connect to the motherboard via its GPIO header so it would be modular and easily removable/upgraded if required. The GPIO for the RPi2 and RPi3 is a 40 pin dual header.
- The Motherboard would provide a filtered 5V/3A supply to the RPi through the GPIO, the PSU would be industrial rated for 24V DC. I have checked numerous experts on this (and many so called experts). The only disadvantage of supplying 5V through the GPIO is that we bypass the fuse and some filtering. This can be easily fixed by putting the fuse and additional filtering on the PSU, electrically there are no other issues.
- The Motherboard would allow the connection of 4 x PT100 temperature sensors and the RPi will read the temperatures off the I2C bus.
- The Motherboard would have 8 relays (as we are a temperature control board these will be 4 heating relays and 4 cooling relays) again these will be controlled by writing to I2C registers
- It must be capable of resetting itself in case of software failure. The RPi does have a built in watchdog timer, however software resets do not always work (been there, done that) and a hardware power off-on reset was preferred. so an external watchdog timer would be on the motherboard and if no I2C communications are received within a pre-determined time (under 2 minutes) the motherboard will power-cycle the 5V.
- Relays will retain there state during a restart of the RPi however if more than 3 restarts are done without communications the system will enter a fail safe mode with all relays open and sound an audible alarm.
David has decided it would be good kudos for his company to release the final design and firmware back to the community so the design will be open sourced.
There are a few novel design elements to the motherboard (read it will require more testing than normal) Firstly I am fairly competent on analog design but I am very happy not to re-invent the wheel so I will be using the Microchip AN687 Design Application Note for the core of the design, however as I will need 4 channels I will be multiplexing 4 external channels using MOSFETS which have very low on resistance. We have also added a 5th channel which connects to a precision 100 ohm 0.1% resistor this will be used for calibration and self-test purposes. (What could possibly go wrong!)
As usual I will be using a PIC controller for the dirty work so it will do the control of the relays, analog multiplexer, watchdog timer and I2C slave to the RPi. I chose the PIC16F1782 this time as it has a 12 bit ADC and also has a 8 bit DAC that I will use to programatically alter the Vref into the constant current source.
As usual I have designed and hosted the Project using EasyEDA which makes it easy for you to get a PCB just by forking the project and pressing the Manufacture Button, I have never had any problems with the quality and price at EasyEDA and they deserve all the praise they get.
I don’t envisage very complicated firmware will be required for the PIC all the action apart from I2C communications will take place in a simple loop.
I am still at the stage of building up the PCB I received so more to come