Advanced level programming examples

Bcurry135

Member
Join Date
Dec 2020
Location
Mid Ulster
Posts
36
Hi all

I am just new to this and relatively new to plc programming, I have been self teaching myself for just over a year now and have done numerous small projects in my work which is a food factory. Some of the projects included HMIs where operators can choose the speed they want their conveyors to run at and another was a tank with submersible pumps which is displayed on an hmi with on and off setpoints which are changeable. I have found doing these small projects to be quite simple and I would just like some feedback from someone who is vastly experienced in programming plcs as to what they would consider an ‘advanced’ or complicated program to accomplish, just so I can possibly practice and take my skills further.
 
My suggestion would be to look at every instruction provided by your brand of PLC, and come up with an application where each would be used; instructions are the vocabulary used to express the behavior of a program*.



TL;DR


Search for "lead lag" on this forum; those are always interesting. There is a current thread similar to that: four filters; two will be normally in the "running" state at any time; the others will normally be in "standby" state, which means it is available to transition to "running;" when a "running" filter transitions to "backwash" (presumably pressure drop reaches a limit, or after a timer expires), one of the "standby" filters will transition to "running" to maintain two in that state; a filter can also be in "bypass" state, which means it is no longer available for operation e.g. undergoing maintenance.


Similar to lead-lag is a PLC controlling a model train set.


Tracking parts, using FIFOs and bit-shift instructions are interesting.

PID controls are interesting, especially with cascade and ratio in the mix.


Motion control is a whole 'nuther kettle o' fish.


IMNSHO, the real complexity is not writing the code*, it is understanding the process. For example, a web** requires understanding things like speed vs. torque control of motors.


* a program is a model of something in the real world; the only real decision is the level of fidelity required, and everything else follows from that.



** e.g. an 8-foot wide roll of paper running over rollers, dancers, accumulatar, nips, drive rolls, etc., at several hundred or a few thousand feet per minute, with no wrinkles, and a tension profile controlled w.r.t wound diameter (square root of length) to prevent telescoping of the wound product.
 
Last edited:
A good challenge is writing a program for a clothes washing machine. You already know the specification. Start with a simple system, but write it with future additions in mind.
Start with one speed, one temperature, one rinse etc.... Then add features. Soak, multi-speed, multi-temp.
The simple one can be just switches, but add analog later for temp, water level, etc..

For an extra challenge, use conditional sub-routines to call the major steps, wash, rinse, spin etc....

Write simulation logic, so above runs without human intervention.
 
Hi all

... another was a tank with submersible pumps which is displayed on an hmi with on and off setpoints which are changeable. ...
How do you change the setpoints?
Does one click on the up arrow increase the setpoint one unit.
I would work on what you have.
Maybe you can make it better.

How about you change it so that as long as you keep your finger on the Up arrow, the Set point increases.
The longer you hold your finger down the larger the value that it increments.
You might want to limit the increment value, and the Max and Min setpoints.
 
IMNSHO, the real complexity is not writing the code, it is understanding the process.

+1

A great deal of what might be considered 'complicated' code is more accurately fairly straightforward code dealing with a complicated process.

Consider Ken's washing machine example -- any individual feature is fairly straightforward, it is as you add in more and more features that the program grows complex and integrating features cleanly becomes a challenge (especially if you don't plan ahead well).
 
Hello, I am doing exactly the same work from past 15 years and I am very much excited to do small projects by myself. Recently I did programming in Delta PLC. The link is given below
https://youtu.be/glYkO0ZjNGs
I appreciate if you want to connect with me in WhatsApp . Since we both work in the food processing and packaging industry, we can be helpfull to each other.
My WhatsApp number +92-322-8208180
 
How do you change the setpoints?
Does one click on the up arrow increase the setpoint one unit.
I would work on what you have.
Maybe you can make it better.

It works by just an io field on the hmi which can be modified by inserting for example 2.5 metres and I have limits set so it can not be set over the limit of the tank capacity.

Appreciate the feedback from everyone thanks
 
Search for "lead lag" on this forum;
What does this mean to you? To me it is a lead-lag filter where there is one zero that causes phase lead and one pole that causes phase lag.





There is a current thread similar to that: four filters; two will be normally in the "running" state at any time; the others will normally be in "standby" state, which means it is available to transition to "running;" when a "running" filter transitions to "backwash" (presumably pressure drop reaches a limit, or after a timer expires), one of the "standby" filters will transition to "running" to maintain two in that state; a filter can also be in "bypass" state, which means it is no longer available for operation e.g. undergoing maintenance.
This a about state machines. This is good stuff/





Similar to lead-lag is a PLC controlling a model train set.
Again, this is about state machines.






Tracking parts, using FIFOs and bit-shift instructions are interesting.
My first real programming job was a lumber trimmer and sorter.
I eventually made a simulator for this. This was back in the early 80s and was done on a 8085 and 8086. PLCs couldn't handle this yet.




PID controls are interesting, especially with cascade and ratio in the mix.
I have good examples but they are simulations again.





Motion control is a whole 'nuther kettle o' fish.
These really should be done with a motion controller and the PLC uses state machines to handle the sequencing.





