Step 7 timers

Carkington

Member
Join Date
Dec 2006
Location
Portland OREGON
Posts
3
Anyone have any words of wisdom regarding step 7 and timers?

I found FC80 TONR and may be able to use that. The built in functions S_ODT and S_ODTS are not very flexible in my opinion. The main issue is the S5time format for the preset and time remaining fields. Why time remaining not accumulated like every other PLC brand?

On a previous project I had to write my own counter function to enable changing the accumulated value. Do I need to write my own timer so I can have preset and accumulated values in a data format I can deal with?

Or has someone already done this?
 
You don't need to write your own timers. S7 has IEC-compatible timers SFB3 TP, SFB4 TON, SFB5 TOF. Times are represented in TIME format, but it's milliseconds only. This is much more useful than S5 Time. Only one remark: if you want to do calculations, it's easier to do in STL, because STL doesn't check data type. You don't need special type conversion.
 
If you do want to roll you own - try this , I posted it before , but I can't find where :-
You need to sub M10.0 for your first cycle flag , and MD58 is your last scan time - you may find it gives you what you want .
FUNCTION "TON" : VOID
TITLE =TON - Timer On Delay
//If the enable condition go true, timer TON starts incrementing according with
//the last CPU cycle time. When the accumulated value is greater than or equal to
//the preset value, the timer stops and sets the timer done bit.
NAME : TON
VERSION : 0.1


VAR_INPUT
EN : BOOL ; //Timer Enabled
Pre : TIME ; //Timer Preset
END_VAR
VAR_OUTPUT
TT : BOOL ; //Timer Timing
DN : BOOL ; //Timer Done
END_VAR
VAR_IN_OUT
Acc : TIME ; //Timer Accumulator
END_VAR
BEGIN
NETWORK
TITLE =Reset Accumulator Value If Timer Not Enabled Or First CPU Cycle

A( ;
ON #EN;
O M 10.0;
) ;
JNB _001;
L 0;
T #Acc;
_001: NOP 0;
NETWORK
TITLE =Accumulator Value Increasing

A #EN;
A( ;
L #Acc;
L #Pre;
<=D ;
) ;
JNB _002;
L MD 58;
L #Acc;
+D ;
T #Acc;
_002: NOP 0;
NETWORK
TITLE =Timer Done

A( ;
L #Acc;
L #Pre;
>D ;
) ;
A #EN;
= #DN;
NETWORK
TITLE =Timer Timing

A #EN;
AN #DN;
= #TT;
NETWORK
TITLE =ENO Setting

SET ;
SAVE ;
END_FUNCTION
 
Thanks for the quick response

Good stuff guys.

The provided timers would work with no issues if I did not have to do math on the accumulated values. We try to adjust the presets based on cycle times.


10BaseT I will try your sub.

I got some more advice from a local vendor. I will have to restructure the code I have 1/2 finished. As a former mentor would say ... GCE. (Gross conceptual error) Oh well live and learn.

I will have a test PLC to try code on this afternoon.
 
Bratt said:
Type checking can be deactivated in Lad and FBD as well under options if you dont like that feature
You are right, but everything taken into account, I think that typechecking is a good thing. Deactivating typechecking because you want to do math with TIME variables, will mean that you remove a safety net that protects you in many other places.
 

Similar Topics

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...
Replies
31
Views
16,779
Greetings, I am coding for S7-300 CPU315-2 DP and I have come to an impasse. I made a function to generate pulses of varying duty cycle. As an...
Replies
4
Views
3,337
This is my first program with Step 7 (300 series PLC) and I have to say it is extremely frusterating. And the fact that the company we bought the...
Replies
9
Views
5,750
Do any of the Siemens timers (specifically S_ODT) have a timer timing bit that you can examine in logic like the A-B TT bit, or do you have to...
Replies
5
Views
2,176
Good day everyone... Im using a siemens plc and step7 to program it. I want to time a coil so that when the time counts down the timers contacts...
Replies
30
Views
12,069
Back
Top Bottom