LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Log DigitalOut and AnalogIn in one waveform

Hi,

I have a data acquisition of several analog inputs and some digital outputs. 

 

Now I want to log both signal groups in one stream (chart or tdms file) to display and save them when the acquisition is done.

The digital signal should be logged as integer values and have the same timestep dt as the analog signal. This is for better reading of the analog data. How do I need to do that?

 

I'm using DAQmx driver but couldn't find any solution. As far as I know you can't handle both analog and digital signals in one daqmx-task.

 

Yves

0 Kudos
Message 1 of 13
(3,238 Views)

The simplest solution is to wire your DO to spare AI chanels and acquire all at the same time in the same task.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 2 of 13
(3,234 Views)
Look at the digital waveform conversion functions. There's one called Digital to Binary. You can use the dt from the analog waveform and the Build Waveform function with the binary array to create an analog waveform type.
0 Kudos
Message 3 of 13
(3,232 Views)

@ Ben: Unfortunately I don't have any spare AI. My Device has got 8 DO and 8 AI...

 

@ Dennis Knutson: I found this vi. But I can't see the path where this should lead me. I don't have a digital waveform yet. Because the DO are switched when a user push a front panel button. Or when the program sets a new state.

 

Until now I have two separated loops for analog IN and digital OUT. This is certainly not good if I want to "synchronize" the signal groups. I'm actually also trying to change this.

 

Yves

0 Kudos
Message 4 of 13
(3,199 Views)

Ok start with the simple and move up...

 

Have you concidered writing the DO data to an Action Engine(AE)  at the same time as you write to the hardware and reading from the AE where ever the AI data is being read?

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 5 of 13
(3,194 Views)

Yes, moving things to the same loop will greatly simplify matters. There are multi-function examples that you can look at.

 

If you are not using a digital waveform for a digital output, then you are either using a Boolean array or a numeric for the DO. Either one can be converted to a 0/1 array. The Boolean to (0,1) function can have an array as an input.

 

 

0 Kudos
Message 6 of 13
(3,177 Views)

@ Ben: In fact I'm actually not using AE yet. I just couldn't remember your great Nugget. And didn't know this could lead me to the goal. Even with "fast" running acquisition and outputs (1kHz). And the DO's are set without any prediction.

 

@ Dennis Knutson: Well in fact I'm already using Boolean array for the DO. And I have it converted to an 0/1 array. But I just couldn't imagine how to write this data into a waveform with a true dt.

It is important for me to have a sinchronisation between AI and DO. This means that both dt should be similar. 

 

Yves

0 Kudos
Message 7 of 13
(3,162 Views)

Since you have not posted any code, I have to guess and make assumptions. It sounds like you are using an NChan/1Samp DAQmx Write and in that case, you don't have a dt. You would have a t0 and the 'real' dt would be the delta between these times. If you do some synchronization so that you start the analog in at the same time you do the digital write, then using the same t0 for both is easy.

 

Are you doing an NChan/NSamp read with the analog in or not? How are you actually doing the digital writes? How are you synchronizing the two?

Message 8 of 13
(3,153 Views)

Wow, you're really THE master. 

For DO I don't have a dt because I'm using NChan/1Samp. And for AI I'm using NChan/NSamp

 

And that's why I don't have a synchronizing between the two.

 

I haven't posted any code because it is not cleaned up and it is loaded with other, not relevant function.

Now I have exported the acquisition part to a separeted vi. (LV8.6)

 

Of course I'm happy for any input.

 

Yves

0 Kudos
Message 9 of 13
(3,134 Views)
I hope my code isn't that bad... :smileysad:
0 Kudos
Message 10 of 13
(3,088 Views)