LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

[Real-time] Trouble with the data acquisition

Good day everybody

 

I'm new to the Labview Real-time. This is a real-time project I made based on the example in Labview 2016.
The picture below is the Labview example I used in the project. 

 

ngocnguyenpukyongackr_0-1686968399197.png

 

I'm planning to collect the input from 4 sensors, then send out 4 control outputs. The DAQ is PXIe-6363.

I edited some major VIs: Global – Configuration Options (Monitoring Loop Rate, DAQ Control Rate, DAQ Input - Output Channels, Safe Output Value); UI Main (including the TDMS) and some more VIs.

 

The 1st problem is in the input. The picture below is the result I collected. 

The step time is 0.002s. The problem is the data collected repeats itself. The first 4-5 inputs are the same , and the the next 8-15 inputs are the same. For example, in the ai_0: from 0 to 0.008 (4 points), the input is 0.001019221; from 0.01 to 0.037 (15 points), the input is 0.001341197.

 

ngocnguyenpukyongackr_1-1686968459513.png

 

I don't know why the results are duplicated like this. I'm looking for this kind of data collected, without the duplicate:

ngocnguyenpukyongackr_2-1686968645384.png

Thank you

0 Kudos
Message 1 of 15
(1,388 Views)

I'll be honest with you -- I (personally) find the more advanced NI Examples (QMH, LabVIEW Real-Time (DAQmx)) too complex and "busy" for me, particularly so when I was starting out doing these things.  I kind of "invented my own" patterns (perhaps not quite as robust as NIs, but certainly more intuitive to me) based on a Queued State Machine model.  Of course the graduate students who had been CS majors as undergrads (and some of my LabVIEW colleagues more experienced than I) said "That's not a real State Machine!", but it certainly "got the job done".  And ever since LabVIEW 2016, I've been using (and might have "invented") the "Channel Message Handler" using Messenger Channel Wires instead of Queues.

 

But never mind, how do you go about getting your LabVIEW RT DAQmx code to "Do What I Want You to Do", as opposed to "Do What I Tell You to Do" (even if it is wrong)?

 

Ordinarily, you don't run code on an RT Target in "interactive mode", but when you are developing, that's an excellent way to see what is going on, and to understand why the data aren't what you expect.  I don't have the patience to try to rummage through your entire Project looking for where you set up DAQmx and where/how you acquire data (that's why it's important to debug with a colleague, preferably one who can ask semi-intelligent questions), but I can try to get you started.

 

A key element of your system is you are acquiring 2 channels of Analog Data from something at some rate.  Write a small VI called "Test Analog Acquisition" that does the following:

  • Configures a 2-channel AI system, specifying the device, the Channels (0 and 1), the sampling rate, and number of samples.  [I'll describe a "trick" for doing this ...].
  • Start the DAQmx Task.
  • Acquire one set of samples.
  • Close and stop the task

Close this VI.  Now, with your RT Target connected to your PC, run this little VI.  You should see it deploy, and then run.  Look at the Indicator where you saved the AI data -- does it look OK?  Are the numbers "sensible"?  If the answer is "No", then do the following:

  • Go to the Edit menu and click "Make Current Values Default".  This will let you close this VI, but will preserve the "bad data" you just got.
  • Reply, attaching this VI, and tell us what you expected to get.

I mentioned a "trick" to help you set up DAQmx.  But I may have mis-spoken -- what I was thinking about only works on the Host, not on the Remote Target.  But there's another way.  If you drop down a DAQmx Create Virtual Channel function on the Block Diagram, you can right-click on the second (left) input and "Create Constant".  This is the required "Physical Channels" input where you name the DAQ device and channels you want to use.  So click the little down-triangle and look over the list of Devices and ports that are shown, and choose the one that matches the DAQ input that is attached to the Target when you do this.  [I can't check this out, as I don't have a PXI system on hand].

 

So try out the simple test and let us know how it goes.

 

Bob Schor

 

Message 2 of 15
(1,312 Views)

Sorry, I don't have the RT module and thus cannot really inspect your code.

 

It looks like the values are quantized to steps, so this could be due to e.g. a FXP datatype with insufficient bits. Do you apply any scale factors? Is your gain (range) reasonable for the expected values?

 

My guess is that your values are not really duplicated, because the times are different, they are just coerced to the nearest possible value based on the datatype.

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

Hi Bob, thank you for the reply, and sorry for the late reply, I was occupied by the final exams in this week T.T. 

I had created a "Test Analog Acquisition.vi" as you said

 

Zang92_0-1687314868217.png

 

The result seem to be different. I attach the excel file below.

I set a task in the NI-MAX which the following parameters: 
- Amplitude - Voltage_0: AI 0 

- Amplitude - Voltage_1: AI 1

 

Zang92_1-1687316100751.png

 

The DAQmx data is: 

- PXI1Slot8/ai0: AI 0

- PXI1Slot8/ai1: AI 1

 

I expected to see the data from AI 0 is the same between Amplitude - Voltage_0 and PXI1Slot8/ai0 but as show in the excel, it's not.

 

 

 

Download All
0 Kudos
Message 4 of 15
(1,248 Views)

You are measuring fractions of millivolts with a range of -10 ... +10V. How many bits is you A/D converter?

0 Kudos
Message 5 of 15
(1,241 Views)

Hi altenbach,

 

I'm using PXIe-6363, it's 16-bit

0 Kudos
Message 6 of 15
(1,238 Views)

Have you "done the math"?  You have a 20V range and are dividing it into 65536 "pieces", so how big is a single bit?  Or should I say, about how many hundred microvolts = 1 bit?

0 Kudos
Message 7 of 15
(1,190 Views)

With such small signals, I hope you are recording differentially (not single-ended) and are shielding the signals (and possibly pre-amplifying them) to prevent noise and cross-talk ...

 

Bob Schor

0 Kudos
Message 8 of 15
(1,186 Views)

Hi Bob, it's 0.000305V for 1 bit.

Honestly,  I inherited this project and setup from a senior, so I trust him and didn't do any re-check match. Now I get some problems and I just start investigate again. 
Thank you for helping me. I'm new to the labview and the real-time in this scale. Can you advice me get through the problems?
Thank you very much

0 Kudos
Message 9 of 15
(1,174 Views)

See if you can use DAQmx to set the A/D range to ±1 V -- this will get you another factor of 10.  Or use an amplifier to get you a factor of 100 or 1000.

 

Bob Schor

0 Kudos
Message 10 of 15
(1,148 Views)