Siemens Step 7 Timers- driving me crazy trying FC80... but PV resets

Nick Birke

Member
Join Date
Oct 2011
Location
North Tonawanda, NY
Posts
54
I have done a fair share of PLC programming in my time... but not with Siemens. So far I don't like it very much. The timers are nearly intolerable. I am mostly a LAD guy. So right now I am self-teaching myself S7 on a 315-2 DP. I thought I would start out by creating a stoplight program. It works the way I like and I am using the included pulse timer... this is all in S5 time.

I made a small HMI to see the stoplight work in WINCC Windows HMI. So far doing pretty well. Then I wanted to display the time remaining in various timers for the "lights" to change. This is when it was necessary to learn much more about timer time bases.

Ultimately... the way I get the timer value to the PLC by moving the Tn value to an MW location, and then pull it in as an integer... but there is a problem... the time base... this messes up my linear scaling. I understand the time base bits... but I don't know how to read them to compensate for them.

I decided to make a test program using FC80. This seems like it has potential... however... instead of loading PV with a constant, I have programmed it to read an MD value. Before the timer is started, I can see that value in debugging, when the timer is started, the PV value is set to some value... 30 becomes 33554462. When the timer is stopped, it retains how much it counted... and the PV value jumps between 30 and 134217758. Then when I reset it... it all resets and goes back to 30.

I am very open minded to different solutions. I generally get STL... I would just rather not write my own timer. PLEASE HELP. I have been staring at and playing with timers for almost two days, so if I am missing something obvious forgive me.
 
By the way there is really nothing else active in the program except this one rung.

TMR_EN - m10.1
RESET - m10.2
PV - md10
DELTA_T - set to a constant 1... I tried using an MW but it behaved the same way
ET - md50
q - 10.3
 
Keep in mind I am new to Siemens. And this may be a big factor in my response... I tried tinkering with those as well... but I really don't have a good understanding of how DBs fit into the picture. Like a few things... right now... I put IEC TON on a rung... it operates with TIME datatypes... I am sure I could deal with this with conversion for changing and reading the timer PT/ET values... but... I have "???" in red above it. It seems that is looking for a DB. I can try this again... last time I did this it just created a DB... I am not very comfortable with these (my problem, more homework required,) I wish there was just a simple timer that took milliseconds, and you could reference different properties on the timer like Tn.PT... I am suspecting that can be done through the DB that is created... I will try to dive into this a bit more and keep you posted. THANKS FOR THE RESPONSE.
 
Ok... so now I have an SB4 running... once it is started it does a similar thing... I initially set PT to MD10, made MD10s value L30000, and then when it starts it just bumps up the value to some huge amount... what is causing this?
 
So when I apply power to the timer, but to not set the IN bit on, the PT value goes from L#3000 to L#1073744824, and it of course does not start timing because the IN bit is 0. When the power(EN) is removed the MD value PT is assigned to goes right back to L#3000.
 
OK... this was sitting in a sandbox project. I started a new project and the timer behaves normally. Must have been something stupid I was doing before that was causing this. Now I just have to figure out how to plug this into the HMI and learn more about accessing DB values... AND how SFB/FBs work.
 
One more important question... a dumb one... does each SFB instance need its own DB instance as well... I made another SFB4 and set it to the same DB... and the DB didn't get any new entries.
 
By the way there is really nothing else active in the program except this one rung.

TMR_EN - m10.1
RESET - m10.2
PV - md10
DELTA_T - set to a constant 1... I tried using an MW but it behaved the same way
ET - md50
q - 10.3

Hi Nick,

It seems that you are off down the path of SFB 4 etc now so this may be academic but be aware that Siemens addressing (and a few other PLC's) means that if you set bits M10.1 and M10.2 you are also altering the value of MD10 as a whole.

So.... MD 10 consists of 32 bits (because its a double word - an single word is 16 bits - a byte is 8 bits).

Those 32 bits from MD 10 are here:

0000 0000 0000 0000 0000 0000 0000 0000

If we split MD10 into words it would consist of MW 10 and MW 11.

Code:
0000 0000 0000 0000 0000 0000 0000 0000
|-----------------| |-----------------|
     MW 10                MW 11

If we further split it into bits then the furthest bit on the right is M 11.0

The next bit to the left of that is M 11.1 all the way to M 11.7

Then we pass into the MW 10 and the first 'bit' in there is M 10.0 all the way to the furthest left bit which is M 10.7

You'll appreciate that by bringing on any of those bits, the double word (MD 10 in this case) increases in value. So if I bring on M 11.0 then MD10 is equal to 1. If I bring on M 11.0 and M 11.1 and M 11.2 then the value of MD10 is 7.

Therefore... if you bring on M 10.1 and M 10.2 (as per your original example) then the value of MD10 goes up to 393,216. If MD 10 is also holding your timer value then things can really start to go awry as you'll appreciate!

Hope that info helps you mate.

;-)
 
