S7. How to compare time with IEC timers or S5 timers

JesperMP

Lifetime Supporting Member + Moderator
Join Date
Feb 2003
Location
ᚴᚬᛒᛅᚾᚼᚬᚠᚾ
Posts
16,292
Hi,

I want to compare the expired time of an IEC timer (preferred) or an S5 timer.
I want to check if a expired time value increases and then store it for later use.
But I see no easy way to compare IEC TIME values or S5TIME values.
You can only compare INTs, DINTs or REALs.

Right now I have made my own timer FB that works as I want, and I have the expired time in INT format.
But I would like to know if there is an easier or more elegant way using the built-in IEC or S5 timers.
 
Hello, Jesper;
If you use iEC timers in Step 7, the ET parameter (remaining time) is displayed in TIME format. Now, a TIME-formatted variable can be read as a DI (as in a compare operation); it appears as a single number in microseconds (on 32 bits). So if all you need to do is check wether in increases or decreases, no problem. Simply compare actual_value to precedent_value, or substract actul_value from precedent_value (the sign of the result will show increase or decrease).
By the way, you can read a DI into a TIME variable; conversion will be done automatically(if the numeric value is acceptable as a TIME value).
The same "trick" can be applied on Siemens timers, using an IEC library conversion function S5T_TIME (converting a S5Time value to a TIME value).

Hope this helps,
Daniel Chartier
 
Thanks Daniel,

I guess that I would have to do it in STL, or turn off the type checking in LAD (which i prefer).
Then I could use a "GT_D" to check for changes in the ET value.
 
Hello Jesper;
Try it directly in LAD. Worst case, transfer the TIME ragister to a DI register (in a DB, for example. But I seem to remember that it worked without type checking procedures (TIME is considered an unformatted numerical value).
Hope this helps,
Daniel Chartier
 
Sorry, but it does not accept it in LAD with type checking turned on.
If I include the IEC timers in the declaration of a DB, the .ET and .ST values are preset with TIME type.
I could do a lot of transferring back and forth between DI and TIME variables, but I dont want that. I simply use GT_D in STL.
Thanks for the "push" in the right direction :)
 
Jesper,

one problem not mentioned here (or did I overlook it?) is that Siemens does not show you the expired time, as most other brands do, but the remaining time. So, to get the expired time, you have to perform some math operations. Why don't you simply convert the S5TIME values to TIME values? There's a standard function available to perform this task.

Kind regards,
 
I will use IEC timers generally. I dont really like the S5 timers anyhow.
Only snag is that the IEC timers takes up quite a bit of memory, and possibly adds to the scan time. But I figure that I have so much memory and such a powerful PLC that memory and scan time will not be hurt.
 
Help Needed

Hi all,
Sorry for bringing up the old problem. I am using IEC timer also but IEC timer gives me ET in form of Time up while I need to present somewhat a counting down time from the preset value as resulted by DUAL/BI when we are using S5Time. Is it anyway to substract the preset timer with ET ? or may be I have to change the data type to any form before I am able to substract it ?
Thank you in advance for any answer


Regards,

Anie
 
Subtract the expired time from the set time to get the remaining time.
Use STL.

L mytimer.ET
L mytimer.ST
-D
T "remaining_time"

"remaining_time" must be a DINT or a TIME address.
 

Similar Topics

Help please. Im new to Omron and have a machine down. I have a compare = for barcode label scan. I've attached two pics. On the Mnemonics you can...
Replies
4
Views
618
Hi everyone! Accidentally closed it and it wont appear again. Checked and unchecked the option and seem to make no difference. Running v7.10.00...
Replies
16
Views
1,886
I'm working on an array that contains a UDT of 5 Items Array[4] DataType[0] - Part 1 - Part 2 - Part 3 - Part 4...
Replies
1
Views
836
Hi. I have 2 files where I would like to see the ladder logic differences (similar to the Rockwell compare function). I am using TISoft Siemens...
Replies
1
Views
1,258
Hello experts, I am just starting with AB programing, I have a questions regarding a compare done in an old RSlogix500 and causing me issues when...
Replies
5
Views
1,927
Back
Top Bottom