05-06-2020 06:45 AM
Hello everybody.
Does anyone know whether it is possible to get any sort of "virtual card" from NI for making work a simple data acquisition/switching on-off code?
Thanks in advance,
Nico P
05-06-2020 07:06 AM
05-06-2020 07:47 AM
You can create a simulated DAQ board in MAX (Measurement and Automation eXplorer). But do note that the AI tasks will read sine waves and DI tasks will read counting patterns. There is not currently a way to create your own simulation data. Go give this idea a Kudos: Interactive DaqMx simulation interface.
05-06-2020 12:15 PM
It is very easy (I do it all the time) to write a little VI that will simulate the output of a DAQmx Read function connected to an arbitrary Waveform. The "trick" is to generate the Waveform at appropriately "real" timed intervals. I've done this for Analog Waveforms, which I'll describe here -- doing it for Digital Waveforms would be similar, but simpler.
So I want to simulate a USB-6002 multi-function DAQ device sampling 1 channel of A/D, and my input is a 60 Hz sinusoid with noise. I'm going to set up Continuous Sampling, 1000 points at 1000 Hz. So my DAQmx code will have a Create Channel to set the number of channels, a Timing module that specifies the sampling rate and sample size, a Start just before the While Loop, and a Read, specifying 1000 samples and outputing a Waveform (or an Array of Waveforms if I'd specified multiple channels). The While Loop will be "clocked" by the DAQmx Read, so every 1000 samples / 1000 Hz = 1 second, it will produce a Waveform of 1000 samples. That's what I simulate.
The Simulating comes down to generating the appropriate 1000-point Waveform at a rate of 1000 points/loop, which means the While Loop needs to run at 1 Hz, easily done by sticking a "Wait" function of 1000 msec inside the loop. The contents of the Loop consist of the Basic Function Generator (from the Waveform Palette, Analog Waveform/Generation sub-Palette. I set up the parameters I want, and wire them into the Basic Function Generator. Note that there is a "Reset" input on top of the Function Generator that (if True) resets its clock -- if you are only running the While Loop once, you can leave this unwired, in which case it will start from Time = 0 anyway.
So once a second, this simulation will do just what DAQmx Read does, give you the next 1000 points as though they came from the waveform you are simulating. That's just what you want to see.
So what about a Digital signal? You just need to synthesize the appropriate Boolean waveform in your own "Digital Function Generator" inside the While Loop. Let your Genertor have a "simulated cycle time" of dt, whatever your sample interval (of your waveform) is. You need a "rule" to determine if the Boolean is True or False, based on the current time as measured by the cumulative sum of all the dt's (or, equivalently, by the number of "ticks" of the Sample Clock). Once you have your Array, add the components to make it a Boolean Waveform and you're done.
Bob Schor
05-11-2020 08:27 AM
Thank you very much all!