Tia Portal plc code

Lukasz_Poland

Member
Join Date
Aug 2019
Location
Poland
Posts
28
Hello everyone

I am learning to program Siemens controllers in Tia Portal. I would have a question for you present on the forum. Would any of you have time to look at my program? Evaluate, comment or suggest something. Thanks for comments.

(By the way, I will ask how to add such a program to the forum, if it takes up some memory.)
 
Hello



1. My plc code



https://drive.google.com/file/d/1vGkC1Syj-m-PpfFqZ3soAVA3BKrS6_0c/view?usp=sharing


2.The appearance of the tank car washing station


https://drive.google.com/file/d/1qgGYJCNgVm9i_S7akJc195S_Aw0qC8bP/view?usp=sharing





The assumptions are as follows:
1. Line_1- all valves and pumps with value 1...
2. Line_2- all valves and pumps with value 2...
3. Preparation line- all valves and pumps with value 3.. and M10(alkaline agent)



I divided my code into several groups.At the moment I am writing a station preparation program and this is what I focus on.
 
Some people do not have TIA but are familiar with it so perhaps post some PDF files here, if they are larger than 250kb perhaps split them into the relevant blocks I think you can add upto 4 at a time.
 
I have had a quick look at your code, however, my knowledge of any other language is well, very poor so my comments below may seem a bit out of place as I can only look at the structure & guess at what you are trying to do.
So here goes.
You seem to have commented it pretty well, although not that I understand them but I'm sure anybody who speaks your language would find the documented comments are well done.
I noticed you seem to have different styles i.e. ladder/FBD, ST etc. I can only assume this is just to learn the different approaches, personally, I stick to one, but do use ST where is is more convenient.
There seems to be a lot of variables compared to the PI&D you posted, again not sure of the process but there does seem to be a lot.
It does appear that the program may be a little over fragmented a lot of smal blocks of code which to anybody de-bugging it could find it a bit confusing, in saying that, it is often quite useful in splitting the code into meaningful blocks, again not knowing the process & unable to read the comments difficult for me to criticise your approach.
Using a lot of set/reset on coils where they are spread over the program certainly seems to be used in Europe more so than other countries, many people frown on that & prefer to use a "Seal in circuit" which is really a latch i.e. a set/reset on the same ladder, I sort of agree as I have had to sort out many programs done in mainland Europe that used fragmented Set/Reset logic, In most cases I just re-wrote it.
Consider using a sequence variable to step through certain functions, this is often better than set/reset but will depend on the operation required.
i.e
Step_Seq_1 0 = IDLE
Start_Button MOVE 10 Step_Seq_1
for each step add 10 to the Step_Seq then use compares on outputs i.e.
assume a pump only runs between steps 20 to 50
then on the pump output just have if Step_Seq_1 => 20 AND Step_Seq_1 =< 50 out Pump_xxx
See attached
Hope this is useful, but for someone who is learning TIA I think you are on the right track perhaps someone with more experience in it could give you some good pointers.
 
I would use FB's rather than FC's as you can use the multiple instance facility for timers/edge detection etc. rather than having to pass them to FC's,
 
Thank you for your answer.

I think writing without set / reset is safer and better, but still it's a habit.

In the attached PDF, my station preparation procedure starts from page 24-29.
I'll try to make sequence. Then I will post again and request a comment.
 
