[phpBB Debug] PHP Warning: in file /mnt/forum-shared/ext/sitesplat/BBCore/event/listener.php on line 70: in_array() expects parameter 2 to be array, boolean given
How do you have the pic output and take in 3v? - SparkFun Electronics

SparkFun Forums 

Where electronics enthusiasts find answers.

All things pertaining to wireless and RF links
User avatar
By sparky
#1954
Most PICs can 'read' or input 3V logic, no problem. The high threshold is 2.1V or something. Read the very end of the PIC datasheet, it will give you logic level high minimums for different pins.
The problem is outputting a 5V high into a 3V device. You run the *risk* of frying inputs on the 3V device. Couple things to consider:

Use a voltage divider. If you put 5V into a voltage divider of 3/5, you of course get 3V out. 0V in, 0V out. But this requires two resistors - not too bad.

You could put an inline resistor inbetween devices. Say 100k or so would limit the current to 20uA (5V to 3V is a 2V drop over 100k is 20uA) being injected into the 3V device. Kinda shady, but it works for bread boards.

Or you could go with the really ghetto implementation and hook the 5V device directly to the 3V device. Many 3V devices are 5V tolerant so they can handle 5V signals. The manufacturer may not say it is 'so' but it may work fine. Other devices are *very* sensitive and must have a nice 3V level logic interface. The worst that could happen is that you fry your 3V device - fair warning.

-Nathan
User avatar
By sparky
#2030
I dont have part numbers in front of me, but the parts I've seen just use a BJT transistor pair to do the level shifting. There are ICs out there, I've just never used one.

-Nathan
By pittuck
#2034
I use a Maxim 3370 IC, quite small but it does level shifting for many voltages. It workes up to 1Mbit, so good for Serial / i2c / spi.

Not sure if u going to find a dealer, but hey they do samples...
By Guest
#2043
Some 3v chips might have you put the config word on one port and read data out the same port. I can see how a voltage devider could be used for output but what would I do when I needed input.
User avatar
By phalanx
#2062
You could use diodes to fix your problem as well. You know what the forward voltage drop is so just put enough of them in series to drop your voltage down. Then do the same thing in the opposite direction to control the voltage going to the PIC input.
Code: Select all

output-------->|-->|-------- device   (drops maybe a couple of volts)
input --------|<------------          (drops small voltage but within PIC tolerances)


I hope you can follow what I was thinking!

-Bill
User avatar
By sparky
#2091
I tried the diode voltage drop trick with the GM862. Didn't work at all for whatever reason. The voltage divider did.

I don't understand the diode from low voltage device to PIC input pin. If the diode drop is .7V, and the device is outputting 3V, the PIC will see 2.3V. What good is this?

I would recommend using the voltage divider from PIC to 3V device. Then attach the device directly to the PIC input pin. The PIC threshold for logic level 'high' is like 2-2.5V, so the 3V device should trip this just fine.

-Nathan
User avatar
By phalanx
#2095
I'm not sure why the diode trick didn't work for you. It might have something to do with the capacitive loading of the MOS gates inside your target. The diodes would prevent it from discharging if the input circuit was not designed with that in mind. You might be able to make it work by adding a pull-down resistor to the pin. I agree the voltage divider will definitely work but it uses more power than a diode solution.

The diode from the low voltage device to the PIC input was put there because the person who posted just before me needed bi-directional communication on the pin. Some low voltage devices can handle +5V being fed to them but I put the diode in just in case so the PIC output is forced through the 2 diodes. Besides silicon diodes that have a voltage drop of 0.7V, you can use schottky or germanium diodes which have a drop between 0.15-0.45V. The lower the drop the better for the return path in this application.

-Bill
User avatar
By sparky
#2341
Works like a charm! We use a similar method on the SMiRF so that you can power the SMiRF at any voltage (3-10V) and the SMiRF will communicate at the system voltage. So if your system runs at 4.34V (for example), the SMiRF will receive these signals, (0-4.34V) and respond with the same signals (0-4.34V). All the while, the SMiRF runs at 3.3V.

The mosfet solution is a good one, just be sure not to use it for very fast signals (>.5MHz) as the pull-up resistor can cause problems. Also, if you are worried about costs, the price of a small signal mosfet can vary by 0-500% depending on where you by from. Digikey is good, but bulk is better other places.

But then again, we are comparing apples and oranges in the main topic: a resistor divider / diode solution versus a mosfet solution.

-Nathan
By pittuck
#2342
LOL

I was composing a email to u about using mosfets on a i2c bus when i came on to look 4 ur email address and found smirf 2 was out and found it already has level translation!

Anyhow i am working on my micromouse lately so have not done anything with the wireless stuff.

I have got a deadline of 15 December to finnish my mouse to a level worthy of showing off at a university interview. Anyhow i think i have to work out odometry today, not 100% needed, but i am waiting for more sensors to arrive by post.