The prototype Solarduino has been under test for the last week. It’s gathering data on itself: Battery Voltage, Temp, Time, Ambient Light. It’s been consistently overcast here in Brooklyn, and the Solar Piston circuit has been good about maintaining battery voltage. But that wasn’t always the case. For a short while, it seemed that the circuit was eating batteries! After some poking around and alittle internet research (thanks Swordfish!) it turns out that the SD card was the culprit, sucking down a consistent 8-9mA. But how? Well, after some digging around on the PCB (post about re-work coming) and messing with the SPI control bus, things started to make abit more sense. First, a recap of my circuit, and then the nitty gritty of the problem.
The key to any long term environmental sensing/logging circuit is power conservation. In-between readings and writings, the circuit must be as quiet as possible. To this purpose, I am putting the ATmega chip into Power Down mode (section 9 of the datasheet) which kills the main clock and timers. That’s great for the ATmega, but the rest of my circuit is littered with resistors and chips that all together draw around 10-12mA. Not good. So in addition to putting the ATmega to sleep, I selectively kill power to the rest of the components on the board with a Power MOSFET (P-Channel) thusly:
The ATmega power pins, and reset pin are the only ones getting power when the P GATE is held LOW. Nice. Works great. Until I added the SD Card. It seems somehow that the power lines attached to the Drain of the P-MOSFET above were still getting power! Turns out, after messing with the SPI bus pin directions on the ATmega, the Slave Select pin is where the leakage was happening. Here’s how:
The image at right is what I believe is the equivalent of what’s inside the SD Card SS pin. The clamping diodes D1 and D2 are there to protect the internal circuitry from voltage potentials above or below Vcc and GND. Great for normal operation, or shipping during an electrical storm, but if Voltage is applied to the INPUT pin, and the Vcc pin is not connected to +V, then current will go through D1! This kind of parasitic, or sneaky voltage is what was causing my board to maintain a high current draw during sleep.
So, what’s the solution?? There are two options:
Option 1: change the direction of the SS pin from OUTPUT to INPUT before pulling down on the P GATE. For now, this is the option I am using. I don’t need to risk doing major surgery on my PCB.
Option 2: Use an N-Channel MOSFET instead of a P-Channel MOSFET, and switch the GND side of the circuit instead of the +V side. Here’s how it works.
The benefits to doing this are a few. First, I don’t need to worry about changing the direction of the SS pin back and forth. This is called ‘idiot proofing’. Second, I’ve read (here, for one) that N-Channel MOSFETs typically have lower ON resistance, and can pass higher currents. Third, the Power Gate is controlled by TRUE logic instead of INVERTED logic (not critical, but kinda nice).
Why, you ask, didn’t I start with the N-Channel to begin with? The question may be ultimately unanswerable.