Search the Community

Showing results for tags 'script'.

More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • News
    • New Users Introduction
    • Announcements
  • Digilent Technical Forums
    • FPGA
    • Digilent Microcontroller Boards
    • Non-Digilent Microcontrollers
    • Add-on Boards
    • Scopes & Instruments
    • LabVIEW
    • FRC
    • Other
  • General Discussion
    • Project Vault
    • Learn
    • Suggestions & Feedback
    • Buy, Sell, Trade
    • Sales Questions
    • Off Topic
    • Educators
    • Technical Based Off-Topic Discussions

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start





Website URL







Found 23 results

  1. Hello, In my waveforms script I am trying to import and run a saved custom 7-bit bus pattern in csv format that I generated from the custom pattern generator. I am able to read the data from the csv, but when I do: Patterns1.Channels.Bus._custom = data all of the data is just written into the first channel of the bus. Is there another format or syntax that should be used when specifying patterns for custom busses?
  2. Hi, I combined a few python scripts from the SDK (AnalogIn_Acquisition, AnalogOut_Play and AnalogOut_Sine) to write a script which is intended to run during the night and save the scope's data into a WAV file. All looks somewhat okay, but there are a few things that don't look perfect. For this test, I connected CH1 and W1 and started both the Scope and Signal generator in the script. I'm intending to generate a 80 Hz sine wave and record it with the scope running at 8 kHz. I attach the whole script, and here are the important parts: # set up signal generation channel = c_int(0) # use W1 dwf.FDwfAnalogOutNodeEnableSet(hdwf, channel, AnalogOutNodeCarrier, c_bool(True)) dwf.FDwfAnalogOutNodeFunctionSet(hdwf, channel, AnalogOutNodeCarrier, funcSine) # ! this looks like a square wave dwf.FDwfAnalogOutNodeFrequencySet(hdwf, channel, AnalogOutNodeCarrier, c_double(signalgenhz)) dwf.FDwfAnalogOutNodeAmplitudeSet(hdwf, channel, AnalogOutNodeCarrier, c_double(1.41)) # ! this doesn't really do anything dwf.FDwfAnalogOutNodeOffsetSet(hdwf, channel, AnalogOutNodeCarrier, c_double(1.41)) I played around with the parameters and after some investigation with Audacity it seems like the funcSine parameter generates a square wave and the amplitude is always 1.0 no matter what I set. The other problem I have is with the FDwfAnalogInStatusData function, it looks like it doesn't just get the raw data from the scope, is contains something else. So in order to get the scope's CH1 data, I need to have a 2-channel WAV file, and discard its first channel. The second is the data I'm looking for. waveWrite =, "wb"); waveWrite.setnchannels(2); # 2 channels for the testing (1 channel would be enough if FDwfAnalogInStatusData returned only 1 channel's data waveWrite.setsampwidth(4); # 32 bit / sample waveWrite.setframerate(samplerate); waveWrite.setcomptype("NONE","No compression"); dwf.FDwfAnalogInStatusData(hdwf, 0, rgdSamples, buffersize) # get channel 1 data CH1 - ! it looks like 2 channels get read here and only the second is the data of CH1 waveWrite.writeframes(rgdSamples); I would expect that if I only need the CH1 of the Scope, I could save it into a mono WAV file.
  3. Hi, I have been using the Waveforms in Mac to control digital discovery. And I am now familiar with using the scripts in Waveforms. I want to use Tool.start option to run python from Waveforms. Below is the command I am using based on the format. But I haven't been successful with running python. Tool.start("/Users/venkatap/anaconda2/bin/python", "/Users/venkatap/Waveforms_v1/py_files/","/tmp/") As all the examples and discussions about this topic are related to windows machine, I wanted to know how to use the Tool.start option in Mac. Kindly assist me with this. Thank you, Praveen
  4. Szia @attila! I'm using WaveForms 3.8.18 on Windows 10. I would like to chart the difference between the currently measured AC RMS compared to the average of the past x values. Is it possible to do with a script? Theoretically, if I could access the past values of the C1ACRMS from script it would be possible to calculate the average and the difference from that average. Or as another approach, can I access the current value of the "Average" column in the script? Let's say I name this script-based signal C1ACRMSDelta. I created another one for C2, and name it C2ACRMSDelta. Will I be able to create a third one using C1ACRMSDelta, C2ACRMSDelta are they accessible from script somehow? The other thing is that the "Maximum" column displays the minimum value, not the maximum. I think that's a small bug
  5. I want to measure Freq vs THD plot . Is it need something script?
  6. Hi, since forum search did not yield much on subject and there seem to be no built in functions did write little something and decided to share below: Script is quite automatic. It will account for sampling rate, memory depth, oversampling changes in real time - just run it to auto create and configure Ref* channels that will display functions. Possible need fiddle Range a little for integration. If wish reset to auto values just disable/delete Ref* and it will instantly re-enable in default configuration. Attached script is provided in demo mode, does integral(derivative(x)) functional check and integral(x). Unneeded doMath*() stuff can be commented out in main() function. If wish for derivative to start from 0 (currently it will remember DC offset for later signal reconstruction) set bDerivativeRetainsDCOffset = false; Code that accounts for Time changes is quite generic so script can be easily expanded with other doMath*() routines. Code tested on: WaveForms version 3.8.10 beta 64-bit Qt5.6.3 Windows 7 // Derivation/Integration for WaveForms, v0.1 // By lab!fyi <> // // This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. // Uncheck or delete Ref[1|2] in Run mode to reset units to automatic values // Config bDerivativeRetainsDCOffset = true; oChannel = Scope1.Channel1; // Used for Ref config detection // Derivative >>> function _derivative(aIn, aOut) { aOut[0] = 0; if (bDerivativeRetainsDCOffset) { aOut[0] = aIn[0] * iSTRate; } for (var i = 1; i < aIn.length; i++) { aOut[i] = (aIn[i] - aIn[i - 1]) * iSTRate; } } function derivative(oIn, oOut) { var aO =; _derivative(, aO); = aO; } // <<< Derivative // Integral >>> function _integral(aIn, aOut) { var f = 0; for (var i = 0; i < aIn.length; i++) { f += aIn[i] / iSTRate; aOut[i] = f; } } function integral(oIn, oOut) { var aO =; _integral(, aO); = aO; } // <<< Integral // Config >>> function getSTRate() { return Scope1.Time.Rate.value * ( / Scope1.Time.Samples.value); } function config(oIn, oOut, fScale) { if (!oOut.enable || !oOut.checked || bInit) { oOut.setEnable(true); oOut.checked = true; oOut.Clone(oIn); oOut.Range.value *= fScale; print ( "(Re)Enabled/Checked & Cloned " + "'" + + "'" + " -> " + "'" + + "'" ); } if ( ( != || (iSTRate != getSTRate()) ) { var iRange = oOut.Range.value; var iOffset = oOut.Offset.value; oOut.Clone(oIn); oOut.Range.value = iRange; oOut.Offset.value = iOffset; } } // <<< Config // ------------------------------------------------ function doMath1(oIn, oOut) { config(oIn, oOut, iSTRate); derivative(oIn, oOut); } function doMath2(oIn, oOut) { config(oIn, oOut, (1 / iSTRate)); integral(oIn, oOut); } function main() { if (!('Scope1' in this)) throw("Please open a Scope instrument");; iSTRate = getSTRate(); while (Scope1.State.value == 6) { while (Scope1.wait()) { // integral(derivative(x)) doMath1(Scope1.Channel1, Scope1.Ref1); doMath2(Scope1.Ref1, Scope1.Ref2); // integral(x) doMath2(Scope1.Channel1, Scope1.Ref3); bInit = false; iSTRate = getSTRate(); } } } // ------------------------------------------------ bInit = true; main(); Scope1.stop(); derivation_integration.dwf3script
  7. Hi, I'm working on a WaveForms script which would be able to generate chart with the frequency profile of a liquid. For this, I need to use a Wavegen and a Scope: first I need to set the generator to a certain frequency and then I'd like to check the power of that signal on the scope. Between the probes of the generator and the scope there will be the liquid I would like to test. I created a basic script to step from 1 Hz to 150 Hz, check that signal with the scope, repeat this loop 5 times, and calculate the min, max and average values at each frequency. Although the script works, I have a few questions: * I couldn't find any documentation about the Scope.Channelx.fftmagnitude and fftfrequency arrays. Where should I look for them? Are there any other properties related to the FFT configuration? * Is there a way to set the number of BINs and samples of the scope's FFT? * Can I somehow use the Goertzel algorithm instead of FFT? (The Görtzel algorithm is designed to tell us the power of a signal at one predefined frequency. I would need this to get the power for the exact Hz value I define, and not the closest one I have from the FFT like I do it now. * Is there a way to change the color/style of the charts? Here is the script itself, but bear in mind that it is just the very first version const hzmax = 150; // the maximum frequency to measure const csamples = 5; // the number of samples to measure for each frequency const cdatapoints = 150; // chart X-axis resolution (currently: 1 datapoint / 1 Hz) var datapoints = new Array(4); // datapoint array datapoints[0] = new Array(cdatapoints); // max datapoints[1] = new Array(cdatapoints); // avg datapoints[2] = new Array(cdatapoints); // min datapoints[3] = new Array(cdatapoints * csamples); // raw data // clear the raw data array for(var j = 0; j < cdatapoints * csamples; j++) { datapoints[3][j] = 0; } // generate the freqeuncies to measure var frequencies = new Array(cdatapoints); for(var j = 0; j < cdatapoints; j++) { frequencies[j] = j+1; } { // configure plot plot1.X.Units.text = "Hz"; plot1.X.Offset.value = -hzmax/2 plot1.X.Range.value = hzmax; plot1.Y1.AutoScale.checked = false; plot1.Y2.AutoScale.checked = false; plot1.Y3.AutoScale.checked = false; plot1.Y4.AutoScale.checked = false; const vmax = 1.00; const vmin = 0.98; var offset = -(vmin + (vmax - vmin)/2); var range = (vmax - vmin); plot1.Y1.Offset.value = offset; plot1.Y2.Offset.value = offset; plot1.Y3.Offset.value = offset; plot1.Y4.Offset.value = offset; plot1.Y1.Range.value = range; plot1.Y2.Range.value = range; plot1.Y3.Range.value = range; plot1.Y4.Range.value = range; } { // configure wavegen Wavegen1.Channel1.Mode.text = "Simple"; Wavegen1.Channel1.Simple.Type.text = "Sine"; } { // configure scope Scope1.BufferSize.value = 1; Scope1.Buffer.value = 1; Scope1.Time.Mode.text = "Shift"; Scope1.Channel1.checked = true; Scope1.Channel2.checked = false; }; for (var n=0; n<csamples; n++) { Scope1.Time.Samples.value = 1024; for (var i=0; i<hzmax; i++) { // change the frequency to the next one var frequency = frequencies[i]; Wavegen1.Channel1.Simple.Frequency.text = frequency; Scope1.Time.Rate.value = frequency * 256; print("Frequency: ",frequency," Hz | Running @ ",Scope1.Time.Rate.value," Hz | ", Scope1.Time.Samples.value," samples"); // take a single sample Scope1.single(); Scope1.wait(); // check out the FFT values var rgmag = Scope1.Channel1.fftmagnitude; var rghz = Scope1.Channel1.fftfrequency; var c = rgmag.length; var minHzDistance = frequency; // check all the FFT values, and get the one closest to our inspected frequency for(var j = 0; j < c; j++) { var hz = rghz[j] var hzDistance = frequency - hz; if (hzDistance < 0) { hzDistance = -hzDistance; } if (hzDistance <= minHzDistance) { minHzDistance = hzDistance; datapoints[3][i*csamples + n] = rgmag[j]; } } // calculate the min, max, avg values var rgmin = 1000.0; var rgavg = 0.0; var rgmax = 0.0; var validsamples = 0; for(var j = 0; j < csamples; j++) { currentsample = datapoints[3][i*csamples + j]; if (currentsample != 0) { if (currentsample < rgmin) { rgmin = currentsample; } if (currentsample > rgmax) { rgmax = currentsample; } rgavg += currentsample; validsamples++; } } rgavg /= validsamples; print("Min:",rgmin," V | Avg:",rgavg," V | Max:",rgmax," V | error: +/-",minHzDistance," Hz"); print(); // save the calculated data into their arrays datapoints[0][i] = rgmax; datapoints[1][i] = rgavg; datapoints[2][i] = rgmin; // check if the error if too high if (minHzDistance > 0.5) { Scope1.Time.Samples.value *= 2; i--; } // plot the most recent values on the chart = datapoints[0]; // max = datapoints[1]; // avg = datapoints[2]; // min } }
  8. I'm trying to write a script to custom define signals on the Patterns tool by following the code in the reference manual. However, these are not working: = "Testing" <- Doesn't change the name of the signal, but once I click on the edit button the pop window shows it as "Testing". Once I run the program a second time it get an error for " = "Testing"" and it's not resolved until I change it to " = "Testing"" Patterns1.Channels.DIO1.DIO.value <- Returns: " Result of expression 'Patterns1.Channels.DIO1.DIO' [undefined] is not an object." Additionally, the reference manual doesn't show how to automatically set up the signals from the start using the script. For example, how to select the output as PP or Type as Custom. Do I have to set this up manually every time? Thank you in advance!
  9. Hi, I recently wrote a program that runs on the AD2 to close the loop on a system I am controlling. My problem now is that I will have a person unfamiliar with coding using this. I was wondering if there were options for creating a simple GUI to control inputs into my script. Like polling from a slidebar the frequency of a sine wave, I use in the script or test windows. I am particularly looking at the StaticIO but it seems to be limited to only the digital I/O pins. If it is not available thru Waveforms Beta will the SDK be able to do something like this? Are there any previous posts (i could not find any) or examples you might have on this? Thanks, Ryne
  10. Hello, So I am trying to write a script that will be taking advantage of both output and both inputs to the AD2 as well as take select information and send it out to two (for now) serial lines. I have written a script to control everything I need minus the actual setup of the UART settings, sending the data over the Tx line and receiving over the Rx line. Are there any examples of how to send the data over script as opposed to using the built-in GUI of Waveforms? Thanks, Ryne
  11. Hello, I have an Analog Discovery (legacy) and the latest Waveforms app. I am trying to write a script that makes the protocol module write to a 24C16 eeprom, read it back, and print to the screen or window. I can access th I2C (can see on my scope), but I can't print anything. The print() function does nothing unless in debug mode, but then the app seems to hang. I tried Custom mode and Sensor mode. And I tried the ADXL345 example, with a known good breakout board, and it always returns the same thing, doesn't change with orientation of the chip (but my main concern is the eeproms) Why is the output window at the bottom of the script area only one line long. The only thing that shows up there is the results of return statements. How can I see the I2C and run the script at the same time ? The logic analyzer only shows the first two I2C bytes, so I'm using an external scope. What does the manual mean when it says the the I2C can only send when in debug ? Isn't that a show-stopper ? Am I missing some key piece of documentation ? The manual does not say much about how all of this stuff works. - Thanks
  12. I am new user of Waveforms 2015 and the Digital Discovery. I want to generate SPI signal and DIOs, to read from multiplexed-CH ADC. According to "Help" on WaveForms, DIO can be set using "DIO." in script for Protocol-SPI. (Help -> Protocol -> 2. SPI -> about Custom mode -> " DIO.: Lets you set(the ones are not declared as SPI signal) and red the digital pins." ) but I can't find its description. So, could I have the example how to use "DIO." in script for Protocol-SPI ? * I'm using WaveForms Ver:3.7.5 32-bit Qt5.6.3 Windows7. Thanks,
  13. Hi everyone, I need to write a script to control the UART Protocol so that I can simulate a serial conversation. So far, I've got just this code: var MyString = "@T00."; function Serial_Send(){ print("Automated Serial Writer"); for(;;) { // Loop at 0.1 sec rate wait(0.1); Protocol.UART.Send(MyString,false); } } if(!('Protocol' in this)) { throw("Please open Protocol instrument"); } Serial_Send(); The configuration of my serial is attached Of course, the endless loop didn't allow me to stop the Script or even abort it. But, it was sending data correctly. To stop the script I had to kill waveforms IDE (v3.7.9). How can I improve it so that I can stop the program anytime I want? Will I have to set a trigger for that using a StaticIO button? Thanks, João Paulo
  14. Hello, I have found this topic with script for counting edges of digital signals and I wonder if it's possible to modify it somehow (or use completely different approach) to read quadrature encoder signals with Analog Discovery? Most important thing, I think, is that I have to compare signals state at current event (i.e. I have "1" on signal A and need to know what is the state of B signal in that particular moment) and be able to compare it with previous state (event) to decide if I should increment or decrement my counter. And it should be triggered with both edges but I assume that trigger options on DIO line decides when events are generated. Is it possible to capture and count edges without sample count limit? I mean something like hardware triggering on digital inputs instead of starting on first trigger and sampling defined number of samples with defined frequency (Stream mode). At the moment it looks more like signals recording and post-processing (offline) and I wonder if it is possible online to execute encoder script live on each trigger? It's not a must but would be nice And one more thing - I have downgraded my WaveForms to version from mentioned topic because in newer version there is no Stream mode. Was it renamed or replaced by something better?
  15. Dear developer, I am using the analog discovery of older version( I bought it long back for academic purposes. Now, my issue I am facing is I want to write a piece of code just to store the data while my analog discovery is aquring the signal. Is there any program or any code available with you in your documentation. If it is not then can you help in writing the code? Thanking You
  16. Hi folks, I'm currently hacking a 433Mhz temperature probe, and attempting to intercept the reading using a standard 433Mhz receiver, such as the Sparkfun RF Link Receiver. Using WaveForms (desktop) I can record the Logic Analyzer output, and can see the single fine. I'm currently in the process of parsing the bit stream. The signal is repeated every 59 seconds. However I need more samples, and the manual translation of the square wave to 0/1's is tedious and time consuming (and error prone). I'd like to create a script that will read the 'repeated' (not recorded, realtime) Logic1 data, look for the periodic transmission bursts, convert the encoded waves to a binary character stream (ex: "0101001010") and print it to the screen (or log to file). Is this approach possible, in the way I'm thinking of it? Or is there an easier/better way to approach it? Also, I haven't been able to find many Script samples around the Logic# object. I understand it is similar to the Scope# (for example), but still a closer sample wound be great. Any tips/suggestions? Thanks -John
  17. I'm using WaveForms2015 version 3.6.8 In the help files it specifies .Run.value under patterns yet it appears to be undefined: .Patterns# .States .Trigger.text .Wait.value .Run.value .Repeat.value .RepeatTrigger.checked my script: var AAtemp=Patterns1.Run.value; and the error message I receive: Error in line: 1 TypeError: Result of expression 'Patterns1.Run' [undefined] is not an object. I would like to set the run length of the pattern via script. How can I go about this?
  18. Hi, I have a SPI slave design with 4-mode and can be auto change by custom script, after updating to 3.6.8, the POL & PHA seems be locked on the upper settings, only the POL & PHA value on the upper settings are valid, even I un-check the "Settings". How can I solve it? thanks.
  19. Hi, I'm trying to use the Analog Discovery 2 to control a stepper motor driver board. All I need to do is send an output (5V) signal using a DIO. I find the Waveforms 2015 manual to be lacking in terms of documentation for this - it does not explain how to give an output signal. How do I do this? Thanks! For instance, the reference manual has this sample code: function doStaticIO(){ print("Running StaticIO script"); StaticIO.Channel0.Mode.text = "IOs"; for(var c = 0; c < 8; c++) { StaticIO.Channel0.DIO[c].Mode.text = "Switch"; } But it is never explained what a Channel is either. What is a Channel and how is it different from DIO1, DIO2, etc.? Thank you so much!
  20. Hello, I want to find a maximum value during a period with a script on the scope. I have done that but the result is wrong: Scope1.single() Scope1.wait() Scope1.Time.Base.value = (1/freq) var data = data.forEach(function(sample){ Vin_Max = Math.max(sample); }) print("Vin_Max: ",Vin_Max,"V") Do you have an idea? Thank in advance.
  21. Hi, I am using an analog discovery to record relay trips. The goal is to record voltage a set time before the trigger and a set time after the trigger. i am writing the average and time to an array and saving the array to a csv file once the after trigger is complete. currently i am using the default script that comes with the program. it works and i get the information but the time stamp using Date() gives hh/mm/ss and i need smaller units of time. My question is: How can i get an accurate time stamp using the script? I need to maximize the number or samples i can take so i do not want a complicated solution i have already run into problems where the script (or usb) can not keep up with the sample rate of the analog discovery. any help would be awesome thanks!
  22. We got the following question: Hi,I'm using your software WaveForms 2015 coupled with your Electronics explorer board to generate 2 synchronised wave form. Now I need to automate my test in which I have a sine1 as reference and a sine2 used as signal. In my automated test I want to change the phase of my sine2 from 0 to 360 and make measurements for each phase shift. My goal would be to have an input and each time my input has a raising edge my sine2 will be shifted by 1 degree. Is it possible to script with this tool under Linux or Windows? Or are there a way to do this with the electronics explorer board?Thank you for your help.
  23. Hi, I am trying to run the python script "", but cannot seem to load the dwf.dll. When I attempt to run the script in anaconda 2 or Idle (python 2.7.8), I get the following error: runfile('C:/Users/John/.spyder2/py/', wdir='C:/Users/John/.spyder2/py') Traceback (most recent call last): File "<ipython-input-8-4aa4827489b3>", line 1, in <module> runfile('C:/Users/John/.spyder2/py/', wdir='C:/Users/John/.spyder2/py') File "C:\Users\John\Anaconda2\lib\site-packages\spyderlib\widgets\externalshell\", line 685, in runfile execfile(filename, namespace) File "C:\Users\John\Anaconda2\lib\site-packages\spyderlib\widgets\externalshell\", line 71, in execfile exec(compile(scripttext, filename, 'exec'), glob, loc) File "C:/Users/John/.spyder2/py/", line 14, in <module> dwf = cdll.dwf File "C:\Users\John\Anaconda2\lib\ctypes\", line 435, in __getattr__ dll = self._dlltype(name) File "C:\Users\John\Anaconda2\lib\ctypes\", line 365, in __init__ self._handle = _dlopen(self._name, mode) WindowsError: [Error 126] The specified module could not be found I have copied the dwf.dll to my working directory with no luck. I am running windows 7, 64 bit. What is the best path forward to get this working? How is the Digilent Adept Runtime used? Thanks, John