LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to get system time from cRIO?

Hello,

 

I have an NI cRIO-9076 chassis with an NI-9467 GPS module and an NI-9234 module.

 

I've downloaded the FPGA Timekeeper application which synchronises the FPGA clock to the 1PPS GPS, this works well.  What I want to do is create a trigger that at a pre-defined HH:MM:SS the system will start to acquire and log data from the Accelerometers connected to the NI-9234 module.

 

I have added the controls for the entry of the HH:MM:SS and calculated the time in seconds.  I would like to compare the system clock once it is locked to the entered timestamp and then trigger.

 

As I only have a value that represents seconds in the day I need to calculate the offset from EPOCH to compare against the GPS time reference.  I have read that the NI system clock runs from 01/01/1904 instead of the EPOCH 01/01/1970.

 

The question is how do I get the current system time so that I can compare it against the entered time?  I only need seconds in the day = (HH * 3600) + (MM * 60) + (SS)

 

Thank you,

 

Kind Regards,

Simon

0 Kudos
Message 1 of 8
(3,851 Views)

Have you tried using the "Get Date/Time in Seconds" VI?

 

http://zone.ni.com/reference/en-XX/help/371361K-01/glang/get_date_time_in_seconds/

 

It works the same on RT targets as it does in Windows.

Craig H. | CLA CTA CLED | Applications Engineer | NI Employee 2012-2023
0 Kudos
Message 2 of 8
(3,830 Views)

You should use the Get Date/Time in Seconds VI which will return a timestamp. You can then format this timestamp using the Format Date/Time String to give you exactly the time format that you need. Then you can extract the numbers you need and do your math.

 

Get Seconds in Day.png

0 Kudos
Message 3 of 8
(3,826 Views)

Thank you, I've tried using the code but I'm getting errors:

 

Target Specific Errors and Warnings:

  Decimal String To Number: Function not supported for current target

  Match Pattern: Functiron not supported for current target

  Diagram Constant: Type not supported in current target

  Wire: Type not supported in current target

  Get Date//Time in Seconds: Function not supported for current target

  Front Panel Terminal 'date/time string': Type not supported in current target

 

These errors only occur once I paste the logic from the "Get Seconds in Day.vi" into the project.

0 Kudos
Message 4 of 8
(3,809 Views)

Just to recap, we have a cRIO-9076, with a NI-9467 and a NI-9234.  I've been talking to NI support and I am told that the string handling functions and time conversion functions are not supported by the FPGA target, which would explain the error messages.  Is it possible to do what I want with the hardware we have?

 

What we are trying to do is synchronise the chassis using the GPS 1PPS clock, then trigger an activity based on a user configurable time.

0 Kudos
Message 5 of 8
(3,775 Views)

You did not mention that you were trying to accomplish this on the FPGA target. The solution I posted will work on the RT target. 

0 Kudos
Message 6 of 8
(3,763 Views)

The first line of my original post specifies the hardware, sorry if I missed something, I thought I had been specific.

 

I'm very new to cRIO and still finding my way. 

0 Kudos
Message 7 of 8
(3,734 Views)

Solved !

 

Have created a VI on the Chassis, I have accessed the FPGA global variables "FPGA Timekeeper time(ns)" and "FPGA Timerkeeper locked".

0 Kudos
Message 8 of 8
(3,723 Views)