PDA

View Full Version : Usb to ttl modules - connection to pics at 3.3v



longpole001
- 4th March 2015, 13:01
HI Guys,

I have had a need to use a number of USB to TTL modules for a project

Most have either been the PLH2303 or CP2102 modules

one problem i had found was that when the USB module was connected to the a 3.3v pic ( gnd , RX,TX only) and the usb was powered via the usb cable , the pic was not happy

the pics RX pin was at 5v and the PIC would not power down correctly or do some strange things while the usb cable was connected to the PC and the PIC powered down.

to resolve this i placed a 4k7 resistor in line with the USB-RX to the PIC RX input , dropping the voltage to about 1.8v ( when the PIC is powered down, but the USB cable is still connected)


wondered if other have seen this issue when using USB on PIC running at 3.3v ?


also i have found when the PIC was running DT's INT_RX to detect terminal input and the USB cable to the USB -ttl model was not connected the PIC RX input was low , which triggered the ISR , slowing the PIC down to service an invalid input

as a result i placed a 100k resistor to 3.3v to ensure when the USB is not connected the ISR is not triggered
note: prior to using a 100K pullup a 4k7 was tried , but cos of the above fix of 4k7 in line to stop issues with 5v input signal the low going pulse was not strong enough to get consistent inputs for the RX line


I wonder if others have had this problems with interfacing the USB to TTl modules to 3.3v pic application ?

cheers

sheldon

Charlie
- 4th March 2015, 13:28
Not sure why you are surprised that applying 5V signals to a PIC running at 3.3 V is a problem. Either level shift the adapter to 3.3 V signals or run the PIC at 5V.

