Jump to content
  • 0

Waveforms software and Python script at same time


agaelema

Question

Hi,

It's possible to execute the Waveforms software and in parallel execute some python script with waveforms API.

I know, this can look crazy, but I'm thinking in add some physical knobs to control the values inside the Waveforms.

Thanks.

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

Hi @agaelema

The device can be accessed by only one application at a time.

However you could use the Script tool to create such features.
- connect the physical buttons to DIO and use simple button or create a microcontroller project which processes the knob signals and communicates with the script using SPI, I2C..
- create a separate application/script which communicates using file with the Script tool. Your application writes to a file the knob position and the script periodically checks the current value and adjust the interface option by the difference.

Here DIO 0 increases and DIO 1 decreases the time base.
i1.thumb.png.d0cae3ba549af575cd246777e838b4fa.png
 

function find125(val){
    var si = sign(val)
    var val2 = pow(10, ceil(log10(abs(val))));
    if(val <= val2/5) return val = si*val2/5;
    if(val <= val2/2) return val = si*val2/2;
    return si*val2;
}
while(wait(0.1)){
    if(StaticIO.Channel0.DIO0.Input.value == 1){ // up
        Scope1.Time.Base.value = find125(Scope1.Time.Base.value*2);
        wait(0.5);
    }
    if(StaticIO.Channel0.DIO1.Input.value == 1){ // down
        Scope1.Time.Base.value = find125(Scope1.Time.Base.value/3);
        wait(0.5)
    }
}

 

Link to comment
Share on other sites

Hi @agaelema

You can find some examples under Protocol/ SPI | I2C / Custom.

In order to have access to other instruments you will have to access Protocol functions from Script tool. Here the functions need to be prepended with Protocol.SPI or .I2C
First open and configure the Protocol SPI or I2C (frequency, pins...) and select Custom tab. Then run the script which uses the SPI or I2C functions, like:

Protocol.SPI.Start(); // activate CS
Protocol.SPI.Write(8, [0x0A]); // write to MOSI, 0x0A as 8 bit command
var rg = Protocol.SPI.Read(32, 4); // read from MISO 4 words of 32 bits
Protocol.SPI.Stop(); // deactivate CS

Scope1.Time.Base.value = 0.000001*rg[0] // use value as micro second

From Script only the UART Send/TX function is available:

Protocol.UART.Send("Hello\n")

 

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...