[SOLVED] Can't get UT61E RS232 interface working on Linux - Page 1
Forum section: electronics / testgear

author: TheoB
author_rank: Regular Contributor
timestamp: December 20, 2016, 11:33:10 pm
content: The UT-61E came shipped with a nice optical RS232 cable. I connect it via a RS232 to USB converter to my PC. But it does not work. I see data but the data is different from what it should be. I want to isolate the problem to either the UT61E being broken or the RS232 adapter being "bad". I foundthis threadthat explains which adapter is supposed to work, and which one not. But RS232 is such a simple protocol I think it should work with any adapter (if drivers are OK, but since I'm on LInux I don't have those issues...)So I decided to investigate and measured the RS232 interface signals on the connector. From there I could see the levels that were used, the timing and the data being send.This is an example of a "1" captured (ASC=49, 0b110001):The problem I see with the UT61E is that a logic bit should be 52us (1/19200) but I measure 69us. The captured signal consists of a start bit(1) 7 bits of data (1000110) a parity bit (1) and a stop bit (0). So 10 bits are exactly 10/19200=520us. The timing of each character is exact, but the 1 is always 69us and a 0 is always 35us. To me this looks like a lot of margin is eaten by the UT61E. 69us is 69/52=1.32 bit interval. A perfect receiver should determine the value in the middle of each bit, at 1.5. If my Chinese adapter also needs such a margin, it is not going to work. Is my meter not OK, or are such deviations normal for RS232?

author: DimitriP
author_rank: Super Contributor
timestamp: December 20, 2016, 11:43:45 pm
content: Since you are on linux, what happens if you docat < /dev/PortNameHere?if the port is receiving data, you should see characters flying by, if it looks like gibberish, the port is set to the wrong speed.

author: TheoB
author_rank: Regular Contributor
timestamp: December 21, 2016, 12:05:42 am
content: Yes that works. But what I receive is a byte valued 3 were I expect a byte values 48 ("ascii 0"). I measured the speed and it is exactly 19200 Baud. I've found several references about this, for instancehttps://www-user.tu-chemnitz.de/~heha/hs/UNI-T/UT61E.LOG. I tried with all kind of terminal emulators. All seem to have the same problem, garbage out. And of course I still tried all settings as well, but no success.

author: DimitriP
author_rank: Super Contributor
timestamp: December 21, 2016, 12:21:23 am
content: QuoteWell... RS232-USB adapters have ruined many perfectly good afternoons and weekends for many people over the years... At this point you probably should try a different adapter which is easier (and cheaper) than trying a different UT61E

author: cdev
author_rank: Super Contributor
timestamp: December 21, 2016, 04:37:01 am
content: Has anybody managed to use their UT-61E with a USB-to-serial adpater ? On WIndows or under Wine.

author: BBBbbb
author_rank: Unknown
timestamp: December 21, 2016, 04:50:43 am
content: I've used mine without any problems (FTDI chip), but I did have a problem of optical alignment on the UT61E end, the connector was small/short and the IRs were just a little bit under the ones on the UT, so I had to pull it up just a little bit to work. Just small blind movement up and trying the communication until I got it in place.Sent from my C6903 using Tapatalk

author: Sairus
author_rank: Contributor
timestamp: December 21, 2016, 06:07:31 am
content: Quotehttp://www.cyrustek.com.tw/spec/ES51922.pdfpage 21QuoteI use cheap adapter from ali (it look like that onehttps://www.aliexpress.com/item/USB-to-RS232-cable-USB-serial-transfer-line-laptop-serial-mini2440-OK6410-tiny6410-Wholesale/32525491623.html) work ok.Just for fun I use OTG cable with this adapter and got data from DMM by using terminal app.

author: thisguy
author_rank: Contributor
timestamp: December 21, 2016, 06:27:09 am
content: Quote from: TheoB on December 21, 2016, 12:05:42 amHere's the stty command that I use to set up the port. I issue this:'stty -F /dev/ttyUSB0 ispeed 19200 cs7 parodd istrip igncr'thencat /dev/ttyUSB0and get the expected result.It looks like you might have the polarity backwards on the scope decode. Try changing the rs232 decode polarity. Also, the scope rs232 decode only understands what's on the screen, so if what is being displayed doesn't start with the start bit, the decoded data will be wrong.If the above stty command doesn't fix it for you, it's possible that polarity from the UT61E serial cable doesn't match your serial/USB adapter. (RS232 logic: low=1. ttl logic: high=1) If that's the problem, a single $0.02 transistor between rx pin, rx wire and ground might fix it.Sorry, never messed with it on wine or windows.

author: SingedFingers
author_rank: Frequent Contributor
timestamp: December 21, 2016, 07:55:09 am
content: Incidentally I couldn't get mine to work at all with various USB<->serial cables. I had to plug it into my desktop which has a real serial port. Worked fine there.

