02-16-2019 12:35 PM
Hi,
I'm a french electronic teacher and I use Labview and MyDAQ board with my students.
So this is my question :
I know that MyDAQ does not support the Hardware-Timed Single Point Sampling Mode (HWTSP). So, if I have well understood, if I make an acquisition with continious samples, this samples are automatically stored in the buffer before they go to the vi treatment ? And the same for the Write function ?
The treatment sequency should be this one :
1 : reading sample
2 : storing in the reading buffer
3 : vi traitment
4 : storing in the writing buffer
5 : writing sample
If the sample frequency is set to 1kHz (see attached VI) : at t=0ms, the board reads only 1 sample, puts it in the reading buffer, then treats the data (this duration is approximativly few microseconds), then the sample goes to the writing buffer, and after it is written to the board analog output.
At t=1ms, we do the same, etc each ms ...
Conclusion : are we making single point treatment (N=1 in the For Loop) ??? The difference with the HWTSP is that we must pass through the buffer ... ?
Thanks for your help !
Regards,
David
Solved! Go to Solution.
02-17-2019 10:28 AM
Tomorrow is a Federal Holiday, and my myDAQ (I think) is at work, so my response will be slightly delayed ...
Bob Schor
02-17-2019 11:15 AM
Hi David,
If the sample frequency is set to 1kHz (see attached VI) : at t=0ms, the board reads only 1 sample, puts it in the reading buffer, then treats the data (this duration is approximativly few microseconds), then the sample goes to the writing buffer, and after it is written to the board analog output. At t=1ms, we do the same, etc each ms ...
Yes, BUT only when your loop spins faster than 1ms…
In case the loop needs more than 2ms to iterate you will also 2 samples as your DAQmxRead is set to read "as much as is available". What might happen when you try to read the next sample before it even was acquired?
- When you really want to handle sample-by-sample (which is not recommended) you should set the "number of samples to read" at DAQmxRead to "1". Now DAQmxRead will rule the loop iteration time!
- Why did you set the loop count to "1" for that inner FOR loop? Are you sure (really sure!) you will never read more than one sample? Why don't you rely on autoindexing? (And why do you need a loop at all here?)
02-17-2019 12:07 PM
02-17-2019 12:08 PM
02-17-2019 12:54 PM
Hi Bob,
Thanks for your answer, and don't worry I will wait !
Regards,
David
02-19-2019 08:23 AM
A few points.
Here's what I tried:
I'm choosing to not attach my VI -- the exercise of laying out the 5 DAQmx functions, defining the Task in MAX, adding your own "data processing" to the loop, and "playing around" with the code will be more beneficial to you. Feel free to experiment and make changes.
Bob Schor
02-19-2019 10:46 AM
Hi Bob,
Thanks for this very specific answer !
However I have a few questions :
- as I am on holidays, and I don't have the MyDAQ device with me, I could'nt create the task with MAX. So I put on the DaqMX Timing function with the same values (1Khz, 10 samples and continuous samples). Is it equivalent ?
- I have put the Daqmx Write, with a rate of 1kHz, since we have used the mean function. Am I OK ?
See my VI on the attached file...
Thanks Bob,
Regards,
David
- on step 6 I can't see Sample Quantity, Samples Per Channel. When I click on the Property list I can see "Sampling clock/write a waveform/use". Is it because I don't have the device with me ?
02-19-2019 12:14 PM
You can manually create the Task (using a few more DAQmx functions -- DAQmx Create Task, DAQmx Create Channel, and DAQmx Timing. The "tricky" one is Create Channel, as you specify the Channel to use by naming it, e.g. "myDAQ1/AI0". Here you need to use the name that LabVIEW "sees" at Run-Time, that is, the name MAX assigns to it! You can, of course "guess" (and if you only ever plug in one myDAQ, the name will probably be OK). What I've done is to write a little VI that does a "lookup" -- it queries LabVIEW for all the connected Devices, lets you parse them looking for, say, "myDAQ" and "do something sensible" (for example, flag an Error if none are found, use the unique one if one is found, or say "There are two myDAQs here, which did you want to use?"). Create Channel is also where you specify the voltage range and input terminal configuration (e.g. "Differential").
You have a Create Channel function to which you've wired a blank Task Constant. You can replace this with writing nothing to Task In, and giving it a (unique) Task Name (a String), and wiring this to the Task In terminal of Create Channel. See above for naming the Channel.
If you use the Timing Function, it has Number of Samples as a required I32 input, so you might as well use it instead of the Property Node. [Incidentally, the property you were looking for is right "beside" the Sample Quantity.Sampling Mode property you used in your code -- click the Property and follow the Triangle Pointer to the right edge where it will expand and show you the two sub-properties.] You don't need the Sampling Mode Property as you already set it with the Timing function.
I'm sure it isn't lost on you that there is a necessary 1 ms delay between Analog In and Analog Out -- you have to collect the Input Point before you can "play" it through Analog Out. I understand that NI Engineers are working on eliminating this delay, but their Time Machine Module is still in development ...
Bob Schor
02-20-2019 03:20 AM
Hi Bob,
I understand that if I use the timing function, I won't have to use the property node.
However I need to understand all the things you explained to me, and when I follow the triangle pointer I don't see the 2 sub properties ... !
See the attached file.
After that I think that all will be good !
Regards,
David