Cycle Time Alias(?), S7-1200

ltwatters

Lifetime Supporting Member
Join Date
May 2020
Location
Wisconsin
Posts
10
Hello,

First time poster and first time Siemens programmer here.

I have an S7-1212 FC I'm programming in TIA Portal V15.1 and I'm hoping there's a word or two somewhere in the program that will allow me to create an alias for the programmed cycle time of the Fail-safe Organization Block.

In other words, I want to read the programmed cycle time of a cyclic interrupt for use in my program.

My goal would be to have an FB or FC that takes five samples from an HSC and averages the pulse rate based on the cycle time, without the use of a separate database constant.

I also see other applications where this would be useful, so I figured it was worth asking.

Thank you
 
The timed interrupt block for safety is locked. If you are a first time Siemens user then you will have bigger fish to fry and I would not worry about having to use a hard coded constant.

1200F.jpg
 
The actual cycle time of the F OB is in: System Blocks -> STEP 7 Safety -> RTG1SysInfo -> F_SYSINFO -> TCYC_CURR


Note also that the 1200 HSC can be put into a frequency mode, so you might not even need to do this at all.


ALSO also, why are you sampling your HSC in your safety program? Not saying its wrong necessarily, I've just never seen that need to be a fail-safe function before. If it is just a standard process function, you could create a standard cyclic interrupt.

If you want the configured value, not the actual value, you can try the QRY_CINT instruction, called out of your main code. I know that works for standard cyclic interrupts, not sure if it works for failsafe ones as well.
 
Isn't this one of the variables inside the OB? Or I may be confusing with OB1? Haveyou checked the parameters inside your OB?

It's a variable I can change within TIA Portal, but I'd like to be able to read it within my runtime. That way, I could do ((HSC Total)-(Previous Scan HSC Total))/(Cycle Time)x10^6=Rate. OB1 is a program cycle OB, so it does not have a programmable cycle time.

The timed interrupt block for safety is locked. If you are a first time Siemens user then you will have bigger fish to fry and I would not worry about having to use a hard coded constant.

I think this is my last fish to fry. Most of the programming is still ahead of me, but I have a working program and all of the other self-checks I hope to implement have been tested in their own environment.

Thank you, both. I guess I'll use a hard coded constant and hope I remember to manually update it with any changes to the cycle time. Worst case scenario, my flow proofing has a greater margin of error than intended.
 
The actual cycle time of the F OB is in: System Blocks -> STEP 7 Safety -> RTG1SysInfo -> F_SYSINFO -> TCYC_CURR

My understanding is that this is a running count of the current cycle time, whereas I want the programmed interval the interrupt is supposed to run at.

Note also that the 1200 HSC can be put into a frequency mode, so you might not even need to do this at all.

I'm using the HSC to count pulses from a flow meter to automatically fill drums. The total count is more important than the average for my application, but the average would be useful for proving that the HSC is functioning properly.


ALSO also, why are you sampling your HSC in your safety program? Not saying its wrong necessarily, I've just never seen that need to be a fail-safe function before. If it is just a standard process function, you could create a standard cyclic interrupt.

I'm sampling the HSC in my safety program for two reasons. One, my assumption is that fail-safe memory is redundant, and so, by immediately passing the HSC count to fail-safe memory, I can monitor and proof changes to it with some semblance of integrity. Two, using the fail-safe interrupt saves me the need of having of having to use a second cyclic interrupt.

If you want the configured value, not the actual value, you can try the QRY_CINT instruction, called out of your main code. I know that works for standard cyclic interrupts, not sure if it works for failsafe ones as well.

I'll look into that now, thank you.
 
Solution

If you want the configured value, not the actual value, you can try the QRY_CINT instruction, called out of your main code. I know that works for standard cyclic interrupts, not sure if it works for failsafe ones as well.

That seems to be exactly what I wanted and it compiles without error. Thank you for the help.
 
I've got no code to speak of in the safety program but the cycle time is reported back as the time set for the cyclic interrupt i.e. 100ms

ssc1.jpg
 
I'm sampling the HSC in my safety program for two reasons. One, my assumption is that fail-safe memory is redundant, and so, by immediately passing the HSC count to fail-safe memory, I can monitor and proof changes to it with some semblance of integrity. Two, using the fail-safe interrupt saves me the need of having of having to use a second cyclic interrupt.
Fair enough, I guess. I'm curious what application that's necessary for, but I always approve of a bit of overkill.


That seems to be exactly what I wanted and it compiles without error. Thank you for the help.


