Introduction
I designed and built 2 projects to go along with the RoadTest of the Eaton easyE4 PLC. These go with the RoadTest, but are extra information. I will try and keep my opinion to the review.
All pages are likely to be updated as I get to grips with adding information. (I can already see the screen grabs of the ladder diagram have lost some resolution and will try again)
I tried to keep everything fairly basic as I was trying to test the PLC and the software that went along with it. As such I also tried to keep the voltage down to 12Vdc. A lot of what I ended up using (Arduino/Ras Pi) could have done the job of the PLC, but that wasn’t the point. I was trying to replicate industrial parts and automation. As such I stuck to using Ladder Diagrams (LD) as this is still seen in many old PLCs.
Pretty much all Arduino code, and the Raspberry Pi code I used, I butchered from previous projects I had done to some degree.
Although I know there is a standard for PLC programs (IEC 61131-3) I am not up to speed on the regulations. Therefore, there will no doubt be issues with the ladder diagram I put together not meeting the standards. If anyone does have the knowledge on these and can advise, I will happily take it on board.
Product LinkProduct Link
Planned Operation
The second project I was going to try and simulate was an engine control system. This is used on lighthouses to turn on an engine three times a week to charge the batteries that power the station.
I thought this was going to be fairly simple but I was wrong. I had a limited number of inputs and outputs with the PLC so thought everything would be short and to the point. But what I was trying to replicate turned out to be a lot more difficult than I thought it would be.
The principle behind it was that there would be an auto start to bring on the engine, and a manual start.
When a start is initialised, the PLC needs to monitor engine speed, temperature and pressure and if these values are not within their set values, switch off the engine again. It should also turn on a fuel solenoid, followed 1 second later by a starter motor. The starter motor should turn off once it gets up to speed or after 15 seconds. The whole process should take 30 seconds to monitor the outputs for a successful start.
To complicate things, the auto start would have three attempts before locking off the engine.
The manual start needed to have the start button pressed for 4 seconds before the start sequence initiated.
If the start was successful then the pressure, temperature and speed continued to be monitored and if the values got out with a set value, it would turn off the engine and lock it off.
This is what happens on the remote lighthouses and I wanted to try and write a program that could do all this.
Design
I was wanting to have four digital inputs – Start_PB, Stop_PB, Estop and Reset. Then three analogue inputs – Engine Speed, Temperature, Engine Pressure. And four outputs – Engine On Indicator, Fuel Solenoid, Starter Solenoid, and Fault Indicator.
To replicate the analogue inputs of temperature, pressure and speed, I used an Arduino Nano 33 Sense with it’s on-board sensors for temperature and pressure. The temperature was easy enough to measure and output.
The pressure I had some problem with but found a solution. As it was a barometric pressure sensor the range input didn’t change much. I was using a fan to replicate the engine, so ended up placing the board in a bag, which when the fan turned on, inflated and increased the pressure. But as the pressure changed with the weather, the code had to take a reading at the start and map values so that when it did increase in pressure, the output value would change enough for the PLC to read and see as the pressure getting up to a working value.
The speed of the fan was measured with a photodiode, a LED and the Arduino. It measured the pulse size of each blade passing the light source, took into consideration there were 9 fins on the fan, and converting the number to rpm.
I used the fan as a replacement for the fuel solenoid as this would turn on and off with the same commands. The other outputs I ended up using LEDs. Two of these would have been a LED anyway, the Engine ON indicator and the fault indicator. It was only the starter motor that is an indicator rather than a moving part.
The Arduino code I managed to get working was as follows:
#include <Arduino_LPS22HB.h> #include <Arduino_HTS221.h> int pin = D10; int tempPin = A0; int pressPin = A1; int rpmPin = A2; unsigned long durationHigh; unsigned long durationLow; unsigned long durationTotal; float freqIn; float rpm; int rpmOut; float rpmVolt; float tempOut; float tempVolt; float pressOut; float pressVolt; int newPress; float startPressure; float newStart; int startVal1; int startVal2; void setup() { pinMode(pin, INPUT); pinMode(tempPin, OUTPUT); pinMode(pressPin, OUTPUT); pinMode(rpmPin, OUTPUT); Serial.begin(9600); while (!Serial); if (!BARO.begin()) { Serial.println("Failed to initialize pressure sensor!"); while (1); } if (!HTS.begin()) { Serial.println("Failed to initialize humidity temperature sensor!"); while (1); } BARO.readPressure(); // take a pressure reading to start chip, never correct on first reading delay(1000); startPressure = BARO.readPressure(MILLIBAR); // take second reading of actual value and set as start pressure newStart = (startPressure*100); startVal1 = (newStart - 10); startVal2 = (newStart + 20); } void loop() { // read the sensor values float pressuremBar = BARO.readPressure(MILLIBAR); float temperature = HTS.readTemperature(); // print the sensor value Serial.print("Pressure = "); Serial.print(pressuremBar); Serial.println(" mBar"); newPress = (pressuremBar*100); pressOut = map(newPress, startVal1, startVal2, 0, 255); pressVolt = ((3.3/255)*pressOut); // for debugging Serial.print("Pressure voltage out= "); Serial.print(pressVolt); Serial.println(" V"); analogWrite(pressPin, pressOut); Serial.print("Temperature = "); Serial.print(temperature); Serial.println(" °C"); tempOut = map(temperature, 0, 120, 0, 255); tempVolt = ((3.3/255)*tempOut); // for debugging Serial.print("Temperature voltage out = "); Serial.print(tempVolt); Serial.println(" V"); analogWrite(tempPin, tempOut); // Measure the fan speed durationHigh = pulseIn(pin, HIGH, 1000000); durationLow = pulseIn(pin, LOW, 1000000); durationTotal = durationHigh + durationLow; if (durationTotal == 0){ rpm = 0; } else { freqIn = 1000000/durationTotal; rpm = (freqIn/9)*60; } Serial.print("The rpm is: "); Serial.println(rpm); rpmOut = map(rpm, 0, 2000, 0, 255); rpmVolt = ((3.3/255)*rpmOut); // for debugging Serial.print("The rpm voltage is: "); Serial.print(rpmVolt); Serial.println(" V"); analogWrite(rpmPin, rpmOut); Serial.println(); // wait 1 second to print again delay(1000); }
This was the feedback from the Arduino while the fan was off:
And this was the feedback when the fan was on:
PLC Code
The following code was the final code that I managed to write after a lot of testing. I had to use the simulation side of the easySoft7 software to remove a few problems. I also ended up building a test breadboard to help iron out some errors, then the final Arduino setup as above to again find errors.
The first 3 rungs were part of the alarm setup that would latch on. The wording in the E_Stop rung would need changed in the end, I started to get confused with which way around it should have been depending on if I was using a NO or NC switch. It had been planned to be a NC, but for testing I used a NO. Rung 2 and 3 would only come on though when there was a successful start.
More alarms
Alarm rungs again, with the final one outputting the fault indicator.
Comparator functions for the analogue inputs from the Arduino. I was only using the 0 - 3.3V out from the Arduino Nano for the PLC analogue inputs which is why the values are low. The PLC would operate from 0 - 10V input.
The speed comparator blocks from the Arduino with value for start motor and operating value.
The start commands. The manual start with a 4 second timer in rung 12, then the weekly timer with three start times in rung 13. Rungs 14 and 15 just turn on marker bits (MB) for the auto start and stop using a pulse.
Rung 16 is the whole start rung which should latch on if all conditions are met.
Rungs 17 to 20 control the starter motor, with a 1 second delay to turn on, 15 second delay to turn off and making sure the speed is good.
The next few rungs are the 30 second start up sequence checks. It makes sure the engine speed is high enough, that the oil pressure has risen to a suitable level, and that the temperature is below a set value.
Rungs 24 and 25 are part of the auto start sequence which makes sure to allow the engine to try to start 3 times before it will lock off.
The final parts are getting the Auto Start to try a restart, with the last rung being a run time counter.
The final rung count and names for this project. Nowhere as simple as first thought.
Simulation
Here is a quick rundown of simulating a manual start on the easySoft7 software.
I had to adjust the analogue inputs to values that would allow a start:
And then use the software to turn on the input:
The next screenshot was the alarm page showing no problems:
A few more alarms with also the pressure check showing that it is okay:
The last one is showing the outputs on:
During the simulation it threw in a few problems that needed fixed or had been overlooked. A lot of it was making sure that alarms didn’t come on early. I also had to make a few changes to enable lines and reset lines, and to get some of the marker bits to latch on when needed. This final design is a good few steps away from the early design.
Testing
During testing of the PLC with the Arduino I ran in to a few problems. It led me to having to connect the PLC to the PC via Ethernet. It had it pros as it meant I could test out this part of the PLC, but I ran in to all sorts of problems.
What I was able to view though with this connected was the analogue inputs feeding back live from the Arduino:
Along with the marker bits after a successful start:
What can be seen is the Start_Fail_Flag is on. This was an error that I ended up having to change in the program.
This was the test board with the input switches and the output LEDs. There is a pot still on the board put this was no longer connected.
Here were a few of the markers bits after forcing a few fails. What can be seen is the Speed_Alarm is on along with the Alarm_Active marker bits. These will only clear with the Reset input button.
I got a few videos of the operation of the PLC turning on the fan.
The first one shows the fan being started from the start push button with the 4 second delay. It then shows the feedback from the Arduino and the marker bits from the software:
The second video shows the start sequence with the starter motor (blue LED) coming on, then turning off after 15 seconds. A stop command from the stop button. An Estop command from the Estop button, which flags up the fault indicator. Which finally gets cleared by the reset button:
The third video shows the end of an auto start sequence after the third attempt to start the fan/engine. The engine on LED comes on, the starter motor LED comes on, the PLC runs through the start sequence, but fails, which is why it stops and goes into a lock off state and turns on the fault indicator:
If this was for an actual work related project I would need to go back and make more changes. If the starter motor gets to the end of the 15 second timer it would need to turn off the engine, I don’t currently have that in the program.
Roundup
For what appeared to be a simple project to turn on an engine, this turned out to be a lot more involved than I had expected. It wasn’t just the easyE4 I had problems with. I definitely over complicated things in this project and at times had to stop myself going further (the servo that moved to replicate the fuel solenoid which would press a switch got dropped last minute). Some of the main issues though were:
I ran into problems with the Arduino and missing .h files.
I had to learn more about ladder diagrams.
I found there were problems with voltages and what the PLC actually operated at.
I managed to crash my PLC so it stopped working completely.
I probably spent more time trying to get the Arduino to work than the PLC, which wasn’t really the point of the project (and ended with a LOT of swearing at electronics, more than the first project!).
A lot of this distracted from what was supposed to be a review of the PLC and its software. But I got from this project and the first one what I was looking for, which was the experience. It just ended up being more than the ladder diagram and PLC experience I was expecting.
Top Comments