Jump to content
  • 0

Script for repeated measurements in oscilloscope mode


dimitar

Question

1. I use the DAQ in oscilloscope mode with measured signal on Channel 1 and rectangular trigger signal on Channel 2.

2. Need to save the signal data every time the trigger signal rises until it falls as a separate data set and repeat it thousands of times.

3. It is preferred to have the data for each trigger rise appended and saved for both channels with trigger counter index included in a single file (csv or matlab) at predefined file path.

4. Issue: The trigger signal overshoots and undershoots for a while (about 1% of the trigger signal length) at each signal rise/fall.

Qs:

1) Can the above be done in the Waveform software environment and if yes, how?

2) Can you share a script if already created or guide me through the steps I must execute?

 

Thank you,

Dimitar

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

Hello,

You could do such with the following script, but processing reduces the acquisition rate and you might loose trigger events.

It would be better to save the acquisition with Logging/Export and process it later.

i1.png

var file = File("~/Desktop/daq.csv")
if(Index==1) {
    // create or overwrite
    file.writeLine("DAQ") 
}

// data array
var ch1 = Scope.Channel1.data
var ch2 = Scope.Channel2.data
// sample count
var cnt = ch1.length
// trigger level 
var trig = Scope.Trigger.Level.value

// append trigger index
var time = new Date()
file.appendLine("#Trigger "+Index+" "+time.getHours()+":"+time.getMinutes()+":"+time.getSeconds()+"."+time.getMilliseconds())
// find trigger position
var idx = 0
for(; idx < cnt && ch2[idx]<trig; idx++);
file.appendLine(idx)
// while trigger is high
for(; idx < cnt && ch2[idx]>trig; idx++){
    // append samples
    file.appendLine(ch1[idx]+", "+ch2[idx])
} 
Index++

 

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...