Last edited:
... AND how SFB/FBs work.

SFB/FBs use instance data to store their parameters and static data which needs to be retained each scan of the program (edge detection and counting are other examples).

When you call an FB, the calling block copies the specified parameters to the instance DB. The FB is then called and accesses data in the instance DB by its parameter or static variable name. When the FB returns to the calling block, the calling block copies the return parameters from the instance DB to the actual parameters. By their nature, FB parameters are optional and if you leave a parameter blank, the FB will access the last value that was written to the instance DB.

It is possible to group together FBs so they share a common instance DB, this is known as multiple instance FBs. One example would be to have a master FB and use multiple instances of SFB4 to create multiple timers without having to take out an instance DB for every timer.
 
Hi Nick,

It seems that you are off down the path of SFB 4 etc now so this may be academic but be aware that Siemens addressing (and a few other PLC's) means that if you set bits M10.1 and M10.2 you are also altering the value of MD10 as a whole.

So.... MD 10 consists of 32 bits (because its a double word - an single word is 16 bits - a byte is 8 bits).

Those 32 bits from MD 10 are here:

0000 0000 0000 0000 0000 0000 0000 0000

If we split MD10 into words it would consist of MW 10 and MW 11.

Code:
0000 0000 0000 0000 0000 0000 0000 0000
|-----------------| |-----------------|
     MW 10                MW 11
If we further split it into bits then the furthest bit on the right is M 11.0

The next bit to the left of that is M 11.1 all the way to M 11.7

Then we pass into the MW 10 and the first 'bit' in there is M 10.0 all the way to the furthest left bit which is M 10.7

You'll appreciate that by bringing on any of those bits, the double word (MD 10 in this case) increases in value. So if I bring on M 11.0 then MD10 is equal to 1. If I bring on M 11.0 and M 11.1 and M 11.2 then the value of MD10 is 7.

Therefore... if you bring on M 10.1 and M 10.2 (as per your original example) then the value of MD10 goes up to 393,216. If MD 10 is also holding your timer value then things can really start to go awry as you'll appreciate!

Hope that info helps you mate.

;-)

You have error in here.

MD10 consists of MW10 and MW12. Those MW's consist of MB10,MB11 for MW10 and of MB12,MB13 for MW12.

Any given MB consists of Mx.y, y is 0-7.

Code:
0000 0000 0000 0000 0000 0000 0000 0000
|-------| |-------| |-------| |-------|
   MB11      MB10       MB13     MB12  
|-----------------| |-----------------|
     MW 10                MW 12
|-------------------------------------|
                  MD10

Same applies naturally for I,L,V,Q,DB memory areas.
 
Last edited:
thanks for the extra and useful information

I have been wondering how these memory addresses relate to each other. Please keep in mind I am working on this thing with no physical manuals or direct access to engineers right now. I think I doing pretty good for what I got here... best way to go is to dive in I guess.

Well thanks a lot... I will need to read the posts regarding the memory layouts very closely... if the is a PDF I might be able to find or somewhere where the memory is discussed at this level please send a link along.

Until the next time I am spinning tires in the mud...

-Nick
 

Similar Topics

Good Morning, Hoping someone with some Siemens experience can give me a hand with this one. Customer has a S7-200 cpu, which has a 6GK7...
Replies
0
Views
271
I'm just trying to figure out the right method of adding a DO card to an existing rack. It's not the *next* open slot, but I have to move the AO...
Replies
5
Views
592
Hi Siemens Experts, I am hoping someone can shed some light on my issue. I have uploaded the code from a S7-300 (317-2PN/DP) using Step 7...
Replies
9
Views
745
Hello, We monitor the temperature of a pipe via a 4-20mA temperature transducer. This goes into DB135(Read Analog Inputs). The issue I have is the...
Replies
0
Views
643
Please excuse the basic question, but I've never worked on Step 7 before (until now, only dealt with Mitsubishi Q-series PLCs)... What is the...
Replies
16
Views
3,399
Back
Top Bottom