1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
-------------------------------------
-- lxi-tools --
-- https://lxi-tools.github.io --
-------------------------------------
-- Example: Working with multiple devices
-- Connect to instruments
dso = lxi_connect("192.168.0.157", nil, nil, 6000, "VXI11") -- R&S RTB2004
psu = lxi_connect("192.168.0.107", 5025, nil, 2000, "RAW") -- R&S NGM202
-- Print instrument IDs
print("Digital Storage Oscilloscope ID = " .. lxi_scpi(dso,"*IDN?"))
print("Power Supply ID = " .. lxi_scpi(psu,"*IDN?"))
-- Set power supply voltage on channel 1 to 1.2V
lxi_scpi(psu, "voltage 1.2, (@1)")
-- Turn on power supply
lxi_scpi(psu, "output on")
-- Wait for voltage to stabilize
lxi_msleep(1000)
-- Read out power supply voltage
volt_psu = lxi_scpi(psu, "voltage? (@1)")
volt_psu = tonumber(volt_psu)
print("volt_psu = " .. volt_psu)
-- Autoset oscilloscope
lxi_scpi(dso, "autoscale")
-- Start measurement on channel 1
lxi_scpi(dso, ":measurement1 on")
lxi_scpi(dso, ":measurement1:main rms")
-- Measure for 4 seconds
lxi_msleep(4000)
-- Read out DSO voltage of channel 1
volt_dso = lxi_scpi(dso, ":measurement1:result? rms")
volt_dso = tonumber(volt_dso)
print("volt_dso = " .. volt_dso)
-- Do voltage comparison
if (volt_psu < volt_dso) then
print("Power supply voltage is lower")
else
print("Power supply voltage is higher")
end
-- Turn off power supply
lxi_scpi(psu, "output off")
-- Disconnect
lxi_disconnect(psu)
lxi_disconnect(dso)
print("Done")
|