I recently acquired a new Fluke 8840A DMM. Sadly, I learned its unconventional command formatting would require some significant tweaks to my existing codebase; moreover, these tweaks would bloat with every new device I have to implement. At least the new devices that have some unconventional setup requirements. Hindsight is 20/20, so I decided to bulldoze my entire repo and start again from scratch. This time trying to emphasis an instrument-agnostic system.
As a reminder I’d like this module to support common instruments such as power supplies, e-loads, oscilloscopes, DMM’s and function generators for starters. I’d like to add some more exotic instruments at a later date, but these are my targets for first release.
To create an instrument-agnostic system, requires some amount of upfront effort to add support for each instrument. This configuration will come in the form of small json config files for each instrument. Each instrument will have several basic methods that should be filled out, dependent on what type of instrument it is. Here’s an example json file for my SPD1168 power supply. The user must fill out the string to be sent to the device to accomplish each function. Some functions may not be supported such as “set_remote_sense”. In cases like this the command can be left blank. On my current version of the project, this will raise a warning, but won’t halt the process.
{
"Manufacturer": "Siglent",
"DeviceType": "Power Supply",
"channels": 1,
"init": [""],
"reset": ["*RST"],
"operation_complete":["*OPC?"],
"set_output_en": ["OUTP CH{channel},ON"],
"set_output_dis": ["OUTP CH{channel},OFF"],
"set_voltage": ["CH{channel}:VOLT {value}"],
"set_current": ["CH{channel}:CURR {value}"],
"set_remote_sense": [""],
"get_voltage":["CH{channel}:VOLT?"],
"get_current":["CH{channel}:CURR?"],
"meas_voltage": ["MEAS:VOLT? CH{channel}"],
"meas_current": ["MEAS:CURR? CH{channel}"],
"meas_power": ["MEAS:POWE? CH{channel}"]
}
Here's a short example of the eload class test script. I’ll be refining the codebase some more this weekend and hopefully making in public (though still prerelease).
# ================ Electronic Load Test ================
elif( device_type == DeviceType.ELOAD):
myEload = ELOAD(USER_Eload_ip, ConnectionType.Ethernet)
print("====================================================\n"
"==================== ELOAD TEST ====================\n"
"====================================================\n")
# Toggling the output - errr. I guesss input in this case ;) -
print("Enable Eload Output")
myEload.set_output_dis(Channel.CH1)
sleep(0.5)
myEload.set_output_en(Channel.CH1)
sleep(0.5)
# Test Constant Current
test_load = round(random(),2)
print("\nTest CC mode @"+str(test_load)+"A")
myEload.set_mode_type(EloadMode.CC, Channel.CH1)
myEload.set_load_value(test_load, Channel.CH1)
# Check if set
set_value = myEload.get_load_value(Channel.CH1)
if(set_value == test_load): print("PASS")
else: print("FAIL -> Read "+ str(set_value))
# Test Constant Resistance
test_load = round(random()*100,2)
print("\nTest CR mode @"+str(test_load)+" Ohm")
myEload.set_mode_type(EloadMode.CR, Channel.CH1)
myEload.set_load_value(test_load, Channel.CH1)
set_value = myEload.get_load_value(Channel.CH1)
if(set_value == test_load): print("PASS")
else: print("FAIL -> Read "+ str(set_value))
# Test Constant Power
test_load = round(random(),2)
print("\nTest CP mode @"+str(test_load)+"W")
myEload.set_mode_type(EloadMode.CP, Channel.CH1)
myEload.set_load_value(test_load, Channel.CH1)
set_value = myEload.get_load_value(Channel.CH1)
if(set_value == test_load): print("PASS")
else: print("FAIL -> Read "+ str(set_value))
# Test Constant Power
test_load = round(random(),2)
print("\nTest CV mode @"+str(test_load)+"V")
myEload.set_mode_type(EloadMode.CV, Channel.CH1)
myEload.set_load_value(test_load, Channel.CH1)
set_value = myEload.get_load_value(Channel.CH1)
if(set_value == test_load): print("PASS")
else: print("FAIL -> Read "+ str(set_value))
# Please for the love of god, use remote sense if your doing efficiency sweeps
print("\nEnable Remote Sense")
myEload.set_remote_sense(1, Channel.CH1)
# How to measure V/I/P
print("\nMeasure Voltage, Current, and Power")
volt = myEload.meas_voltage(Channel.CH1)
curr = myEload.meas_current(Channel.CH1)
power = myEload.meas_power(Channel.CH1)
print("Voltage -> " + str(volt) +"V")
print("Current -> "+ str(curr) +"A")
print("Power -> "+ str(power) +"W")
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.