First Project with S7-1200 TIA V16

Bullzi

Lifetime Supporting Member
Join Date
Jun 2012
Location
Colorado
Posts
1,530
Hi Everyone,
Got a project that will use a S7-1200 (CPU 1214C). Am more of a AB guy and I have had the TIA Portal Software for awhile and have played with it some but this is my first full Project using Siemens.

I have watched a bunch of Youtube videos and have a general grasp on the software and how it works from a functional perspective. I want to learn how to do things the "Siemens way" and not try and make the Siemens work like AB. So I have some questions about the general philosophy around Siemens Programming.

1) OB's seem to be some what like Subroutines in AB. Is it common to have more than 1 OB that has your programming in it? In the videos I watched it seemed like they only used one OB (OB1) and put all the FC's in them.
2) FC's: It looked like you could use FC's as a Subroutine. They would take the FC and create some programming and they call it in OB1. Other times they used it as a user defined function that could be reused. What is the general thought process with these? How do you use them?
3) DB's: These I like, coming from the AB world these seem to make a lot of sense to me. Is there more to them than what is on the surface? Maybe some cool trick you can turn me on too?

The next couple of questions are more specific:
1) I have a CPU 1212C that I have selected when I first started my programming. How can I change the PLC in the program to the CPU 1214C? I don't want to start all over.
2) Is there a Linearization function in TIA Portal? I need to input some tank strapping info into the PLC and get a volume based on the level. I am looking for something like the FGEN Function Block in AB.
3) I am going to communicate to a Modbus device via RS-485 can you point me to some good tutorial on reading on doing that in TIA?

Thanks again for the help!!
 
S7-1200 ob/fc/fb/db

OB's are event driven and called by the PLC operating system. OB100 is called once on system startup
OB1 is called after system system up

Other OB's are called for timed interrupts, programming errors etc.


FC's are functions - they have no inherent memory to store data between scans although you can use parameters to provide data storage in a DB. Functions should really have a bunch of inputs and a return value (e.g. calculating the volume of a silo), however, due to the past history of older Siemens PLCs you can write Functions with OUT and IN_OUT parameters.


FB's are function blocks - and are called with an associated data block (instance data) which is used to store data which is remembered between scans (e.g. edge detection, IEC timers etc)


Data blocks are generally in two forms, global data blocks for using throughout the program and instance data blocks for using with Function blocks.


Of course, the are further nuances but they will come out as you gain more experience.
 
Change CPU

In devices and networks, Right Click on the device and use the 'Change Device' drop down

cdev.jpg
 
One advice is to organize the data in user-defined Data Types.
Especially the data that is stored in shared DBs and is passed to and from FCs and FBs by IN/OUT pins should be organized in this way.
This should be very recognizable for someone coming from Controllogix.

FBs in TIA is like AOIs in Logix, only the FBs in TIA works better. You can do online change in FBs which you cannot really do with AOIs.
 
On TIA you can have multiple OB blocks which runs same time.


This differs from clssaic step7 where you only have OB1 for main program, and time interrup OBs like OB31 and OB32 where PID-controllers were usually called.
 
Thank you everyone for the replies!!

I got the PLC CPU Changed and I will look into the Polyline instruction along with the code that you linked to.

On the OB subject, as Lare pointed out it looks like I can add a OB that is part of the program cycle. I don't have any Interrupts or things like that in this program. It is actually a very simple program. So would it be considered "good practice" to use OB's as sub routines and put FC's and FB's in them? Or is it more the norm to put all your sub routines in FC's and put all of them into only OB1? Again I am thinking like a AB Programmer and I want to get to the point that I am thinking in Siemens Programmer.

Thanks again!!
 
Call everything from OB1


Use FB's


Don't use FC's until you have the need for a function that returns a value.
 
Use FB's

Don't use FC's until you have the need for a function that returns a value.

Isn't that the other way around? As I understand FC's the don't have dedicated memory and FB's do. Just trying to keep my head on straight here :)
 
Hi Everyone,
Got a project that will use a S7-1200 (CPU 1214C). Am more of a AB guy and I have had the TIA Portal Software for awhile and have played with it some but this is my first full Project using Siemens.


Good luck!



I have watched a bunch of Youtube videos and have a general grasp on the software and how it works from a functional perspective. I want to learn how to do things the "Siemens way" and not try and make the Siemens work like AB. So I have some questions about the general philosophy around Siemens Programming.


Take a look at the Programming Guidelines linked below. It's a manual discussing a lot of best practices for programming the Siemens Way. Some of it is S7-1500 only, but most items should work in 1200 & 1500.

https://support.industry.siemens.com/cs/ww/en/view/81318674



