• 0
jamesbraza

Getting Input Phase Programmatically

Question

Hello Digilent Forums,

I have an Analog Discovery 2 + Impedance Analyzer board, and have been programmatically manipulating the board via the DWF library.

I am now trying to plot Input Phase (∠) programmatically.

The SDK for Python comes with a `dwfconstants.py`, which houses values of `c_int()`, corresponding with various measurement types.  For example, `DwfAnalogImpedanceImpedance` measurement type corresponds to `c_int(0)`.

I do not see a constant for Input Phase inside `dwfconstants.py`.  Is it possible to get Input Phase?

Thank you in advance for your help!

Share this post


Link to post
Share on other sites

7 answers to this question

Recommended Posts

  • 1

Hi @jamesbraza

  • I constantly see the prefix `rg` in your programs.  What is the meaning of `rg` prefix in all array namings?
    This are so called Hungarian notations originating from physics, to help identifying variable kinds like: rg Array, sz String, i Index, c Count
  • Why does the gain term = V_C1 / V_C#?  I would think it's the inverse... gain = output / input = V_C2 / V_C1
    This is how the function returns it. You can convert it using 1.0/gain
  • Does the formula you listed, M = gain2 - 1.0, come from a simplification of M = (V_C1 - V_C2) / (V_C2 - 0)?
    Yes.
  • Also, please see the attached image.  It's of input phase.  Note sometimes the points are flipped about 360°. My final question is, do you know why this might be happening?

The phase should be normalized to +/-PI. The next software version will correct this, but you can correct it in you script/application like this:
if phase2.value > math.pi :
    phase2.value -= 2.0*math.pi
if phase2.value < -math.pi :
    phase2.value += 2.0*math.pi

Thank you for the observation.

 

Share this post


Link to post
Share on other sites
  • 0
Posted (edited)

Hi @attila,

Thank you again for your response.  I have several follow-up questions:

  • I constantly see the prefix `rg` in your programs.  What is the meaning of `rg` prefix in all array namings?
  • Why does the gain term = V_C1 / V_C#?  I would think it's the inverse... gain = output / input = V_C2 / V_C1
  • Does the formula you listed, M = gain2 - 1.0, come from a simplification of M = (V_C1 - V_C2) / (V_C2 - 0)?

Also, please see the attached image.  It's of input phase.  Note sometimes the points are flipped about 360°. My final question is, do you know why this might be happening?

Phase_LogLin_Plot.png

Edited by jamesbraza
Added clarification

Share this post


Link to post
Share on other sites
  • 0
Posted (edited)

@attila okay thank you for answering all of my questions, your answers all makes sense!  Also, I was not previously aware of Hungarian notation.

So I implemented the code you suggested above:

On 7/23/2019 at 1:25 AM, attila said:

You can use the FDwfAnalogImpedanceStatusInput(hdwf, 1, &gain2, &phase2)

The equivalent for the WF IA "input gain" when using IA adapter = gain2 - 1.0

I ran the Impedance Status Input on a load of a 100 kΩ resistor and a 0.1 μF capacitor in series.  I found the formula `gain2 - 1.0` does not match what WaveForms is outputting.

Waveforms output, attached

WaveformsInputGain.thumb.png.aa0f6ecbfbee7debd4a6ea94879a43a6.png

 

 

 

 

 

 

 

 

 

 

 

My output (gain2 - 1.0), attached

gain2Minus1.thumb.png.3b93608515743f6f32231ae9326a208f.png

 

 

 

 

 

 

 

 

 

 

These are slightly off, and I am trying to figure out why.  @attila do you know if WaveForms has some compensation done internally that a raw FDwfAnalogImpedanceStatusInput would not output?

Edited by jamesbraza

Share this post


Link to post
Share on other sites
  • 0

Okay @attila, thank you for providing that script!  That cleared me up.

My mistake was thinking that FDwfAnalogImpedanceStatusInput returns a value with units = dB.  It seems the units were actually = V/V.  This is more desirable functionality.

One suggestion: maybe in future Waveforms versions, specify the units of gain returned by FDwfAnalogImpedanceStatusInput in the SDK documentation.

Again: thank you again for answering all of these questions!

Share this post


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