Search the Community

Showing results for tags 'javascript'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • 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

Calendars

  • Community Calendar

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests

Found 7 results

  1. Hi Guys, I'm new to the AD2 & Waveforms, and in the need of some help. I'm trying to import a csv file into a custom wavegen and then output it. Here is my code: if(!('Wavegen1' in this)||!('Scope1' in this))throw"Please open a Scope and a Wavegen instrument"; var filename = "/Users/PaulBritten/Documents/AFWorkMain/AFWork/Waveform/single_qrst_improved_twave_1khz.csv"; var file = File(filename); print("exists? " + file.exists()); var arr = file.readArray(); print(arr); Wavegen1.Channel1.Mode.text = "Custom"; Wavegen1.Channel1.Custom.Type.set("MyWave", arr); Wavegen1.Channel1.Custom.Type.add(arr); Wavegen1.Channel1.Custom.Offset.value = 0; Wavegen1.Channel1.Custom.Frequency.value = 1; Wavegen1.Channel1.Custom.Amplitude.value = 1; Scope1.Trigger.Trigger.text = "Repeated"; Wavegen1.run(); Scope1.run(); Can anyone explain to me why I'm getting this error: Thanks for any help in advance. Best wishes Paul
  2. I'm using WaveForms (and Javascript) for the first time. My problem is really simple; I measure a voltage signal with the Analog Discovery 2, and want to get a "long" file with data over several seconds. When using the record-function and exporting data, I only get 1000.000 data points with the frequency required, and I can't seem to figure out how to save the raw data in the script. If anyone can help this rookie, I'll be very grateful! I think I'll need a whole new script, but it looks like this right now: ch = Scope.Channel1 var newfile = File("~/Desktop/scope/measure.csv") if(!nyfil.exist()){ var AllData = Date()+","+ch.data+" nyfil.appendLine(AllData) Index++
  3. Does Digilent offer any services for custom script programming to control the Analogue Discovery 2? I need to better harness the device's existing capabilities in a more streamlined manner and it would be much easier to contract this work to an expert instead going through the scripting process myself.
  4. Note To Staff There is no need for help here; I just wanted to share this with others, since it was useful to me. As far as I'm concerned (have power to say?), this code, text, graphics, and attachments are all public domain (preferably with attribution). If there is a specific area or protocol for these sorts of things, I haven't seen it. This post and contents could be stickied, moved, and otherwise used as the powers that be see fit. If there is something wrong, something that needs changed, or something the needs clarified, feel free. /Note To Staff Hello all. I have a small gift for anyone that wants it. The following is working javascript for GY-521 breakout boards, which holds the venerable InvenSense MPU-6050 6 axis IMU chips. // -UNOFFICIAL SCRIPT- -AS IS- -NOT ENDORSED BY DIGILENT- -USE AT OWN RISK- // Author: Charles Scoville // // GY-521 breakout board: InvenSense MPU-6050 i2C Gryo + accelerometer // Set clock = 400kHz: Rate up to 400Hz (more may work): Itterations ~1k const adr = 0x68; // 0x69 is an alternate address. function initialize(){ if(Clear()!=true) return "I2C bus error. Check the pull-ups."; if(Write(adr)!=true) return "Device NAK"; //if(Read(adr, 0x75, 1) != 0x68) return "Device ID mismatch"; *FIXME* Read() bug? Does NOT actually return 0x68 if(Write(adr, 0x6B, 0x03)!=0) return "Communication error"; // REG: PWR_MGMT_1 (Z gyro as clock source) if(Write(adr, 0x23, 0x78)!=0) return "Communication error"; // REG: FIFO_EN (FIFO only for Gyros and accelerometer) if(Write(adr, 0x6A, 0x45)!=0) return "Communication error"; // REG: USER_CTRL (Reset FIFO and signal paths for all sensors) if(!FileWriteLine("~/Desktop/default.csv", ["temp", "ACCEL_XOUT", "ACCEL_YOUT", "ACCEL_ZOUT", "GYRO_XOUT", "GYRO_YOUT", "GYRO_ZOUT"])) return "File write failed - init"; return true; } function loop(){ var rg = Read(adr, 0x3B, 14); // DATA var xa = ((rg[0]<<24) | (rg[1]<<16)) /256/256; var ya = ((rg[2]<<24) | (rg[3]<<16)) /256/256; var za = ((rg[4]<<24) | (rg[5]<<16)) /256/256; // NOTE: REG 0x23 must be written as 0xF8 for temp to be buffered var tmp = ((rg[6]<<24) | (rg[7]<<16)) /256/256/340 + 36.53; //temp (deg C) //tmp = tmp * 1.8 + 32; //temp (deg F) var xg = ((rg[8]<<24) | (rg[9]<<16)) /256/256; var yg = ((rg[10]<<24) | (rg[11]<<16)) /256/256; var zg = ((rg[12]<<24) | (rg[13]<<16)) /256/256; if(!FileAppendLine("~/Desktop/default.csv", [tmp, xa, ya, za, xg, yg, zg])) return "File write failed - loop"; return true; } function finish(){ return "done"; } This script is to be used in the "protocol>i2c>sensor" section of the WaveForms application. I have only run this on the Electronics Explorer, I have no idea if it even applies to anything else. The results when run (with a GY-521 attached, of course!) are a CSV file on your desktop, just as with the PMOD gyro or accelerator example code it was based on. For this data capture to make much sense, you will most likely want to graph the columns in the resulting file. I did so for the accelerometer and gyrometer as independent groups, as that provides the most informative and expected form for the data. The following are some graphs of a couple of my more interesting captures, as examples. They were made with LibreOffice 6.0 directly from the CSV files. The ods files are also attached. (Embedded malware is thoroughly unlikely, but you still open at your own risk.) This one was just me picking it up and turning it all around. It's a nice shot because it's pretty obvious when I picked it up, and what exactly I did. This one was of me lifting the board up onto one corner, rapidly twisting it back and forth, then just setting it down. This one clearly has more samples too. Anyway, thanks for reading. I hope this post has value to you. MPU-6050 readout1.ods MPU-6050 readout2.ods
  5. Hi, I am trying to do some test automation on the electronics explorer board. I have been looking through the Javascript and Python documentation and haven't been able to find a good mapping of values passed to the API's and where they correspond to the on-board resources. Does one exist? I have really been struggling for example trying to enable/change power supplies. Have variable Vp/Vn values and Vcc (on/off/5v/3.3v). Thank you for your time! Dylan
  6. Hi, so I am trying to complete a project for one of my classes and I decided to us the script part of the analog discovery; however, there is not enough comments on the code to explain what it is specifically doing. I found an example code that is titled "Wavegenpiano". I would like to know if someone can explain what that code is doing., ie, what each part of the code is doing. I would like to use that code associated with a buzzer to output a song. TL;DR How can I use the script part of the analog discovery to have a buzzer output out a sound?
  7. Hi, I would like to add several custom measurements based on my Scope Channel 1 signal: 1. Current measurement through a 220 ohm resistor 2. Min and max Frequency measurement of the signal applied to the same 220 ohm resistor. For number 1 I clicked "Add Channel" -> Custom, and added C1/220 to the textarea. This resulted in a new channel in the scope.channel column. I then went to Measurements column and did "Add" -> Custom Channel -> Math 1. This added an M1 measurement to my measurements. I modified the default Javascript to the code below, which (if I understand correctly) should average current through the resistor: value = 0 Channel.data.forEach(function(sample){ value+=sample }) value /= (Channel.data.length) value *= 1000 Is there a cleaner, better way to do this? Regarding #2, I wasn't able to figure out how to to obtain time measurements, which I assume I would have to do. My guess is I would have to diff two sequential times, and get their inverse to calculate the frequency. If someone could provide an example I would greatly appreciate it. Thank you in advance, -Nathan