Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Trivial example: Loop through single [Sample - Process - Output] in fixed intervals

 

Hi Everyone:

 

I have been having difficulty finding sample code to do the following. I need to:


1) [Read 1 analog sample (just 1) In from channel 0 (ie Ai0)]

2) [Process the analog sample you just read in - do something with it,
ie. divide it in half]

3) [Output the result of the computation on your sample on an output
channel (ie Ao0)]

These three sequential steps form the basic temporal element that need to happen in a continuous loop within "FIXED" time interval (can be as long as necessary, but fixed) . 

 

This seems like a trivial program and can be implemented in a few lines in a number of embedded microprocessor environments. But for some reason I haven't been able to get a sample code running in NI-DAQmx framework? Anyone aware of a sample that might provide some insight?

 

Thanks,
Devor

 

 

0 Kudos
Message 1 of 4
(3,139 Views)

Hello Devor!

 

What you need are two tasks run in the same while loop - one for reading and one for writing, with a "wait until next ms" function to grant the fixed interval of the loop.

 

I have created a very simple example which I'm attaching that might be showing a situation similar to yours

 

 simple IO loop.png

 

 

Hope this helps you to get your application working!

Could you please let me know, if this solved your problem?

 

Feel free to ask if you have any other questions about the example!

 

Have a nice day!

 

Best regards,
Jano
0 Kudos
Message 2 of 4
(3,133 Views)
Unfortunately LabView based solution is not an option. We were looking for a ni-daq based ( c code) solution that can be compiled via standard windows compilers. Thanks for the response anyway!
0 Kudos
Message 3 of 4
(3,125 Views)

Hello Devor!

 

The DAQmx C code is in structure quite similar to the structure in LabVIEW. Anyway, for more infromation, where to search for text based examples, I would recommend you this knowledge base which deals with examples for text based NI-DAQmx.

 

In any case, what I should have mentioned is that for truly fixed intervals you would need a real time operating system.

 

Last, since I see you have been discussing the same topic in a different thread, I suggest that you continue the discussion there.

 

Have a nice day!

Best regards,
Jano
0 Kudos
Message 4 of 4
(3,106 Views)