S7 Byte to Int question

snydl0ga

Member
Join Date
Apr 2005
Location
Tennessee
Posts
21
I have a line of code that gets the current D/T and places it into a DB as 8 Bytes. My problem is I compare that to see if a particular hour and minute has occured but that criteria is in Decimal. The System time appears in Hex so the 2 do not compare properly.

I was thinking I could convert the Bytes of Current time to Int but can not seem to find that solution.

Any ideas?


Lance
 
Since Jesper's been looking at this for five minutes and still not answered, I guess I'm right in thinking that this isn't as easy as it sounds at first glance.

The first thought that occurs to me is that you could convert both of them to BCD and then compare them using an XOW instruction, when they are identical your result is zero otherwise non-zero.

Just a thought.
 
Why not have the compare criteria in DT format ?
You can then use the FC9 "EQ_DT", or FC12 "GE_DT", or FC14 "GT_DT" (from the IEC function blocks).

Otherwise you will have to convert the BCD values to decimal with the BTI "BCD to Integer" instruction.
 
Thanks to All, It turns out that I moved the Bytes to BCD then to Int for now and it works.

I will look at stream lining this using these suggestions.

I could use the compare in DT format probably. I am converting COntrol Logix code over to S7 and that is why I had that code like that.


Thanks all,

Lance
 

Similar Topics

Hey all, I'm struggling with the following in Sysmac right now. Any help would greatly appreciated. I am dealing with socket comm strings, a...
Replies
2
Views
2,916
Hello All! I am having difficulties mapping register values. In the TURCK register there are 24 unique register bytes corresponding to different...
Replies
2
Views
2,566
Hi All I have recently had cause to start using Unity Pro but am still struggling with it a bit. I a trying to convert a speed reference for a...
Replies
5
Views
3,499
Hi This may be a stupid question but in Step 7 is it possible to convert a byte to a Double Integer eg convert DB*.DBB* to DB*.DBD* Your...
Replies
12
Views
9,618
Has anybody got a routine handy that will take an INT as input (1 - 21) and convert it to the Byte.Bit format that is needed to add to a basic...
Replies
14
Views
21,208
Back
Top Bottom