Jump to content
  • 0

AD2 or EE as ADC/ DAQ recording system


Jon Frey

Question

With limited funds and  learning curve time , trying to decide on system(s) to purchase.

AD2  looks as if it suits me well for support instrumentation used for  auxiliary circuit development .The software is well done and versatile

The 100Ms scope sample  rate and multiple device syncing lean me toward the AD2 ,but the EE is better for bread-boarding.

I am not seeing much info/clarity  in either the GUI interface, scripting  or the SDK in using either board as a high rate DAQ.

I don't want to get down to the level of the FPGA itself , looking for functional tools to make progress with other interests .

If neither of these will support fast DAQ, then I will go with the EE for breadboarding and look elsewhere for seperate DAQ.

I would like to stay in same product ecosytem, there are impossibly many options, so it looks like I need to pick a "side".

 

 

Link to comment
Share on other sites

17 answers to this question

Recommended Posts

I just tried inserting the above script in the script window, replacing the script that is present at startup.  The initial function main(){ and last main(); lines remain.  I have a Scope 1 present. I successfully started the script, setting 10 buffers and manual trigger. At the completion of 10 triggers, the script then went to  print buffer 1 and this is the script output/error message:

1

Error in line: 24

TypeError: ambiguous call of overloaded function write(); candidates were

write(QString)

write(QVector<qreal>)

The line that caused the error is:   file.write(Scope1.channel[c].alldata)

I then replaced ".alldata" with ".data" in this line, and the script completely executed, though of course with 10 buffers, it outputs 20 files (for each channel and acquisition) which is a pain to load all at once into Matlab.  I notice you often advise people to use ".alldata".  Is this some new variable in a revision of Waveforms2015 (my version was installed on my Mac summer of 2016). ".alldata" clearly causes errors. Next, if I run a script in the logging window of Scope, why does the name need to be "Scope" eg Scope..Buffer.value, Scope.Channel1.data etc rather than "Scope1" in the script window.  Last question, these text data files are huge - in the attached script3.txt from my prior question, with 256 buffers, they add up to 45-90 MegaBytes each.  I attempted to use appendInteger or appendDouble in the logging script but this didn't seem to work.  How would I instead save the data as doubles or integers so it can be read in Matlab by freed()?

Link to comment
Share on other sites

Hi @greig

The appendFloat writes only one 32bit floating point value to the file. The writeFloat writes an array of values.

The code in Script interface is running in the main application thread. From here you can set any option, like Scope1.Buffers.value = i
The code from other places (logging, measure,...) is run in background thread. It is not safe to change application options from here since these could be applied out of sequence.

Link to comment
Share on other sites

Thanks.  I did forget to mention that when running in the Script tool, I had already changed from Scope to Scope1. About stability, sometimes running the prior script in the logging tool caused a crash of WF, so for sure the logging tool isn't so stable.  And yes, the appendLine works fine - the files are the correct size.  The issue is when I do appendInteger/Float/Double, the file size on a Mac changes very little from the initial writeFloat etc.  Could you verify that if you write out 256 buffers using the script below in the Script tool, what file size you get for appendFloats.  For me, with 8192 data points, the initial writeFloat makes a file that is 33kB (if I comment out the appendFloat).  With the appendFloat uncommented, I get only 34K in the file created.  Below is the exact script I ran in the Script tool, to store pre-acquired data in the Scope tool.  Is there an alternative, where you convert the data into an array, and then use a single writeFloat  for the entire array?

function main(){

if( !('Scope1' in this)) {

throw("Please open a Scope instrument");

}

var b = Scope1.Buffers.value

var fileD = File("~/Desktop/AD/acqD.csv")

if(1) {

var buff = 1 ; //set to 1 for all

Scope1.Buffer.value = buff;

fileD.writeFloat(Scope1.Channel1.alldata);

if(b >buff ){

for(var i = buff+1; i <= b ; i++){

Scope1.Buffer.value = i;

fileD.appendFloat(Scope1.Channel1.alldata);

}

}

}

}

main();


Link to comment
Share on other sites

Hi @greig


The write, writeLine, append, appendLine functions are for text to file.

The writeInteger/Float/Double write array of data in binary format. 32bit integer, 32bit and 64bit float
The appendInteger/Float/Double append binary data.

Please run the script from the Script tool. You just have to prepend "Scope = Scope1" and your script will work.
The Scope/Logging is intended for working on current acquisition data. Changing the buffer from here seems to be unreliable.

Link to comment
Share on other sites

I did one more test.  I added the appropriate function wrappers to the above and ran it instead from the Script window.  In this case, data saving is appears repeatable with 256 buffers.  So why does running this from the logging window in Scope result in different behavior?  One thing though, the file.appendFloat, appendInteger, appendDouble still doesn't work as advertised.

Link to comment
Share on other sites

Hi, yes my version was a year old.  I have now updated to the most recent version of WF, and now alldata works.  But there are two issues. First, it appears file.writeFloat, file.writeDouble, and file.writeInteger all work, but file.appendFloat, file.appendDouble, and file.appendInteger do nothing. Only the .appendLine functions grow the file.  You can tell by how small the file sizes are.

The second issue, is I am seeing data corruption in trying to write large numbers of appended buffers (256).  I did a test in the following script, where I had captured 256 buffers at 8192 each. In one case I wrote all out.  Then I repeated (not recapturing).  Approximately the latter half of data had changed.  When I wrote only buffers 129 to 256, then repeated, the data is the same.  Is there an undisclosed memory limit on writing out/saving buffer data?  This issue remains on the newest version of WF.  This script is run from the logging window in scope, where the manual save is used.

// number of acquisitions

var b = Scope.Buffers.value

var fileX = File("~/Desktop/AD/acqX.csv")

var fileY = File("~/Desktop/AD/acqY.csv")

var fileD = File("~/Desktop/AD/acqD.csv")

// Warning see corrupted data above buffer 150 or so. If redo save of same data, I can get different data when loaded into Matlab.

if(1) {

buff = 129;    // change to 1 to write all buffers

Scope.Buffer.value = buff;

fileX.writeLine(Scope.Channel1.alldata); // ensure write-over

fileY.writeLine(Scope.Channel2.alldata); // ensure write-over

fileD.writeFloat(Scope.Channel1.alldata);

if(b >buff ){

for(var i = buff+1; i <= b ; i++){

Scope.Buffer.value = i;

fileX.appendLine(Scope.Channel1.alldata);

fileY.appendLine(Scope.Channel2.alldata);

fileD.appendFloat(Scope.Channel1.alldata);

}

}

}

Link to comment
Share on other sites

Hi @greig

Probably you have an older version of WF, without alldata property.
You can find the latest version at:
https://analogdiscovery.com/
https://reference.digilentinc.com/waveforms3

You can use writeFloat for 32bit or writeDouble for 64bit floating point data.
 

for(var c = 0; c < 2; c++){
   var file = File("~/Desktop/AD/acq"+i+".ch"+c+".bin")
   file.writeFloat(Scope1.channel[c].alldata)
}

 

Link to comment
Share on other sites

Forgot to mention:  In the script window the opening line is changed only to ask for the Scope, not the Wavegen. Is there a checkbox in the Scope window that is needed for ".alldata" to be a valid field?  Below is the opening line of the script.

function main(){

if( !('Scope1' in this)) {

throw("Please open a Scope and a Wavegen instrument");

}

Link to comment
Share on other sites

In the end, my AD2 upon start up seems to just use Scope not Scope1 and the "alldata" gave an error.  I took the above and made two cases, the first where all Channel 1 data of all buffers is appended, and then Channel 2.  I tried this with up to 256 buffers.  However sometimes, Waveforms will then crash on my Mac (testing 256 buffers).  The script (attached) is inserted in the logging script tab under Scope. I acquire 256 sets of data (256 buffers),  and then do the Manual Save of the script. I have noticed that for buffer lines above 210 or so, the result can be corrupted in the save - I can repeat the save and these data will differ!  Is there a memory leak for high buffer counts?  In matlab, I just do "load acqX.csv" or "load acqY.csv".  In general the script save all data into 2 ( if(1) ) or 1 ( if(0) ) file but I need to see what the nature of the corruption is.

script3.txt

Link to comment
Share on other sites

In the above script example, how is this to be used?  Is it cut and pasted into the logging window for the scope, as is, or to be placed in the script tool? In copying to the logging window script, and setting for manual & hitting save, I got an Error in line: 2 ReferenceError: Can't find variable: Scope1. 

  In studying this code snippet, it seems to  write a whole new file for each buffer.  For importing to Matlab, how could ALL buffer data be concatenated (in sequence of course) to one single file.

Link to comment
Share on other sites

Hello,

Separate (Repeated) acquisitions will always have gap between them. The duration of this depends on many things, system performance, time to export to csv, opened views, measurements...
I see about 5-10ms delay between acquisitions with WaveForms with the attached Script.
With a custom application you might get a bit better result. After installing WaveForms 2015 see C:\Program Files (x86)\Digilent\WaveFormsSDK\samples\py

With Record mode (select instead Repeated option) you can stream capture 10M samples at up to 1-2MHz
 

// number of acquisitions
var b = Scope1.Buffers.value

// store acquisitions in PC buffers, fast
Scope1.run()
for(var i = 0; i < b; i++){
    Scope1.wait()
}
Scope1.stop()

// save data to file, slow
for(var i = 1; i <= b & wait(); i++){
    print(i)
    Scope1.Buffer.value = i;
    if(1){ 
        // channel data in separate files
        for(var c = 0; c < 2; c++){
            var file = File("~/Desktop/AD/acq"+i+".ch"+c+".csv")
            file.write(Scope1.channel[c].alldata)
        }
    }else{
        // acqisitions in separate files, very slow...
        var file = File("~/Desktop/AD/acq"+i+".csv")
        file.writeLine("C1,C2")
        var rgdata = []
        rgdata.push(Scope1.Channel1.alldata)
        rgdata.push(Scope1.Channel2.alldata)
        var cdata = rgdata[0].length
        for(var l = 0; l < cdata; l++){
            file.appendLine(rgdata[0][l]+","+rgdata[1][l])
        }
    }
}

 

Link to comment
Share on other sites

I am only seeing a  single16k sample buffer , so a very short time to fill buffer at max 100M samples rate.

The logger function in the Scope GUI looks like it only dumps/ sends buffer to PC in CSV format , so some data overhead there and delay before next buffer sent?

 Overhead from scope GUI process?

Output to PC is limited by USB2

So I don't see any way to get full sample rate data out except for one buffer fill?

 

Question 1 :With GUI ,what sample logging rate can the AD2 accomplish as a stream, no breaks in data?

Question 2: If I am using triggering to log samples , how to calculate max rate of triggers the AD2 can keep up with?

Question 3:If I go into deeper into the system software either through AD2  SDK or Adept software , can I stream data faster from the digitized samples coming into the FPGA out to AD2 digital outputs, where I can pick them up with external DAQ card with digital input?

 

Link to comment
Share on other sites

Hello,

I don't see any clear technical question. The decision is up to your requirements.

The Electronics Explorer has more scope and digital channels, powerfull power supplies, voltmeters, reference voltages...
https://reference.digilentinc.com/reference/instrumentation/electronics-explorer/start?redirect=1
The Analog Discovery 2 is a newer cheaper smaller portable product with faster higher resolution differential scope channels.
https://reference.digilentinc.com/reference/instrumentation/analog-discovery-2/start?redirect=1

These can be used with the same WaveForms 2015 software.
https://reference.digilentinc.com/reference/software/waveforms/waveforms-3/start

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...