This widget could not be displayed.

Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

Suggestions for Accurate digital sampling and control program using M-series DAQ

Hi,

 

Recently, I found a method to develop a digital control program on C or C++,

which uses the M-series NI DAQ device just as like other microprocessor units(e.g. ARM). My device is NI-USB 6281.

I have searched for many example codes and manuals from NI.

 

I would like to share this for those who struggle to configure the DAQ settings

for a digital control program such as a conventional PID control or a Linear Quadratic Regulator.

 

This program uses internal hardware clock to make sampling time.

Since the M-series usb devices don't support any hardware-timed non-buffered actions,

sampling tasks are based on buffered operation.  

 

A counter is used as a reference clock for analog input or analog output.

 

Analog input task has an event call back function each time it gets an sample in its buffer.  

This event function works as an interrupt service routine which increases a count value for soft-timed loop in every iteration.

It fetches a sample from the buffer in the loop.

 

Analog output task writes dummy samples before it starts, and it regenerates output when

the user calls the write functions in the loop. The major problem was that the analog output task is so hard to handle using NI-DAQs.

They almost consume all of the loop sampling times. If one tries to use a OnDemand mode,(fully soft-timed mode) it will take about 2ms or more.

 

The main do-while loop will act asynchronously though the control script will be executed only once

by the flag. This ensures the idling time for control code.

(Using only flag to block the main code is really vulnerable, though. I would expect that someone could solve this and help me)

 

Using this looping method, I could achieve up to 1800Hz sampling rate without any time-delays.

However, as the main soft-timed loop depends on the speed of processor, one could get only up to 1000Hz or 1500Hz.

Nevertheless, this program ensures a rich sampling rate compared to the soft-ware timed program using Windows times.

 

If you have any inquiries or suggestions, please feel free to reply.

 

Best regards,

 

Byeong-uk, Im.

 
1492068490707_PastedImage
Im, Byeong Uk
MS Course |Active Aeroelasticity And Rotorcraft Lab.
Mechanical And Aerospace Engineering |Seoul National University

1 Gwanak-Ro, Gwanak-Gu, Seoul, 151-744, Bd. 301, Room 1357
Tel:82-2-880-1901 |C.P.:82-10-2439-0451 |W:http://helicopter.snu.ac.kr
 
Download All
0 Kudos
Message 1 of 1
(2,685 Views)