Lookout

cancel
Showing results for 
Search instead for 
Did you mean: 

How do you convert a Modbus Datatype TIME in Lookout

How do you convert a Modbus Variable with a Datatype of TIME in a Lookout Expression to display MM:SS.
0 Kudos
Message 1 of 11
(5,982 Views)
Hello mchen,

Can you elaborate a little bit more please. I believe there is no 'time' datatype in modbus datamembers. Did you mean read in a timestamp as an absolute value and then convert it in accordance with system time in Lookout?

Regards,

Arun V
National Instruments
0 Kudos
Message 2 of 11
(5,965 Views)
Hi Arun,


What I am trying to do is read a 40000 register from a modicon PLC, that is a datatype of "TIME". The register on the PLC shows a value of 1m_10s_410ms. When I create an expression in Lookout, the display is set to numeric with a format of HH:MM:SS.S, however the final display is something like [118896:00:00.0]. I have experimented with several display formats, converted the TIME to an INT,changed the expression to "TEXT".

Any help would be appreciated..

mchen
0 Kudos
Message 3 of 11
(5,960 Views)
Hello mchen,

Please refer to the following knowledge base. http://ae.natinst.com/operations/ae/public.nsf/web/searchinternal/1a3bb7b3299c11c78625680c004da744?OpenDocument

I think the number that is displayed might be a total in seconds and you might have to manually divide it down to get the right format.

Regards,

Arun V
National Instruments
0 Kudos
Message 4 of 11
(5,938 Views)
Hi Arun,


My expression in Lookout reads 10000 when the PLC timer is at 10 seconds and 60000 when the PLC timer is at 60 seconds. Which is easy to read the seconds from 0 to 60, however 61 seconds needs to be converted to 01:01. I tried to format the expression using the TEXT() function, but the results would not become minutes:seconds, just seconds.

Any Thoughts?


mchen
0 Kudos
Message 5 of 11
(5,925 Views)
Your PLC is giving you the time value as an integer. The units are in msec.
Lookout date/time values are in days. Therefore hours, minutes and seconds are held as a fractional part of one day.

01.0 = 1 day = 24 hours = 1440 minutes = 86400 seconds

0.25 = 0.25 day = 6 hours = 360 minutes = 21600 seconds

You can experiment with this by creating a pot with a range of 0 to 86399. Next, insert (pot/86400) as a displayable object. Choose a display format of hh:mm:ss. Your display should range from 00:00:00 to 23:59:59.

If your requirement is for display only, you need to divide your value by 86,400,000 (msec in a day).

Should you need a further breakdown into separate hour, minute or second integers use mathematical functions such as trunc and mod. Used in combination with appropriate divisors, you'll get what you need.

Bob
0 Kudos
Message 6 of 11
(5,915 Views)
What I think lookout does:

* Counts the number of days elapsed since Jan, 1 1900(Midnight)
* One day has 86400(60*60*24) seconds, hence 1 sec=1/86400 days.

So, if you divide the register's value by (86400*1000) and use the numeric format "hh:mm:ss" you will get a valid "time". Note that if you use the format "dd/mm/yy hh:mm:ss" you will get "00/01/00 time".


JPSS

Mensaje editado por jpss

0 Kudos
Message 7 of 11
(5,915 Views)
The URL provided above must be an internal N.I. link - for us folks on the outside it's
http://digital.ni.com/public.nsf/allkb/1A3BB7B3299C11C78625680C004DA744
I use a time_to_word function in the modicon when I need to display a data type of time in Lookout. What you get when looking at the register with the modbus object in Lookout is the time in msecs - just divide by 1000 to get the seconds. But you must 'build' the display for minutes, hours, etc. The numeric displays in Lookout are not
based on seconds, they are based on days as the above knowledge base article indicates. The following will work on a word read from the modicon, and may or may not work with a data type of time. The expression
(Modbus1.400001/86400000)
first takes the number in msecs and divides by the number of msecs in a day. This puts the number into a fraction of a day that Lookout can then display using the numeric formats such as "HH:MM:SS". I know it’s a little clumsy to divide that number for every time value – but hopefully you don’t have a lot of these expressions. Hope this helps.
0 Kudos
Message 8 of 11
(5,907 Views)
If I use (Modbus1.400001/86400000)and set the display to the numeric format as "HH:MM:SS", it works fine till the PLC value hits 65536. If I divide the TIME block by 1000, it doesn't register low values. I'm not sure what you meant by "'build' the display for minutes, hours, etc".


mchen
0 Kudos
Message 9 of 11
(5,905 Views)
400001 will be a 16 bit integer with a max value of 65535. Try displaying Modbus1.D400001. (32 bits)

Bob
0 Kudos
Message 10 of 11
(5,893 Views)