8

I am currently using the PIC24FJ128GA010 and I am planning to use Input/Output port to connect my 4.2 V LiPo battery and to check if the voltage value doesn't go below 3.7 V.

I am thinking to connect it to any of my input/output pin but I am wondering two questions:

  1. Is it the correct pin?
  2. Should I do a specific montage with resistor?
stevenvh
  • 145,832
  • 21
  • 457
  • 668
Mattew
  • 163
  • 1
  • 2
  • 7

2 Answers2

9

The PIC24F etc. is a 3.3 V device, so you can't apply the LiPo's voltage directly to an input pin.

You can use an ADC (Analog-to-Digital Converter) channel, or a built-in comparator. The ADC will give you the actual voltage at any time, the comparator only good/no good.

Like I said you can't apply the battery's voltage directly: it's too high. Use a resistor divider to scale the 4.2 V down to 3.3 V. A 10 kΩ resistor in series with a 33 kΩ will do fine. The divider will draw a constant current of 100 µA, which isn't much, but you don't want this 24/7. You can use a logic level gate P-MOSFET as a high-side switch to enable or disable the divider, like the Si2303.

Oli Glaser
  • 55,140
  • 3
  • 76
  • 148
stevenvh
  • 145,832
  • 21
  • 457
  • 668
  • I think the ADC is a good idea, I am looking for a really small solution (not enough space). If I use ADC, do I still need to use the resistor divider/P-MOSFET? – Mattew Sep 03 '12 at 15:42
  • @Mattew - The FET only takes a few mm$^2$, 0402 resistors even less. You need the divider; the inputs are 5 V tolerant, but according to the datasheet that's only for the digital inputs. A higher than 3.3 V on the analog inputs may damage them. You can drop the FET, but them the resistor divider will (slowly) drain the battery. – stevenvh Sep 03 '12 at 15:54
5

(Credit for much of this goes to @stevenvh's suggestion... For sake of more visual readers, I'm just providing a rough schematic of my circuit based on the suggestion!)

EDIT: Schematic further refined with a suggestion made by @Nick and @stevenvh:

enter image description here
More in this thread.

boardbite
  • 4,922
  • 11
  • 48
  • 73