Shop OBEX P1 Docs P2 Docs Learn Events
A Cheap easy way to interface Prop with 5V Peripherals — Parallax Forums

A Cheap easy way to interface Prop with 5V Peripherals

ElectronegativityElectronegativity Posts: 311
edited 2014-07-31 19:32 in Propeller 1
These things will convert signals from 3.3V to 5V in one direction and 5V to 3.3V in the other: http://focus.ti.com/lit/ds/symlink/cd40109b.pdf

Digikey has them in DIP packages that will handle 4 lines of communication for about 40 cents each if you buy 25: http://search.digikey.com/scripts/DkSearch/dksus.dll?Detail&name=296-3505-5-ND

That's only 10 cents per pin, and when the Prop2 comes out at 1.8V this kind of thing will become even more important.

Comments

  • Dr_AculaDr_Acula Posts: 5,484
    edited 2010-11-30 18:56
    Interfacing is tricky. There are many solutions for 3-5V and 5-3V, but as far as I know, no chips that can do both. And that would make sense, because how would a translator chip know in advance whether the prop pin has been configured as an input or an output.

    For 3 to 5V digital, I use 74HCT chips. 74HC are not quite in spec, but I have got away with them working too.

    For 5 to 3V, a 1k resistor.

    But for the situation where sometimes the data goes one way and sometimes the other, the 1k resistor is the only answer I know of.

    I have a drawer full of 40109s which I bought before some clever person on this forum pointed out the 1k resistor solution.
  • ElectronegativityElectronegativity Posts: 311
    edited 2010-11-30 19:06
    Perhaps I missed the boat here, but my understanding of how these work is that you supply the low voltage and high voltage to the chip and it steps up the low voltage signal and steps down the high voltage one.

    So you put a 3.3V signal into the "left" side and a 5V signal comes out the "right" side.
    Sending a 5V signal into the "right" side caused a 3.3V signal to come out of the "left" side.

    The particular application I have in mind is the IR thermal module, which is a 5V part that needs back and forth communication with the 3.3V propeller.

    I have not tested this since I am still waiting for them to come in the mail.

    Did I miss something?
  • hover1hover1 Posts: 1,929
    edited 2010-11-30 19:18
    Perhaps I missed the boat here, but my understanding of how these work is that you supply the low voltage and high voltage to the chip and it steps up the low voltage signal and steps down the high voltage one.

    So you put a 3.3V signal into the "left" side and a 5V signal comes out the "right" side.
    Sending a 5V signal into the "right" side caused a 3.3V signal to come out of the "left" side.

    The particular application I have in mind is the IR thermal module, which is a 5V part that needs back and forth communication with the 3.3V propeller.

    I have not tested this since I am still waiting for them to come in the mail.

    Did I miss something?

    The part you quoted is a one way level shifter (Low to High). I don't think it goes the other way.

    Today's technology brings us great items such as:

    http://focus.ti.com/docs/prod/folders/print/txb0108.html

    Your application may be as simple as 1K-4.7K resistor in series from the module's TX line to the propeller, and nothing on the RX line, (if the module reads 3.3 as a high).

    Do you have a Data Sheet on the module?

    Jim
  • ElectronegativityElectronegativity Posts: 311
    edited 2010-11-30 19:57
    Hello Hover1.

    If you look at the data sheet that I linked the second bullet point on the right hand side of the first page says "Up and down level shifting capability".

    It also shows 2 distinct level shifters in the functional diagram (See attached snapshot).

    I guess it's possible that I have completely failed to understand what I bought.
    It certainly wouldn't be the first time...
    960 x 720 - 63K
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2010-11-30 20:57
    I need to study it more for high to low level translation - maybe you can do that with two gates https://www.futurlec.com/4000Series/CD40109.shtml

    I think that has something to do with the enable line which you could use to determine which way the data goes. But the enable line will take an extra propeller pin.

    On the other hand, a 1k resistor will handle bidirectional transfer and level translation without needing an enable line.

    A 1k resistor is more cunning than it initially looks. For 3V to 5V driving, say, a 74HCT gate, the voltage goes straight through at minimal current (HCT gates have a high input impedance). For 5V to 3V, the 1k resistor limits the current, which then flows into internal diodes on the prop chip that go from the input to the 3V rail.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-11-30 21:54
    Dr Acula wrote:
    For 5 to 3V, a 1k resistor.
    No: 2.2K minimum. The Prop's protection diodes are rated for 500uA, max., and
    (5V - 3.3V - 0.6V) / 500uA = 2.2K ohms.

    -Phil
  • TubularTubular Posts: 4,703
    edited 2010-11-30 22:20
    No: 2.2K minimum. The Prop's protection diodes are rated for 500uA, max., and
    (5V - 3.3V - 0.6V) / 500uA = 2.2K ohms.

    -Phil

    But why are the series resistors for mouse and keyboard on the demo and proto boards 100 ohms, given these peripherals are supplied 5V to operate on?

    Do these peripherals output using open collectors/drains, or is it a low duty cycle nature of the input device, or some other reason that lets us get away with something as low as 100 ohms?

    just curious
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-12-01 00:07
    A quick check with Google indicates that the PS2 interface is, indeed, open-drain.

    -Phil
  • wmosscropwmosscrop Posts: 409
    edited 2010-12-01 13:38
    These things will convert signals from 3.3V to 5V in one direction and 5V to 3.3V in the other: http://focus.ti.com/lit/ds/symlink/cd40109b.pdf

    Digikey has them in DIP packages that will handle 4 lines of communication for about 40 cents each if you buy 25: http://search.digikey.com/scripts/DkSearch/dksus.dll?Detail&name=296-3505-5-ND

    That's only 10 cents per pin, and when the Prop2 comes out at 1.8V this kind of thing will become even more important.

    I've used one of these... a little more expensive, though:

    http://www.sparkfun.com/products/8745
  • ElectronegativityElectronegativity Posts: 311
    edited 2010-12-04 17:48
    wmosscrop wrote: »
    I've used one of these... a little more expensive, though:

    http://www.sparkfun.com/products/8745

    Nice find! Sparkfun and Parallax go together like peaches and cream.

    I have these level shifters up and running now.
    They can shift from low to high or high to low but not both, so you need 2 separate ICs for bidirectional communication. The "enable" pin allows toggling between output and high impedance.
  • HumanoidoHumanoido Posts: 5,770
    edited 2010-12-04 23:49
    I'm not using a level shifter in going from 3.3 volts to 5 volts and from 5 volts to 3.3 volts. I use a 2.2K ohm resistor in the same line used for half duplex TX and RX and get a stable logic signal out. I originally learned about this in a post by Mike Green. The setup which requires the two signal references is from Stamp to Propeller and visa versa. I ran this through many thousands of operations and after code tuning and conditioning, no errors occur. I would not advise making a pin to pin connection directly without a protection resistor.
  • ElectronegativityElectronegativity Posts: 311
    edited 2010-12-05 06:39
    Hi Humanido, I'm sure that's much less expensive, but you are still technically in excess of the Propeller's Absolute Maximum Ratings.

    Maybe the best compromise between part count, cost, and correct voltages would be a conventional diode from the Propeller to the 5V part, and a 3.3V Zener diode from the 5V part to the Propeller.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-12-05 08:13
    I'm sure that's much less expensive, but you are still technically in excess of the Propeller's Absolute Maximum Ratings. ...
    Actually, he's not. Considering the protection diodes' forward voltage drop, he's right on the edge: (5V - 3.3V - 0.6V) / 2.2K = 500 uA.

    -Phil
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2010-12-05 09:14
    [I thought this 3V-5V thing was done to death a long time ago.]

    Attached is a bi-directional 3V-5V level shifter. It should be called an "accomodator." You can use a BS170, a VN2222L, or a 2N7000, I've verified it using them all.

    3V_5V_mosfet.jpg

    PE - The resistors should be 2K-10KΩ
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-12-05 09:31
    Believe it or not, that circuit is under patent by Phillips (now NXP). It was originally developed as a means of accommodating multi-Vdd devices on an I2C bus. BTW, to understand how it works when driven low on the 5V side, one has to remember that there's a body diode between source and drain of the MOSFET.

    -Phil
  • ElectronegativityElectronegativity Posts: 311
    edited 2010-12-05 15:55
    PJ Allen wrote: »
    [I thought this 3V-5V thing was done to death a long time ago.]

    Attached is a bi-directional 3V-5V level shifter. It should be called an "accomodator." You can use a BS170, a VN2222L, or a 2N7000, I've verified it using them all.

    3V_5V_mosfet.jpg

    PE - The resistors should be 2K-10KΩ

    Thanks Dogbert, That's one Demon of Ignorance down and 4,367,982 to go.
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2010-12-05 16:46
    PhiPi - based on your maths (which is of course, correct, I was just guestimating values), would 2.7k be a suggested value?
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-12-05 18:50
    I used 2.2K on the Propeller Backpack. It's possibly (but not typically) driven high, being pulled high with a 10K resistor. But I needed to make extra certain that the 10K - 2.2K divider to ground would register "low" with all logic families on the other side of the interface. One Parallax engineer recommended 3.3K, as a safety margin, for lines that are actually driven high. But it seems that some people get by with 1K. (That's certainly not recommended, though, since there could be slow but cumulative damage.)

    -Phil
  • Beau SchwabeBeau Schwabe Posts: 6,566
    edited 2010-12-05 21:40
    Here is a bi-polar transistor version based on what Phillips (now NXP) has provided for their I2C.

    http://forums.parallax.com/showthread.php?106323-3.3-vDC-to-5v-DC&p=749167&viewfull=1#post749167

    BTW) I find it difficult to believe that NXP has patent rights on this... The MOSFET version is identical to a layout cell I have put together between 2000 and 2002. <-prior art. The only difference was the voltages used were different. ... It was commonly called a level-shifter.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-12-05 22:04
    Beau,

    I agree that a patent on such a simple and obvious circuit is absurd. But here it is, Pat. 5689196, granted in 1997. Whether or not they enforce it, of course, is another question.

    -Phil
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-12-05 22:16
    This document (PDF) describes a rather intriguing two-transistor solution. What's nice about it is that, excluding two pullup resistors, it can be built from a single dual "digital" transistor (i.e. one with built-in base resistors).

    -Phil
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2010-12-05 22:37
    The 'accomodator' looks like the way to go for shifting up. I am wondering if it will work with 1.8 volts to 5.0 volts as well.

    But more importantly, the fact that this topic was 'beaten to death' long, long ago makes the case for either HOW TO files or Application Notes. Presentation of key facts in Forum threads tend to get buried in lenghthy, but informative Pro and Con.

    It is unfortunate that Phillips holds a patent for such a simple fix. But they will never enforce it on individual hobbyist. This 'factum' about ownership is added to a resentment list that includes the owner of the copyright to "Happy Birthday" and the fact that Penrose tiles are not allowed to be decorative art without a royalty to the mathematician. In all these case, there seems to be more ego that revenue to be gained.
  • jrjr.jrjr. Posts: 45
    edited 2010-12-06 06:32
    All,

    Parallax has proper bi-directional level shifter(s) on the PropUSB (28830) servo boards.

    Excerpt from TI Datasheet :

    "
    The TXB0108 architecture (see Figure 1) does not require a direction-control signal to control the direction of
    data flow from A to B or from B to A. In a dc state, the output drivers of the TXB0108 can maintain a high or low,
    but are designed to be weak, so that they can be overdriven by an external driver when data on the bus starts
    flowing the opposite direction.
    "

    Even the OE's are available to be pulled down with a spare prop pin

    You may need to enforce some different conditions on tristate with your own pullups/pulldowns.

    This is the closest off the shelf (and in the stable, for you kool aid drinkers).

    The board could also be used with additional clamping diodes to the supply rails
    for even better (or worst case) protection issues.

    ESD to 15KV is provided on chip as well

    Is Parallax Sales having a senior moment ?
    ...they're even discounted lately...

    jr
  • Beau SchwabeBeau Schwabe Posts: 6,566
    edited 2010-12-06 08:20
    jrjr,


    The TXB0108 are not without restrictions ...

    Quote from datasheet:
    The TXB0108 is designed to drive capacitive loads of up to 70 pF. The output drivers of the TXB0108 have low dc drive strength. If pullup or pulldown resistors are connected externally to the data I/Os, their values must be kept higher than 50 kΩ to ensure that they do not contend with the output drivers of the TXB0108.

    For the same reason, the TXB0108 should not be used in applications such as I2C or 1-Wire where an open-drain driver is connected on the bidirectional data I/O. For these applications, use a device from the TI TXS01xx series of level translators.



    Still, I'm baffled that Phillips (NXP) is trying to patent or for that matter was able to get a patent on the CMOS equivalent to the "Common Base Amplifier" , a topology common in radio since the early tube days.

    http://en.wikipedia.org/wiki/Common_base
  • User NameUser Name Posts: 1,451
    edited 2010-12-06 08:37
    jrjr. wrote: »
    This is the closest off the shelf (and in the stable, for you kool aid drinkers).

    What Kool-Aid are you referring to?


    Edit: BTW, thanks to all who participated in this rehash of level shifting. I wasn't here the first time through, and find this info extraordinarily useful. Makes me wonder what other jewels reside in the archives of this forum.
  • __red____red__ Posts: 470
    edited 2014-07-31 06:51
    PJ Allen wrote: »
    [I thought this 3V-5V thing was done to death a long time ago.]

    Attached is a bi-directional 3V-5V level shifter. It should be called an "accomodator." You can use a BS170, a VN2222L, or a 2N7000, I've verified it using them all.

    3V_5V_mosfet.jpg

    PE - The resistors should be 2K-10KΩ

    Sorry to perform thread necromancy but I just applied this solution to one of my designs and have this odd behavior and am looking for advice:

    99AVPyH.jpg


    Not exactly a square wave.

    I'm not seeing any variation or movement on the 3.3V or 5V line. The signal coming out of the propeller is as close to square as you can get.

    This is feeding into a string of WS2812s.

    The circuit is functional because 95% of the pulse is considered a "1" by the device but it doesn't sit easy with me and this is an opportunity for me to learn what I did wrong. I'm using a BSS138 and tried values for the resistors ranging between 3k and 10k with no different (even in the angle of the slope).

    Thanks for any insight!



    Red
    960 x 540 - 44K
  • JonnyMacJonnyMac Posts: 9,105
    edited 2014-07-31 07:51
    I use the TC4427 for driving WS2812s (and similar) LEDs from the Propeller. It's available in DIP form if you need it that way, and provides a stiff output at your desired voltage. In fact, I also use them for driving servos and any other device that wants a nice, clean pulse over a length of wire.

    The pics show a mini controller I made using a Propeller Mini that was part of a Cylon dress for a fashion show at Comic-Con. The dress was made by Jinyo from the TV show, "Heroes of Cosplay." The TC4427 is sitting underneath the Propeller Mini on the PCB.
    800 x 600 - 92K
    415 x 533 - 51K
  • edited 2014-07-31 19:32
    Parallax Application Note AN010 - Low-Cost Bidirectional Mixed-Voltage Interfacing shows how to use a simple resistor to interface to 5V devices. The note specifies a minimum value of 4.7k for the resistor and goes into detail about why this is so.

    I've use this approach to interface with a 5V MCP3201 with good results. CS, CLK and DATA lines are connected via 4.7k resistors. The diagram in the attached code only shows the one ADC but I'm driving two by connecting both CS lines to one pin, both clock lines to another pin and I/O lines to separate pins. The code is attached.

    Sandy
Sign In or Register to comment.