01-30-2020 05:54 PM
I am attempting to generate a custom waveform analog output, in place of the original square pulse (digital) output.
First, the custom waveform: a piecewise function:
f(x) = 1 when 0< x ≤ 2.5
f(x) = -x^2+9 when 2.5< x ≤ 3
Second, I paste here what I have so far. This is embedded in a larger program that outputs specific waveform during set trials/times, but this should not matter so please ignore. The piecewise function above is written in the small grey box (denoted (f(t)) in the left hand corner.
The error message that comes up is as follows:
Any help will be appreciated, thank you.
01-30-2020 06:08 PM
What is your DAQ device?
I don't see the code where you write the generated data to a DAQmx Write.
01-30-2020 06:15 PM - edited 01-30-2020 06:20 PM
I am using a USB-6356.
Ok I'll look into making sure we have DAQmx Write somewhere.
Edit - we do not. Where should this go, at the end before it clears?
01-30-2020 06:26 PM - edited 01-30-2020 06:27 PM
Ok thank you, that helped clear the first error.
Now it states: multiple samples cannot be written using a single sample write.
Ensure the waveform contains only a single sample.
I think this problem is related to the piecewise function. Should I write it another way?
To reiterate, it is written as:
f(x) = 1, 0< x ≤ 2.5
f(x) = -x^2+9, 2.5< x ≤ 3
For the record, I am using "Analog Wfm 1Chan 1Samp" for my DAQmx Write function.
01-30-2020 06:48 PM
When you wire a waveform, you can't use 1 channel 1 sample. You need 1 channel >> multiple samples >>waveform from the selector below the DAQmx Write. And of course you need to write to the buffer BEFORE you start the task.
I don't see our the equations you wrote now are different than the first message.
Attach your actual VI so we can see what you've done, and we can see how you actually coded it.
01-30-2020 07:08 PM
It's ok, I found a link that is helpful for what I need. Thank you for your help.
In case anyone else might benefit, here it is: https://forums.ni.com/t5/LabVIEW/Generate-signals-based-on-data-file/td-p/3651612?profile.language=e...
01-30-2020 07:21 PM
If I remember right, last time I tried doing an analog waveform output that I wanted to repeat over and over, I had to set an extra property in the DAQmx task. Something like this:
01-30-2020 08:20 PM
Just a little caveat about onboard memory:
The tip to regenerate solely from onboard memory can be necessary for particularly high-rate output. And it's probably a good idea any time there's enough onboard memory to store your whole waveform.
But in a lot of typical cases, it can be considered optional as the DAQmx driver is pretty good at keeping the data moving from the task buffer in PC memory down to the device. And when your waveform is too big to fit in onboard memory, you *can't* set the property. (Or at least, if you try to set it, it won't actually work. Not sure if it'll produce an error.)
-Kevin P
02-02-2020 07:43 PM
Thanks Kevin, I'll keep that in mind.