Fair warning, the compiler won't check if the OB number is valid. That won't get checked until RunTime, so be on the look out once you DL.
 
There is no separate memory for the fail safe program. If the data is not coming from a safety device I would be reluctant to process it in the safety program as if it did.
 
Last edited:
I agree with L D[AR2,P#0.0]... I have been adding/modding enough of other peoples code to know that I'd be head scratching for a day why is this in the safety. Is someone gonna get hurt because I added the hourly flow they asked?

I'm kinda kidding, but safety is for safety...

And also, your comment that this saves you from having another OB makes me think that you are cramping everything into safety and that I really wouldn't do..
 
The actual cycle time of the F OB is in: System Blocks -> STEP 7 Safety -> RTG1SysInfo -> F_SYSINFO -> TCYC_CURR

I've got no code to speak of in the safety program but the cycle time is reported back as the time set for the cyclic interrupt i.e. 100ms

I was mistaken, then, TCYC_CURR is the proper tag. It would be nice if the default value was updated during compilation.

Fair enough, I guess. I'm curious what application that's necessary for, but I always approve of a bit of overkill.

I agree with L D[AR2,P#0.0]... I have been adding/modding enough of other peoples code to know that I'd be head scratching for a day why is this in the safety. Is someone gonna get hurt because I added the hourly flow they asked?

I'm kinda kidding, but safety is for safety...

And also, your comment that this saves you from having another OB makes me think that you are cramping everything into safety and that I really wouldn't do..

This isn't actually for a safety system; we've had people leave wrenches in a deadman valve for a bulk fill line and flood our mixing room on multiple occasions. Management insisted that we install a fail-safe system while also refusing to buy anything expensive. Also, I consider the area of installation a Class 1 Div 1 location, although our engineer disagrees. So, I've got one flow sensor and I'm just trying to do what I can to prevent the HSC from undervaluing the flow.

There is no separate memory for the fail safe program. If the data is not coming from a safety device I would be reluctant to process it in the safety program as if it did.

Ah, I falsely assumed Siemens achieved SIL by redundancy, as opposed to diversity. That's very useful information. Since HSCs are asynchronous, I could have run into ghost problems (failed diversity checks.) Are F-DBs only really there for simplicity and F-runtime communication then?
 
The way siemens have implemented the safety program is to run two diverse implementations of the same logic and compare the results. Put simply, the safety compiler takes your code and re-generates it in the opposite sense. The results of the execution of the two sets of code must match - one example where you can get caught out is if you have an OB of higher priority which interrupts the safety program half way through execution and modifies a variable being used - you will then get a safety fault - make the safety program the highest priority (I generally use priority 15 so that comms will not interrupt the safety program). The safety DBs are also used for status/diag information when the CPU is communicating with safety cards.
 
The way siemens have implemented the safety program is to run two diverse implementations of the same logic and compare the results. Put simply, the safety compiler takes your code and re-generates it in the opposite sense. The results of the execution of the two sets of code must match - one example where you can get caught out is if you have an OB of higher priority which interrupts the safety program half way through execution and modifies a variable being used - you will then get a safety fault - make the safety program the highest priority (I generally use priority 15 so that comms will not interrupt the safety program). The safety DBs are also used for status/diag information when the CPU is communicating with safety cards.

I think I understand. An inverse OB is generated during compilation and run after the initial OB. The results are compared and, should a logical XOR produce any 0, the processor will fault. This does lead me to assume that each F-DB is actually two DBs stored within the same memory, in which case there is still benefit to moving my HSC count to one; I just need to make sure my value doesn't change during execution of the F-runtime Group.
 

Similar Topics

Hello PLC friends. I've been going through a saga of diagnosing and fixing an old PLC setup that I inherited. I am learning as I go. Initial...
Replies
14
Views
329
Hi everyone. I have an issue with an Allen Bradley PLC model 1769-L30ER. This PLC had a previous program with a different IP address but when I...
Replies
4
Views
509
My Panelview plus 700 HMI stopped working and I replaced it with a new one. Moved the sd card from the previously installed panel to this one and...
Replies
16
Views
976
Hi everyone, I recently put in a 1769-AENTR, and where it is installed has had a couple power outages. Every time when the PLC comes back online...
Replies
3
Views
682
Hello Friends, I am looking for a way to take my PID Output( it is the result of my PI Algorithm in Real format) and generate a PWM Signal in...
Replies
16
Views
2,463
Back
Top Bottom