NWT.Stuff
I have a problem with one function of my conversion from python to Open PLC.

In my Home I am using relay outputs to carry out power resets. (e.g. re boot a webcam).
The wiring is failsafe so when the 
#1 RPI System is powered down the power circuit is live.

#2 On RPI Boot Up GPIO floats until the Main Routine configures the Relay Output with a GPIO.output(PinQ0, GPIO.HIGH)

#3 If a power reset is called then the output is switched using GPIO.output(PinQ0, GPIO.LOW) for 5 seconds and then new instruction GPIO.output(PinQ0, GPIO.HIGH).

#4 If the RPI crashes the current output status (usually GPIO.HIGH) is maintained.

#5 If the RPI Main Routine has a controlled stop the current output status (usually GPIO.HIGH) is maintained.

  
With the OPen PLC The intention/what's happening is as follows:
#1 RPI System is powered down the power circuit is live.

#2 On RPI Boot Up I will run the PLC automatically using the "Start OpenPLC in RUN mode" Function in OpenPLC. My RPI.cpp config file instructs (PinQ0, GPIO.HIGH).

#3 The power reset is now a PLC Rung as shown below. I have QX1 registers that are effectively my "Modbus Control Word" so in the example below the A7 Power Circuit is pulled down for 5 Seconds.


PP-PLC_Rung.jpg

#4 No sure what happens when the PLC Crashes ??

#5 Controlled Stop using STOP PLC ??

So this leads me on to my problem. A controlled PLC STOP sends my relay outputs LOW hence cutting of all my power circuits (including the one with the Router & Server). Hopefully you can understand my problem now. Is there a way of maintaining the "Relay Outputs HIGH" or even in the "last current state" on a controlled stop ?

I have also noticed that on PLC Start there is a momentary LOW on the Relay Outputs. This may not be a problem but I'm guessing if the previous problem could be fixed this too could be addressed in the same hit !!

I have a quick fix which is don't push the "STOP PLC" button but this means as I am running PLC on Start Up that your very useful Monitoring Tool doesn't seem to be available.

Many Thanks in advance, Kevin
Quote 0 0
thiagoralves
Hi Kevin, it appears to me that this needs to be fixed in hardware, not software. I would recommend you to use the NC contact of the relay instead of the NO. Then your circuit will be powered even when the Pi is off. Your logic on software will then be reversed. When you want to reset, you power the output coil (not the negated coil), opening the NC contact of the relay. This is the safe way of doing it. All PLCs I know will clear all its IOs to LOW state in a crash condition. You need to determine, for your system, what is the safe state based on all outputs in LOW state.
Quote 0 0
NWT.Stuff
Thanks Thiago.  I need to work through my electrical drawings and hardware.  Unfortunately I can't make Hardware modifications due to COVID19.  Fortunately I know a man who can 🙂
Quote 0 0
NWT.Stuff
I've managed to have a good think and I know can explain everything clearly now. My background in PLC Control comes from my experience and not from any formal training. Over my years spent in Industrial Automation as a Project Manager I have acquired very useful skills from others, e.g. Hardware Design, Electrical Wiring, PLC Software Design & Commissioning, SQL and Server Management. I do lack the fundamental knowledge in certain areas (e.g. in this case PLC Output Relay Modules).

Let's take an good example of "Industrial" Factory Automation.

The link is a Peugeot Paint Shop in Slovakia where I Project Managed the "Control Systems" element.

The Factory consists of 50 RS-Logix PLC's and 1 Control Room PLC which is mainly comms cards and a bit of IO. 
Peugeot don't (or didn't in 2006) go for "Conventional SCADA".
They Transfer the Factory Data to their business systems for Data Logging, Fault Management.
They also don't go for central control per se the only Control in their Control Room would be Factory On/off.

In the Control Room there is an SQL server transmitting all the shop floor data to these systems.

Communications PLC <> PLC and PLC <> Control Room is using Ethernet TCP/IP Communications over a Fibre Ring.
Several Industrial Switches supplying copper drops to the PLC Network.

Now we get onto the Power Management.
All the PLCs, The Main Server and Switches are powered from a UPS Supply.
PLC Outputs and Inputs are NOT on this UPS hook up.


So Let's move on to my approach for Home Automation. Strangely Enough I have a very similar architecture !! 3 RPI PLC's talking to a Server over Ethernet TCP/IP. Why 3. It's a big property and the 3 units cover a physical location. Ground Floor, Lower Ground Floor & Swimming Pool. OK so it's a Villa in Sunny Spain that we spend time at during the Winter and Rent out during the Summer.

Hence the requirement for complete Remote Control including power resets !! 
We're close now to where I made my first big mistake...
I need to be able to power reset the main router and server. I included this Function as an output relay on RPI#1.
As mentioned previously this can create a tricky situation.

So now we're onto the Output Relay Bit.
All my Power resets are wired on NC contacts.
To reset I need to open the Contact and close it.
The Output Relays I use are "ACTIVE LOW".
This means I have a problem when a PLC stops, the main one for me is I lose my remote control and can't reset it.

So How to Fix it?
Well the first thing I need to do is get that critical power circuit off the Output Relay board on PI#1.
OK so now I know that you can have ACTIVE LOW and ACTIVE HIGH Relays let's have a look at the the best option for my Functions.

#1 Power Resets - No choice here has to be ACTIVE LOW
#2 Run Swimming Pool Pump & Pool Fill Solenoid Valve - ACTIVE HIGH would be better.
#3 Electric Water Tanks Control (Using Contactors) - ACTIVE HIGH would be better.

OK So I want to standardise on Hardware in My System and on 1 Output Card I need both ACTIVE LOW & ACTIVE HIGH Relays.
Something I've wanted to do for a while is change my Control Voltage from 5V to 12V.
So now is the time (Well when the COVID thing dies down).

I still need to reset the Server & Router from time to time.
I will move this power reset to a Ethernet/IP network relay (especially as I have one on my panel and 1 spare contact).


If I was building a Multi millionaire house from scratch I would accomodate a UPS Power Circuit, but unfortunately most normal people are not multi millionaires so we have to make do with what we've got.

Conclusions
- Never put critical power resets on PLC Output Relays, especially if you using VPN 🙂
- Research the basic hardware functionality and options before purchasing any kit.
Quote 0 0