Jump to content

Ostin Flores

Members
  • Posts

    11
  • Joined

  • Last visited

Ostin Flores's Achievements

Member

Member (2/4)

2

Reputation

  1. This is for a Linear RMS Averaging like the one perfomed in the Waveforms application. I collected various samples and then performed a Root Mean Square of the incomming samples and I do not get the results that you get. Root Mean Square formula Xrms= sqrt[(X1^2 + X2^2 + X3^2 ... + XN^2)/N] N is the number of averages XN is the FFT Data
  2. Thanks @attila your answer was very helpful, one more thing that is bothering me is if there are any examples on how to do an RMS Averaging.
  3. Hi all, I am writting an script to determine the Spectrum Analysis of a signal with the Analog Dicovery Board 2. When using the AnalogIn_spectrum.py I obtain the FFT data and then plot it, it seems like the data comes in as dBV/HZ but I want to convert this value to V/Root(HZ). Is there an easy way to do this? The following Lines in the AnalogIn_spectrum.py example get the FFT data in Volts (rgdBins1) and convert it into dBV/HZ for i in range(nBins): rgdBins1[i] = 20.0*math.log10(rgdBins1[i]/sqrt2) # to dBV rgdBins2[i] = 20.0*math.log10(rgdBins2[i]/sqrt2) # to dBV So what should I do to rgdBins1[i] to convert the data into V/Root(Hz)? My second concern has to do with a small DC value that is recorded at 0Hz (See picture). What does it represent? I do not have an input voltage to the signal displayed. Your help is highly appreciated. Software Version 3.20.33
  4. Hi @attila, I set up the scrip on my work bench and it seems to be working ok now. Maybe there was an intermitent connection. I had my input measurement DC Coupled last time as well
  5. Hi, I want to generate a PWM signal that changes frequency, Amplitude and Duty Cycle. I am using the "DigitalOut_Duty.py" Provided inside the SDK folder which seems to work fine until I increase the frequency then my signal shrinks as shown in the attachment. There is a comment in the code saying "# for low frequencies use divider as pre-scaler to satisfy counter limitation of 32k". I tried messing with this number and I still get bad results. Can someone please guide me in the right direction?
  6. Hi @attila, Running the python scrip provided in the samples and C# console application made by me (AnalogNetwork_Analyzer) both give me errors when returning some values. Specifically those in: ........ dwf.FDwfAnalogImpedanceStatusInput(hdwf, 0, out gain1, out zero); // relative to FDwfAnalogImpedanceAmplitudeSet Amplitude/C1 dwf.FDwfAnalogImpedanceStatusInput(hdwf, 1, out gain2, out phase2); // relative to Channel 1, C1/C# rgGaC1[i] = 1.0 / gain1; rgGaC2[i] = 1.0 / gain2; rgPhC2[i] = -phase2 * 180 / Math.PI; gain1; returns as infinity, gain2 returns as NAN phase2 returns as 0 This is a new computer that I am trying with Windows 11. I know that those returned values are wrong as there is sinosoidal at the input of channel 1. If I do the sweep in the Waveforms application I get the results that I want. Do you know if there is something that I am not considering? Edit: I am using 3.2.1 is this what you are reffering to? Code: using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Runtime.Remoting.Channels; using System.Security.Policy; using System.Text; //using WaveFormsSDK; namespace AnalogNetwork_Analyzer { class AnalogNetwork_Analyzer { public static readonly System.IO.TextWriter cout = System.Console.Out; public static void Wait(double sec) { System.Threading.Thread.Sleep((int)(sec * 1000)); } static void Main(string[] args) { try { int steps = 500; double zero; double start = 10e3; double stop = 1e6; double reference = 1e4; double amplitude = 1; double hz; byte none = 0; byte sts; double[] rgHz = new double[steps]; double[] rgGaC1 = new double[steps]; double[] rgGaC2 = new double[steps]; double[] rgPhC2 = new double[steps]; double gain1, gain2, phase2; int phdwf = 0; string version, szerr; dwf.FDwfGetVersion(out version); cout.WriteLine("Version: " + version); // open automatically the first available device var hdwf = dwf.FDwfDeviceOpen(-1, out phdwf); dwf.FDwfGetLastErrorMsg(out szerr); cout.WriteLine("Device Status: " + phdwf); //this option will enable dynamic adjustment of analog out settings like: frequency, amplitude... dwf.FDwfDeviceAutoConfigureSet(hdwf, 3); dwf.FDwfAnalogImpedanceReset(hdwf); dwf.FDwfAnalogImpedanceModeSet(hdwf, 0); // 0 = W1-C1-DUT-C2-R-GND, 1 = W1-C1-R-C2-DUT-GND, 8 = AD IA adapter dwf.FDwfAnalogImpedanceReferenceSet(hdwf, reference); // reference resistor value in Ohms dwf.FDwfAnalogImpedanceFrequencySet(hdwf, start); // frequency in Hertz dwf.FDwfAnalogImpedanceAmplitudeSet(hdwf, amplitude); // 1V amplitude = 2V peak2peak signal dwf.FDwfAnalogImpedanceConfigure(hdwf, 1); // start // it will run until stopped or device closed Wait(2); foreach (int i in Enumerable.Range(0, steps)) { hz = stop * Math.Pow(10.0, 1.0 * (1.0 * i / (steps - 1) - 1) * Math.Log10(stop / start)); rgHz[i] = hz; dwf.FDwfAnalogImpedanceFrequencySet(hdwf, hz); // frequency in Hertz Wait(0.01); dwf.FDwfAnalogImpedanceStatus(hdwf, out none); // ignore last capture since we changed the frequency while (true) { if (dwf.FDwfAnalogImpedanceStatus(hdwf, out sts) == 0) { dwf.FDwfGetLastErrorMsg(out szerr); cout.WriteLine("Error: " + szerr); // Console app System.Environment.Exit(1); // WinForms app //System.Windows.Forms.Application.Exit(); } if (sts == 2) { break; } } dwf.FDwfAnalogImpedanceStatusInput(hdwf, 0, out gain1, out zero); // relative to FDwfAnalogImpedanceAmplitudeSet Amplitude/C1 dwf.FDwfAnalogImpedanceStatusInput(hdwf, 1, out gain2, out phase2); // relative to Channel 1, C1/C# rgGaC1[i] = 1.0 / gain1; rgGaC2[i] = 1.0 / gain2; rgPhC2[i] = -phase2 * 180 / Math.PI; } dwf.FDwfAnalogImpedanceConfigure(hdwf, 0); dwf.FDwfDeviceClose(hdwf); // stop Array.ForEach(rgPhC2, Console.WriteLine); Console.ReadKey(); } catch (Exception ex) { cout.WriteLine("Error: " + ex.Message); } } } }
  7. Hi All, I did a simple console application based on some projects that I found on GibHub "https://github.com/Andrei-Errapart/WaveFormsSDK" My goal is to make a GUI that displays a resonance frequency when sweeping over a range of frequencies. I have not tried to plot the returned amplitude values as I am planning to do it in the GUI. You are welcome to take my project and put it out there as an example (You can also make changes or comments as you please). The application sweeps a sinusoidal 1Vp (2Vpp) between 10kHz-1MHz, it works nicely. This is Done in C#, I translated the code from "AnalogNetwork_Analyzer.py" found in "C:\Program Files (x86)\Digilent\WaveFormsSDK\samples\py". Again, my code does not include the plot part. AnalogNetwork_Analyzer.zip
  8. Hi @attila, I found a class containing calls to the functions that can be used in the Analog Discovery 2 under C:\Program Files (x86)\Digilent\WaveFormsSDK\samples\cs. But I did not see a full example application such as the ones in the Python library. I guess my questions is if there are any examples such as the ones in the python scripts.
  9. Hi, So far I had fun playing with the Python Scripts specifically with the Network Analyzer, but I want to be able to run the same with a C# application. I did not see examples in the samples under WverFormsSDK. Is there any resources on how to run the Network Analyzer in C#? This is in the Analog Discovery 2.
  10. Great!!! This worked beautifully!! Thanks for the help :)
  11. Hi, I am working on a simple application to send and read a DC voltage from The Digilent Discovery 2. I am doing this through a python scrip and my FDwfAnalogOutNodeOffsetSet command works fine but when I feed this output voltage into CH1 Scope I get a small voltage reading (~1mV) regardless of what I send. Below is the code that I am using... #Code to open devise.... HeaterVoltage = c_double() dwf.FDwfAnalogOutNodeOffsetSet(hdwf, c_int(0), AnalogOutNodeCarrier, c_double(0.3)) #Sending 0.3V out time.sleep(2) dwf.FDwfAnalogInChannelOffsetGet(hdwf, c_int(0), byref(HeaterVoltage)) #Reading the Voltage back print("Voltage readback: " + str(HeaterVoltage.value)) I am using the Discovery BNC CH1 is my output 0 ohm termination, input is CH1 and I tried both AC and DC coupling. Can you please tell me if I am doing something wrong?
×
×
  • Create New...