Hi all,

I am looking for help with a measurement using a Keithley 2612B. What I want to do is

1. Apply a set voltage (typically ~4V)

2. Immediately begin recording current data to a buffer

3. After a set amount of time/counts of measurements turn off the voltage

Here is my Lua code:

function run_experiment(voltageLevel, voltageApplicationTime, samplingInterval)

    chargingTimer = trigger.timer[1]
    chargingTimer.count = voltageApplicationTime / samplingInterval

    chargingTimer.delay = samplingInterval

    smub.reset()

    smub.source.func = smub.OUTPUT_DCVOLTS
    smub.source.rangev = voltageRange
    
    smub.nvbuffer1.appendmode=1
    
    smub.measure.rangei = 0.01             -- Set current range for measurement
    smub.measure.autozero = smub.AUTOZERO_OFF
    smub.measure.autorangei = smub.AUTORANGE_OFF
    smub.measure.count = voltageApplicationTime / samplingInterval
    smub.trigger.measure.i(smub.nvbuffer1)  -- Measure current into buffer1
    smub.trigger.measure.action = 1
    smub.trigger.measure.stimulus = chargingTimer.SOURCE_COMPLETE_EVENT_ID

    chargingTimer.stimulus = smub.trigger.ARMED_EVENT_ID

    smub.source.levelv = voltageLevel
    smub.source.output = smub.OUTPUT_ON

    waitcomplete()

    if smub.nvbuffer1.n > 0 then
        printbuffer(1, smub.nvbuffer1.n, smub.nvbuffer1.readings)
    else
        print("No data in nvbuffer1.")
    end

end

What am I doing wrong? No data is being created in the buffer and I do not understand why. No errors are being created either. For first tests I set samplingInterval = 0.1 to make things simple but always there is nothing in the buffer!

Additionally, voltageApplicationTime is set to 5.0 so values generally are sensible.

Any help is greatly appreciated thanks!!!