Author Topic: Reading signal from open drain connected to LED  (Read 523 times)

0 Members and 1 Guest are viewing this topic.

Offline okwTopic starter

  • Frequent Contributor
  • **
  • Posts: 325
  • Country: no
Reading signal from open drain connected to LED
« on: November 24, 2024, 11:53:30 pm »
I'm trying to read the value of a charge status pin (TP4056, charge done, open drain) with LED are connected. LED anode is on the TP4056 VDD rail (USB, 5V), as I don't want the LED to draw anything when USB is not connected. However, I'm reading 2.56V when charging (status is low, LED lit) and 2.01V when charge is done (stauts floats, LED dark).
How do I solve it so MCU can read a proper low, without affecting the LEDs?
 

Offline Benta

  • Super Contributor
  • ***
  • Posts: 6387
  • Country: de
Re: Reading signal from open drain connected to LED
« Reply #1 on: November 25, 2024, 12:15:10 am »
Put a 47 kohm resistor between your test leads, redo the measurement and come back with the voltages you measured.
 

Offline okwTopic starter

  • Frequent Contributor
  • **
  • Posts: 325
  • Country: no
Re: Reading signal from open drain connected to LED
« Reply #2 on: November 25, 2024, 12:33:17 am »
2.194V (charging) and 1.987V (done).
 

Online Someone

  • Super Contributor
  • ***
  • Posts: 5114
  • Country: au
    • send complaints here
Re: Reading signal from open drain connected to LED
« Reply #3 on: November 25, 2024, 06:26:17 am »
2.194V (charging) and 1.987V (done).
Seems like you'll need to provide significantly more detail. Why do you expect the chip to do anything specific when USB is not connected?

How can a pull down read a higher voltage when pulled down than when floating????
I'm reading 2.56V when charging (status is low, LED lit) and 2.01V when charge is done (stauts floats, LED dark).
 

Offline okwTopic starter

  • Frequent Contributor
  • **
  • Posts: 325
  • Country: no
Re: Reading signal from open drain connected to LED
« Reply #4 on: November 25, 2024, 09:40:52 am »
Seems like you'll need to provide significantly more detail. Why do you expect the chip to do anything specific when USB is not connected?

I don't expect that. And I don't care about the status when USB is not connected. I only care whether the battery is getting charged or not when USB is connected.

How can a pull down read a higher voltage when pulled down than when floating????

That's why I posted :) Nothing else is on the signal (i used to have a 200k 3.3V pull-up, but removed it). The charger (TP4056) STDBY pin --> 1k (and LED up to VCC 5V) --> MCU.
If I remove the LED it reads correct, battery in reads high, and out low.
 

Online Someone

  • Super Contributor
  • ***
  • Posts: 5114
  • Country: au
    • send complaints here
Re: Reading signal from open drain connected to LED
« Reply #5 on: November 25, 2024, 10:43:55 am »
How can a pull down read a higher voltage when pulled down than when floating????
That's why I posted :) Nothing else is on the signal (i used to have a 200k 3.3V pull-up, but removed it). The charger (TP4056) STDBY pin --> 1k (and LED up to VCC 5V) --> MCU.
If I remove the LED it reads correct, battery in reads high, and out low.
You'll need to draw a schematic of exactly what configuration you have, and details of how you're taking the measurement. Photocurrent would tend to pull the open collector up not down.
 

Offline okwTopic starter

  • Frequent Contributor
  • **
  • Posts: 325
  • Country: no
Re: Reading signal from open drain connected to LED
« Reply #6 on: November 25, 2024, 10:57:27 am »
The MCU_CHARGE_DONE goes directly to the ESP32-C3. I also have a DW01 protection circuit, which I omitted for readability.
 

Online pcprogrammer

  • Super Contributor
  • ***
  • Posts: 4629
  • Country: nl
Re: Reading signal from open drain connected to LED
« Reply #7 on: November 25, 2024, 12:01:26 pm »
That is what you get when you measure between the series resistor and the LED. Connect it like shown in the attached image and you will measure ~0 when the LED is lit.

Offline okwTopic starter

  • Frequent Contributor
  • **
  • Posts: 325
  • Country: no
Re: Reading signal from open drain connected to LED
« Reply #8 on: November 25, 2024, 08:03:34 pm »
Thanks so much.
By the way, I see dim flickering on the red LED when charging is finished (it should be completely off). Not sure if the TP4056 is from a bad batch or what's going on. I guess they're all knock-offs anyway...
Any trick to mediate this?
Could it be cause it's connected directly to the ESP32-C3?
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf