Is it possible to program this onto a Click PLC? If so, I need help anyway.

The thing that I am controlling is the electric to pneumatic transducer, so I am controlling the air going into the air pump. After the pump the system starts to pressurize water inside of the system. yes the operator can do it manually, all the person does is turn a knob which slowly allows air to go into the pump. They watch the pressure go up and adjust the knob to get it to stop at the pressure they want. The pressure does not have to be exact, I talked to my boss and he said sometimes they do over the pressure target 50 psi. I bet I can get the pressure to +-10 psi or even less.

My programming experience is almost none. I am a mechanical engineer so I have no taken a coding class yet. I will watch those videos ASAP and also have a look at Parky's code, I will probably come back later with questions.
 
The code I showed you should work I suppose all you need to do is start at say 100% for the analog out then reduce it by a percentage obviously you probably will not need to decrement it to 0 or you will never get there. so I would find the lowest percentage required to give a increase of pressure say a 10% before setpoint, again I think you could just do what I have done full pressure until a few PSI before setpoint then reduce it to say 10 or 20%, you could even have stages i.e. 4 stages 100%, 75%, 50%, 25%.
These could be engineering values on a setup screen once configured only engineers could change them.
Had a similar problem on a cooking process, the original design had temperature PID control, however, the product would thicken as the temperature rose, these were shallow vessels, at some point the direct steam injection would blow holes through the product so in effect stop heating it, the PID would see the rate of temperature climb fall so try to increase the flow, this made it worse, so I removed the PID & had set 4 levels of steam flow, this worked a treat.
 
This is gonna sound crazy. But I have no idea what is going on in your code. I learned what AND and MOVE commands are, but I never encountered AND= or ANDE<, MOVE_E, AND<=. If you could lead me to a website or video that explains more of the commands you showed in the code. I never heard of the INT to real command. The first rung I don't understand, what RAW analog input is it receiving? Is it the pressure put into the hmi? And it is converted to analog the next rung. There is a lot I don't understand so I will go learn more code.
 
