S7 Time comparison

PLCdave

Member
Join Date
Apr 2003
Posts
15
Hi
Can anyone help me with the folowing in Step 7?

6 cardinal points are entered at SCADA for times between which a different setpoint will be valid. Each of these times will be passed to the PLC as two reals i.e. Quarter past ten will consist of 10 and 15.

In order to determine if it's after 10:15 it looks like I have to get the time and date using the read_CLK function then convert that to time then convert that to a real in milliseconds, then covert the 10 hours and fifteen minutes to milliseconds and compare with current time.

Q?? is there a neater way of achieving this ???

Thanks in advance to any S7 programmers who can help.

Dave
 
Dave

I am not sure if I understand you correctly, but you state that you will be entering a time from a SCADA as 2 integer's, I take it that these will be written to a DB (say DB2 byte 0 and byte 1), now using the read clk block (SFC1) put the date and time into a DB (say DB1 bytes 0 to 7),set this DB up to receive bytes, you will see from the picture posted below that the bytes that you require are bytes 3 and 4, using the 'move' function, move these bytes one at a time to bytes 8 and 10 respectively (which are declared as INT) then you have the current hour and minute as a real number, all you have to do then is compare with the two numbers from the SCADA.

I hope this helps, I am sure others will offer advice.

Paul

db1.jpg
 
Dave

Jean Pierre states a good point there, one which I forgot!

I had a little play with it and I had to move the hour and minute bytes again and set the next byte in the DB as a zero this enabled me to do the conversion from BCD to INT as this is 1 word long not a byte.

The picture below should make my 'not so clear' explanation a little bit clearer for you.

One other point, to use SFC1 (READ_CLK) I set up a 'DATE_AND_TIME' area in OB1 local memory and then used SFC20 (BLK_MOVE) to move that data to DB1 (byte 0 to 7)

Paul

plcdave.jpg
 
Thanks PAul * Jean Pierre (y)

I tried coverting the date and tome to time of day and manipulate that, this didn't work out too well so I followed your example and yes I did spot the deliberate mistake !! :D

You need to move byte 3 to 9 and 4 to 11 and have a zero in bytes 8 and 10 so the BCD words are correct.

You've both been a great help,

best regards

Dave
 
PLCdave said:
yes I did spot the deliberate mistake !!

You need to move byte 3 to 9 and 4 to 11 and have a zero in bytes 8 and 10 so the BCD words are correct.

I didn't think I made mistakes deliberately!

The last time I done something like this I was sending the data to a TP27-10 HMI over profibus, with that you get the 'good ol' Siemens' byte swap syndrome which is why I posted the example the way I did (well, that's my excuse and I am sticking to it!)

Paul
 

Similar Topics

Per title - what's the worst and best wire duct brands you have worked with, and why? They all look the same on the outside, but there are...
Replies
13
Views
2,329
I have installed a Cognex barcode scanner on a machine. I have a 1769-L18ER CompactLogix processor. I have communication setup and working. I...
Replies
26
Views
4,502
Is there anyway to be certain that the memory module in a ML1400 has been written to with the current program? I have controllers in the field...
Replies
0
Views
857
Hello all, I'm trying to come up with an elegant solution to check an Array of Values to see if they are greater than zero but less than 15 My...
Replies
11
Views
2,341
Hello experts; If i want to compare two companies PLC's features which points should be considered especially if i want to compare Siemens and...
Replies
9
Views
2,407
Back
Top Bottom