Odd RS232-USB (CH340) Connection Behaviour

martinwinlow

New Member
Hi,

I hope someone can help with this...

I have an old PICAXE-based project that I resurrected to try to test the serial port on an old laptop that I want to use for some legacy work (connecting to the digital inverter on a 2007 electric Ford Transit conversion).

First I confirmed the PICAXE project was still working and sending text data out using the project's original 3.5mm stereo jack connector and using the AXE027 serial-USB lead to connect project to laptop and it worked normally, outputting the text that the project generates into Hyperterminal running on the laptop.

Then I tried using a CH340 RS232-USB adaptor and despite connecting the Tx wire and ground connections from the PICAXE stereo jack to the correct pins on the CH340's USB port got no output. So I tinkered... and to my surprise found that with PICAXE gnd connected to (CH340 DB9)Pin 5 and PICAXE TD connected to (CH340 DB9)Pin 4 ('DTR' pin, not 'RD' Pin 2 as I understand it should be) the serial output appears correctly in the Hyperterminal window! What the heck is going on?!

I would also welcome a suggestion as to how I can test the laptop's serial port. I want to be sure it works properly before I try connecting to the Transit's inverter.

Thanks in advance, Martin Winlow.
 

premelec

Senior Member
Manual 1 under serial [p44 in my version] shows D9 pin2 to serial out, pin3 to serial in, pin5 v- - if you have the old PICAXE d9 to phone plug that should work... and should already be wired that way...
 

martinwinlow

New Member
Sorry but I don't have the 'proper' PICAXE DB9 cable - I'm just connecting the PIC output to the CH340 DB9 (female) via a male DB9 soldered to a bit of 2 core shielded cable and stereo jack...
 

Technical

Technical Support
Staff member
Remember a male 9 way pinout is mirrored to a female pinout so pin 4 may 'look' like pin 2...
 

premelec

Senior Member
"I would also welcome a suggestion as to how I can test the laptop's serial port. I want to be sure it works properly before I try connecting to the Transit's inverter."

You don't need the CH340 for this - just use D9 to stereo plug connections...
 

martinwinlow

New Member
I wish it were that simple - double checked it and defo pin 5 (gnd) and 4 (Rx'ing)... but at least you have made me revisit the PICAXE website and confirmed that my laptop (with serial port) should work with the PIC directly... and it isn't at the moment! I'll have another go.
 

hippy

Technical Support
Staff member
double checked it and defo pin 5 (gnd) and 4 (Rx'ing)
It might be worth posting a photo just to dispel any scepticism there may be.

It is possible that mis-wiring things may still work because voltages are all relative to some point we just conveniently call "0V" or "ground", so signals may still be seen even if things are not actually what would be expected.
 

lbenson

Senior Member
I would also welcome a suggestion as to how I can test the laptop's serial port. I want to be sure it works properly before I try connecting to the Transit's inverter.
Don't know if you have successfully done this yet or not. Check in Device manager in Control Panel to see what the serial port number is. Then connect a terminal program (like putty) to the port at any baud rate (but preferably the one you will be using). Short RX & TX (pins 2 and 3 on a DB 9, or the designated pins on a usb/serial module). (I have used a hand-held paper clip to short the pins, or an alligator clip.) Then when you type, the characters should appear on the terminal screen.
 

martinwinlow

New Member
A-ha! Now you mention it, I remember reading about this decades ago when serial ports were much more mainstream. I'll give it a go, thanks. MW
 

martinwinlow

New Member
Hi,

I have tried the loop-back test and with pins 2 & 3 connected nothing happens when I type at the keyboard.

However, with pins 3 & 4 connected...

Mis-wired USB-RS232 cable 1.jpgMis-wired USB-RS232 cable 1.jpeg

... the chars appear. WT flippin'-heck F? ...or am I being dim?

MW
 

lbenson

Senior Member
Are those the characters you typed?

What happens if you short pins 2 & 3 on your PC? If that works, there's something wrong with the cable.

Do you have a non-db9 usb/serial module to test?
 

martinwinlow

New Member
Are those the characters you typed?

What happens if you short pins 2 & 3 on your PC? If that works, there's something wrong with the cable.

Do you have a non-db9 usb/serial module to test?
I should have made it clear that the DB9 connector in the photos is the serial end of a CH340 RS232-USB adaptor cable as I don't have a serial port on this laptop (the laptop that does have one appears to be malfunctioning as the loop-back test does not work and scoping the TX pin shows nothing as I type at the keyboard whilst doing the same with the CH340 connected to the laptop shows very nice what I assume is binary coded square wave patterns at 0-5V - I think it was). And I don't have a non-db9 usb/serial module to test.
 
Last edited:

Pongo

Senior Member
A loopback test is less confusing if you use a split window (send/receive) terminal program like AccessPort - also a very handy terminal to use when testing devices that communicate in Hex :)
 

inglewoodpete

Senior Member
I should have made it clear that the DB9 connector in the photos is the serial end of a CH340 RS232-USB adaptor cable as I don't have a serial port on this laptop (the laptop that does have one appears to be malfunctioning as the loop-back test does not work and scoping the TX pin shows nothing as I type at the keyboard whilst doing the same with the CH340 connected to the laptop shows very nice what I assume is binary coded square wave patterns at 0-5V - I think it was). And I don't have a non-db9 usb/serial module to test.
Your photograph in post #12 is of a DE9 female connector. This breaks the tradition that serial connectors from PC COM ports are usually male. I just checked the COM port on my PC (the motherboard has a true serial header) and also a couple of aftermarket USB to serial adapter cables (Prolific PL2303 and ATEN UC-232A). The male plugs have pin numbering from the left 1-2-3-4-5. The photo shows, and as we would expect, your female plug has pin numbering reversed 5-4-3-2-1.

You have found that serial in and out appear on pins 3 and 4. I suspect this is a consequence of getting a cheap knock-off of the standard (no offence intended). The send and receive legs appear in the correct positions for a USB to serial adapter cable but are on a female version of the plug, with correct pin numbering embossed in it.
 

hippy

Technical Support
Staff member
The send and receive legs appear in the correct positions for a USB to serial adapter cable but are on a female version of the plug, with correct pin numbering embossed in it.
Well spotted. And that does look to be the correct answer. It's a working USB to serial adapter but they erroneously fitted a female socket rather than a male plug to it. The connections therefore go to the wrong pins.

With two 9-way plugs you should be able to make an adapter to fix things.
 

lbenson

Senior Member
There appear to be lots of differences between different usb to DB9 CH340 cables. I have one which is considerably faster than my PL2303 DB9 cables in doing a picaxe download. However, I've bought about a half dozen other CH340 USB/DB9 cables and haven't found one which works for the download at all (no break implementation, I suppose, though I haven't tried to debug in detail).
 
Top