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

Raspberry Pi, PyFace Digital, the lost documentation, I found it finally

The Raspberry PI or R-pi from  http://www.raspberrypi.org/  is well known these days. It is not an accident that I have one, I have been doing Linux stuff since 1991, and professionally since 1996 I can not skip over these developments, have to keep up with the new kids. :-) Times have changed, hardware has become very affordable, everybody knows the Arduino , Raspberry Pi and Beagle-Bone-Black (BBB). Not everybody knows the stuff that  http://www.acmesystems.it/  aka Acme-Systems and  https://github.com/OLIMEX/OLINUXINO  aka  Olimex make, so I will endorse them here. Since I am an engineer I expect to connect switches and relays to the boards and some documentation with products, not so with the " PiFace Digital " board, it comes without serious documentation, not a even the schematic. All links on their blog point nowhere. People asked them many times, yet nowhere is the schematic to be found. I finally found some info after hours of google-work, someone made a c