I'm a bit confused as to how the Waveforms manages its buffer. I'm using the Waveforms SDK (via LabVIEW) to both generate a pulse and act as a scope using the Analog Discovery Kit 2. I am generating a 50 ms, 5V pulse with a frequency of 230 kHz. This is connected to a hardware device. I then want to use the scope function to record the output form this device. I can get the scope to read, but I don't really understand why it works the way that it does.

As it stands, the only way that I can consistently get a waveform is as follows (AnalogIn):

AutoTimeout: 0.5

Sample Frequency: 160 kHz

AcquisitionMode: Record

RecordLength: 2 seconds

I also have a 2.5 second wait on my analog out.

If any of these settings change, my waveform will not show up. If perhaps I want a 200ms pulse, I need to change the sample frequency to 40 kHz.

Attached is a screenshot of what the waveform looks like. There are two problems with this. The waveform is pushed far to the right. I want the waveform to take up the entire buffer. Second, if I'm sweeping frequencies, the waveform will show up at slightly different spots between frequencies. My ideal situation is that the ADK2 outputs a pulse, and when the pulse starts it immediately begins to record, filling the buffer after 50 ms. This buffer is emptied into an excel document, and then awaits use again.waveformcapture.thumb.PNG.eb3177bb43dc3a6bc753c68bfe68b3b5.PNG

I've searched and read through the SDK reference manual but I can't seem to get a grasp on how to fix this. I feel like it's a lack of understanding of how the buffer is managed, but any help would be appreciated.


EDIT: Follow-up/related question: How would these settings translate into SDK functions? 



Edited by TurgidWater45
Link to post
Share on other sites

4 answers to this question

Recommended Posts

  • 0

Hi @TurgidWater45

In record mode the trigger position is relative to the left or the capture, first sample.
The configuration for your last screenshot looks like this:
FDwfAnalogInRecordLengthSet(hdwf, 0.1) # 100ms 
FDwfAnalogInTriggerPositionSet(hdwf, -0.01) # -10ms 

After starting it, the Scope will stream data until prefill expires (-position) 10ms. Then it will arm looking for trigger and continues data streaming. After trigger event it will stream for (record_length + position), 90ms.
After the record is done the data needs to be aligned, so that the last returned sample to be the last in your buffer, last + one to be the first.
Having trigger position 0 for record mode the streaming will only start after triggering, so no alignment is needed.

Here you have a Python example for record with trigger at 25%:

Link to post
Share on other sites
  • 0


Thanks for helping. I think I'm still a little confused about the alignment. I feel like this isn't even that complicated, but I just can't grasp it. Below is two examples of results I've gotten from messing with TriggerPosition. I have turned AutoTimeout to 0 and that has seemed to help the reliability of my program.


This is RecordLength = 50ms and Trigger Position = 10ms. +/- trigger position yields the same results


This is RecordLength = 50ms and Trigger Position = 30 ms. +/- once again makes no difference. 


This is RecordLength = 50ms and TriggerPosition = 0. 

I just want this waveform to fill up the entire buffer while being sure that no data is lost


This is RecordLength = 60ms and TriggerPosition = 0. I'm not sure if this helps at all, I'm just trying to provide a lot of data. I'm really struggling with this.

Edited by TurgidWater45
Additional Information
Link to post
Share on other sites
  • 0

Hi @TurgidWater45

Here the trigger position is set to 20%, -1 sec for a 5 seconds record.
The trigger was detected at X1 and the record is continued for 4 more seconds, to X2.

The data needs to be aligned, shifted to last recorded sample, X2 to become the last sample in the record buffer:

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now