05-03-2011 08:17 PM
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
05-04-2011 03:13 AM - edited 05-04-2011 03:14 AM
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
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!
05-04-2011 11:28 AM
05-05-2011 03:53 AM
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!