Doorgaan naar hoofdcontent

DPS5005 power supply, remote control using python serial port modbus

Just a short one.
I bought one of these things.
It can do 50 volt 5 Amp, I have not looked at the quality of the output (noise, overshoot all unknown to me)  but should be alright to control a lamp, a battery or a strip of LED's is my guess.


You can easily control the current and voltage output using a serial port. (a usb-serial-rs485 was provided)

I seems to talk modbus protocol.

To change the baud rate and modbus-slave-address, keep POWER button pressed during power on, this will enter you into the configuration menu.

register list here :
Register Map for this device.

Function
Description
Number of bytes
Decimal places
UNIT
Read/Write
Register address
U-SET Voltage setting
2
2
V
R/W
0000H
I-SET Current setting
2
3
A
R/W
0001H
UOUT Output voltage display value
2
2
V
R
0002H
IOUT Output current display value
2
2
A
R
0003H
POWER Output power display value
2
1 or 2
W
R
0004H
UIN Input voltage display value
2
2
V
R
0005H
LOCK Key lock
2
0
-
R/W
0006H
PROTECT Protection status
2
0
-
R
0007H
CV/CC Constant Voltage / Constant Current status
2
0
-
R
0008H
ONOFF Switch output state
2
0
-
R/W
0009H
B_LED Backlight brightness level
2
0
-
R/W
000AH
MODEL Product model
2
0
-
R
000BH
VERSON Firmware Version
2
0
-
R
000CH
EXTRACT_M Shortcut to bring up the required data set
2
0
-
R/W
0023H
U-SET Voltage settings
2
2
V
R/W
0050H
I-SET Current setting
2
3
A
R/W
0051H
S-OVP Over-voltage protection value
2
2
V
R/W
0052H
S-OCP Over-current protection value
2
3
A
R/W
0053H
S-OPP Over power protection
2
1
W
R/W
0054H
B-LED Backlight brightness levels
2
0
-
R/W
0055H
M-PRE Memory Preset Number
2
0
-
R/W
0056H
S-INI Power output switch
2
2
-
R/W
0057H



Here is the test code I wrote, works for me, if it burns down your house, sorry but not my problem. I just post my example code, I make no claims about it.




#!/usr/bin/env python

import random

import minimalmodbus

minimalmodbus.BAUDRATE = 19200
minimalmodbus.TIMEOUT = 0.5  # must be low latency somehow??
minimalmodbus.CLOSE_PORT_AFTER_EACH_CALL = False


def decode_response(b):
    if len(b) != 20:
        print len(b)
        return

    rv = {'U-Set': b[0] / 100.0,
          'I-Set': b[1] / 1000.0,
          'U-Out': b[2] / 100.0,
          'I-Out': b[3] / 1000.0,
          'P-Out': b[4] / 100.0,
          'U-In': b[5] / 100.0,
          'Locked': {0: 'OFF', 1: 'ON'}.get(b[6]),
          'Protected': {0: 'ON', 1: 'OFF'}.get(b[7]),
          'CV/CC': {0: 'CV', 1: 'CC'}.get(b[8]),
          'ON_OFF': {0: 'OFF', 1: 'ON'}.get(b[9]),
          'Backlight': b[10],
          'Model': str(b[11]),
          'Firmware': str(b[12] / 10.0),
          }
    return rv


if __name__ == "__main__":

    instrument = minimalmodbus.Instrument(port='/dev/ttyUSB0', slaveaddress=1)  # port name, slave address (in decimal)
    # instrument.serial.baudrate = 9600
    instrument.debug = False  # True

    for i in range(1000):
        try:

            temp = instrument.read_registers(registeraddress=0x0,
                                             numberOfRegisters=20)

            print decode_response(temp)

            v = random.random() * 25.0  # between 0 and 25 volt output setting
            i = random.random() * 5.0  # between 0 and 5 amp output setting

            print "set to {v:2} V {i:2} A".format(v=v, i=i)
            instrument.write_register(registeraddress=0, value=v, numberOfDecimals=2) # set V
            instrument.write_register(registeraddress=1, value=i, numberOfDecimals=3) # set I

            # set Limit Current and Voltage protection values
            instrument.write_register(registeraddress=0x52, value=v, numberOfDecimals=2)  # set V
            instrument.write_register(registeraddress=0x53, value=i, numberOfDecimals=3)  # set I

        except (IOError, ValueError) as e:
            print e

Reacties

Populaire posts van deze blog

Denon DHT T100 DESIGNED TO FAIL : bad caps (ceramic caps this time)

A friend gave me a Denon DHT-T100 to look at. Do not spend much time on it.. ok. It had a problem, it started clicking and ticking after power on, and after some time. (a so called intermittent problem) Sometimes it did not tick or click, but it was basically not usable. The clicking had a sharp click in one channel and repeated after about a second, then sound recovered and it would click and drop out again. He told me, do not spend any time on it, yeah, right. ;-) like I would give up after 15 minutes. I wanted to know what was going on with this thing, I found some schematic online and started measuring the usual things. The power supply, 24V did it drop down when a tick occurred ? Difficult to find out because sometimes the thing would play for hours without a glitch. I eventually found out the 24 V PSU, the step down SMPS on board and the LDO's were all ok, all power rails remained within spec, but it still glitched sometimes. (while power was ok) I investigat

Fixed voltage on cheap buck converter (MP1584) conversion with single 0805 resistor

Everywhere I look on the Ali and Ebays I see these step down converters based on MP1584. I bought a couple and actually they are not bad at all. The output voltage is set by the trimming-resistor in the left top corner of the picture. This works OK, but.. it is dangerous because it is rather sensitive to the touch. I decided that I wanted fixed output, so I had to figure out how this thing worked. The datasheet looks like this : R1 in the datasheet is what I call "R feedback" in my image. The value of R2 is mostly 8.2K Ohm in the boards I have seen.  So to set some common values for output voltage: change R1 to 27K for 3V3 output (actually 3.4 volt, but 27K is a standard value) or change R1 to 43K0 for 5.0 Volt output. (43 K is a standard value) A standard 0805 size resistor fits precisely, how convenient ;-). Make sure the other resistor is really 8.2K because that determines the feedback ratio. This way you can not burn up your circ

Aircon Repair on Hyundai Getz (on the hottest day of the year)

Yesterday was the hottest day of the year 2013 to date. Temperatures reached 36 degrees C. Normal value for this time of year is about 24 degrees (according to KNMI). My wife's car, a Hyundai Getz had a broken AC unit and I decided to fix it.  The AC light lit up just like normal but the clutch to the compressor did not kick in. After spending hours googling for schematics and diagrams, reading forums I found out why. The system is protected by a clever pressure switch, (conveniently located behind the glove compartment) It disables the clutch when pressure is too high or too low. After checking all things electrical, fuses, sensors, the clutch, the fans and switches I was out of options, I could not measure the pressure in the system. I visited a local car repair shop specialized in Airco systems, Rene van de Louw, st. Oedenrodeseweg 40, and he quickly noticed that I had a leak in my condenser. How? He put some pressure on the system with nitrogen and I could hear a hissing so