Yes it is a habit I had at one time, although I did not have any real problems using set/reset, after many calls to systems that others wrote I realised how difficult it was to sort out, one particular system was a strapping machine (quite a complex one) there were about 12 different strapping patterns these comprised of straps on pallets without bottom runners, with, different sizes straps one way, straps both ways (rotate), for example if the pallet had bottom runners, swords would extend between the top/bottom wood runners to feed the strap through so depending on size could be 3 straps with/without swords, rotate & strap etc. plenty of combinations, originally this was selected by an operator on the hmi before the pallet entered, the original mods were to add pallet length encoders, width detection, photocells on the swords to align with the gaps (if no clear route was found between the spacing blocks it would move back/fwd to try & see a gap 3 times) so it would not require the operator to select but do it automatically. so quite complex I worked with the original programmer, it was a disaster, even he had problems there were so many set/resets and he was adding more to overcome gliches, at one time the machine was doing a dance without a pallet i.e. the compression head was cycling, the swords extending & retracting. The machine went to site, customer requested more support I went to site with another engineer from the manufacturer, still had problems tried to re-write it in sections but every time we did this some other problem would occur, in the end the customer took it out of service & demanded it be sorted, I ended up completely scrapping the original & re-wrote it, worked a treat, ended up re-writing another two machines on other sites.
Anyway, back to your code.
I noticed that your alarm handling seems rather complex a lot of ST code.
My approach is create a standard function block for valves & another one for motors, pass the relevant signals to & from the FB & call the instances for each motor/valve etc.
I generally create different functions for variable speed or direct drive motors but on valves just one with selectable parameters for N/O or N/C etc.
The block handles everything like alarms for limits, output(s). write once & forget.
I had a quick look at the PI&D sketch & it is so similar to a CIP (cleaning in Place) system. This one is a small one I did some years ago, based on another one I did a few years before but that one had 3 tanks, heat exch rather than coils & 7 channels.
You will notice that as I used sequence values, the status of the tanks convieniently is the sequence number so the status is just a lookup of the sequence numbers i.e.
0 = IDLE
10 = Starting
.....
100 Pre-rinse to Cooler
& so on.

CIP.png
 
Thank you for you answer parky.



Thanks for clearing up a lot of things.


I know I should use FB and multiinstance blocks but




I just don't know how to create multi-instance.

From what I understood from you Mr. Parky, I should create one block for valve and alarm operation and another block for drive and alarm operation.
But what to do with analog valves (4-20mA) and inverters where speed is set etc.
How to handle these devices. It seems to me that I will do it with your help, but I must break it down into smaller fragments because I lack experience.
 
As I mentioned, I do not have TIA but most modern IDE's are pretty similar regarding IEC programming.
Attached, is part of a Mitsubishi program it demonstrates how to create a standard block for valve handling, the valve block is a FB, in this it is called as a single instance i.e. every call is to the one block of code rather than have separate instances so when you call the block you give it the same name.
The bits & bobs are passed to it, the program jumps to the code & returns with any return data. If you gave each call to a FB a different name it becomes a seperate bit of code for each call.
If you think about basic or C etc. it would look like this
Call Valve_Stat with a name like _Valves_Control //this jumps to a subroutine called Valve_Control
When you call it again with the same name it jumps to the same bit of code, however, if you give each call a different name then the compiler generates a new subroutine for each call (wastes memory).
The ones shown are simple FB's but you should be able to see what I mean, I never use timers for alarm delays, I tend to use an integer variable as a count with an internal seconds bit to increment it so in the example I have a 3 second delay passed to the function the alarm_timer is configured as an IN/OUT parameter of type integer in the function so it retains it's status for the next scan.
So this pdf just shows the function block code & the calls to in in a program block.
I would not bother with creating a FB for the PID control as it in it'self is just that, I would have my scaling blocks for analog (nowadays most systems do not need them as the cards can be configured to scale them).
So what I do is the following.
A program block that calls the functions for Valves & motors, A block that calls the Analogs if required, (could have the PID's in here) or another block for the PID's & blocks for the control of the process.
Alarms are already generated for valves/motors in the calls to the functions
however, you may have alarms logic for other purposes so another program for general alarms.


_
 
Plc code one morę time

I decided to delete my entire program and rewrite it from scratch according to your instructions. I will try to post each stage on the forum for evaluation. Thank you all for your help and your time.
 

Similar Topics

Hi All, Someone at work has put a PLC system on my desk, that's just been taken off an idle production line. He said "It's an S7 PLC. We don't...
Replies
10
Views
255
Hello gentlemen, Im working on a small project on TIA Portal, about establishing a Modbus TCP connection between my ET200SP plc and a socomec...
Replies
12
Views
310
Hi all Trying to remotely connect to a TIA Portal PLC. I can ping it without a problem but can't get my software to connect. I've opened port...
Replies
8
Views
345
Looking for a way to export PLC status to Kepware ultimately. In Rockwell we can do a GSV and get a lot of information about the PLC. Is there...
Replies
1
Views
1,567
Hi Experts, Good day! We've encountered an error while uploading the program from S7-400PLC using TIA Portal software and try all the TIA...
Replies
10
Views
3,541
Back
Top Bottom