For example AND >= is just a greater than or equal to of integers, the E part means the variables are reals (or floats as some plc's call them) The AND means that it will only be evaluated if the EN pin is true There are also some compatible functions like >= without the AND, these these do not use the EN pin so are shown it means they are always evaluated every scan it is a way of not needing to connect the function to the left hand poer rail.
These are sometimes specific to the type of PLC, for example some IEC logic in some PLC's you can use an integer or a float as the input, however, in this application the MOV_E means the EN pin has to be true to move an integer from one variable to another, if you are moving a real (float) then the function is called EMOV the E in front means float or real.
Attached is a pdf of some of those symbols this PLC has probably 250 plus functions, ways to mix ladder & FBD some are the same but can be displayed in more than one way.
 
I am writing down questions for each rung and trying to explain what they do. This next post will be a long one, but in the end I will ask my main questions. For right now my main question is, I see you coded the pump to turn on for step 10 (rung 13), but it just turns on and builds pressure untill the values compared from the pressure transmitter and the pressure set point are close enough. I will be using a transducer so I am not sure how that will work for step 10, I need to send it an analog signal to make it start pumping, I am not sure if the transducer continuously pumps at that pressure or if it pulses. Either way I will need to replace the pump in the code to a analog signal to the transducer. Also where in the code does the pump get a signal to slow down once it is close to the set point? Is that rung 14 and 15 where the last thing done was the slow pump and fast pump analog signals are sent to the pump to either slow down or speed up? When the pressure is met where does the pump shut down at?
I will follow post with a bunch of questions and me trying my best to explain the code. So far I understand it all but just need to somehow learn how to transfer this into the click software. I am using the do-more designer simulator and I cannot find these AND functions anywhere.
 
Last edited:
The way it works is that the pump is fed by main air, so there is an isolation valve that is the pump if you like perhaps I should have re-named it, there is also a shut off valve after the pump, this is to stop back pressure leakage not sure if you need this but it is worth thinking about, the analog signal change is on rungs 14 & 15 if the pressure is below the Slow changeover SP on the HMI for example if it was set at 150psi it puts 100%(pump fast speed SP) to the analog output (not shown here as this is usually set in the analog card setup). When the pressure in the vessel goes above 150 PSI, the slow SP is moved to the analog output variable
So if the required pressure setpoint is 200 PSI iWhen the actual measured pressure is below 150 psi the fast speed is sent to the analog output variable when the actual pressure rises above 150 PSI, the slow speed is SP is moved to the analog out variable.
I bet when you run this only two speeds are required. but you could add more so extra stages, it all depends on the time it takes to get to pressure and if any overrun is high, I doubt it the PLC can stop the feed valve in a few milliseconds but the pump stopping & valve closing may be in fractions of seconds, even then, at low speed assume the rate of climb is 1 PSI a second & the shut off of the pump and possibly the valve was 3 seconds then you will only go over by 3 PSI I think you are overthinking this.
However, without knowing what the physical plasnt can do I can only guess from experience, I do not believe that ramping down the feed is required continuously (unless of course there are some reasons I do not know off, As I said, I did a number of Vacuum test machines, these did the opposite, the air was removed to almost 0 psi gauge (15 psi is atmospheric), I was then held for x seconds, if the packs split then the vacuum dissipated due to the pressure in the packs (this was if sealed properly at least 15 psi (air pressure at sea level) the extra volume of air would reduce the vacuum so in effect became a non sealed pack. So it is exactly the same as what you are trying to do but in reverse. We did others that rather than draw a vacuum a cylinder would press down on the top of the pack & if it went too far (measured with a linear transducer then the seal was no good, all these packs were sealed with a gas mixture to increase the shelf life so had a slight dome on the top foil or film, if the film was not sealed at a given pressure then the cylinder travelled further hence a pack that had a bad seal.
Both these systems required far more accurate vacuum or position than your test & did not need to ramp as you seem to want to do.
I may be wrong but over 40 years doing this sort of thing I have some experience, The only thing that could be an issue is if what you are testing could not stand a quick change in pressure then perhaps a more linear reduction of pumped air would be required. We did have to release the vacuum a little slower or the sudden pressure increase could cause the film to rupture but again it was not a major problem.
 
It sounds like this process is similar to setting the water temperature in the shower (assuming the starting point is that the hot water is on full and the hot water has reached the shower head):

  1. Turn the cold knob to increase the cold water slightly to mix with hot water and bring down the temperature of the mix coming out of the shower head.
  2. Wait for for the outlet water to come to equilibrium with then new mix at the shower head.
  3. Put hand in the water coming out of the shower head (Ow! briefly)
    • If we sense (measure) that it is still too hot
      • then return to step 1 above
    • If we sense that it is the desired temperature,
      • then leave the cold knob as is and start the shower
Is that about right? If yes, then the rungs would be similar but re-ordered:

  • Rung 1: increment pump speed
    • If
      • in the raise-pressure state [NC contact on internal bit],
      • AND pressure is low [LESS-THAN instruction on pressure measurement]
      • AND sample_timer has expired [NC contact on sample_timer, or on .Q bit of sample_timer]
    • then
      • increment signal to pump output transducer by some delta [ADD instruction]
  • Rung 2: repeating sample timer
    • If
      • in the raise-pressure state [NC contact on internal bit],
      • AND sample_timer has not expired [NO contact on sample_timer, or on .Q bit of sample_timer]
    • then
      • run TON (Timer ON-delay) sample_timer, [TON instruction]
        • duration of say 1000ms
        • or whatever seems suitable for the air-pump=>pressure response
  • Rung 3: move to next (hold?) state, and hold there, when pressurization finishes (Start/Stop Circuit pattern)
    • if
      • EITHER
        • BOTH
          • in the raise-pressure state, [NC contact on internal bit]
          • AND pressure is greater than 200psi [GREATER-THAN instruction on pressure measurement]
        • OR
          • were in the hold state on the previous scan, [NC contact on internal bit]
      • AND
        • not in the next state after hold, [NO contact on internal bit]
    • then
      • enter (or remain in) hold state, [Output coil on internal bit]
  • Rung 4: move to, or stay in, raise-pressure state (Start/Stop Circuit pattern)
    • if
      • EITHER
        • BOTH
          • in start state, [NC contact on internal bit]
          • AND solenoid valve is closed, [NC contact on internal bit]
        • OR
          • were in the raise-pressure state on the previous scan, [NC contact on internal bit]
      • AND
        • not in the next state (hold) after raise-pressure, [NO contact on internal bit]
    • then
      • enter (or remain in) raise-pressure state, [Output coil on internal bit]
Actually the order is probably not critical, because the PLC scan cycle will be executing these rungs every few milliseconds. The point to understand is that programming PLCs is about time: detecting when inputs (discrete or analog) change; calculating internal state(s) for the current (now) scan cycle; detecting when internal state(s) change from previous scan cycles; and saving internal state(s) that persist to inform future scan cycles; choosing when to change outputs (discrete or analog).
 
Last edited:
Yes Brian, that is correct, however, I don't think it is required to ramp down the speed in such a way, as I have posted, simple full on til within a few PSI of setpoint then reduce this over time either by a set amount.
Alternatively, reaching value some psi below setpoint use a simple algorythm to ramp down the analog output but there must be a minimum to allow the pump to keep up the rising pressure, no idea exactly what this air pump is but my guess it is a reciprocating one so the pressure will increase in lumps.
A double diaphram with non return valves. This one have two diaphrams, each cycle it pumps a given amount of what ever medium is to the output port or it could be a positive displacement one with rotary air driven system, the first will produce pulses of medium each cycle however, reducing the air supply below a limit it will stall, the later is more subtle so continuous steady flow but again many will not run under a set pressure, so some sort of minimum is essential.
It is a bit of trial & error but simple to commission.
One thing has just occurred to me is in one later post the OP mentioned this is water leak test, I assumed that it was air but it sounds like the air is just the pump drive & the meduim is water not air.
 
Btw, in that example in my last post:

  • rungs 3 and 4 implement something like the Step pattern from that Patterns of Ladder website.
  • rungs 1 and 2 act (or not) based on the current state (step) of the process.
  • there are two approaches to take
    • put the rungs that implement all the steps of the Step pattern transition logic (e.g. has the pressure reached 200psi in the raise-pressure step so I should change to the next step?) in one section of your code, and all the rungs that execute the process business logic specific to each step (e.g. in the raise-pressure step, run the timer and increment the pump speed) in another section
    • OR
    • put the transition and business logic for each step together.
  • Since there are only a few steps (states), I use that Step pattern, and there is a bit for each state. Another approach would be to have a single PLC-internal integer variable named STEP, that has an enumerated value for each step of the process e.g.:
    • 0: not running
    • 10: raise-pressure
    • 20: hold-pressure for some duration of time
    • 30: indicate results after hold-pressure time expired
    • In this approach, we do not use the Start/Stop Circuit pattern as much, because internal integer variables hold their value across scans, so the seal-in is not needed, and since there is only one STEP variable, it can only hold one value, i.e. the process can be in only one step/state, at a time.
 
Yes Brian, that is correct, however, I don't think it is required to ramp down the speed in such a way, as I have posted, simple full on til within a few PSI of setpoint then reduce this over time either by a set amount. ...


Agreed: the way to do it will depend on the process. For example, according to OP, currently an operator turns a knob and watches the pressure. If they are anything like me in our shower at home, by the time they have gone through the process a few times, there is an arrow drawn on the knob that is pointing roughly up when the air pump will reach the target pressure, the same as when I get in the shower I have already memorized the approximate knob positions, so I start there and get in being neither scalded not frozen, and tweak it (maybe it's summer and I need more cold, or maybe the washing machine is running and I need less cold).

If feedback control is necessary instead of bang-bang control, then PID or even floating control might be good enough and is certainly trivial to implement; I would think the update time would be the more critical parameter.
 
I am sorry but I am doing the best I can, I have a little more than a couple questions. Also I have no idea how I am going to convert this into click PLC programming software, but time will tell.

MAIN QUESTIONS:

1.What is the scaled_analog_value and what do we use it for, what does it mean in our system for controlling everything?
2.1st and 2nd rung: What analog input are we converting? Is it the pressure transmitter? Converting the raw input to analog and then to scale (actual pressure we can read)
3. 3rd rung- Why is the test complete message, over_press_alarm, and test failed message all displaying after the HMI start button is pressed? Or are those commands disabling them and removing the messages from the screen after the last test was complete?
4. 4th rung- Why does the system go to idle if the E-stop is false (not pressed)? Is the E stop enabled when the button is not pressed? Why is there not a open contact there, so when the E stop is pressed (True) the system goes to idle?
5. 5th rung- What is HMI_in_flight and why are we subtracting the setpoint and the hmi in flight? Then we compare the scaled_analog_value to be greater than or equal to the number we got from (pressure_set_point – hmi_in_flight)
6. 13th rung- Why is the shut-off-valve opened? Wouldn’t that make the system not be able to build pressure? If I am using a current to pneumatic transducer to control the pump, shouldn’t that always be on? And I will need to send signals to the transducer to start pumping air into the pump. How will I control the transducer, will I start it at a specific pressure and leave it until the pressure set point is met? Or will I turn the transducer on and off quickly and lower the pressure as it gets closer to the setpoint?
7. 14th and 15th rung - What is slow_pressure_change_At and HMI_fast_press_lev_sp? How do they correlate to the setpoint? Shouldn’t it be compared to 80% of the pressure setpoint, and if its above that then slow down the pump. Why are we comparing the current pressure in the system to slow_pressure_change_at. Is slow_pressure_change_At just 80% or more of the pressure setpoint wanted? If the scaled_analog_value is greater than 80% of the pressure setpoint, then the slow press should be sent to the pump.
8. 1st rung simulation- Is Raw_analog_input from the pressure transmitter? If so, why when it’s greater than 10 are we simulating falling pressure? Why are we subtracting 10 from the Raw pressure every 100ms? Shouldn’t it be falling already in the system and the pressure transmitter will be showing It realtime therefore we don’t need to simulate it?
9. 2nd and 3rd rung simulation- Why are we simulating pressure going up? If the pump is running then the Raw analog input should be increasing in real life which would also update the Raw analog input, therefore we can show it on the HMI screen instead of simulating it. Why are we simulating? Is Scaled_analog_value not the real time pressure from the pressure transmitter? Is it a saved value at the beginning of the test?

Trying to Explain and Understand Code

1st and 2nd Rung- What analog input are we converting? Is it the pressure transmitter or the current to pneumatic transducer. If it’s for the transducer, then why are we converting it? We don’t need to use the input on the transducer, all we need is output (raw analog) of the pressure transmitter, and then convert it to a real number like 500 psi. Then use that to compare to hmi_pressure_setpoint.
3rd Rung- I see once the hmi start button is pressed a AND= function is used to check if the system is at idle using seq-register and 0. Once that’s checked and is true then the next step is started, so we put 10 into seq_register. Now I see also that test complete message, over pressure alarm, and the test failed message are all enabled once the hmi_start_button Is pressed or are those removing the outputs on the hmi screen before resetting the system.
4th rung- If the E-stop is false (not pressed) and there is a normally closed contact for it, why does the system go to IDLE? Or is the E stop enabled or on when the button is not pressed in this case?
5th rung- What is hmi in flight and why are we subtracting the setpoint and the hmi inflight, and then comparing the scaled analog value to be a greater than or equal to (pressure_set_point – hmi_in_flight)
6th rung- Once step 20 starts a TON (timer on delay starts) for 2 seconds before sending a signal to grab the scaled Analog Value (pressure transmitter) and move it to and save it as pre test pressure and also starts step 30
7th rung- Once step 30 starts and step 20 is done and the pressure is met, a one second pulse is connected to a counter, the counter saves its time using the HMI_Act_pressure_test_time.
8th rung- As rung 7 is counting, rung 8 is checking if its still on step 30, if it is then it checks if HMI_Act_pressure_test_time is greater than or equal to the actual HMI_test_time_sp, if it is step 40 is started and the scaled analog value from the pressure transmitter is saved and stored as post_pressure_result.
9th rung- checks if its on step 40, the pressure we saved before starting the pump is subtracted by the HMI_Min_test_pressure_dif (pre_test_press_store – HMI_min_test_pressure_dif) and then put into an ANDE<, where the scaled_analog_value (pressure in system now, realtime) is compared to it. If the pressure in system is less than the subtracted value then the test failed and a message is put out, also step 50 starts too.
10th rung- after the test failed (rung 9) the system checks if its in step 40 and changes it to step 50
11th rung- checks if it’s on step 50, if so then the ANDe< is used to check if the scaled_Analog_value is less than 0.5 psi. If it is, then the MOVE_E command is used to set the step back to 0. Also, if the test_failed_message is false or not showing then the test complete message will be activated to show on the HMI.
12th rung- Checks if it’s on step 10 or above step 10. If it is, then it checks if the system is on or below step 40. If the system is on or between steps 10 and 40 then the bleed valve is turned to close (which is true for the bleed valve)
13th rung- Checks if the system is on step 10 using AND=. If it is then the pump is started ad the shut_off_valve is opened.
Why is the shut-off-valve opened? Wouldn’t that make the system not be able to build pressure?
If I am using a current to pneumatic transducer to control the pump, shouldn’t that always be on? And, I will need to send signals to the transducer to start pumping air into the pump. How will I control the transducer, will I start it at a specific pressure and leave it until the pressure set point is met? Or will I turn the transducer on and off quickly and lower the pressure as it gets closer to the setpoint?
14th rung- First it checks if the system is on step 10, if it is then the ANDE< is used to check if the scaled_Analog_Value (pressure in system) is less than slow_pressure_change_At, if it is less than it then HMI_Fast_press_Lev_sp is sent to the pump via pump_Analog_out.
What is slow_pressure_change_At and HMI_fast_press_lev_sp? How do they correlate to the setpoint? Shouldn’t it be compared to 80% of the pressure setpoint, and if its above that then slow down the pump
15th rung- same questions as rung 14. Why are we comparing the current pressure in the system to slow_pressure_change_at. Is slow_pressure_change_At just 80% or more of the pressure setpoint wanted?
If the scaled_analog_value is greater than 80% of the pressure setpoint, then the slow press should be sent to the pump.

Simulation

1st rung- why is a AND> being used to compare Raw_analog_input and the number 10 (step 10). Is Raw_analog_input from the pressure transmitter? If so why when its greater than 10 are we simulating falling pressure? Why are we subtracting 10 from the Raw pressure every 100ms? Shouldn’t it be falling already in the system and the pressure transmitter will be showing It realtime therefore we don’t need to simulate it?
2nd rung-If the pump is running and the bleed valve is closed then use AND< to see if Raw_Analog_input is less than 4096. If it is then the scaled analog value (psi pressure in system) is compared to slow_pressure_change_At to see if its less than it. If it is then every 100ms 10 is added onto the Raw_Analog_input.
Why are we simulating pressure going up? If the pump is running then the Raw analog input should be increasing in real life which would also update the Raw analog input, therefore we can show it on the HMI screen instead of simulating it.
3rd rung- Same thing as rung 2 except the scaled_analog_value is compared to see if its greater than slow_pressure_change_At. If it is then every one second that passes by a 10 is added to the Raw_analog_input value.
Why are we simulating? Is Scaled_analog_value not the real time pressure from the pressure transmitter? Is it a saved value at the beginning of the test?
 
My logic does not have seal in. initially, the sequence is 0 (IDLE), pressing the start button moves 10 into the seq register, so it is retentive, no latch needed, the resets are just to reset the status message bits on the screen display i.e. Test Failed or Test Complete & reset an alarm as an example, no need to have seperate step for slow down as this is done in the last two rungs. did not want to have too many steps i.e. one each for the full/low pressure, operator probably is not interested (well that is what I found on the vac test rigs I did.).
This rig is so simple however, have include a steps to store the actual pressure before the test (not directly after shut off of the air & after a short settle time also, after test complete, it populates the final pressure so in effect you have both the start pressure & the final pressure as a record until the next test. I have not bothered to reset them on initial start as this might confuse the OP with a lot of logic on the first rung. this comes later.
 
You are correct about the water medium. This is for a hydrostatic testing unit. The air pump pushes air into the tube and the medium is water. So yea the system is pressurized with water. But it should be the same pressure as the air yes?

Also, Brian, I mentioned it earlier, but the pump does not have to ramp up or down to be an exact amount. Usually, the manual operators go over 50 psi the recommended test amount when doing these tests. So I think implementing a slow and fast pump system would be easier and should get me a tolerance that will work for my project. Also, there will be multiple pressures and things that will need to be tested, so there can be 200 psi tests or up to 1200 psi tests. All depends on what we are testing. The program from parky helped me a lot to understand how his program worked and I am now confident after analyzing it that I could replicate some of these functions into a code of my own. The things that really trip me up are what variables and values are we using and comparing them too. Check my main questions I had about the program above, but I really like this style of approach. I never coded once in my life before and I could still make sense what each thing was meant to do. Just need to brush up on the variables and why we do some functions, and I can hopefully make a program that is semi-broken.

I will try to download clicks PLC software and see what I can make from there next week. Hopefully it will seem like it works.
 
Last edited:
Why are we simulating?
Because it's agile* (doing things piecemeal).

To make development easier and safer, a process simulation allows us to exercise, test, and validate our PLC logic without a physical connection to the actual process hardware.

TL;DR

Many systems are fairly trivial and can be simulated in a few rungs e.g.

  • if the air-pump is running, then increment pressure (value of integer or float variable) by 1psi every 100ms; pressure will reach 200psi in 20s.
  • if air-pump is not running, then hold pressure at current value
  • if the solenoid valve is open, then decrement pressure by 1psi every 100ms.
That is not a high-fidelity model, of course, but it is good enough to validate most the logic of the PLC trying to control it. And I can run it on my PC using the PLC emulator that Click provides, while I am still waiting for the physical PLC to arrive.

* WAY-TL;DR: Pluto TV is a streaming service that is basically broadcast TV i.e. with lots of commercials. But it also has some great (in the eye of the beholder;)) channels; one of those channels is the Ed Sullivan channel, which has clips of various acts that were on the Ed Sullivan show over 23y several decades ago. One act is a guy on a unicycle juggling while balancing a stick vertically on his forehead. I suspect he did not learn to do that trying to all three things at once. Surely he learned to just ride a unicycle, then just juggle the pins, and then just balance the stick, before trying any combination of those three ski;ls.

Developing computer programs can be accomplished (performed) the same way, and it also has the benefit of not being overwhelming when looking all at once at everything we want the program to do.

So, pick a single task, e.g. can I convert and scale the pressure sensor signal to a floating-point REAL value in the PLC? Once that is working, try something else e.g. can I set or clear a bit based on whether the pressure is above 200psi or not?

Two things will happen with this approach:

  • By working a sub-task on one aspect of the process, we learn about other aspects of the process
    • E.g. while learning to convert and scale the pressure sensor signal, we run the air pump and get an idea about how the pressure responds to the air pump speed.
    • What we learn in earlier sub-task will allow us to make better choices in later work.
      • E.g. we might realize that if we run the air pump at 100% and turn the pump off at 198PSI, the pressure will overshoot 200PSI by only a few PSI, so there is no need to ramp up the pump speed gradually.
  • We won't initially know when we are done: we will finish the last sub-task, and look for the next sub-task, only to either realize that there are no more unfinished sub-tasks and the program is complete, or learn that the other sub-tasks, which we thought were needed, will not provide enough benefit to justify the effort to do them, and we know this because we learned so much about the process while completing the other tasks.
 
Could you link me that PLC emulator that click provides?

Now I understand why it was being simulated. Since there was no actual pump connected or pressure transmitter we had to simulate if the pump was actually stopped, pumping air, or dropping pressure. So to test the code, we needed to add that simulation part or else nothing would change values and therefore there is no way to test the program.
 

Similar Topics

Hello. I have been trying to crack this one without success and could not find any hint after several search attempts. I wonder if any CODESYS...
Replies
4
Views
3,920
Hello, I'm pretty sure I know the answer to this, but wanted to verify with the experts. Am I able to write a program using the Micro Starter...
Replies
7
Views
3,150
First off, i am new to ladder logic. I do have some experience programming microcontrollers in C. I will try and give a short version and if more...
Replies
7
Views
2,011
This is a CompactLogix L33ERM, version 30 (31 is too unstable on my machine to work with), with a Kinetix 5500 drive. I have a program where...
Replies
2
Views
2,000
Good morning guys! I have a doubt. I uploaded a program from a S7-200xp on the field and took it to the office. Before doing any test I tried to...
Replies
7
Views
2,151
Back
Top Bottom