From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Real-Time Measurement and Control

cancel
Showing results for 
Search instead for 
Did you mean: 

READ 2 ANALOG INPUTS - CONTROL - WRITE ANALOG OUTPUT - AT 1000 Hz

Hello everybody!

 

Attached you can find my project so far and the error i get after i run it with the shown settings (sample-rate: 1000, buffer-size: 1) and stop it.

 

The setup is LabView2016 and the NI USB-6221 for data aquisition.

 

The purpose of the project is as follows. I have two analog voltages (DC), which i want to read from an analog circuit, apply a control system and afterwards write the result as analog output (DC) back to the analog circuit.

An important point is, that the whole thing must work at a frequency of 1 kHz, means i want to write a value to the analog output every 1 ms.

 

If you look at the project you can see, that in the last True/False-condition before the DAQmx-write i generate a signal either 0 or 5 which is just for the purpose of observing the analog output with an oscilloscope in case you are suprised about this condition.

 

The problem i have now is, that if i run the project with the shown settings (sample-rate: 1000, buffer-size: 1), i recognize with the oscilloscope that the analog output is writen with a large delay of around 10 seconds and when i stop the run, i get the error attached which says, that the application is not fast enough for the hardware-aquisition.As i need to control the output dependent from the two inputs, the large delay is a very big problem.

I have googled a lot and meanwhile almost tried every approaches i could find to synchronize analog input and analog output, but i didn't get my project running as i need it.

 

I hope i described my problem sufficiently and would be very glad if you can help me getting my project running.

 

As this is my first project with LabView, i appologize for possibly not very well designed parts of my project. Independent of my main problem i am always happy, if you give me improvement proposals what i could have made better.

 

Regards,

Peter

 

 

 

0 Kudos
Message 1 of 7
(3,175 Views)

Are you using a RealTime computer?  Something like this does not belong on a Windows computer.  In fact, I would use an FPGA board (PXI or cRIO) to perform what you are trying to do.

 

Another option if you insist on trying it with your current setup is to try a Producer/Consumer setup.  The idea is to constantly read from the DAQ and use a queue (or a Channel, since you are using 2016) to send that data to another loop that does the calculations and analog output.  By splitting up the processing between loops, you can often gain some performance.  But anything running on a Windows machine cannot have the determinism you want.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 7
(3,162 Views)

Hi Peter,

 

crossrulz already addressed a major point. Your HW is not well suited for this task.

 

First of all regarding your SW approach: If you read with a 1000 Hz HW clock you will likely read muliple samples at once which is normally not the right thing to do when doing control.

You probably should always get a single value at the maximum speed (which should be also at around ~1ms for a USB device). At the moment it looks to me that you get multiple samples so your real control loop rate is not 1 kHz but 1kHz/N samples

 

From the HW side you should probably move to a stand alone real-time system like a cRIO or a FPGA card (R series). At the very least you should get a internal PCIe card (supports for HW-timed single point I/O would be nice) since the PCIe bus has a way lower latency than a USB attached device.

 

Regards,

Christoph

Staff Applications Engineer
National Instruments
Certified LabVIEW Developer (CLD), Certified LabVIEW Embedded Systems Developer (CLED)


Don't forget Kudos for Good Answers, and Mark a solution if your problem is solved
0 Kudos
Message 3 of 7
(3,139 Views)

First of all thanks for your fast reply!

 

No, i'm working on a windows computer.

 

I already informed myself a little bit of the possibility to work on a real-time system with LabView. And if i get it right, i need to buy the real-time add-on for LabView and of course any real-time-able hardware like for example theCompactDAQ right?

 

Concerning the alternative with the Producer/Consumer setup. For me it sounds like this could probably work, but not for sure and that it's not a really nice solution. Additionally i understand it this way, that the timing is then software-dependent (loop-iterations), and therefore get problems with the exact timing on a windows machine again.

 

 

0 Kudos
Message 4 of 7
(3,132 Views)

Hi!

 

Event though there are CompactDAQ Standalone Systems that also support Real-Time it it is normally not a good fit for single I/O systems with frequencies >=1kHz. You should rather pick a CompactRIO system.

 

Regards,

Christoph

Staff Applications Engineer
National Instruments
Certified LabVIEW Developer (CLD), Certified LabVIEW Embedded Systems Developer (CLED)


Don't forget Kudos for Good Answers, and Mark a solution if your problem is solved
0 Kudos
Message 5 of 7
(3,129 Views)

Hi Christoph,

 

i don't understand, why i read multiple samples at once at 100Hz HW clock.

 

"You probably should always get a single value at the maximum speed (which should be also at around ~1ms for a USB device)"

I not really sure what you mean. Can you show me a concrete example, how to do this? 

0 Kudos
Message 6 of 7
(3,128 Views)

Hi Peter,

 

the screenshot following the heading 'Sample Block Diagram' shows a block diagram that is usually used for controll I/O.

 

NI-DAQmx Hardware-Timed Single Point Lateness Checking - National Instruments
http://www.ni.com/tutorial/3215/en/

 

Similar article:

Hardware-Timed Simultaneously Updated I/O Using the Timed Loop (LabVIEW Only)
http://zone.ni.com/reference/en-XX/help/370466Y-01/mxcncpts/controlappcase6/

 

Your hardware has to support Hardware-Timed Single Point Sample Mode:

 

Does My DAQ Device Support Hardware-Timed Single Point Sampling Mode? - National Instruments
http://digital.ni.com/public.nsf/allkb/B4E831774F29FB038625754C0081C050

 

Regards,

Christoph

Staff Applications Engineer
National Instruments
Certified LabVIEW Developer (CLD), Certified LabVIEW Embedded Systems Developer (CLED)


Don't forget Kudos for Good Answers, and Mark a solution if your problem is solved
0 Kudos
Message 7 of 7
(3,117 Views)