Python 3 library to interface with the Korad KA3005P and related programmable power supplies.
This provides a Python class which wraps the serial communication protocol, and works around a firmware bug or two.
The object supports the python with
statement to release the serial port automatically:
from koradserial import KoradSerial
with KoradSerial('/dev/tty.usbmodemfd121') as power_supply:
print "Model: ", power_supply.model
print "Status: ", power_supply.status
This library uses the pyserial and enum34 libraries.
Connect a small-value resistor (approximately 100Ω) across the positive and negative outputs.
The unit tests exercise as much as I'm able given my equipment.
The constructor takes a string containing the serial device to attach to. It attempts to connect to the power supply immediately.
If debug
is set to True
, then print
statements will detail the data sent and received.
Turns the beep on or off.
Note: This functionality doesn't appear to work reliably on my units.
from koradserial import KoradSerial
with KoradSerial('/dev/tty.usbmodemfd121') as power_supply:
. . .
power_supply.beep.on()
. . .
power_supply.beep.off()
This is an array of channel objects. Channel 1 is the first element of the array. Channel 2 is the second element of the array, etc.
Thus, for single-channel power supplies channels[0]
will give access to Channel 1.
Each channel has the following attributes:
Sets or reads the current for the channel as a floating-point number.
Setting the current turns the output off.
Returns the output current reported by the power supply as a floating-point number.
If the output is off, this may be 0.0 or None
.
Returns the output voltage reported by the power supply as a floating-point number.
If the output is off, this may be 0.0 or None
.
Sets or reads the voltage for the channel as a floating-point number.
Setting the voltage turns the output off.
Closes the serial port to the power supply.
Indicates whether the serial port to the power supply is open.
This is an array of memory settings. Memory 1 is the first element of the array. Memory 2 is the second element of the array.
Thus memories[0]
will give access to Memory 1.
Each memory has the following attributes:
This selects the memory, which turns the output off and sets the channels' voltage and current.
This saves the memory's settings.
Note:
Apparently to save a setting to a memory one must do the following:
- Select the memory with
recall()
. - Set the channels' voltage and current.
- Save the memory with
save()
.
from koradserial import KoradSerial
with KoradSerial('/dev/tty.usbmodemfd121') as power_supply:
channel = power_supply.channels[0]
m1 = power_supply.memories[0]
m1.recall()
channel.voltage = 1.00
channel.current = 0.100
m1.save()
Returns the power supply model information.
Opens the serial port to the power supply.
Turns the output on or off.
from koradserial import KoradSerial
with KoradSerial('/dev/tty.usbmodemfd121') as power_supply:
. . .
power_supply.output.on()
. . .
power_supply.output.off()
Turns the over current protection on or off.
from koradserial import KoradSerial
with KoradSerial('/dev/tty.usbmodemfd121') as power_supply:
. . .
power_supply.over_current_protection.on()
. . .
power_supply.over_current_protection.off()
Turns the over voltage protection on or off.
from koradserial import KoradSerial
with KoradSerial('/dev/tty.usbmodemfd121') as power_supply:
. . .
power_supply.over_voltage_protection.on()
. . .
power_supply.over_voltage_protection.off()
Returns a Status
object (documentation below) containing decoded status information.
Sets the tracking method for multi-channel power supplies.
Note: This is untested.
Indicates the beep on/off state.
Note: May not be reliable.
Indicates Channel 1's mode.
Indicates Channel 2's mode.
Indicates the lock on/off state.
Note: May not be reliable.
Indicates whether the output is on or off.
This contains the raw value returned by the STATUS?
command.
Indicates the power supply's tracking state.
- Multi-channel functionality has not been tested due to lack of access to an appropriate power supply.
- There is conflicting information about the tracking values sent and received. Somebody with a multi-channel power supply will need to verify the values.