author: TheoB
author_rank: Regular Contributor
timestamp: December 21, 2016, 09:23:00 am
content: QuoteThe scope decodes fine. I put it on line to show the exact bits it sees (which are correct).I tried the exact same stty command and get this (od added to show the values, otherwise it is garbage):Code:$ cat /dev/ttyUSB0|od -c0000000 003 003 003 003 003 033 002 003 003 023 003 \v \b 021 003 0030000020 003 003 \v 032 002 003 003 023 003 \v \b 0210000034$ cat /dev/ttyUSB0|od -x0000000 0303 0303 1b03 0302 1303 0b03 1108 03030000020 0303 1b03 0302 1303 0b03 11080000034I know it should end with\r \nl (0D 0A).This linkgives a nice overview of what the meter outputs.I partly solved the duty cycle distortion by pulling the adapter a bit out from the meter. The pulse width reaches close to 52us just before it completely fails. I do see some bits toggle during the exercise, but the data is not correct. I think that rules out the UT61E.Found some old threads about the ch341 device driver (ch341 5-1:1.0: ch341-uart converter detected). It mentions it did not support parity. But I can easily work around that in software (just assuming 8 bits of data and stripping the MSB).Probable best to try the aliexpress adapter.......

author: TheoB
author_rank: Regular Contributor
timestamp: December 23, 2016, 06:29:20 pm
content: Dual booted to Windows 10. Tried Putty and that did not work as the DTR (data terminal ready) line did not go high (and that is the power of the sensor). I could manually get it to work by powering it externally. I then tried dmm.exe and that worked out of the box. So meter is OK, rs232 => usb adapter is ok. It must be a driver issue under Linux.Any suggestions for an adapter not based on the 341 chip that runs under Linux?I just noticed the 341 driver is loaded but the chip reports 340.TheoFor ther record: I'm running Linux Mint with kernel 4.4.0-57-genericAdapter details:Code:sudo lsusb -s 005:002 -vBus 005 Device 002: ID 1a86:7523 QinHeng Electronics HL-340 USB-Serial adapterDevice Descriptor:bLength 18bDescriptorType 1bcdUSB 1.10bDeviceClass 255 Vendor Specific ClassbDeviceSubClass 0bDeviceProtocol 0bMaxPacketSize0 8idVendor 0x1a86 QinHeng ElectronicsidProduct 0x7523 HL-340 USB-Serial adapterbcdDevice 2.54iManufacturer 0iProduct 2 USB2.0-Ser!iSerial 0bNumConfigurations 1Configuration Descriptor:bLength 9bDescriptorType 2wTotalLength 39bNumInterfaces 1bConfigurationValue 1iConfiguration 0bmAttributes 0x80(Bus Powered)MaxPower 96mAInterface Descriptor:bLength 9bDescriptorType 4bInterfaceNumber 0bAlternateSetting 0bNumEndpoints 3bInterfaceClass 255 Vendor Specific ClassbInterfaceSubClass 1bInterfaceProtocol 2iInterface 0Endpoint Descriptor:bLength 7bDescriptorType 5bEndpointAddress 0x82 EP 2 INbmAttributes 2Transfer Type BulkSynch Type NoneUsage Type DatawMaxPacketSize 0x0020 1x 32 bytesbInterval 0Endpoint Descriptor:bLength 7bDescriptorType 5bEndpointAddress 0x02 EP 2 OUTbmAttributes 2Transfer Type BulkSynch Type NoneUsage Type DatawMaxPacketSize 0x0020 1x 32 bytesbInterval 0Endpoint Descriptor:bLength 7bDescriptorType 5bEndpointAddress 0x81 EP 1 INbmAttributes 3Transfer Type InterruptSynch Type NoneUsage Type DatawMaxPacketSize 0x0008 1x 8 bytesbInterval 1Device Status: 0x0000(Bus Powered)$ modinfo ch341filename: /lib/modules/4.4.0-57-generic/kernel/drivers/usb/serial/ch341.kolicense: GPLsrcversion: 9E73466FFB6B6191F10D294alias: usb:v1A86p5523d*dc*dsc*dp*ic*isc*ip*in*alias: usb:v1A86p7523d*dc*dsc*dp*ic*isc*ip*in*alias: usb:v4348p5523d*dc*dsc*dp*ic*isc*ip*in*depends: usbserialintree: Yvermagic: 4.4.0-57-generic SMP mod_unload modversions

author: joeqsmith
author_rank: Super Contributor
timestamp: December 23, 2016, 06:39:24 pm
content: I tried mine under Windows 10 using an FTDI adapter and with the built-in port on my new PC. I also tried it with my old PC and it seemed very solid.

