Background

The original PICDIV project was useful at getting things off the ground, but turned out to consume way too much power for a battery-powered IoT project like the J-Box.  After consulting with a EE on ways to save power, it was suggested to replace the original PICDIV method with PIC firmware that uses the TIMER1 prescaler and counter.  In working with a firmware engineer on the project, it was decided to switch from the original PIC12F675 (an older 8-bit PIC) to a more current PIC12LF1822.

The PIC12LF1822 is about twice the price of the 675, but much more powerful and most importantly, it includes Microchip’s “XLP Nanowatt” technology.

Firmware Now Available

The firmware source code for this project, like all the J-Box firmware, is available for general use under the Creative Commons Attribution-ShareAlike license. This means anyone is free to use and modify the firmware and source code for their own personal or commercial use, provided the original copyright and license information is maintained in all copies and derivatives.

Attribution-ShareAlike
CC BY-SA

Power Savings

The original PICDIV-based firmware and PIC was measured to be drawing a few milliamps at 1 MHz and up to 6 ma. at 30 Mhz. Because the PICDIV code was a main timing loop, it just sat there and burned up the CPU, generating a divided clock signal as its output; e.g., one output pulse for every 10,000 input cycles.  This turned out to be too much current drain for the battery powered use case, particularly one where constant RF signals and RF harvesting is being used to replenish battery power.  At rest with no input, the PIC12F675 drew 85 uA while doing nothing.  To counteract this, I had added a power switch and RF detector circuit, bring additional costs and complexities into the picture.

The new PIC12LF1822 device and  firmware draws virtually nothing at rest – it reads 0.00 ma. on my bench meter, but specs suggest it’s drawing no more than about 40 nanoamps while sleeping.  At 1 MHz, it draws just 35 uA, and 46 uA at 2 Mhz, up to 358 uA at 30 Mhz, which is the worst-case current drain. So when the frequency counter is running, it draws an order of magnitude less current than the original PICDIV.  Accuracy is decent at 2% to 3%.  In this use case, low power trumps accuracy.

The original PICDIV divided the RF signal by 10,000.  The new prescaler divides by 32,768, which saves even more power and which will reduce power and interrupts onto the main MCU, as well.

Programming the Firmware

This was a great project, in that I learned a lot about PIC programming and development in the process of working with the developer.  The following tools were used:

  • Microchip MPLAB X IDE
  • Microchip XC8 compiler
  • PICkit3 programmer and ZIF socket

I found a great deal on the PICkit3 and ZIF programming socket for just $22 on ebay. The Microchip software is free.  The PIC12LF1822 devices are about $1 at Digikey and Mouser.

Here’s the latest J-Box schematic incorporating the new PIC12LF1822.