Author Topic: Help with battery powered Moteino sketch  (Read 22247 times)

perky

  • Hero Member
  • *****
  • Posts: 873
  • Country: gb
Re: Help with battery powered Moteino sketch
« Reply #60 on: May 15, 2016, 07:42:37 AM »
It seems to me you would need to know exactly when the transmitter is transmitting as to when to sample the ADC, or alternately continually sample at the highest rate possible from intitiating transmission until the end and use the lowest recorded value. You'd also need a low source impedance on the voltage divider (<10k) for the ADC to sample correctly, if you use high value resistors you'll need a cap but that has a long RC constant, your radio would need to tx for a long time and the ADC conversion rate won't even come into it. Maybe 1Mohm total divider with 10nF cap. At 3.3V. The Thevenin equivalent would produce an RC constant of around 5ms, so you may have to wait up to 50ms to get a stable voltage to read. It would sink 3.3uA constantly though. Higher value resistors would decrease the quescent current at the expense of increasing the settle time at the ADC.

If you go for speed (i.e. low tx time) you'll end up using lower value resistors with little or no capacitance for the divider. That means you'll need a high side switch, and if you've got that there's no real point in using the radio as you could easily make the resistor values draw a known current. You'll need to size those resistors so they draw the required current at the lowest voltage that the radio is to work at.

Mark.



Mark.

joelucid

  • Hero Member
  • *****
  • Posts: 868
Re: Help with battery powered Moteino sketch
« Reply #61 on: May 15, 2016, 09:49:58 AM »
Quote
It seems to me you would need to know exactly when the transmitter is transmitting

Once you set the radio to TX it will send preamble until you switch it back to standby. So you could just setMode( TX ); delay( 1 ); measureVcc(); setMode( standby). The delay because it does take some time for PLL to lock etc.

The different powerLevels give you a nice way to control the load on the battery during measurement. I think you could monitor Vcc even if you're using a voltage regulator without voltage divider, provided you don't use full tx power in the normal course of business: just set the radio to TX and increase powerLevel until you either drop below 3.3V or hit 31.

If you can expend 130mA and still stay >3.3V you're safe for a while longer. And given the fairly fixed internal resistance of the battery you can extrapolate what your "normal load" voltage currently is.

Joe

davegravy

  • Jr. Member
  • **
  • Posts: 56
  • Country: ca
Re: Help with battery powered Moteino sketch
« Reply #62 on: May 15, 2016, 01:51:34 PM »
Rather than setting the radio for TX then back to standby specifically for the purpose of measuring the battery, I was thinking of taking said measurement as part of a regular transmission.

In my applicaiton, when the moteino exists listenmode because an update is requested from Gateway, the response is given using sendWithRetry(). If battery measurement could be taken as part of  sendWithRetry, stored, and returned to gateway with the NEXT requested update... the gateway would always be behind one update on battery level, but it would still show the trend, and it would reduce overhead.

Also even though the gateway is one update delayed, the node locally is not, and can use it's knowledge of the battery level to make intelligent decisions about power management... whatever that may mean.

perky

  • Hero Member
  • *****
  • Posts: 873
  • Country: gb
Re: Help with battery powered Moteino sketch
« Reply #63 on: May 15, 2016, 01:58:45 PM »
Once you set the radio to TX it will send preamble until you switch it back to standby. So you could just setMode( TX ); delay( 1 ); measureVcc(); setMode( standby).
Joe

Yes, good point. You still would have a problem with the ADC voltage settling on the voltage divider though, you'd need a lower impedance resistor network for that which would require a high side switch to be turned on and off during that period.
Mark.

joelucid

  • Hero Member
  • *****
  • Posts: 868
Re: Help with battery powered Moteino sketch
« Reply #64 on: May 16, 2016, 01:48:19 AM »
Quote
You still would have a problem with the ADC voltage settling on the voltage divider though, you'd need a lower impedance resistor network for that which would require a high side switch to be turned on and off during that period.

Yeah - these days I mostly run without regulator so I don't do much of this anymore. I do remember my lake thermometer though which does have a very high impedance voltage divider. If I remember correctly a 200us delay handled the issue in that case. I did not add a cap.

But these were the days when I considered 4uA an acceptable sleep current - and the mote is potted in epoxy so I can't even fix it :-)

WhiteHare

  • Hero Member
  • *****
  • Posts: 1300
  • Country: us
Re: Help with battery powered Moteino sketch
« Reply #65 on: May 16, 2016, 11:51:53 AM »
Rather than setting the radio for TX then back to standby specifically for the purpose of measuring the battery, I was thinking of taking said measurement as part of a regular transmission.

In my applicaiton, when the moteino exists listenmode because an update is requested from Gateway, the response is given using sendWithRetry(). If battery measurement could be taken as part of  sendWithRetry, stored, and returned to gateway with the NEXT requested update... the gateway would always be behind one update on battery level, but it would still show the trend, and it would reduce overhead.

Also even though the gateway is one update delayed, the node locally is not, and can use it's knowledge of the battery level to make intelligent decisions about power management... whatever that may mean.
Exactly.  The notion is that you're leveraging current that's going to be spent anyway, not expending extra current for the sole purpose of taking a measurement of voltage under load.
« Last Edit: May 16, 2016, 11:54:47 AM by WhiteHare »

joelucid

  • Hero Member
  • *****
  • Posts: 868
Re: Help with battery powered Moteino sketch
« Reply #66 on: May 16, 2016, 03:53:42 PM »
Quote
Rather than setting the radio for TX then back to standby specifically for the purpose of measuring the battery, I was thinking of taking said measurement as part of a regular transmission.

Sure why not. I actually do something similar in my bootloader: I need to detect whether I'm running on a coin cell since then I can't run the radio at max tx. So I just tx at 0dBm and if that doesn't succeed and voltage during tx didn't significantly decline I switch to full power.