author: TheoB
author_rank: Regular Contributor
timestamp: December 23, 2016, 09:29:55 pm
content: Quote from: thisguy on December 21, 2016, 06:27:09 amDo you have a ch341 based adapter?I tried to invert the rx line and that also does not work. Instead of 3 I now receive 18 as value for zero (should be 48). Reason I still try to make it work is that I have to wait for another adapter for a couple of weeks to be delivered. So in the mean time I play around to see if I can get it to work. I found one other mention of the data inversion. The Linux driver was not detecting that automatically. So that made me do this one transistor exercise.I plan to buy a PL2303HX based one to see if that works better.

author: cv007
author_rank: Frequent Contributor
timestamp: December 24, 2016, 02:54:24 am
content: Maybe you have done this already, but try using 8N1 letting the parity bit come in as data (MSb set or not set- just discard MSb). If the driver is botched, I would think they would at least get 8N1 right.Also, just jumper tx/rx on the adapter, then send data (a text file or whatever) over the terminal with echo off and see what you get back. Try it with 8N1 and 7O1 and see if 7O1 even works.

author: Marc M.
author_rank: Regular Contributor
timestamp: December 24, 2016, 07:26:25 am
content: I purchased the GW Instek version (GDM-461) because it had better input protection compared to the Uni-T version. I repair CNC machining centers and occasionally I run into intermittent faults which may not appear for a few days making them exceedingly difficult to troubleshoot. To help find these faults I wanted to set up a data logger with time stamps for long term monitoring of a suspected supply voltage, input line, etc. but couldn't justify the $$$ for a commercial meter.I have a bunch of Arduino Mega's laying around so I picked up the 461 to use with one and roll my own logger. I ran into the same issue, I couldn't get either my laptop thru a RS232 to USB converter or the Mega to read the 461 data stream. I hooked up my Rigol to it and found the RS232 output was inverted. Whacked together an inline inverter and both were able to read it without a problem.I designed a shield for the Mega with a micro-SD slot, RTC, inverter, buzzer, and a relay. I should be getting the boards from iTead next week. The idea behind the buzzer was to alert the user if whatever was being monitored exceeded a preset parameter, typically under/over voltage/current. Similar idea for the relay allowing me to stick a light outside of the electrical cabinet where you probably won't hear the buzzer, shut things down if it's critical, etc.My biggest hurdle is the software side. I suck at software and struggle with getting even simple things to work correctly. I've got it decoding properly, it's really the UI that's been very slow going. If someone is interested in writing the software for it, I'd be happy to send them a shield in return. PM me to work out the details.

author: thisguy
author_rank: Contributor
timestamp: December 24, 2016, 09:15:36 am
content: Quote from: TheoB on December 23, 2016, 09:29:55 pmMy adapter uses a ch340 chip. It does 3v or 5v ttl voltage levels. I had to invert rx to make it work.

author: TheoB
author_rank: Regular Contributor
timestamp: December 24, 2016, 12:14:09 pm
content: Quote from: cv007 on December 24, 2016, 02:54:24 amI played with that idea indeed. I can remove the parity myself if that would be the only thing. The jumper between TX and RX I had not tried so that's a good suggestion. I tried and the result is weird. It does not work, so I monitor on the scope. I can see that the TX data is plain wrong. 8N1 coded data comes out with some characters correct if I ignore the MSB bit (so 7 bit decoded on the scope). But others characters come out upper case instead of lower case. There is no difference in upper and lower case anyhow. Regardless of how it's encoded, I should see difference between upper and lowercase characters.I compiled the driver from the manufacturer website (CH341SER_LINUX) and get the same result. Unless someone has an idea I have to wait for the PL2303HX I ordered.

author: TheoB
author_rank: Regular Contributor
timestamp: December 24, 2016, 02:32:31 pm
content: Solved. I had to take the following steps:Driver needs to be patched. I followedthis articleData should not be inverted. The data is correct coming from the UT61E.Data should be read as 8N1 So 8 bits no parity 19200 baud. Reason for that is that the driver does not support 7 bit data. I'm not sure if that is true, but it is mentioned in the driver patch:QuoteI tried and 7 or 8 bits gives exactly the same output.After I read in the data I ignore the MSB (parity bit).Now my output looks like this:Code:python read_dmm.py100000;00080Not very exiting yet, but I can now focus on the python code

author: lordvader88
author_rank: Frequent Contributor
timestamp: December 25, 2016, 02:58:18 am
content: My cheap DDM can be modded to use its RS232 chip pinout.But how old r all these DDM chips if RS232 is all they mainly use??? Even new very expensive quality DDMs use it , WHY??

author: cdev
author_rank: Super Contributor
timestamp: December 25, 2016, 03:24:12 pm
content: They use it both out of habit and becauseit's the standard in this context, simple, and usually works. It's the subsidiary adaptors that make it difficult. Problem is solved magically if you have a real serial port, or better adaptor. It's not the chip so much as the presence of the other lines in the adaptor.UT61s use of opticals isolation makes it more useful. Another option would be Bluetooth.