SIMATIC S7 SCAN time

plcsimpleuser

Member
Join Date
Sep 2005
Location
BS AS
Posts
11
Hi,
I`m making an application, where i need several timers. So I`m planning to make my own time base, and simply use counters. I was thinking in using the #OB1_PREV_CYCLE as my time base. The definition for this is: Cycle time of previous OB1 scan (milliseconds).

The question: Is #OB1_PREV_CYCLE the complete SCAN time in mSec or is just the OB1 Execution Time?

Thanks in advance,

IO

(I will improve my english!!!)
 
yes, why not timers? btw... sometimes i'm using ob35 bit signal t o detect new 100ms sign (or other time for what is ob35 set) for key reading and some similar which are not really needed to be so precise.
 
Hi, I`m not using Timers, because I have to use near 200 timers with a very precise funtionality, so is easier for me to develop a TIMER block with the exact requirements I have.
The OB35 is already used in this CPU with a configuration time in 1 sec. and I don`t want to modify that.

Thank`s anyway!!

IO
 
plcsimpleuser said:
Hi,
The question: Is #OB1_PREV_CYCLE the complete SCAN time in mSec or is just the OB1 Execution Time?

It is the complete cycle time of the PLC, i.e., the time since OB1 was last called.

I also use the scan time for many of my timers. I don't use a lot of timers in my code anyway as a rule, but I find that using the scan time and decrementing an INT and comparing to a setpoint gives me all the funtionality I need.
 
How about using the clockbyte from the plc?
This would give you up to 10Hz!

As far as I know, that clock byte, may change during the SCAN. So if I have a long SCAN (Larger than 100 msec) for example, I can't use the 10 HZ bit, I may lose some pulses.

IO
 
I generally use the clock byte for this function, With a low scan time, it is generally not a problem if it changes.
If you don't want it to change during scan, then map it to another byte at the start of OB1. This byte would then be fixed for the rest of the scan.

Another alternative, before I discovered the clock byte I used to access the date time local memory in OB1 and calculate it from that. Each time the 100ms counter reached "0" I would create a pulse using a compare block. This function required a bit of data translation, since in their wisdom Siemens have put the time data into a format that none of their other functions can read.

Hope these ideas help,

Doug
 
I also use #OB1_PREV_CYCLE. It works very precisely. Even though it has to round off the scan time to nearest whole millisecond, it looks like it carries the "remainder" to the calculation of the next scan. In that way it becomes very accurate over the long time.
 
plcsimpleuser said:
How about using the clockbyte from the plc?
This would give you up to 10Hz!

As far as I know, that clock byte, may change during the SCAN. So if I have a long SCAN (Larger than 100 msec) for example, I can't use the 10 HZ bit, I may lose some pulses.

IO

If you have a scantime that passes 100msec then you have a big problem, normally it shouldn't be above 30msec (even thats high).

Cheers
Borte
 
danpantea said:
Why don't you use SFB 4 which is the Siemens timer function. You can have thousands that way. KISS
True.
There are actually a number of reasons why it could be a good idea to make ones own timer.

The IEC timers use relatively much memory.
The preset and accumulated time values are formatted to the TIME type. If you want to acces these values in order for comparing or math operations then it is much easier if the are allready formatted as DINT in stead of TIME.
If you need a functionality that the standard timers do not cover (such as some sorts of retentivity) then you have to make your own.

I use both IEC timers and "homegrown" timers in my programs. Plus the occasional use of an S5 timer here and there.
(hmmm... maybe I should try to decide on only one type of timer).
 
Here is my complete block that I'm using for timers in my programs. It uses int values instead of time data.

Code:
FUNCTION "T_ODT" : VOID
TITLE =
//Name:
//  T_ODT (V 1.0)
//
//Description:
//  Same functionality as built in system function "on delay timer" (ODT) but 
//  uses integer data values instead of timer data.
//
AUTHOR : BORTE
FAMILY : UTILS
NAME : T_ODT
VERSION : 1.0


VAR_INPUT
  Cond : BOOL ; //Condition: TRUE = Timer running, FALSE = Timer reset
  ClockPulse : BOOL ;   //Input: Clock pulse
  Time_Setting : INT ;  //Setting: Time delay in units of ClockPulse (Delay = ClockPulse x Time_Setting)
END_VAR
VAR_IN_OUT
  M_EdgeBit : BOOL ;    //Memory: Edge detection memory bit (Can not be TEMP data)
  M_Timervalue : INT ;  //Memory: Timer value storage integer (Can not be TEMP data)
END_VAR
BEGIN
NETWORK
TITLE =

// Is time input set to zero? If so set output directly
// and exit block.

      L     #Time_Setting; // Read delay time
      L     0; 
      ==I   ; // Delay equal to zero?
      A     #Cond; // Condition true?
      SAVE  ; // Save RLO in BR
      BEC   ; // IF RLO equals TRUE then Exit block 

// Reset timer when not used
      A     #Cond; // Is Cond TRUE?
      JC    _001; // If TRUE jump
      L     L#0; 
      T     #M_Timervalue; // Set TimerValue to zero
_001: NOP   0; 

// Run timer
      L     #M_Timervalue; 
      L     #Time_Setting; 
      <I    ; 
      A     #Cond; 
      A     #ClockPulse; 
      FP    #M_EdgeBit; 
      JCN   _002; 
      L     1; 
      L     #M_Timervalue; 
      +I    ; 
      T     #M_Timervalue; 
_002: NOP   0; 

// Timer finished...
      L     #M_Timervalue; 
      L     #Time_Setting; 
      >=I   ; 
      JC    _003; 
      CLR   ; 
      SAVE  ; 
      BEU   ; 
_003: NOP   0; 
      SET   ; 
      A     #Cond; 
      SAVE  ; 
      BEU   ; 
END_FUNCTION

Cheers
Borte
 

Similar Topics

HI i would like to know how to get a variable that will store the amount of times a program has been executed. The issue is I have 3 DBs for 1 FB...
Replies
2
Views
61
Dear sir, I am using SIMATIC 300, CPU 315-2DP , (6ES7 315-2AF03-0AB0) VIPA 603-1CC21 A1.0 RAM 32KB, Firmware=V4.0.8 The problem Im using MPI...
Replies
2
Views
160
Hi, I received this SIMATIC S7-300 training kit for maintenance. When I power it up, the PLC doesn't go to RUN mode and the STOP mode led is...
Replies
7
Views
295
I'm trying to build my Classic Step 7 programming skills this weekend. I get stuck on little things that are not covered in YouTube tutorials. I'm...
Replies
7
Views
311
I am utilizing both HMI and SCADA for my project. Both HMI and SCADA have identical tags. When I modify the tag value on HMI, it is reflected in...
Replies
2
Views
138
Back
Top Bottom