A big part of it is making a lot of your code reusable (even if you'll only use it once) by utilizing the inputs/outputs/inouts & internal data of FCs/FBs, instead of reaching out to global tags for everything.



1) OB's seem to be some what like Subroutines in AB. Is it common to have more than 1 OB that has your programming in it? In the videos I watched it seemed like they only used one OB (OB1) and put all the FC's in them.
2) FC's: It looked like you could use FC's as a Subroutine. They would take the FC and create some programming and they call it in OB1. Other times they used it as a user defined function that could be reused. What is the general thought process with these? How do you use them?
3) DB's: These I like, coming from the AB world these seem to make a lot of sense to me. Is there more to them than what is on the surface? Maybe some cool trick you can turn me on too?


1)You CAN have more than one main OB. They just execute one after the other in number order.


In theory, it can help with organization. In practice, I've never seen anyone do it yet with a 1200.



2) FCs are pretty flexible, and can be used for both of the things you mention. They are great for self contained reusable code that doesn't need to remember anything from a previous scan, or for non-reusable code that accesses global tags, similar to how a subroutine would typically be used.


2.5) FB's are what I would recommend for most code, though. Having the instance DB for internal data is nice, and the ability to "multi instance" where you combine instance DBs when calling an FB within another FB is really nice, and can make things very flexible. You can have a standard Sensor FB contained in your RobotControl FB contained in your standard Zone FB, and then create a 2nd zone by just calling Zone again, and remapping the block parameters.



3) DBs are useful. I'd say the "cool trick" with them is when you pair them with FB's, to store the instance data.


However, besides the change of no longer typing XIO/XIC/etc for LAD code, the differences with how DB tag are treated is often the biggest adjustment for AB folks new to Siemens. In AB land, all tags are what we would call "retentive", they keep their value when you turn the PLC off. Also, if you do a full download, they lose the old value.


In TIA land, things are different, and there are both plusses and minuses. Every tag has both the actual value in the PLC (used for logic) and a Start Value which is what it gets set to when the DB is reinitialized (PLC restarts or DB structure is changed). Tags can be marked as retentive, but aren't by default. This means you typically don't need much initialization logic in the PLC, because it happens automatically, but you also need to set the Start Value to something useful. There is a tool called Snapshots available to help with that.


On the plus side, the Start value is the only value for the DB downloaded from the project, so the data in a DB isn't overwritten when you download, as long as you don't change the structure of the DB. When you do a DL from Portal, the DL window will tell you exactly what will happen in the PLC (some blocks change, some blocks are created, some DBs are reinitialized, some blocks are deleted, etc). It is a best practice to actually read that list (although no one every does), to make sure the download only affects the parts of the program you are expecting.
 
Isn't that the other way around? As I understand FC's the don't have dedicated memory and FB's do. Just trying to keep my head on straight here :)


You are correct about the memory. I am suggesting you use FB's for splitting up the program etc. and only use FC's as functions with return values. Of course you can use FC's for splitting up the program, but the sooner you get to FBs the better.



https://www.fernhillsoftware.com/help/iec-61131/common-elements/program-unit/function.html
 
Again I am thinking like a AB Programmer and I want to get to the point that I am thinking in Siemens Programmer.

Thanks again!!


You're asking good questions, which is a huge step 1.



Call everything from OB1


Use FB's


Don't use FC's until you have the need for a function that returns a value.


I agree with what he said.


It is not common practice to use more than one program cycle OB, although I think Siemens technically considers it a "best practice". There is usually no functional difference; it's mostly a style thing. Most Siemens programmers expect OB1 to have all the code, because that's how things were back in the older 300's. 1200/1500 break a lot of those traditions, but that's one where the "new way" doesn't really offer any benefit, so no one bothers.


Use FB's by default. Get used to using the internal tags, instead of mapping everything globally. The "dedicated memory" you mentioned in the other post is a benefit, not a detractor.
 

Similar Topics

I need to make my Siemens PLC S7 (1212C) output one digital byte ..Q0.0 - Q0.7 (QB0) … output byte 0 … to represent any number from 0 to 255...
Replies
28
Views
12,580
I'm trying to import a .prj file and I keep getting the error message: Project import error. i Any ideas how to get around this? Thanks.
Replies
0
Views
51
I'd like people's opinions on which manufacturer of hardware they prefer. We are an aerospace manufacturing facility that does little to no SCADA...
Replies
10
Views
483
Hello everyone, In a factory where we installed Citect 7.20 the computer began to show the first signs of end of life. They never considered...
Replies
0
Views
57
Hi All, I've been pulling my hair out trying to fix this for a few days and need some advice. I have V19.01, v20.05, V21, V24, V30, V31, V32...
Replies
5
Views
350
Back
Top Bottom