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

2)On the main program, rungs numbered 2 and 3 which are safety features. Do I need to copy and paste these 2 rungs into the subroutines 10,20,30, and 40? If the program is scanning subroutine 20 and as the pressure is building someone pulls the emergency button or maybe the pressure goes over the overpressure point, will rungs 2 and 3 on the main program execute while scanning the subroutines?


Yes, the scan cycle ensures that rungs 2 and 3 will be evaluated at around 1kHz. So even if safety features are activated after rungs 2 and 3 are evaluated during one scan cycle, those events will be detected when rungs 2 and 3 are evaluated again, a few milliseconds later, on the next scan cycle.
 
In easier terms, will rungs 2 and 3 work if at any point someone pulls the emergency button, or the pressure is over the overpressure point?


I am answering this question again, because I perceive you may be asking a different question than question (2) from that post.

Specifically I will answer this question: will the PLC program respond to the emergency stop button being pressed, at the instantaneous moment that button is pressed?

The answer is no. The emergency stop button does not generate an interrupt in the PLC. The PLC polls the inputs as part of the scan cycle, usually just before it starts evaluating the logic of the PLC program (also immediately after evaluating the logic, because the scan cycle repeats, but any changes will be detected on the next scan cycle).

So the PLC does the following:

  • poll inputs, write inputs' statuses to Data Register memory (X001, X002, etc.)
  • evaluate program logic based on contents of Data Registers
  • poll inputs, write inputs' statuses to Data Register memory (X001, X002, etc.)
  • evaluate program logic based on contents of Data Registers
  • poll inputs, write inputs' statuses to Data Register memory (X001, X002, etc.)
  • evaluate program logic based on contents of Data Registers
  • poll inputs, write inputs' statuses to Data Register memory (X001, X002, etc.)
  • evaluate program logic based on contents of Data Registers
  • etc.
So any change in the inputs, e.g. an emergency stop button pull, will be

  • detected on the next input poll after the pull, and
  • responded to on the next evaluation of the program logic after that input pull.
 
I won't be able to finish a rewrite of the program today, but if someone can point me to any electrical drawing or I/O list at least, and tell me what make/model of HMI is going to be used, that should be enough info to finish up the basic functionality.

I see that my suggestion of using subroutines was probably a mistake, since it has led the OP, being new to PLCs, to take an approach that would not be good, so I apologize for not making more clear my concept. For that mistake, I will get something churned out tonight or tomorrow that will be a really good head start.
 
@drbitboy @parky Hello I am back from the weekend. Time to get to work. I will read all the things you guys posted. It seems like you guys really want to help, I really appreciate it. I will do some more learning from what you recommend and also the codes you posted. I have skimmed through them, and it all makes sense to me so hopefully I can get something out of this week. I am planning to learn more about the electrical side of the PLC. If I don't know how everything connects then how will I know what PLC to get, so that's why I will focus on that. Also, I will give you my parts list I made already if you two want to skim over it.

NCP2-20-3120N ( pressure transducer, current to pneumatic transducer)- https://www.automationdirect.com/ad...o_pneumatic_(i-z-p)_transducers/ncp1-20-3120n

SPT25-20-2000A (pressure transmitter)- https://www.automationdirect.com/ad..._sensors/pressure_transmitters/spt25-20-2000a

EA9-T6CL-R (hmi touchscreen)-https://www.automationdirect.com/adc/shopping/catalog/hmi_(human_machine_interface)/c-more_touch_panels_ea9_series/c-more_ea9_series_touch_panels/ea9-t6cl-r

PARKER GRESEN Pressure Relief Valve: 0 to 2000 psi (mechanical relief valve)-https://www.grainger.com/product/38D924?gucid=N:N:pS:paid:MS:CSM-2295:TVRYAD:20501231&gclid=9335421c701c1e763b3f21dc7e0b7dd5&gclsrc=3p.ds&gclid=9335421c701c1e763b3f21dc7e0b7dd5&gclsrc=3p.ds&msclkid=9335421c701c1e763b3f21dc7e0b7dd5

