
Series 3700A System Switch/Multimeter Reference Manual
Section 6: Reading buffers
3700AS-901-01 Rev. D/June 2018
6-13
Example 3
To see if the high limit 1 was exceeded during the reading:
stat_info = readingbuffer.statuses[3]
if (bit.bitand(stat_info, dmm.buffer.LIMIT1_HIGH_BIT) ==
dmm.buffer.LIMIT1_HIGH_BIT) then
print("Limit 1 high exceeded")
else
print("Limit 1 high okay")
end
Dynamic buffer programming example
The programming example below shows how to store data using a dynamically allocated buffer
named
mybuff
.
-- Reset the DMM.
dmm.reset("all")
-- Create a buffer named mybuffer and allocate space for 100,000 readings.
mybuffer = dmm.makebuffer(100000)
-- Enable append buffer mode.
mybuffer.appendmode = 1
-- Set count to 1.
dmm.measurecount = 1
-- Select the DMM function as DC volts.
dmm.func = dmm.DC_VOLTS
-- Start for . . . do loop. Measure and store readings in buffer. End loop.
for x = 1, 100 do
dmm.measure(mybuffer)
end
-- Return readings 1 through 100.
printbuffer(1, 100, mybuffer.readings)
-- Return units 1 through 100.
printbuffer(1, 100, mybuffer.units)
Buffer for . . . do loops
The following examples illustrate the use of for . . . do loops when recalling buffer data from a reading
buffer called
mybuffer
. The following code may be sent as one command line or as part of a script.
Sample outputs follow the line of code. Also see the
(on page 11-299) command.
Buffer
mybuffer
has timestamp collection enabled in the example below.
This example loop uses the
printbuffer()
command to show the reading, units, and relative
timestamps for all readings stored in the buffer. The information for each reading (reading, units, and
relative timestamps) is shown on a single line with the elements comma-delimited.
for x = 1,mybuffer.n do
printbuffer(x,x,mybuffer, mybuffer.units, mybuffer.relativetimestamps)
end