limitations/advantages of using cyclic OB's in S7-400 PLC's

J

Thread Starter

John Depp

Hello,
I've seen that several S7/PCS7 library functions state in their documentation that they should be used from cyclic OB's (OB3x's). Can anyone tell me if there is any meaning behind that recommendation? Is it an actual limitation, meaning it won't function from OB1? Are there any differences between the OB types making code illegal in some? Or just performance advantages?

Thank you
 
D

Daniel Chartier

Hello;

In S5/S7 PLCs, cyclic OBs execute their codes at the appointed time, independantly of the scan time of the CPU (basically, OB1). The scan time of a S7 CPU is nopt fixed, since the code executed at each scan can be different (through conditional calls of FCs and FBs). There are times where code must be executed at a specific known time interval for the process to work.

One example is PID loops; math operations to calculate output values must match the sample time of the loop (if they don't match, directly or as a multiple of the sample time, then your math operations will give you false results). The easiest way (in S7 CPUs) to ensure stable and repetitive timing is to use the cyclic OBs. Other CPU families provide different but similar tools; Rockwell offers cyclic tasks in their Controllogix families, for examples.

Hope this helps,
Daniel Chartier
 
T

Ton van de Pol

Hi,

The best reason I think is that many blocks use the scantime of the OB for timer functions (addition of a real value each cycle). This time is usually passed through a parameter called SAMPLE_T. The parameter is generated automatically while compiling the chart. If you don't use CFC, this parameter must be filled in correctly. In PCS7 you will only use these cyclic OBs.
 
D

David Mertens

Many of these blocks use the SAMPLE_T value as a basis for internal timers (e.g. monitoring times) rather than the hardware timers. The value of SAMPLE_T can be determined automatically by the PCS7 compiler based on the cyclic OB in which the block is used. However because the time is calculated internally based on the number of times SAMPLE_T is added to the timer this only works if the cycle time is correct and consistent. In time based algorithms (e.g. PID controllers), this becomes even more critical as the time is a fundamental component of the algorithm. PCS7 automatically places the blocks in cyclical OBs, so only when used with S7 you should be aware of this and set the SAMPLE_T input to the correct value. The PCS7 blocks also use ALARM_8P internally and therefore they can only be used in S7-4xx PLCs as the 3xx series doesn't support ALARM_8P.
 
J
You have a maximum watchdog time. This can be easily exceeded if everything is put in OB1. If you use the cyclic interupts and phasing you can actually get a much faster scan for your program than doing everything in a linear program in OB1. In summary: Use your Cyclic OBs to service the parts of the program in a time frame that it needs servicing, such as putting a temperature controller in a 10ms OB dies not make sense!!
 
Many mathematical functions, for example a PID loop depend upon knowing the amount of time elapsed between two sampled values. In the case of the PID function it is necessary for calculation of the integral and derivative terms. Calling the functions from a cyclic OB ensures that the sample time is a known value and is consistent from sample to sample.
 
Top