LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Custom waveform analog output

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.

moyashi1_0-1580428355018.png

The error message that comes up is as follows:

 

moyashi1_3-1580428452327.png

Any help will be appreciated, thank you.

0 Kudos
Message 1 of 9
(2,653 Views)

What is your DAQ device?

 

I don't see the code where you write the generated data to a DAQmx Write.

0 Kudos
Message 2 of 9
(2,642 Views)

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?

0 Kudos
Message 3 of 9
(2,630 Views)

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.

0 Kudos
Message 4 of 9
(2,624 Views)

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.

0 Kudos
Message 5 of 9
(2,607 Views)

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...

0 Kudos
Message 6 of 9
(2,598 Views)

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:

AO_Waveform.png

0 Kudos
Message 7 of 9
(2,588 Views)

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

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 8 of 9
(2,571 Views)

Thanks Kevin, I'll keep that in mind.

0 Kudos
Message 9 of 9
(2,298 Views)