A Cheap easy way to interface Prop with 5V Peripherals
Electronegativity
Posts: 311
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.
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
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.
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
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...
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
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
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.
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
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.
PE - The resistors should be 2K-10KΩ
-Phil
Thanks Dogbert, That's one Demon of Ignorance down and 4,367,982 to go.
-Phil
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.
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
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.
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
The TXB0108 are not without restrictions ...
Quote from datasheet:
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
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.
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:
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
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.
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