Timers/Scan Cycle

theNoob

Member
Join Date
Apr 2008
Location
New York
Posts
19
Hi All,

I'm fresh to PLC programming with a Java/C++ background. I'm using S7 SCL to write software to communicate with a large number of wireless sensors through a serial transceiver connected to an S7-300 PLC.

The wireless sensors are slow. I need to create pauses (0.5 - 1.0 seconds) in the program flow between attempts to query them. In other languages, I would typically just be able to tell the program to "wait(1000)" in a loop. Not so here.

I tried to use an S5 timer in conjunction with a "while" loop to create the desired effect, however, this overruns the acceptable scan cycle time.

What's the best way to tackle this?

Thanks!

- theNoob
 
Hi,

There are several solutions to your problem.

1: Using OB35. This OB gets called at precise intervals. These intervals are configurable in the Hardware Config.

"To start a cyclic interrupt, you must specify the interval in the cyclic interrupts parameter block using STEP 7. The interval is always a whole multiple of the basic clock rate of 1 ms.
Interval = n X basic clock rate 1 ms"

2: Use your timer, but in stead of a loop, use a Conditional Call to the FC/FB which contains the logic. As long as timer is still running, then no call. Moment when timer reaches desired value, you call your FC/FB.

Wait(1000) would translate to:
Code:
L S5T#1sec  // Load 1sec time value
SD T10  // Start On Delay timer with given time value

A T10  // When timer reaches set time value
CC FC10  // Call the logic

Or something very close to it.

Few things to play with. Some of the more advanced guru's might have other solutions.....
 
Here's what jeebs is sayig but implemented in a function block in SCL using the IEC timer SFB4. For demo purposes I'm incrementing a count every second.

Code:
FUNCTION_BLOCK FB111
VAR_TEMP
  // Temporary Variables
END_VAR
VAR
  sfbWaitWireless:sfb4;
  iCount:INT;  
END_VAR
 
  sfbWaitWireless.IN := NOT sfbWaitWireless.Q;
  sfbWaitWireless.PT := t#1000ms;
  sfbWaitWireLess();
  
  IF sfbWaitWireless.Q THEN
  iCount:=iCount + 1;  
  //process info every second  
  END_IF;
END_FUNCTION_BLOCK
 
I attempted using the snippet provided by L D[AR2,P#0.0] as an FB called by OB1. The counter increments each time OB1 is called (without regard for the pause that should be introduced).

Any ideas as to what I could be doing wrong? If the TON is in an FB, does it need to be assigned an instance DB in order to work properly?
 
FB's are almost always called with an associated instance DB. All parameters and static vars are stored in the instance DB. How are you calling the FB - can you post the code you are using to call it ?

Are you running the code in a real plc or the simulator ? Certain versions of the simulator have a bug with SFB timers (which can be cured with a hotfix from Siemens)
 
Last edited:

Similar Topics

Hi all, I probably have some short questions for you. I'm trying to understand timers and the Siemens operating system in more detail...
Replies
9
Views
12,287
I'm writing some alterations to an FPWin program and need to see the running value of timers so I can set them correctly. It's my first time with...
Replies
0
Views
119
Hi everyone I am using Winproladder software for programming FATEK FBs PLCs and in programming, we often use Timers for activation of the...
Replies
4
Views
478
Hi all, I have what is likely not a complex issue, but I am working in Automation Studio and want an accumulating/retentive timer when a...
Replies
17
Views
1,831
Dear all, I want to use the interrupt service routine in FATEK PLC using WinproLadder Software. I had configured the interrupt in software as...
Replies
17
Views
1,513
Back
Top Bottom