Tektronix Technical Forums are maintained by community involvement. Feel free to post questions or respond to questions by other members. Should you require a time-sensitive answer, please contact your local Tektronix support center here.

Code for saving data

Use this forum for questions about Keithley Test Script Builder software.
Post Reply
holubowitch
Posts: 3
Joined: October 31st, 2014, 8:11 am
Country: United States

Code for saving data

Post by holubowitch » April 19th, 2015, 7:14 pm

For the 2450 SMU, I am very confused about coding in TSB to save my data in a simple format. I am performing a current sweep where I need to measure the voltage during steps lasting 300 seconds each, I'll provide the script below. How do I tell the instrument to record the voltage, say, every 1 s or every 5 s? Do I need to use the filter function, delay, or what? In the code below, I have tried to adjust the NPLC and measurement number to get each step to last about 300 s.

I will do this for a device (a fuel cell), then switch the leads to another fuel cell, take the same measurement, and repeat for many cells. I just want to be able to start the trigger model to characterize each device via the script, have all the data saved, and be able to move it to excel for processing. Do you recommend creating a new buffer for each fuel cell?

I've got the TSP commands for controlling the SMU more or less figured out, but am totally lost on saving the data. I think I want the "printbuffer" command, but I don't know what things like .n, i =, for, do, if, , ==, '\t', %g, string.format, etc. mean. I have been scouring the reference manual and forums but there seems to be no guide as to what this coding means, how to use it, and what their resultant output is. Where can I read in detail about how to use this code?

Also, please let me know if the code is okay for the measurement: 10 applied current steps from -1.5 to 0 mA with ~300 s steps. I think it's not quite right as-is.

Code: Select all

reset()
fuelcell_1 = buffer.make(100000)

--Measure Settings
smu.measure.func = smu.FUNC_DC_VOLTAGE
smu.measure.autorange = smu.ON
smu.measure.nplc = 10
smu.measure.sense=smu.SENSE_4WIRE

--Source Settings
smu.source.func = smu.FUNC_DC_CURRENT
smu.source.vlimit.level = 0.1
smu.source.delay = 0.01
smu.source.sweeplinear('LinearSweep', -0.0015, 0, 10)

--Trigger Model configuration
trigger.model.setblock(1, trigger.BLOCK_BUFFER_CLEAR)
trigger.model.setblock(2, trigger.BLOCK_CONFIG_RECALL, "LinearSweep", 1)
trigger.model.setblock(3, trigger.BLOCK_SOURCE_OUTPUT, smu.ON)
trigger.model.setblock(4, trigger.BLOCK_BRANCH_ON_EVENT, trigger.EVENT_SOURCE_LIMIT, 15)
trigger.model.setblock(5, trigger.BLOCK_DELAY_CONSTANT, 10)
trigger.model.setblock(6, trigger.BLOCK_MEASURE)
trigger.model.setblock(7, trigger.BLOCK_BRANCH_COUNTER, 1000, 6)
trigger.model.setblock(8, trigger.BLOCK_CONFIG_NEXT, "LinearSweep")
trigger.model.setblock(9, trigger.BLOCK_BRANCH_ON_EVENT, trigger.EVENT_SOURCE_LIMIT, 15)
trigger.model.setblock(10, trigger.BLOCK_MEASURE)
trigger.model.setblock(11, trigger.BLOCK_BRANCH_COUNTER, 1000, 10)
trigger.model.setblock(12, trigger.BLOCK_BRANCH_COUNTER, 9, 8)
trigger.model.setblock(13, trigger.BLOCK_SOURCE_OUTPUT, smu.OFF)
trigger.model.setblock(14, trigger.BLOCK_BRANCH_ALWAYS, 0)
trigger.model.setblock(15, trigger.BLOCK_SOURCE_OUTPUT, smu.OFF)
trigger.model.setblock(16, trigger.BLOCK_LOG_EVENT, 2733, "source limit exceeded")

trigger.model.initiate()
waitcomplete()

printbuffer(1, 1000, fuelcell_1.readings,fuelcell_1.sourcevalues,fuelcell_1.relativetimestamps)
print("Rdg#","Times","Voltage (V)")
for i=1,fuelcell_1.n do
print(i,fuelcell_1.[i], fuelcell_1.sourcevalues[i], fuelcell_1.readings[i],fuelcell_1.relativetimestamps[i],fuelcell_1[i]))
end

brian.d.smith
Keithley Applications
Keithley Applications
Posts: 402
Joined: June 10th, 2013, 6:00 am
Country: United States

Re: Code for saving data

Post by brian.d.smith » April 20th, 2015, 5:29 am

There is no TSP command for saving data. You will need to use your choice of Python, C++, Visual basic, Matlab, Labview, etc. to create an application capable of saving data.

holubowitch
Posts: 3
Joined: October 31st, 2014, 8:11 am
Country: United States

Re: Code for saving data

Post by holubowitch » April 20th, 2015, 6:08 am

Does the printbuffer command not write the data to the specified buffer? Perhaps "saving" is not the right word, I just want all the data written to the buffer easily so I can then transfer it to my USB drive. What do .n, i =, for, do, if, , ==, '\t', %g, string.format mean? I would like to do this without creating an application.

Can you please address the other questions about my script?

brian.d.smith
Keithley Applications
Keithley Applications
Posts: 402
Joined: June 10th, 2013, 6:00 am
Country: United States

Re: Code for saving data

Post by brian.d.smith » April 20th, 2015, 6:57 am

I misunderstood your question. Yes you can write your buffer to a USB FLASH memory device. Have a look at the instructions file.open(), file.write(), etc. This is how you get your buffer contents written to the USB memory device.

For your source/measure timing, have a look at the instruction smu.source.sweeplist() and the associated coded example in the 2450 Reference Manual.

Try the example exactly as written and then modify it one instruction at a time until you obtain the behavior that you desire.

Post Reply

Return to “Test Script Builder”

Who is online

Users browsing this forum: No registered users and 1 guest