time compare

Unregistered

Guest
U
can any one tell me how i can compare two time of the day variables in siemens S7 300 ,as a time comparator is not available with s7.
 
A TOD variable is 4 bytes long so if you declare two time of day variables as follows just load them into the accumulators and do a 32 bit comparison.

VAR_TEMP
TodA : TIME_OF_DAY ;
TodB : TIME_OF_DAY ;
bTodsEqual : bool ;
END_VAR

L TodA;
L TodB;
==D;
= bTodsEqual;
 
Hello;

Maybe these functions from the IEC library can be useful:

IEC_DT.jpg


Not exactly what was requested, but you do have date_and_time compares, so if you are reading from the real-time clock, you can use the results for comparision, and the extract the TOD values (for archiving or display).
hope this helps,
Daniel Chartier
 
Hello, all; I recieved the following PM and thought it was best to return this to the public thread. DC.



Re: time comparator
Quote:
Originally Posted by kartik
hey..hanx i had jus posted the time comparator question...

but the only thing is how do i compare for 2 different time blocks...cos

fc8 from IEC library only contains a block to read time from date block...can u suggest please?



Hello Kartik;
I suggest you get back to the main post, so others can give an opinion on this.
What I propose is you do your compare in D_T format, as per FC9, 12, 14,18, 23 or 28.
Hope this helps,
Daniel Chartier
 
So if we want to compare two S5time data firstable we should convert them to D_T format with SFCs and then compare with SFCs ....

Ok but i still think there is a more simple way to do that out there....

Maybe if we only compare the minute or second data we should compare these data bits directly is it possible...

What the Guru s says..??
 
Time compare wat ever u want

Hi people,


CALL "READ_CLK" // call RTC
RET_VAL:=#retHR
CDT :=#hallo // store in temp var.
NOP 0
L P##hallo // pointer on var
LAR1
L LB [AR1,P#0.0]
T MB 0 // Year in BCD
L LB [AR1,P#1.0]
T MB 1 // Month in BCD

L LB [AR1,P#2.0]
T MB 2 // Day in BCD

L LB [AR1,P#3.0]
T MB 3 // Hour in BCD

L LB [AR1,P#4.0]
T MB 4 // Min in BCD

L LB [AR1,P#5.0]
T MB 5 // Sec in BCD

L LW [AR1,P#6.0]
SRW 4
T MW 6 // Milisec in BCD

L LB [AR1,P#7.0]
L B#16#F
AW
T MB 8 // Day of week
NOP 0 // Sunday = 1



What I feel is that if we can declare another hallo that will be read from
the OP17 Text Display, and similarly I can break the Dt code into fragments of time,
and store them in to Marker byte via an accumulator can it work?

my question is only that we have to again convert this BCD code be it MB3 (hour) for instance , to
an Integer and furthur compare the two integers? will it work??

Kartik
 
If you wanna compare data of S5Time type then:
1) use FC33 S5TI_TIM from IEC library to convert them into Time type
2) use dint comparison instructions (in this case they will do).
 

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
635
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,936
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
850
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,275
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,950
Back
Top Bottom