02-09-2024 08:50 PM - edited 02-09-2024 08:52 PM
Hey,
I am a final Year Student, Making a Curve Tracer to test 2 and 3 lead Discrete Semiconductors using a NI MY DAQ.
Im Currently working on a VI which interfaces with a Analogue Circuit, which takes a sine wave and DC control voltage and Digital Control Signals from the DAQ. Before attempting to complete this using labview and a DAQ, I initially tested functionality using a Microcontroller ADC and DAC successfuly. As such my attempt throughout this has been largely trying to recreate my original C code in labview, with limited success.
I need to Generate a 50Hz sinewave, and a DC Voltage "Step" . Both of which can be manipulated via user controls. These waveforms are first calculated and then wrote to arrays before being wrote to the two DAC's. The 50Hz sinewave consists of 200 data points for each period. For every data point I need to both write the new value and then read from the DAQ's ADC. The value from the ADC is quickly wrote to an Array to keep the real time data processing to a minimum. Upon completing the full 200 Data points. I can then freely manipulate the array data without effecting DAC timing.
Upon running my VI using a MY-DAQ without any software delays, the output waveform is a clean sinewave, however at around 2hz. The only thing that I can think of that can effect the frequency of the wave is the rate the VI writes to the DAQ. I removed all the ADC polling side of the VI to test to see if lightening the work done between samples increases speed, and it did marginally improve the speed.
Is there a better approach to writing a waveform to the DAC(s) which can be synchronised to the ADC? and how do the examples write to the DAC substantially faster than my attempt?
Im not after my work to be done for me, just pointers towards a solution would be greatly appreciated as im sure the issue here is down to my method.
Find attached my VI without the ADC sampling.
Thank-You
Isaac Walsh
Solved! Go to Solution.
02-10-2024 02:18 AM - edited 02-10-2024 02:22 AM
Your LabVIEW program is running as one of many processes on your Windows computer, sharing the CPUs with many other things that Windows will do randomly. taking away control from LabVIEW several 100 times per second. Worse even, every analog write you do has to go through a large stack of driver calls and eventually the CPU has to switch into kernel mode as that is the only way a driver can access physical hardware, then everything has to be pushed through the USB bus to the myDAC, which has to do another slew of operations to output that single value and send back an acknowledgment to your LabVIEW program, which has to go in reverse order though all the mentioned buses and drivers before your LabVIEW program can send the next value. This is of course very slow since the latency of each analog value update is huge.
The way this is normally solved is by sending a whole buffer, at least your entire waveform period, at once to the device and configure it to do buffered waveform generation with a configurable update clock, in our case likely 200 * 50 = 10000 samples per second. If the waveform is repetitive you can normally send one period and enable waveform regeneration. The device will then replay the buffer over snd over again.
However I never used a myDAQ and don’t know its capabilities. Some low cost devices may not support waveform generation. With a more standard NI DAQmx device this is normal basic functionality however. Getting a 10000 kHZ update rate under Windows (or any other desktop OS) through single value updates is never ever going to work with any possible hardware at your desired speed.
02-12-2024 02:19 PM
Hey,
Thanks for your answer, it was very helpful.
Iv had a read over the Timing and synchronisation information on NI.com, I have a couple more questions if you wouldn't mind.
How would I go about sending a whole buffer to a DAQ. I assume its part of the DAQ MX? I cant find any Information online regarding this.
Is it possible to have two timing clocks of the same frequency but out of phase? I ask as the My-DAQ Has a one channel ADC which is then multiplexed as such only one of the ADC inputs can be read at once.
Thank-You
02-12-2024 03:44 PM
As said I don't know if myDAQ supports waveform generation. If it does you should search in the Help->Find Examples ... for "Voltage - Continuous Output".
As to acquiring more than one channel, yes that is possible but not with different clocks per channel. If you setup a Continuous Analog Input acquisition, you can add more than one channel to the task and they will be sampled quasi simultaneous. They can't be read truly simultaneous since that would require one ADC per channel, instead the analog channels will be multiplexed and the ADC will actually read in sample rate * number of channels samples per second. LabVIEW returns the data as 2 dimensional data, one dimension are the channels, the other are the samples.
If you need the sampling to be more close to each other between the channels, you can change the interchannel delay, but what value that can be and if it can be even changed depends very much on the hardware. I would guess that the possibilities for that are very limited on the myDAQ.
02-23-2024 08:34 PM
Thank-You!
The example you highlighted, while not solving my exact problem did indeed give me sufficient information about the DAC to be able to work it out.
Thank-You again