Jump to content
  • 0

Set the Trigger on the Wavegen Channel 2 to "Scope" via the SDK in Python


Hansi

Question

I use an Analog Discovery 2 device. 

With it, I create two pulses on Channel 1 and Channel 2 respectively. With the WaveForms GUI, I am able to set a trigger for channel 2 and include a wait and run time. Next I would like to reproduce this with the SDK in Python for easier integration into my existing measurement procedure. This mostly works but two things are not clear to me. 

1. Do I need to set the two channels to "Independent" (as opposed to "No synchronization" or "Synchronized")? Or is this done automatically as soon as I configure a wait time or run time of the signal ? For instance, a small part of my code includes:

dwf.FDwfAnalogOutWaitSet(hdwf, c_int(1), c_double(67e-6)) # wait length
dwf.FDwfAnalogOutRunSet(hdwf, c_int(1), c_double(2e-6)) # pulse length

Is this enough to have them be "independent"?

2. How do I set the trigger to "Scope"? In the reference manual, I have found what I believe to be the correct command (FDwfAnalogOutTriggerSourceSet), but I am confused as to which of the arguments is the correct one to achieve this (trigsrcDetectorAnalogIn, trigsrcAnalogIn, etc).

 

Any help would be greatly appreciated :)

set_trigger_to_scope.PNG

Edited by Hansi
Not all words were written correctly
Link to comment
Share on other sites

6 answers to this question

Recommended Posts

  • 0

Hi @Hansi

The app's "no synchronization" just hides these options to simplify the interface.
Setting wait/run is sufficient in the custom app/script and for synchronized mode use FDwfAnalogOutConfigure(hdwf, -1, 1) or FDwfAnalogOutMasterGet

FDwfAnalogOutTriggerSourceSet(trigsrcAnalogIn) trigger on oscilloscope T0
The trigsrcDetectorAnalogIn looks for trigger condition on the analog input.

 

image.png

 

image.png

Link to comment
Share on other sites

  • 0

Thank you attila for the help! I think I've figured out the correct settings with regards to the trigger now. 

But I have run into another problem. Maybe for a bit more context, what I'm trying to accomplish is the following:

1. Generate a repeating pulse on channel 1 (every 100ms, and stays on for 1ms). 

2. Within this first pulse, have a second one that is delayed by 67us and is on for 2us. 

To achieve this, I use the settings provided in the screenshot:

waveforms_settings.thumb.PNG.46d678b5a1877215a795616f57c2dd76.PNG

The result is then the following:

waveforms_zoomed_in.thumb.PNG.7fc478cf112a0a1bdcbb0365eef88985.PNG

 

However, when I try to recreate this with the SDK, the FDwfAnalogOutRunSet somehow seems to cause problems. It remains in the "high" state:python_plot_with_run_specified.png.60aaa8eddb382df2b58d647ba8d241c3.png

Not specifying (or commenting out the respective line) this FDwfAnalogOutRunSet looks like this:

python_plot_without_run_specified.png.d22edf4d4f25ec8e82d3f461a981c638.png

 

Why am I not able to specify the run lenth of the pulse ?

If it helps, here is my Python code, maybe the error is somewhere else entirely...

double_pulse_and_acquisition_SDK.py

Link to comment
Share on other sites

  • 0

Thank you very much @attila for taking the time to correct my script ! 

The images you show are exactly what I'm trying to accomplish :)

Unfortunately, in the Python script you provided, I get stuck at the while loop just after the "Starting oscilloscope" print statement:

while True:
        # fetch status and data from device
        if dwf.FDwfAnalogInStatus(hdwf, 1, byref(sts)) != 1 :
            szerr = create_string_buffer(512)
            dwf.FDwfGetLastErrorMsg(szerr)
            print(szerr.value)
            quit()  
        if sts.value == DwfStateDone.value :
            break

 

Do you know what might be the issue ?

Link to comment
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
×
×
  • Create New...