Section 9: Measuring power using digitizing and TSP-Link
DMM6500 6½ Digit Multimeter User's Manual
9-6
DMM6500-900-01Rev. A / April 2018
-- Set up reading buffers.
node[2].defbuffer1.capacity = 50000
-- Set up trigger model.
node[2].trigger.model.setblock(1, node[2].trigger.BLOCK_WAIT,
node[2].trigger.EVENT_TSPLINK1)
node[2].trigger.model.setblock(2, node[2].trigger.BLOCK_MEASURE_DIGITIZE,
defbuffer1, 50000)
-- Show graph of measurements on swipe screens.
node[1].display.changescreen(node[1].display.SCREEN_GRAPH_SWIPE)
node[2].display.changescreen(node[2].display.SCREEN_GRAPH_SWIPE)
delay(1.0)
-- Initiate trigger model on both instruments.
node[2].trigger.model.initiate()
trigger.model.initiate()
-- Wait for test to complete.
waitcomplete()
-- Retrieve buffer statistics.
voltage_buffer = node[1].defbuffer1
voltage_stats = node[1].buffer.getstats(voltage_buffer)
avgVolt = voltage_stats.mean
print(avgVolt .. " Volts")
current_buffer = node[2].defbuffer1
current_stats = node[2].buffer.getstats(current_buffer)
avgCurr = current_stats.mean
print(avgCurr .. " Amps")
-- Print results to the USER swipe screen.
node[1].display.changescreen(display.SCREEN_USER_SWIPE)
node[1].display.settext(display.TEXT1, "AVG V: " .. string.format("%.2e", avgVolt)
.. " V")
node[1].display.settext(display.TEXT2, "Average Power: Calculating... ")
node[2].display.changescreen(display.SCREEN_USER_SWIPE)
node[2].display.settext(display.TEXT1, "AVG I: " .. string.format("%.2e", avgCurr)
.. " A")
node[2].display.settext(display.TEXT2, "Average Power: Calculating... ")
-- Calculate power using reading index-based method.
power_total = 0
num_readings = current_buffer.n
-- Iterate through each current and voltage reading, and calculate power.
for i = 1, num_readings do
current = current_buffer.readings[i]
voltage = voltage_buffer.readings[i]
-- Keep track of the total power
power_total = power current*voltage
end
-- Find average power by dividing total power by the number of readings.
average_power = power_total / num_readings
print(average_power .. " Watts")
--Print results to USER swipe screen.