5v input to ATmega88 at 3v3

Go To Last Post
12 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,

I've got a TSOP4846 IR receiver which I'm trying to correctly interface to an ATmega88. I got it all working when the ATmega88 was running off a 5v supply, matching that required by the TSOP4846, but now need to run the ATmega88 at 3v3.

Checking the datasheets I think the following are the relevant constraints:

ATmega88: Vih max = Vcc + 0.5 (i.e. 3.8v)
TSOP4846: Output supply 5v at 5mA max.

Additionally the TSOP4846 datasheet says:

"The output voltage should not be hold continuously at a voltage below V O = 3.3 V by the external circuit ."

I figured a potential divider should be able to reduce the 5v output to 3.3 for the ATmega88, so made a circuit as follows:

             +-----+
 TSOP4846 ---| 3k3 |--------> ATmega88
 (5v, 5mA)   +-----+    |     (3.3, max 40mA)
                        |             
                +-----+ |
          GND|--| 6K8 |-+
                +-----+       

5v across both resistors (10k1 ohms) gives ~0.5mA, so I think the current should be fine, but the circuit doesn't work as the ATmega88 fails to see any edges from the TSOP4846 :(

If I remove the 6K8 resistor, the ATmega88 does see edges, but is then receiving 5volts instead of 3v3, which probably isn't great for running the circuit for long periods.

How should I be level shifting this input?

Regards,

Mike

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

There are a few things which could prevent the simple voltage divider from working in this situation.

Did you disable the internal pull-up in the AVR?

Have you measured the port pin at steady state? Is it about 3.3V? There are other characteristics of the IR recevier which could stop this from working.

Another method you could try is to use an NPN transistor as an inverting buffer.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,

The pull up is definitely disabled, and the pin is a little under 3.3v when the IR receiver is seeing nothing (it's active low, so normally outputs 5v).

I was wondering if the potential divider maybe upsetting the TSOP4846, particularly that the datasheet warns:

"The output voltage should not be hold continuously at a voltage below V O = 3.3 V by the external circuit."

I don't think the potential divider should be doing this, but I'm not sure.

The transistor suggestion is an intersting one - I had wondered if that were a better method. Do you have any examples anywhere (most searches seem to be listing mosfets for level shifting instead) :(

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I couldn't find any good example of what I am thinking of online and I don't feel like drawing it out right now.

The NPN buffer suggestion can be quite simple especially if you get a transistor with built in biasing. For example, if you use a DTC114E you wouldn't need any other components assuming the pull up in the AVR is enabled.

If you look on page 2 of the linked data sheet, they show an "equivalent circuit".

Of course, since this is an inverting buffer, you would need to make sure to update the software to expect the opposite polarity of signal.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Just to get rise time / fall time issues etc. out of the way, try it with 1K and 2K resistors. These values work fine for me. However, I am going the other way - peripheral IC running at 3.3V, AVR running at 5V (need that 20 MHz clock capability).

Incidentally, if there are any signals going from the AVR to the IR receiver (don't know the one you are using), then those have to be level translated as well.

If you think education is expensive, try ignorance.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

emuler - I wired up the USART and added some debug, and the pin isn't seen as changing, so there is no problem with timing - something worse than that :(

kevin123 - I've removed the potential divider and placed a 2N5551 with the base on the TSOP4846 output on the base, the collector on the ATmega88 pin and the emitter on ground. Having enabled the internal pull up and inverted the software logic, this now works! Since the transistor is only grounding the pulled up ATmega88 pin, I'm happy it's not getting an out of spec voltage being applied. I was slightly concerned that the TSOP4846 is sinking constantly through the transistor base, so I put a 1K resistor in to limit the current there just in case.

It works now, and I hope to write up the project and publish the schematic and code over the next few weeks.

Thanks,

Mike

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Mike,

A few more thoughts for you:

Is your 3 V supply ground tied to the 5 V supply ground?

The 40 mA on the AVR is when using the pin as an output, it has no bearing on using it as an input.

If the High is truely 5 V, then the input to the AVR is 3.4 V, which is greater than 3.3 V. You would do better to possibly rescale your resistive divider so the the voltage to the AVR is slightly under 3.3 V, not slightly over 3.3 V. As is you are relying on the AVR's input circuitry to clamp the peak input to a tolerable level. Check the data sheet to see what the MINIMUM voltage is for a High on the input, then just be sure to exceed this by a bit.

Is your 3.3 V supply clean? Was your 5 V supply better filtered? Do you have by-pass caps on your AVR's power supply pins, say 0.1 uF and 10 uF?

Have you confirmed that the AVR is up and runnning on the 3 V supply, a simple LED flasher, etc?

Recheck your wiring, your circuit looks like it should work.

JC

Edit: Typo and simultaneous posts...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
I was slightly concerned that the TSOP4846 is sinking constantly through the transistor base, so I put a 1K resistor in to limit the current there just in case.
A series resistor to limit the current is definitely a good idea. The transistor I mentioned in my earlier post has this resister built in. Without it, you would most likely exceed the recommended current of the IR receiver. Even with a 1k resistor, you are probably drawing a little over 4mA. I would probably go a bit larger, say 10k.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You can also use a small signal schottky diode (like the BAT46, BAT85 etc) with cathode to TSOP output and anode to AVR-pin; turn on pull-up and you're done :)
Simple and within specs

Nard

A GIF is worth a thousend words   They are called Rosa, Sylvia, Tessa and Tina, You can find them https://www.linuxmint.com/

Dragon broken ? http://aplomb.nl/TechStuff/Dragon/Dragon.html for how-to-fix tips

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I think resistor divider is not possible here if the IR receiver module has open-collector output (with an internal very high pull-up resistance like 10k-100k).

So it is not possible to do a practical resistive divider from that, not unless you use megaohm range resistors.

The transistor as inverter is a good idea and should work. Also liked the schottky diode idea.

Other possibilities are to use a LVC series logic buffer chips which allow 5V inputs while outputs are run from 3.3V supply.

Another thing comes to mind is to use a (n-channel) FET as a level translator. Gate to 3.3V, source to IR side, drain to AVR side. But actually this just takes advantage of the internal diode of the FET as the communication is unidirectional, the FET allows bidirectional communication too.

- Jani

Edit: the drain and source should be reversed. source=diode anode, drain=diode cathode. Source to AVR side, drain to IR side.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Some LVC series ICs are also available in single gate versions, in a SOT23-5 package, like the 74LVC1G07.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I like Nards idea. Low current, fast, nice and simple - sounds good.

oddbudman