Author Topic: Battery monitor/sensing ratio calculation on MotionMote/WeatherShield  (Read 8364 times)

ssmall

  • Full Member
  • ***
  • Posts: 113
  • Country: us
    • View Profile
Re: Battery monitor/sensing ratio calculation on MotionMote/WeatherShield
« Reply #30 on: January 17, 2017, 12:15:47 PM »
To give you more information what I am doing, I have a solar panel that charges a Lipo battery during the day and the battery provides power at night.  The solar panel puts out a max of 6 volts.  What size capacitor would I use between A3 and the Gate of the FET?

-Steve

perky

  • Hero Member
  • *****
  • Posts: 841
  • Country: gb
    • View Profile
Re: Battery monitor/sensing ratio calculation on MotionMote/WeatherShield
« Reply #31 on: January 17, 2017, 02:29:59 PM »
If you remember your theory, the resistance times the capacitance is the RC constant. That is the time taken for the capacitor to charge up to about 2/3 of its final value. Under off conditions (after the capacitor has fully charged with A3 in the high state) the voltage at the gate will be at Vin. When you drive A3 low the voltage at the gate will immediately drop by Vcc, turning the FET on. You want this voltage to remain well below the gate threshold voltage to keep it on during the measurement (so that's at least 3ms plus the time to measure). As soon as measurement is made A3 can be driven back high which will immediately drive the gate to above Vin by the amount that it has been charged up with, turning the FET back off.

So you need an RC constant big enough. About ten times the time to measure should be OK, that'll guarantee the FET is hard on for the duration, thats RC = 0.03 (assuming you use 10nF and 10k/4k7 divider), so for your 10k pull-up that's a C of 3uF. I would probably use a 100k pull-up resistor instead of 10k and use a 330nF or 470nF to give roughly the same time constant. The procedure is then drive A3 low, wait 3ms, make the mesurement, and drive A3 back high.

Mark.
« Last Edit: January 17, 2017, 02:39:55 PM by perky »

ssmall

  • Full Member
  • ***
  • Posts: 113
  • Country: us
    • View Profile
Re: Battery monitor/sensing ratio calculation on MotionMote/WeatherShield
« Reply #32 on: January 18, 2017, 09:30:00 AM »
Mark, I will change the battery monitor voltage divider as you suggested and make the changes you suggested on the P-FET side of things as well.  I need to order some parts.  :)  I appreciate all your help.

-Steve

MrGlasspoole

  • Newbie
  • *
  • Posts: 35
  • Country: de
    • View Profile
Re: Battery monitor/sensing ratio calculation on MotionMote/WeatherShield
« Reply #33 on: January 27, 2017, 11:09:07 AM »
What I'm missing that you use this circuit?
Isn't that code enough:
https://provideyourown.com/2012/secret-arduino-voltmeter-measure-battery-voltage/

perky

  • Hero Member
  • *****
  • Posts: 841
  • Country: gb
    • View Profile
Re: Battery monitor/sensing ratio calculation on MotionMote/WeatherShield
« Reply #34 on: January 27, 2017, 12:25:38 PM »
That link you supplied was for calibrating by reading the 1.1 bandgap voltage (which is not particularly accurate in absolute terms but is reasonably stable over temperature) and comparing it with a known input accurate voltage. This problem though is about reading voltages that are above Vcc and keeping the power down at the same time.

Mark.

MrGlasspoole

  • Newbie
  • *
  • Posts: 35
  • Country: de
    • View Profile
Re: Battery monitor/sensing ratio calculation on MotionMote/WeatherShield
« Reply #35 on: January 28, 2017, 02:15:18 AM »
Ah yes. Sorry i did forget not everybody is using 2x 1.5v batteries.

ssmall

  • Full Member
  • ***
  • Posts: 113
  • Country: us
    • View Profile
Re: Battery monitor/sensing ratio calculation on MotionMote/WeatherShield
« Reply #36 on: February 05, 2017, 06:38:12 PM »
Mark, I made the changes to the circuit you suggested.  A 10nF cap and 10k/4k7 resistors for the voltage divider.  I used a 100k pull-up resistor between the gate and the source instead of the 10k.  Everything appears to work correctly.  I can see the voltage is zero across the voltage divider when A3 is set to INPUT (high-z) and I can see a voltage drop when A3 is set to OUTPUT, LOW.  If I put a 330nF capacitor in series with A3 the voltage is always zero.  Am assuming I am missing something.

perky

  • Hero Member
  • *****
  • Posts: 841
  • Country: gb
    • View Profile
Re: Battery monitor/sensing ratio calculation on MotionMote/WeatherShield
« Reply #37 on: February 05, 2017, 08:51:34 PM »
The thing you're missing is that with the 330nF capacitor in circuit A3 should always be an output (and note, the capacitor is connected to A3 on one side of the capacitor and the gate/pullup on the other side). From my previous post then: "The procedure is then drive A3 low, wait 3ms, make the measurement, and drive A3 back high." The default state for A3 should be driven high.

Mark.
« Last Edit: February 05, 2017, 08:56:54 PM by perky »