pedja089
- 4th March 2015, 15:44
Simple solution is to use 2x transistor inverter(http://hyperphysics.phy-astr.gsu.edu/hbase/electronic/ietron/bufi2.gif), or optocoupler on USB Tx pin...
Or use one inverter with transistor if your pic suport inverted UART input.

longpole001
- 4th March 2015, 17:33
always thought the PIC input pins are 5v tolerant
the resistor 100k pull up to 3.3v and the 4k7 inline solved the problem for the USB RX pin into the PIC , but perhaps a level converter would be best

pedja089
- 4th March 2015, 18:06
Problem is when pic doesn't have supply voltage, current flow from Tx pin thru resistors, parasitic diode between pin and Vdd, and charge capacitors on Vdd. When voltage rise above 1,8V, pic start, and then lock up, doing weird things...

Charlie
- 5th March 2015, 13:24
5 V tolerant does not mean nothing happens when you connect a signal higher than Vdd. It simply means you won't permanently damage the device. Pedja089 is absolutely correct. If there is a 3.3 supply in place, it's low impedance sinks the current from the signal pin. If the supply is not there, the signal voltage tries to power the PIC. With a big series resistor, there is not enough current available to power the PIC. So leave the resistor - a level shifter likely won't solve the problem.

longpole001
- 5th March 2015, 22:05
yes 4k7 in series with the usb ttl module is needed , i am also thinking there must be usb -ttl modules that have a 3.3v signal in/ out level option

Charlie
- 6th March 2015, 00:38
Here you go...https://www.sparkfun.com/products/12009

rsocor01
- 6th March 2015, 05:42
yes 4k7 in series with the usb ttl module is needed , i am also thinking there must be usb -ttl modules that have a 3.3v signal in/ out level option

FTDI makes their USB/serial for 5V and they also have a 3.3v version. Have you tried the 3.3v FTDI USB version?

tumbleweed
- 6th March 2015, 09:40
You'll have the same problem with a 3V3 converter if you apply an input signal to an unpowered PIC unless the pin doesn't have protection diodes.

Charlie
- 6th March 2015, 13:43
Agreed - anything you use can't be allowed to supply power. The PIC input should be connected to the PIC supply through a resistor, and then a diode (or equivalent) connected in series in the signal line, with the anode connected to the input pin. The serial converter can then only pull low. When it's high, the diode makes it high impedance, and the resistor pulls high to the PIC VDD. When power is removed everything will then truly shut down.
This problem has nothing to do with 5 V vs 3 V. It's all about a low impedance signal source, idle state high, able to supply enough current to power the PIC through the protection diode.

Dick Ivers
- 6th March 2015, 20:07
Charlies's approach sounds good. Would it not be wise to use a Schottky diode to keep the low input to the PIC as low as possible?

Charlie
- 7th March 2015, 00:33
Can if you like, or if signal speed is an issue, but otherwise it doesn't matter. Any old diode in the box will do.

longpole001
- 7th March 2015, 23:09
the modules on hand give a 5v signal,, and provide a 3v output when cable connected to the pc - usb

but there are a few that appear to be able to select a 3v or 5v input to vcc and should give a 3v signal input/output
http://www.ebay.com.au/itm/USB-To-RS232-TTL-CH340G-Converter-Module-Adapter-STC-replace-Pl2303-CP2102-M71-/291297583731?pt=LH_DefaultDomain_0&hash=item43d2b06273


yes the diode is a good idea , since the 4k7 is in line already a schotky is better to reduce the signal drop

think this is the way to go with 5v modules

7727

tumbleweed
- 8th March 2015, 00:48
It'd be better to move R4 so that it's directly on the USB_RXD pin. That way it won't create a voltage divider w/the pullup.

Charlie
- 8th March 2015, 00:56
*sigh*. It would actually be hard to get it more wrong. The problem is with TX, not RX. The arrow heads to the PIC are the wrong direction, as are the labels on the PIC side of those arrows. The Diode is in the wrong leg. It needs to be between pin 3 of the module, and the RX pin of the PIC. The 4.7 K resistors are doing nothing - replace with a short. The 100K is way too big, replace with 4.7K. For RS-232 signals, schottky makes no difference. Use it if you have extra, but don't run out to buy one if all you have is a 1N914. On the positive side, the diode is in the correct direction.

You should probably test it before posting an update to the schematic. As shown it should not work at all.

Dick Ivers
- 8th March 2015, 17:12
I must be missing something regarding the discussion of the benefit of using a Schottky diode in this application. From a reading of the PIC data sheet the maximum pin input voltage for the low state is 0.8 volts. The USB module is said to be TTL ... so I believe its normal working range would be 0 to 5 volts. An ordinary diode's forward drop is about 0.7 volts whereas a Schottky is typically 0.3 volts. Therefore, the Schottky would provide 0.5 volts of noise margin, but the normal diode only 0.1 volts of margin.

longpole001
- 9th March 2015, 05:28
ok thanks guys ,
what stuff up that last cct was

this appears to work after some testing

placed a NCH mosfet i had on hand ,

the internal diode of the mosfet is blocking the 5v signal from the TTL module
when usb cable is connected , but PIC Pwr is not on, then mosfet gate is inactive ,
the mosfet acts as level converter from PIC TX 3.3v signal to the 5v on the RX TTL module ,

the pic TX line is pulled high internally, TTL Rx line is also pulled high , so no additional pullups are required on the Source or Drain of the mosfet

this stops any signal power to the PIC until its powered up , Tried fitting resistor to TTL RX line but found 2v is always going to be there


D2 stops the voltage from TX of the TTL module to the pic when powered down , 4k7 pull up on input RX to pic at 3.3v

D2 is better to be a schotcky ( i have many of both ) as the low going signal swing was going closer to ground than using a standard signal diode , but both worked ok

cheers

Sheldon

7733

Charlie
- 9th March 2015, 13:12
Almost perfect. The FET is serving no purpose - replace it with a piece of wire and you have the final circuit.

By the way, not sure what purpose USB_ON is serving since you don't show where it's connected, but if it is going to the PIC, then that is another source of parasitic powering. As a matter of fact, it's probably the true source of your problem, since thinking back, I've never seen a 2303 TX signal able to parasitically power a PIC. 3V3, however, is intended to supply a bit of power. Also what purpose does R8 serve?

longpole001
- 10th March 2015, 01:12
7734

the mosfet stops the 5v pullup voltage on RX from usb module , which is there when usb cable is in , without it voltage is being applied to the PIC TX pin when, the pic is not powered

this caused other PIC pins to float to 1.8v - measured 4 pins that eventually got to 2v

the mosfet also allows the voltage at PIC TX pin to stay at 3v3 and the RX on usb module to stay 5v when they are connected - when the PIC is on

the "usb_On" signal was not used in the testing yesterday , but signal is to be isolated when the PIC is not on , but the usb cable is in , will test this today

it is intended to indicate to the PIC that the usb power is there and adjusts others settings / program options

R8 is Changed now other mosfet on "usb_on" signal is connected

longpole001
- 10th March 2015, 01:14
wrong image should be this one


7735

Charlie
- 10th March 2015, 13:20
Which PIC are you using? I measured a PL2303 module and the RXD pin (4 in your drawing) is floating at 1.8V idle, and not able to supply much current. As an input, it shouldn't be able to supply any, but some input designs allow a little in unusual conditions. To power the PIC through the protection diode, the PIC would need to operate down to 1.2 V or less, and would need to draw very little current. So I want to check the spec sheet for you. Maybe you actually have an out of spec device. The TXD pin (3 on your drawing) sits at 4.5 V and is designed to supply current, so it should be the only culprit. D2 fixes that.

The circuit you have on the USB_ON pin will work, but might be a bit more traditional if the gate went to the module and the drain went to the PIC VDD. This would allow you to use it with VDD at any (reasonable) voltage without having to change the circuit.

longpole001
- 10th March 2015, 22:28
Hi charthe pl2303 ttl module has TX, RX led with a 1.5k resistor on each signal , which is pulling the line high , looking at the pcb

the module is one of these

7737

there are 3 pic chips i am testing this usb modules on - 18f67k22 ,18f87k22, 18f46k80 , the measurments so far are using the 18f67k22

there are 3 usb - ttl modules to be tested and checked cp2102 module , pl2303 module , ch340G module

i am still trying to get the correct cct for each of ttl modules / boards i am using for the test

But from a quick look on the net and the boards them selves , there is wide number variations and ways they make the boards , some have leds on the TX,RX line , with different values of resistors inline on those lines others do not

i want to ensure that no mater what ttl usb module of the 3 i am testing , the PIC is not powered or effected by the different possible TTL modules

A design making use of USB -TTL modules needs to allow for this.

the mosfet ensures no possible voltage from the TTL MODULE RX line to the TX on the pic , when the PIC is not powered . regardless of TTL module used


cheers

Sheldon

longpole001
- 10th March 2015, 22:45
hi charlie ,


The circuit you have on the USB_ON pin will work, but might be a bit more traditional if the gate went to the module and the drain went to the PIC VDD. This would allow you to use it with VDD at any (reasonable) voltage without having to change the circuit.


yep that seems like a good idea and is a more traditional approach

longpole001
- 12th March 2015, 20:03
well after testing 3 different USB modules and 3 different pics , the cct works well , the requirement to isolate the TTl signals when the the PIC is not on is a requirement that should be done when using the USB -ttl models