• How to speed-up triangle wave generation?

    I wrote the following script for the 2450 & 2470 SMUs.

    The goal is to be able to output a triangle wave and capture the current through a 2 terminal device connected in 4 wire configuration. The problem is that I am far from being able to scan at the rate of my slope which I set to 0.1 v/sec so going from 0V to 1V should take 10 seconds. When running the scripts as-is this takes around 30 seconds. This is with delay = 0.

    How can I adjust this code so I can actually run faster sweeps? Thanks

    -- Reset the instrument
    reset()
    
    -- User input for parameters
    local targetVoltage = display.input.number("Enter Target Voltage (V)", display.NFORMAT_DECIMAL, 1, -10, 10)
    local slope = display.input.number("Enter Slope (V/s)", display.NFORMAT_DECIMAL, 0.1, 0, 10)
    local numRepeats = display.input.number("Enter Number of Repeats", display.NFORMAT_INTEGER, 5, 1, 100)
    local numPoints = display.input.number("Enter Number of Points", display.NFORMAT_INTEGER, 100, 2, 1e6)
    
    -- Triangle sweep parameters
    local start = 0 -- Start voltage
    local stop = targetVoltage
    local points = numPoints + 1
    -- local sDelay = targetVoltage / slope / numPoints
    local sDelay = 0
    local count = numRepeats 
    local rangeType = smu.RANGE_BEST -- Best fixed range
    local failAbort = smu.ON         -- Abort the sweep if the source limit is exceeded
    local dual = smu.ON              -- Sweep up & down
    local bufferName = defbuffer1    -- Buffer name
    
    smu.source.sweeplinear("Triangle", start, stop, points , sDelay, count, rangeType, failAbort, dual, bufferName)
    
    -- Measure Settings
    smu.measure.func = smu.FUNC_DC_CURRENT
    smu.measure.autorange = smu.ON
    smu.measure.nplc = 1
    smu.measure.sense = smu.SENSE_4WIRE
    
    trigger.model.initiate()
    waitcomplete()