Converting CST and WALLCLOCKTIME high/low to EPOCH

pickedaname

Member
Join Date
Mar 2013
Location
Rochester, NY
Posts
3
Hi guys, I am (via a transaction management software) recieving a high and low number representing a moment in time from an Allen Bradley 1756-L61, 5561 ControlLogix PLC. Revision 19.11. I am no PLC programmer, have no access to this device and I have been told that the output being sent to the transaction server will not be changing. I am currently working in Oracle 11, so forgive the PLC ignorance. All I need to know is, what math do I need to do to those two numbers to get a single number, preferrably EPOCH (seconds from 1970-01-01)? I cannot see the math that creates these two numbers which makes it difficult to reverse engineer the function. I have searched the net and have come up frustratingly empty handed, partly because I do not speak your speak so am probably not using the right key words to search with. Also, when the low bits represent a negative number, does it need to be treated differently? A million thank you's for your help!
 
Last edited:
The only thing which I was given by the controls people at our company was this:
CurrentValue
LINT
GSV SSV
Current value of the wall clock time. DINT[0] contains the lower 32 bits of the value; DINT[1] contains the upper 32 bits of the value. The value is the number of microseconds that have elapsed since 0000 hours 1 January 1970. The CST and WALLCLOCKTIME objects are mathematically related in the controller. For example, if you add the CST CurrentValue and the WALLCLOCKTIME CTSOffset, the result is the WALLCLOCKTIME CurrentValue.
 
The key is the datatype: it's a 64-bit Long Integer.

ControlLogix controllers are fundamentally 32-bit devices, so they're just sending you the low and high 32-bit integers that make up that one 64-bit long integer. You'll have to reassemble them at a hex level, rather than interpreting them as 32-bit integers.

The information is the same as an Epoch value, except in microseconds instead of seconds. So divide by 1,000,000.

As an example, the Wallclocktime Current Value on my controller a moment ago is

CurrentValue[0] = 2095753508 = 0x7ceaa924 (hex)
CurrentValue[1] = 317577 = 0x0004d889 (hex)

Divide that number of microseconds 0x0004d8897ceaa924 (hex) by one million (0x000f4240) to get Seconds: 0x514cc21c (hex).

Run the hex value 0x514cc21c through a handy online Unix Epoch Converter, and I get Friday, March 22 at 1:45 PM Pacific Time.
 
Hi Ken, thank you for your help and explanation! This is working for me most of the time. When the PLC sends me a high value of 317516 and a low value of 469984752, I get the expected 3/19/2013 15:28:25 (I am adding the -4 hour EST timezone offset to the result). However, when I recieve a negative number for the low value, I am unsure of how to handle this, as I am unsure how it became a negative value.
For example, the PLC sent a high value of 317535 and low value of -1563843277 . The time should resolve to 3/20/2013 14:46:11 but it doesn't, of course this makes the number much different. I am not sure how to handle these negative low values.
A second issue I have run into is High 317516 Low 234362143 (converted to hex as 4D84C and DF8151F) gives me us of 317516234362143, which puts my date somewhere in the year 1972, when the date expected is
3/19/2013 15:24:30 . Not sure if I need to apply a padding charactor to the low hex value or what. I do apreciate any guidance that you can give me. Thank you.
 
You need to make sure your datatypes are unsigned, or use instructions that move the data as bytes, rather than attempting to interpret it as an integer.

I'm not at all familiar with Oracle so I can't say what that looks like.
 

Similar Topics

Hello everyone, can anyone help me with covert the STL code to ladder. Iam using plc s71200. A %DB1.DBX33.7 // angel of vaccum...
Replies
2
Views
208
Hello PLCs Forum, I am in a bit of a pickle and was hoping someone could offer me some help. I have a .rss file and just need to see the ladder...
Replies
2
Views
122
Hello nice to meet you, im new in here, I'm currently trying to convert code written in STL for a S7-400 to SCL for an S7-1500, because when i run...
Replies
5
Views
317
Hello, did anybody know, if there exist an converting cable like the1492-CM1746-M01 (for an 1746-IB16 to an 5069-IB16), for an 1746-HSCE to an...
Replies
3
Views
389
Hello, This will be my first time converting powerflex 40's and 400's from devicenet to ethernet. I did some research, and it seems I will need...
Replies
4
Views
751
Back
Top Bottom