Jump to content
  • 0

AD2 + wafeforms - script not working for scope trigger


Xarach

Question

Hi all,

Running the AD2 with Waveforms 3.7.5 64-bit Qt5.6.3 under Linux (Ubuntu 12.04.5 LTS).  I am trying to write a script which sets the scope triggering settings, but it issues an error for the expression

Scope1.Trigger.Mode.text = "None";

saying that Scope1.Trigger.Mode is not an object.  In fact, using the Qt script debugger, it appears that Scope1.Trigger doesn't exist.  Other stuff is working e.g. Scope1.Time.Samples.value=500 works.  Other things mentioned in the script documentation also don't seem to work.  For example, I have to use Scope1.channel[0] instead of Scope1.Channel1.

I'm an old hand at Python, C++ etc., but a newbie at Javascript so it's probably something dumb I am doing.  Any ideas?

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

OK, tried that, but it doesn't actually set the trigger mode to "None" since it is still waiting for an external trigger (in the interface, trigger mode is set to 'normal' with conventional rising edge etc.) Normally, triggering is used, but when calibrating we just want to collect a small number of samples without the normal trigger.

I understand that it's better to use the interface, but in this case we are kind of OEMing for a customer of ours and we want to simplify the initial calibration process for this data acquisition.  We are writing a simple script to automate this, but when running it temporarily needs to change the scope settings.  Here is the script so far...

var scale1 = 4.13     // Inch per volt (this depends on positive supply providing 1.5V)

var scale2 = 21        // lbf per volt (raw output from load cell interface)


var acquisition_threshold = 0.5    // Automatic acquisition when handle is displaced this far (in inches).


function doCalibOffset(){

    print("")

    print("Sampling for reference offsets...")

    var oldsamps = Scope1.Time.Samples.value;

    //print("oldsamps: " + oldsamps);

    Scope1.Time.Samples.value = 64;

    Scope1.Time.Mode.text = "None";

    Scope1.single();

    if(!Scope1.wait()){

        Scope1.Time.Samples.value = oldsamps;

        return;

    }

    var average1 = 0;

    var average2 = 0;

    var data1 = Scope1.channel[0].data;

    var data2 = Scope1.channel[1].data;

    data1.forEach(function(sample){average1 += sample;})

    data2.forEach(function(sample){average2 += sample;})

    average1 /= data1.length;

    average2 /= data2.length;

    print("Offset (displacement): "+average1+" V");

    print("Offset (force): "+average2+" V");


    Scope1.channel[2].Function.text = "(C1 - " + average1.toPrecision(3) + ") * " + scale1;

    Scope1.channel[3].Function.text = "(C2 - " + average2.toPrecision(3) + ") * " + scale2;

    Scope1.Trigger.Level.value = average1 + acquisition_threshold/scale1

    Scope1.Time.Mode.text = "Normal";

    Scope1.Time.Samples.value = oldsamps;

    print("Done.");

}

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

    throw("Please open a Scope instrument");

}

doCalibOffset();

 

Link to comment
Share on other sites

OK, so Scope1.Time.Mode is not the right control anyway: that one has the values "repeated, shift, screen, record".  I need the one to the right of that which allows "none, auto, normal".  What's its name?

It's a shame the Qt debugger doesn't allow introspection of the objects, otherwise I could work this out myself.  If you inspect an object like 'Scope1' in the Locals window, it does not list any of the documented fields like Trigger, BufferSize etc.  Must be some magic going on.  In Python I would just look in __dict__ (or use help or dir) to sniff around; don't know how to do that in JS.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...