'Isolating' pins of an unpowered ATmega328 from open collector outputs

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

Dear Gents,

 

I would like to get your help in relation to a one-off battery powered project (it a conversion of an old Russian 35mm still picture film projector to LED light source with additional features).

 

As this is really a home project to 'keep using the device with some added features as it is fun' I went really basic on the design and used ebay available boards on a strip board and fitted it into the original housing. Also, this is my first 'chargeable battery operated appliance'.

 

The idea is the following:

I power the device from a 18650 LiIon battery with a step up converter to 5V powering and Arduino board running normal C code. The charging of the battery is via a TP4056 CC/CV with added over/under voltage protection from a USB port.

 

The powering on/off of the device is achieved by disconnecting the whole charging+battery circuit from the step-up converter's input by the means of a basic switch.

 

With this I can still charge the battery and when I use the device I flick the switch on, it powers the ATmega328 which is needed to adjust LED brightness and do some other stuff.

 

So far so good, the problem came in when I thougth about to connect the two open drain outputs (charging and charged state) of the 4056 to two of the GPIOs to monitor the charging status of the device (when the MCU is turned on).

The two open drain outputs have LEDs connected to them (powered from the USB side 5V) allowing to see the charging state even when the MCU is powered off.

 

The 4056 always has one of the open drain outputs engaged to show charging or charged status when in operation (ie powered from USB).

 

When my device is powered off (MCU is powered down by the switch) but charged by the 4056 via USB (one of the open drain outputs is on) I have experienced that the not active LED is also lit up, hence the two un-powered MCU pins are acting as a 'link' and providing the drain for the other LED also, hence both LEDs are on.

 

Obviously when the MCU is powered it is not a problem as the pins are set as inputs (with pull-up).

 

I realised it comes from the fact that the non-engaged open drain actually pulls the connected MCU pin to 5V which phantom powers the MCU and causes it to probably create this undesired feature also it is not good for the MCU either. I have a 2kOhm resistor in series with the LEDs so current is limited but it is still a distracting feature.

 

My question would be (I think my solution is correct but would like to get your opinion on it):

- Would it be a proper solution to add a diode between the open drain outputs and the MCU pins for both outputs of the 4056 (the anode being on the MCU pin side) stopping current to flow from the USB 5V towards the MCU but still allowing to use the MCU pin to monitor the charging state when it is powered up by setting it as an input with pull-up enabled?

 

thanks and regs.:

 

Ferenc

This topic has a solution.

Snaps

Last Edited: Fri. Sep 29, 2017 - 09:00 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I think the problem is the current running through the leds to the avr. One solution is to power the leds from the avr supply. This means the leds won't work when the avr is not powered. Another possible solution is to use optocouplers.

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

Yes, I see that the problem is caused by the 'off' open drain output of the 4056 leaving the attached MCU pin to be pulled to 5V via the resistor and the LED and then inside 'somehow' the current finds its way to the gnd point hence lighting the LED (either via the MCU gnd pin or the other GPIO being on the gnd).

 

MCU side power for the LEDs:

Yes, I thought about that but in this case I would lose charging indication when the MCU is off...

 

Opto isolator:

Ahh, great idea. Unfortunately I dont have one (two) to hand and as it is on a small strip board, space is heavily limited even when thinking in 3D. That is why I thougth about a simple diode.

 

Snaps

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

snaps78 wrote:
- Would it be a proper solution to add a diode between the open drain outputs and the MCU pins for both outputs of the 4056 (the anode being on the MCU pin side) stopping current to flow from the USB 5V towards the MCU but still allowing to use the MCU pin to monitor the charging state when it is powered up by setting it as an input with pull-up enabled?
Yes

Figure 4. Final interface solutions using a Schottky diode and an external or internal pull-up resistor.

from

Planet Analog

Planet Analog

SIGNAL CHAIN BASICS #66: How to interface a 5V transceiver to a 3V controller

Planet Analog, , 6/25/2012

https://www.planetanalog.com/document.asp?doc_id=528335

Schottky diodes are leaky so would recommend the pull-up resistor.

 


http://e2e.ti.com/cfs-file/__key/telligent-evolution-components-attachments/00-142-01-00-00-69-72-13/3V-MCU-to-5V-XCVR-Interface.pdf

 

Edit : Texas Instruments

 

"Dare to be naïve." - Buckminster Fuller

Last Edited: Fri. Sep 29, 2017 - 12:17 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I think you'll find it is nothing to do with the open drain output of the tp4056. The current flows through the resistor,led then through the input diodes on the avr to 0V.

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

Yes. It is clear that not the 4056 causes the issue and the current is sourced from the 5V via the led and the resistor. I just have not experienced the avr to be in a semi powered state allowing current to flow towards 0V. It was a new experience to me... When the avr is fully off I cannot se how the current would flow via the cathode of the diode towards 0V.

Snaps

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

All of the AVR's pins have integrated protection diodes:

 

 

Any voltage applied to a pin, higher than that applied to VCC (plus the diode's forward voltage) will get shunted to the chip's VCC bus.  Similarly, any voltage lower than that applied to GND (minus the diode's forward voltage) will get shunted to the chip's GND bus.

 

If VCC is unconnected, than any voltage above 0.7V on an input pin will 'lift' VCC above GND.  As soon as that's high enough to power up the chip, away she goes.

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"Read a lot.  Write a lot."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

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

Ofcourse, the current is not flowing to 0V from the pin itself. It flows through the the power rail then as it 'powers' the core, down to 0V.

 

Yes, I was short sighted to only think about the two diodes at the pin and ignored that there is a Vcc rail which feeds the core whichis a load.

 

Trees, wood...

 

Thanks Joey

 

 

Snaps

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

Thankgchapman for the verification and thanks Joey for opening my eyes.

Snaps

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

Second time this week!