Jump to content
  • 0

Changing phase between signals with Waveforms SDK


Alec

Question

Hi all,

I have an application where I need to generate two signals with a phase shift of different values between them for different measurements. For example

For 5 seconds - W1: 0.04V 60Hz @ 0 Degrees , W2: 0.25V 60Hz @ 30 Degrees 

For 5 seconds - W1: 0.04V 60Hz @ 0 Degrees , W2: 0.25V 60Hz @ 60 Degrees 

For 5 seconds - W1: 0.04V 60Hz @ 0 Degrees , W2: 0.25V 60Hz @ 90 Degrees 

This test involved another instrument which is reading the phase of these two signals, and we are trying to confirm it's operation.

The problem is, I am running these outputs from the Waveforms SDK (will attach script below), and I have a feeling that something is not working properly.

When I read the output, In terms of phase, there seems to be a delay when the phase is changed (E.g. from 30 to 60), or occasionally, the phase does not change at all for 1/3 changes.

When I run the same tests using the Waveforms GUI, there are no issues.

I am looking for someone with more knowledge of the SDK to review my commands here, in case there is something obvious that I am missing (delay required between acquisitions (?), not shutting off output correctly (?), need to keep output on for the tests (?), etc.

Additionally, my colleague noticed that when changing phase between two output signals in the Waveforms GUI, there is some inconsistency unless the outputs are disabled before changing the phase setting, before enabling the outputs again.


Any help is appreciated.

digilent_ctrl.py

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

Hi @Alec

See the following example: AnalogOut_Phase.py

...
# 0 = the device will be configured only when calling FDwf###Configure
dwf.FDwfDeviceAutoConfigureSet(hdwf, c_int(0))
# enable two channels
dwf.FDwfAnalogOutNodeEnableSet(hdwf, c_int(0), AnalogOutNodeCarrier, c_int(True))
dwf.FDwfAnalogOutNodeEnableSet(hdwf, c_int(1), AnalogOutNodeCarrier, c_int(True))
# for second channel set master the first channel
dwf.FDwfAnalogOutMasterSet(hdwf, c_int(1), c_int(0));
# slave channel is controlled by the master channel
# configure enabled channels
dwf.FDwfAnalogOutNodeFunctionSet(hdwf, c_int(-1), AnalogOutNodeCarrier, funcSine) # CH1&2
...
for i in range(len(rgFreq)):
    print("Step "+str(i+1)+" "+str(rgFreq[i])+"Hz "+str(rgAmp[i])+"V "+str(rgPhase[i])+"* ")
    dwf.FDwfAnalogOutNodeFrequencySet(hdwf, c_int(-1), AnalogOutNodeCarrier, c_double(rgFreq[i])) # CH1&2
    dwf.FDwfAnalogOutNodeAmplitudeSet(hdwf, c_int(-1), AnalogOutNodeCarrier, c_double(rgAmp[i])) # CH1&2
    dwf.FDwfAnalogOutNodePhaseSet(hdwf, c_int(1), AnalogOutNodeCarrier, c_double(rgPhase[i])) # CH2
    if i==0: 
        dwf.FDwfAnalogOutConfigure(hdwf, c_int(1), c_int(0)) # CH2 configure
        dwf.FDwfAnalogOutConfigure(hdwf, c_int(0), c_int(1)) # CH1 start
    else: 
        dwf.FDwfAnalogOutConfigure(hdwf, c_int(1), c_int(3)) # CH2 apply
        dwf.FDwfAnalogOutConfigure(hdwf, c_int(0), c_int(3)) # CH1 apply
    time.sleep(5)
...

 

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