IMNSHO, the real complexity is not writing the code*, it is understanding the process. For example, a web** requires understanding things like speed vs. torque control of motors.
agreed. You can't control what you don't understand.



* a program is a model of something in the real world; the only real decision is the level of fidelity required, and everything else follows from that.
Modeling things can be a project in itself. If you can write a good model then you surely must know a lot about the behavior of the machine.


** e.g. an 8-foot wide roll of paper running over rollers, dancers, accumulatar, nips, drive rolls, etc., at several hundred or a few thousand feet per minute, with no wrinkles, and a tension profile controlled w.r.t wound diameter (square root of length) to prevent telescoping of the wound product.
This is more of a motion controller application.


I would add learning the tricks for debugging. Sometimes a FIFO is a good way to record things and capture events. A well written program will be about 1/3 monitoring and debugging aids.
 
I coded my first "pump selection" application recently and would recommend it particularly if your platform supports arrays and constants for declaring the size of the arrays (I used Siemens TIA Portal)

The system had 7 pumps (but you should code it for N pumps) and the number of pumps required was a function of the flow rate - a simple linear relationship will suffice. Each pump can be either off (not available to run) or auto (available to run). The pumps must be selected to run to even out the run time of the pumps. The pumps are only allowed to stop/start when the flow rate dictates a change in the number of pumps required.
 
I coded my first "pump selection" application recently and would recommend it particularly if your platform supports arrays and constants for declaring the size of the arrays (I used Siemens TIA Portal)

The system had 7 pumps (but you should code it for N pumps) and the number of pumps required was a function of the flow rate - a simple linear relationship will suffice. Each pump can be either off (not available to run) or auto (available to run). The pumps must be selected to run to even out the run time of the pumps. The pumps are only allowed to stop/start when the flow rate dictates a change in the number of pumps required.

That sounds interesting, so is it like an alternate duty cycle only with 7 pumps? So after first pump comes on and off then move on to next pump when flow rate requires ? May I just ask aswell what the use of arrays is for in that type of project? I haven’t really touched on arrays much as I have had no need or I don’t think I have anyway lol.
 
Say there is no flow so no pumps running. Low flow so pump with least hours starts, flow increases, so next pump with the least hours starts etc. as the flow increases. As the flow decreases, the pump with the most hours stops etc. If a pump is turned off then it is ignored.
 
Arrays - very useful for dealing with a number of pumps in the same way, e.g.


Code:
If bOneSecondPulse then 
  For i:=1 to NumberOfPumps do
   If Pump[i].Running then 
    Pump[i].Runtime:=Pump[i].Runtime + 1;
   End_if;
  End_For;
 End_if;
 
What does this mean to you? To me it is a lead-lag filter where there is one zero that causes phase lead and one pole that causes phase lag.


In the context of this thread and this forum, it means the same thing to me as it does in 19 of the first 20 PLCtalk.net hits Google gives for the search term [lead.lag].


Yes I know lead-lag has other meanings, and there are also probably other terms people use for the same algorithm (pump sequencing, etc.), but in this context that seems like the right phrase.


That reminds me, RonB wrote a balanced run-time sequencing program for someone on this forum, and it was posted here as well. IIRC it was for vacuum pumps, but I am not sure about that. I thought I found a minor, 1-scan, hiccup in the switchover logic, but the user sang its praises, so that hiccup was meaningless (if it existed at all); in any case, it was a sweet instance of the kind of thing the OP here might be looking for.
 
Say there is no flow so no pumps running. Low flow so pump with least hours starts, flow increases, so next pump with the least hours starts etc. as the flow increases. As the flow decreases, the pump with the most hours stops etc. If a pump is turned off then it is ignored.

Yes I understand, do you mind sharing a few shots of your code just so I can compare with my own? I would like to compare just to make sure I am programming efficiently and ‘properly’ so to speak.
 
That reminds me, RonB wrote a balanced run-time sequencing program for someone on this forum, and it was posted here as well. IIRC it was for vacuum pumps, but I am not sure about that. I thought I found a minor, 1-scan, hiccup in the switchover logic, but the user sang its praises, so that hiccup was meaningless (if it existed at all); in any case, it was a sweet instance of the kind of thing the OP here might be looking for.

Thanks for that I will try to find that👍
 

Similar Topics

This video shows the things I think about on page 1. I use Laplace transforms a lot. Laplace transforms allow one to express differential...
Replies
2
Views
1,806
Oh No! Not that again! I will start out sort of simple ( evil thoughts ) Suppose I have a tank that is 4 meters tall with a constant surface area...
Replies
15
Views
7,417
The purpose of this thread is to use a simple system to show how one can approach systems that are much more complicated. Everyone knows...
Replies
22
Views
12,280
Is anyone interested in covering this topic at a college level? Tank level control is a simple application but I can go where most have not gone...
Replies
26
Views
6,541
Hi folks, I'm not as accustom with Siemens & WinCC, however I've been asked to increase the amount of data an existing application is logging...
Replies
2
Views
67
Back
Top Bottom