From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

AI and AO logging

Solved!
Go to solution

Hi,

I have a query on LabVIEW, i'm using few Analog Input(AI) and Analog Output(AO) cards, presently i'm recording the AI data in a .csv file with sampling rates (say 100HZ to 2KHz), and now i want to record the AO data too to be logged for those particular Timestamps of AI’s (As Shown in the Figure) in the csv file. The AO’s applied are On Demand DC signals.

 

 

 

 

AI & AO.png

 

Can someone please reply to solve this issue.

 

Thanks,

Siva

 

 

0 Kudos
Message 1 of 15
(3,755 Views)

Does it have to be in the same unique csv file? Maybe a TDMS file would help you, it is quite handy when you have multiple tasks that run at different rates and that have to log data in the same file. 

 

Do you have the same rate for acquisition (AIs) and generation (AOs)?

 

In your code, is the AO task anywhere near the AI task?


We have two ears and one mouth so that we can listen twice as much as we speak.

Epictetus

Antoine Chalons

0 Kudos
Message 2 of 15
(3,741 Views)

you need just recall your .csv file(read file) back as array then use insert into array to insert new data and again save it in new .csv file 

0 Kudos
Message 3 of 15
(3,727 Views)

Hi Siva,

 

what's the problem to add the current AO values to your file save routine?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 15
(3,722 Views)

As reported by Titou, saving data in TDMS seems to be the bet solution. Using TDMS you can save data with different sampling rate, add data of new channel at any time and in ease.

You can also view the TDMS file using Excel (a plugin is required for this).

0 Kudos
Message 5 of 15
(3,709 Views)

Both the AO and AI data should be in the same csv file. 

No the Rate of Acquisition (AIs) and genration (AOs) are different. (The AIs are continuosly acquired and recorded and the AO values are generated discretely, and whenever a AO value is generated, it is to be recorded with the AI values in the csv file)

And the AO tasks and AI tasks are seperately coded in different VIs so they are not nearby.

 

Hope these will answer your questions, please let me know if any other information is required.

 

Thanks,

Siva

0 Kudos
Message 6 of 15
(3,704 Views)

Hi Hatef,

Thanks for the Reply.

The scenario is that I'm acquiring AI data continuosly and AOs discretely so if i recall the csv and try to add AO data then the timestamps will be incorrect. I want to continuosly acquire AIs and whenever there is a AO data generated it has to be recorded with the AI data at that timestamp in the .csv file.

 

Is there any solution for this?

 

Thanks,

Siva

0 Kudos
Message 7 of 15
(3,696 Views)
Solution
Accepted by topic author ramssrk

Yes, the description is quite clear now.

 

I have 2 suggestions :

 - a. you can compromise on the file format, use a TDMS file with 2 groups (AIs eand AOs) have both you task log into it, have an "export to CSV" option, to do that you'd have to load both groups from the TDMS and match, base on the timse stamp, the AI lines on which to add the AO changes.

 - b. transfert each discreate change of AO to the log function in the AI code in order to add the few columns you have to only when there is an AO change. Tansfert technique can be queues.

 

Hope this helps


We have two ears and one mouth so that we can listen twice as much as we speak.

Epictetus

Antoine Chalons

0 Kudos
Message 8 of 15
(3,692 Views)

1) Just take whatever the current value of the AOs are when you write to the file (e.g. using a no-wait notifier / FGV / local / global variable) and write them into the file - you'll get repeated data in your file but that probably isn't a problem.

2) Wire the AOs back to your AI - that way you can sample the actual AO value as an input and log it along with your other AI signals.

 

As others have said, TDMS does allow you to write data at different rates (e.g. your dt-sampled AI and periodic AO update events) but it's a completely different file format so it may not be suitable in this case.


LabVIEW Champion, CLA, CLED, CTD
(blog)
0 Kudos
Message 9 of 15
(3,675 Views)

Hi TiTou,

As you explained in option b - I think this will serve my purpose, i'm trying to do this way and check.

Thanks for the solution.

 

Regards,

Siva 

0 Kudos
Message 10 of 15
(3,661 Views)