Solenoid Valve: 1/4 in Pipe Size - Valves, 120V AC, 0 psi Min. Op Pressure Differential- https://www.grainger.com/product/REDHAT-Solenoid-Valve-1-4-in-Pipe-6WTT0

Click C0-12DRE-1-D- https://www.automationdirect.com/ad...stackable_micro_brick)/plc_units/c0-12dre-1-d

Click Power Supply C0-00AC- https://www.automationdirect.com/ad...ackable_micro_modular)/power_supplies/c0-00ac

Serial to RJ-12 cable for hmi- https://www.automationdirect.com/ad..._panel_-a-_micro-graphic_panel_cables/ea-2cbl

This post has all my input and output parts selected. I might get different brands or versions but the main input and outputs are there and also my hmi.

Inputs: pressure transmitter

Outputs: current to pneumatic transducer, normally open solenoid valve, normally closed valve
 
Consider this rung from the 10 Pumping to Setpoint subroutine:

Untitled.png

This subroutine is called unconditionally from the Main Program, so this rung will execute on every scan cycle.


So there are two possibilities for this rung:

  • When the value of DS1 Sequence Step is equal to 10:
    • the Y002 Pressure Relief Valve output will be assigned a value of 1 by the OUT output coil,
    • which will close the dump valve, and
    • ensure the pressure rises once the pump starts.
    • That is good.
  • When the value of DS1 Sequence Step is not equal to 10:
    • e.g. when DS1 Sequence Step is equal to 20 Pre Test Pressure or to 30 Pressure Test,
    • this rung will still be evaluated,
    • but the equals-compare instruction evaluation will make the rung False,
      • which rung is going to the OUT output coil for Y002 Pressure Relief Valve.
    • In that case, what value with the OUT output coil assign to the Y002 Pressure Relief Valve output?
      • Is that good, especially for steps 20 and 30?
 
Consider this rung from the 10 Pumping to Setpoint subroutine:

This subroutine is called unconditionally from the Main Program, so this rung will execute on every scan cycle.


So there are two possibilities for this rung:

  • When the value of DS1 Sequence Step is equal to 10:
    • the Y002 Pressure Relief Valve output will be assigned a value of 1 by the OUT output coil,
    • which will close the dump valve, and
    • ensure the pressure rises once the pump starts.
    • That is good.
  • When the value of DS1 Sequence Step is not equal to 10:
    • e.g. when DS1 Sequence Step is equal to 20 Pre Test Pressure or to 30 Pressure Test,
    • this rung will still be evaluated,
    • but the equals-compare instruction evaluation will make the rung False,
      • which rung is going to the OUT output coil for Y002 Pressure Relief Valve.
    • In that case, what value with the OUT output coil assign to the Y002 Pressure Relief Valve output?
      • Is that good, especially for steps 20 and 30?

So, should I make each subroutine be called conditionally from the main program by putting, If DS1 sequence step is equal to 10 call subroutine 10 pumping to setpoint, and the same for calling sequence step 20 and 30.
I did that yesterday and people said that would cause a lot of problems if I called it conditionally on the main program.

Also, I don't see any way for the sequence step not to equal 10 when getting to this subroutine. I also thought that subroutines are only scanned when they are called and untill they are returned back to the main program. What do you mean by it will always execute on every scan cycle? I thought that it would only be scanned when the subroutine was called, why is it scanned all the time?
 
Last edited:
So, should I make each subroutine be called conditionally from the main program by putting, If DS1 sequence step is equal to 10 call subroutine 10 pumping to setpoint, and the same for calling sequence step 20 and 30.
I did that yesterday and people said that would cause a lot of problems if I called it conditionally on the main program.


No. Try to think of another solution.

For example, this subroutine is called unconditionally from the Main Program on every scan cycle.

Therefore, this rung is evaluated on every scan cycle.

