Open iotlearner0level opened 6 years ago
hello, can you describe what you were trying to do? more info please. Could you confirm the baud rate? you have selected for the program matches the baud rate of your power supply. I have never tried the program from Windows. I will give it a go soon.
this happened as soon as i pressed the connect button. it showed lock, i saw a graph then this checksum error. serial link was over bluetooth so may be it was not receiving data properly. i think the program should not crash, it should just display a message and disconnect gracefully. the user should be given an oppertunity to try a reconnection until it succeeds. in addition there were some dependencies issues. i installed it using pip3 tool. there were some errors with print statement, i had to put everything next to the print within curly brackets, then there were no such errors. baudrate was 9600 exactly as in the official dps5005 program. however, i was using bluetooth connection so maybe distance was quite large...right now i don't have access to the device. will come back later with reduced distance..i suggest to you to explore windows10+bluetooth connection becuase a)windows is quite popular b) bluetooth makes it wire free, so we need not have a clutter of wire near our computers (and not blow it away due to wrong connections)
I discovered the python3 and brackets myself recently. I've been trying to figure out 'PyPi' and 'setup.py' to remove the hassle of installing dependencies when I came across the brackets missing. It will be easier to install the program soon.
So today I have installed the program in Windows 10 using python 3.6.5 and virtualenv.
when using 'pip install' I have these dependencies
configparser==3.5.0 future==0.16.0 iso8601==0.1.12 MinimalModbus==0.7 numpy==1.14.2 PyQt5==5.10.1 pyqtgraph==0.10.0 pyserial==3.4 PyYAML==3.12 serial==0.0.62 sip==4.19.8
using 'pip3 install' I get the same list however 'configparser' is not required.
Anyhow I can successfully connect and control the power supply via bluetooth, tested at a distance of approx. one metre. Not deliberate but just where it is located, previously I only used the USB link as Fedora my OS was being difficult with bluetooth.
i've a few more suggestions (i know it is asking too much for a free software) but i think, with these functionalities, your software will surpass original dps5005 soon:
but i think most important is to prevent the program from crashing and sending data to some cloud service...may be google drive/google sheets to begin with
Of course, maybe one day someone with the knowledge of dps5005 protocol will make/attach esp32 via bluetooth or a esp8266 via serial to dump all the data to the cloud!! and someone an android app ;-)
For the usb serial part, i don't like this idea at all! even today, while trying to make a 12V relay work from esp8266 while flashing the espurna firmware, some wrong pins touched other wrong pins and a USB3 port on my dell usb dock is completely dead....i can't do anything just happenned in 1 second :(
Anyway, thanks for your effort and sharing your program. really appreciated.
iotlearner0level, you have quite a wish list there. To do this I would need help. I have changed the program to prevent crashes when serial comms is dropped and some other minor tweaks. its currently sitting in 'branch_1' will push to master in a week or so.
lambcutlet first of all thanks for response. Please do not take wishlist too seriously, thats why i call it a "wish" :D
Right now i do not have access to the dps5005, i will report how it works but please give me some time! Ideally, i "wish" the original manufacturer used esp32 (or esp8266) instead of the bluetooth module which would have allowed both ble/and cloud logging. I think "cloud" logging is really powerful feature. I've been testing out batteries (nimh, 18650, nicd in various configurations, 1s, 2s, 4s etc) if it were possible to just send data from the "source" to some cloud service like thingspeak or google firebase, i will not have to go the place everytime. instead i can check from anywhere and plot the results! Google firebase is quite easy. i generally allow anonymous access to the realtime database. Then it is simply a matter of making a HTTP (they prefere https) POST request in json form to https://
Unfortunately i can not write complex software, nor do i know python, i am just another hobbyist know a little C++ from school.
Again thanks for your effort. This one is really useful because the original software doesn't have these features! I will come back later with my findings.
Just want to add that sending data to Thingspeak is very easy, it can be done in a bash script in fact, as I have done in the example below:
busybox wget -q -O- "http://api.thingspeak.com/update?key=$KEY&field1=$VOLTAGE&field2=$CURRENT"
No need to worry about sending the timestamp, as soon as the message posts to Thingspeak it uses the current UTC time as the timestamp. Updates can be sent at minimum 20s intervals at least for the free account. I use Thingspeak to graph data from ESP8266s mostly.
i hope you are still listening! now the program doesn't crash. but there are a few quirks:
hi, sorry to hear your having trouble. A quick fix would be to use a fixed com port. serial port can be fixed by modifying 'port_set' parameter within 'dps5005_limits.ini' i'll look into your com port problem.
i set port manually to COM3 but after some checksum error, it drops connection. it asks me to try again. after a few attempts it crashes. here is what i get on command window:
D:\Software\DPS5005_pyGUI-master\DPS5005_pyGUI-master\source_files> python.exe .\dps_GUI_program.py Manual port is set! ['COM3'] 9600 1 Disconnected Manual port is set! 19-03-09 16:24:08 Error - Checksum error in rtu mode: '\x00\x00' instead of '&è' . The response is: '\x00\x0e\x00\x00\x00\x00\x00' (plain response: '\x00\x0e\x00\x00\x00\x00\x00') PS D:\Software\DPS5005_pyGUI-master\DPS5005_pyGUI-master\source_files> python.exe .\dps_GUI_program.py Manual port is set! ['COM3'] 9600 1 def shutdown Disconnected Traceback (most recent call last): File ".\dps_GUI_program.py", line 51, in run result = self.fn(*self.args, **self.kwargs) File ".\dps_GUI_program.py", line 330, in off_change self.pass_2_dps('onoff', 'w', str(0)) File ".\dps_GUI_program.py", line 614, in pass_2_dps a = eval("dps.%s('%s', %s)" % (function, cmd, value)) File "<string>", line 1, in <module> File "D:\Software\DPS5005_pyGUI-master\DPS5005_pyGUI-master\source_files\dps_modbus.py", line 95, in onoff return self.function(0x09, 0, RWaction, value, self.limits.onoff_set_max, self.limits.onoff_set_min) # reg_addr, decimal_places, RWaction, value, max_value, min_value File "D:\Software\DPS5005_pyGUI-master\DPS5005_pyGUI-master\source_files\dps_modbus.py", line 174, in function self.serial_data.write(reg_addr, value, decimal_places) # register, value, No_of_decimal_places File "D:\Software\DPS5005_pyGUI-master\DPS5005_pyGUI-master\source_files\dps_modbus.py", line 56, in write self.instrument.write_register(reg_addr, value, decimal_places) # register, value, No_of_decimal_places File "D:\Software\Python37\lib\site-packages\minimalmodbus.py", line 296, in write_register self._genericCommand(functioncode, registeraddress, value, numberOfDecimals, signed=signed) File "D:\Software\Python37\lib\site-packages\minimalmodbus.py", line 697, in _genericCommand payloadFromSlave = self._performCommand(functioncode, payloadToSlave) File "D:\Software\Python37\lib\site-packages\minimalmodbus.py", line 798, in _performCommand payloadFromSlave = _extractPayload(response, self.address, self.mode, functioncode) File "D:\Software\Python37\lib\site-packages\minimalmodbus.py", line 1075, in _extractPayload raise ValueError(text) ValueError: Checksum error in rtu mode: 'Y;' instead of '\x00\x1b' . The response is: '\x00\x00\x00\x00\x00\x00Y;' (plain response: '\x00\x00\x00\x00\x00\x00Y;') Manual port is set! 19-03-09 16:24:37 Error - Checksum error in rtu mode: '\x01Ñ' instead of '\x1bP' . The response is: '\x01\x10\x00\t\x00\x01Ñ' (plain response: '\x01\x10\x00\t\x00\x01Ñ') Try again !!! Manual port is set! 19-03-09 16:24:42 Error - Checksum error in rtu mode: '\x0e9' instead of 'qL' . The response is: 'Ë\x01\x03\x02\x00\x0e9' (plain response: 'Ë\x01\x03\x02\x00\x0e9') PS D:\Software\DPS5005_pyGUI-master\DPS5005_pyGUI-master\source_files>
could this be due to character encoding difference in windows 10 and linux/python?
Are you using a USB cable or bluetooth connection? When the connection is lost do you press the 'Disconnected' button to force a reconnect?
Could you try something for me? modify file 'dps_modbus.py' by adding this minimalmodbus.CLOSE_PORT_AFTER_EACH_CALL=True
in the next line immediately after 'import minimalmodbus'
Bluetooth connection, distance is about 1 foot intel 9560/windows 10 64 bit yes i pres the disconnected button
After adding that line, program doesn't crash. however, it still drops connection quite frequently.
After disconnection/reconnection, previous data is lost
Official
Upper Control Software
doesn't drop connection over bluetooth. It holds connection to 'COM3' i've to connect and disconnect again very quickly to make the 'upper control software' to work otherwise that shows connection exception. Here is what i get on the commandline:
` D:\Software\DPS5005_pyGUI-master\DPS5005_pyGUI-master\source_files> python .\dps_GUI_program.py Manual port is set! ['COM3'] 9600 1 Disconnected Manual port is set! ['COM3'] 9600 1 Disconnected Manual port is set! ['COM3'] 9600 1 def shutdown Disconnected Manual port is set! ['COM3'] 9600 1 Disconnected Manual port is set! ['COM3'] 9600 1 def shutdown Disconnected Failed to write to instrument Manual port is set! Failed to read from instrument ['COM3'] 9600 1 Failed to read block from instrument Disconnected Manual port is set! Failed to read from instrument ['COM3'] 9600 1 Failed to read block from instrument Disconnected Manual port is set! Failed to read from instrument ['COM3'] 9600 1 Failed to read block from instrument Disconnected
`
iotlearner0level, in Device Manager -> Bluetooth, i see DPH5005_1, OK. in Device Manager -> Ports, i see two COM ports one (incoming) the second (outgoing). The net suggests connecting to (outgoing) as these ports are related to the order of connection. However I cannot get my DPS5005 to communicate using bluetooth. OS win10 64bit. From my searching windows doesn't seem to play nice with python and the COM port occasionally can block access to the port with a message suggesting you need admin access. The resolution for this is a reboot. People suggest its a bluetooth driver issue but i haven't got a fix for it yet. I'll persevere to find an answer.
iotlearner0level, in Device Manager -> Bluetooth, i see DPH5005_1, OK. in Device Manager -> Ports, i see two COM ports one (incoming) the second (outgoing). The net suggests connecting to (outgoing) as these ports are related to the order of connection. However I cannot get my DPS5005 to communicate using bluetooth. OS win10 64bit. From my searching windows doesn't seem to play nice with python and the COM port occasionally can block access to the port with a message suggesting you need admin access. The resolution for this is a reboot. People suggest its a bluetooth driver issue but i haven't got a fix for it yet. I'll persevere to find an answer.
i don't think it is a driver or reboot issue because the dps5005 software (made by the manufacturer) works ok without any connection drop. i think it is related to python<->COM movement. some buffer overflow/underflow problem? i am not knowledgeable enough so can't suggest anything more...
to be sure i checked the official software (it is called Upper software or something like that) works fine for 15 minutes or so which i checked. to be doubly sure, i tried my older laptop (on battery as well as power mains) and same problem with windows 10/64-bit and realtek wifi+bluetooth combo.
to connect to the bluetooth in windows 10, we first need to add the device using windows 10->settings->search for add bluetooth device. first pairing is required and a new COM port is created (in addition to the two you mentioned). we have to communicate through this new com port not the earlier ones. it can only be accessed by one device. so if another software is accessing that COM port it blocks connection.
iotlearner0level, I've added a new branch I would like you to test called 'IOT-test' My setup: OS: Fedora comms detected on my system: /dev/ttyS4 /dev/rfcomm0 'Bluetooth' the bluetooth connection takes approx 20seconds to connect. When the bluetooth link is made there is some serial comms between the bluetooth board HC-05 and the PSU. The comms 'AT?' and 'CONNECTED' may confuse the PSU which delays the initial data transfer. Please provide feedback with your results.
iotlearner0level, I've added a new branch I would like you to test called 'IOT-test' My setup: OS: Fedora comms detected on my system: /dev/ttyS4 /dev/rfcomm0 'Bluetooth' the bluetooth connection takes approx 20seconds to connect. When the bluetooth link is made there is some serial comms between the bluetooth board HC-05 and the PSU. The comms 'AT?' and 'CONNECTED' may confuse the PSU which delays the initial data transfer. Please provide feedback with your results.
i will try when i get time. right now, i am a bit tight on time.
Hey no problem.
I get this error: Traceback (most recent call last): File ".\dps_GUI_program.py", line 377, in loop_function self.read_all() File ".\dps_GUI_program.py", line 406, in read_all data = self.pass_2_dps('read_all') File ".\dps_GUI_program.py", line 489, in pass_2_dps a = eval("dps.%s('%s', %s)" % (function, cmd, value)) File "", line 1, in
File "C:\Users\XYZ\Downloads\DPS5005_pyGUI-master\source_files\dps_modbus.py", line 127, in read_all
data = self.functions(0x00, 16, RWaction, value) # reg_addr, number of bytes, RWaction, value
File "C:\Users\XYZ\Downloads\DPS5005_pyGUI-master\source_files\dps_modbus.py", line 158, in functions
return self.serial_data.read_block(reg_addr, num_of_addr)
File "C:\Users\XYZ\Downloads\DPS5005_pyGUI-master\source_files\dps_modbus.py", line 44, in read_block
return self.instrument.read_registers(reg_addr, size_of_block)
File "D:\Software\Python\Python36-32\lib\site-packages\minimalmodbus.py", line 498, in read_registers
numberOfRegisters=numberOfRegisters, payloadformat='registers')
File "D:\Software\Python\Python36-32\lib\site-packages\minimalmodbus.py", line 697, in _genericCommand
payloadFromSlave = self._performCommand(functioncode, payloadToSlave)
File "D:\Software\Python\Python36-32\lib\site-packages\minimalmodbus.py", line 798, in _performCommand
payloadFromSlave = _extractPayload(response, self.address, self.mode, functioncode)
File "D:\Software\Python\Python36-32\lib\site-packages\minimalmodbus.py", line 1075, in _extractPayload
raise ValueError(text)
ValueError: Checksum error in rtu mode: '\x8d\x00' instead of 'Jt' . The response is: '\x01\x03 \x00\x96\t─\x00\x95\x00Z\x00\r\x07ñ\x00\x00\x00\x00\x00\x00\x00\x01\x00\x04\x13\x8d\x00' (plain response: '\x01\x03 \x00\x96\t─\x00\x95\x00Z\x00\r\x07ñ\x00\x00\x00\x00\x00\x00\x00\x01\x00\x04\x13\x8d\x00')
PS C:\Users\XYZ\Downloads\DPS5005_pyGUI-master\source_files> D:\Software\Python\Python36-32\python.exe .\dps_GUI_program
.py
Traceback (most recent call last):