S7 Holding a value during a timed cycle

s7killsme

Member
Join Date
Nov 2010
Location
Texas
Posts
7
Hello,

I'm using S7 on a S-300 series Siemens controller. My goal is to write a function into my program that triggers every cycle time (for example 24 hours, would prefer this to be adjustable), and during this function enables a coil for a set amount of time. The tricky part is that both during this cycle and for an adjustable amount of time after the cycle is completed I need to freeze a few database values to provide a recovery time.

I wrote a function that converts an integer input to the s5time, but I'm not sure how to implement the freeze time.
Originally I attempted to use ODTS timers with some cobbled together ladder logic, but it isn't working.

My S7 knowledge is somewhat limited as well.

Any suggestions?

Thanks for your help.
 
Thank you for the responses,

I'm trying to implement the SE timers now.

Yes, I mean data in a data block.

On a side note, S5time is ridiculous. I don't understand the need to create a new data type to hold time and force its use. I think half my problems are still in the conversions.
 
There are some alternative IEC timers in the standard library (SFB4 etc).
You call the SFB with an instance data block.
 
The conversions can be a PITA, but SCL makes them much easier.

Example:
Code:
FUNCTION "TimeToINT" : VOID

VAR_INPUT
    tTime : TIME;
    
END_VAR

VAR_OUTPUT
    iTime : INT;
    
END_VAR

VAR
    dTime : DINT;
    
END_VAR

BEGIN

dTime :=TIME_TO_DINT(tTime);
iTime :=DINT_TO_INT(dTime);

END_FUNCTION
Only limitation here is the INT data type only goes to 32767, but you can always change the TIME_TO_DINT and make the output a DINT.

I did that up in an effort to save timers, instead of using multiple TONs I was able to just create a free-running timer and sample the ET and use Greater Than and Less Than, sorta like the limit instruction in AB stuff
 
Last edited:
There is a standard function to convert a TIME variable to S5Time no need to make your own conversion function...

I think the function is in the standard library -- IEC functions..

The Time format is just a dint where a value of 1 represents 1ms..
 
I was always taught to stay away from S5Time.

I remember writing the above because for example SFB4 (TON) the ET value is in TIME format. You can't write it to a DINT.
 
I think I got it close to figured out. I used the SFB4 along with the old extended pulse timers and some ladder logic to get the job done. Also had to scale the conversions to get them to work right.

Now I know not to use S5time for next time!

Thanks for your help.
 

Similar Topics

I have a machine with 6 Kinetix 5700 Drives powering MPM motors attached to Box Ways with ball screws. My problem seems to be a high holding...
Replies
0
Views
651
My first time using a SEL 3350 RTAC (or any RTU for that matter). Setting up with most Modbus TCP functions - both Server and Client - seems...
Replies
1
Views
1,552
Hi, I'm currently most of the way done with my first experience with "Industrial Control Panel" building... quotes because, as you'll see, this...
Replies
4
Views
2,255
I am trying to break the link between a wonderware tag and a tag in RSLogix. No matter what i do to the tag in the PLC the wonderware is holding...
Replies
3
Views
1,793
I am new to unity so I apologize for the basic question. I am trying to hold an output fox x secs. In AB i would use the .TT field of the timer...
Replies
3
Views
1,302
Back
Top Bottom