Can you think of a way to ensure this OUT instruction will assign a value of 1 to Y002, whenever it is evaluated (i.e. on every scan cycle), and the value of DS1 Sequence Step is EITHER 10 OR 20 OR 30, i.e. between 10 and 30 inclusive, and not just equal to 10?
 
Okay I am confused. If on every scan cycle this subroutine is called and being scanned and being evaluated, then why won't the value of ds1 reset it if it goes to 1?
My subroutine is called unconditionally from the main program. That means it's being evaluated every scan cycle right? If so why did you say no to all my other questions?
You said the counter will reset when ds1 is 1 in the subroutine. So does that mean it will only reset if ds1 is changed to 1 while in the subroutine? I thought if it's being scanned at all times and being executed so why when ds1 changes to 1 outside the subroutine the counter won't reset?
 
people said that would cause a lot of problems if I called it conditionally on the main program.


What was actually said about that was
You don't want to put conditions on the subroutine calls. That opens up a can of worms that will quickly turn into a can of whoop a$$.

And what I believe they were referring to was that, if a subroutine is being called conditionally, and that condition and call are being evaluated at 1kHz, and if the program also exhibits a bug (i.e. does something you did not want it to do but inadvertently told it to do), then it is harder to determine which rung(s) are causing the bug, either directly by being evaluated or indirectly by not being evaluated, because with conditional calls running at 1kHz you cannot be sure which rungs are actually being evaluated.

The solution is to make all of the calls unconditional, so the program executes the called subroutines in order, which would be the same as if all of the subroutines' rungs were concatenated, in order, in the Main Program (as @OkiePC wrote many posts ago).

The primary benefit of using subroutines in this hydrostatic test application is textual separation of logic, so when you are trying to implement or understand the behavior for the Pressure Test step, you do not have to wade through the rungs that implement the Pumping to Setpoint step.
 
Okay I am confused. If on every scan cycle this subroutine is called and being scanned and being evaluated, then why won't the value of ds1 reset it if it goes to 1?
My subroutine is called unconditionally from the main program. That means it's being evaluated every scan cycle right? If so why did you say no to all my other questions?
You said the counter will reset when ds1 is 1 in the subroutine. So does that mean it will only reset if ds1 is changed to 1 while in the subroutine? I thought if it's being scanned at all times and being executed so why when ds1 changes to 1 outside the subroutine the counter won't reset?

Sorry, I misinterpreted the question.

When the comments asked "During any part of this program if the [DS1] Sequence Step goes to 1 will this counter reset?" I interpreted "During any part of this program if X happens" to be a description of an instantaneous time event. And with that interpretation my answer is correct: if DS1 Sequence Step becomes 1 during an evaluation of Rung 1 of subroutine 0 Pre Start Check, this counter will not be reset immediately upon the change of DS1 i.e. before the next rung in subroutine 0 Pre Start Check is evaluated.

However, as you note, the next time that Counter instruction on Rung 1 of subroutine 30 Pressure Test is evaluated, that is when the counter will be reset, assuming DS1 Sequence Step is still 1 at that point.
 
Last edited:
However, as you note, the next time that Counter instruction on Rung 1 of subroutine 30 Pressure Test is evaluated, that is when the counter will be reset, assuming DS1 Sequence Step is still 1 at that point.


P.S. This is why we almost always want to make the subroutine calls unconditional.
 
In (hopefully) easier words: it does not matter when the value of DS1 changes to 1; whether the counter is reset is only dependent on what the value of DS1 actually is when the counter instruction is evaluated.
 
I finally understand, you wanted me to put a set command instead of the out command haha. I finally wrapped my head around it, that rung for seq step 10 is being scanned all the time, so when step 30 and 40 is happening and the seq step changes to 30, next scan that rung will be evaulated and will make the relief valve 0 and the air shut off valve 0 which will release all the pressure in the vessel which we dont want. Now when that rung is false there is a set command so only a 1 can be assigned when the rung is true.
 
Last edited:

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,937
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,165
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,026
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,016
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,158
Back
Top Bottom