We'll start of with someting like this one:
This one was $12 at Target... could probably find a cheaper one at Wallmart. They are essentially all the same, in that they all use identical motors, and they all run on a single 1.5 vold AA battery. The important thing is that it be big enough to hold 3 1.5 V. AA batteries and some electronics tucked in behind.
Off the shelf these clocks can typically run for one year on a single 1.5V AA cell. Back of the napkin, this leaves us with the remaining 2 AA batteries worth of energy to run the electronics for one year. Not suggesting we run the clock motor off of 1 battery and the electronics off the other two. We are just doing ball park power budget estimates.
Your basic long life alkaline AA 1.5 volt battery packs about 9360 joules. That's 5.2 watt-hours for 2 AA batteries. We need to run for 1 year, or 8760 hours. Therefore, on average the electronics must not draw more than 5.2 / 8760 = .0006 watts, a little over half a milli-watt. Assuming an operating voltage of 4V, our max. average current drain can't exceed .00015 amps, or 150 micro-amps. Ouch! I don't know of any afordable compute platform that can operate continuously at this low power level... do we need to run the electronics continuously?
Ok, so we need a reliable time base accurate to 1/10th of a second. An internet connected NTP server could serve that pupose. This would imply internet connectivity presumably over Wi-Fi. We can easilly run that on a Pi.
Using NTP on the Pi, Linux would provide with ajusted local time.
Again, Linux would provide with ajusted local time.
Sure. It's a clock. We need 100% up-time.
So far, we've got:
So... we'd like to run a NTP server on a Linux platform but even a Pi Zero would blow our clock power budget, even not turning on Wi-Fi for internet connectivity. We also have a low power device with good motor control capabilities and accurate watch crystal for timing that might work for the clock electronics, but no Wi-Fi for connectivity.
Nothing says that we can only use one component. Both the Pi and the PSoc have Bluetooth Low Energy (BLE) radios. We could have a uitlity powered Pi running the NTP server discretely tucked away somewhere in the room, and the battery powered PSoC in the clock driving the motor, talking to each other over BLE. Need to see if we can get the PSoC average power consumption low-enough. To do that we need to understand a little about how the clock motor works.
You can find plenty of detailed explanations of how these devilishly simple and clever little motors work on Youtube. They use a single electro-magnet coil and you'll need to study one of these videos in order to dismantle the casing and gearing to disconnect the two coil leads from the factory circuit and connect then to external leads going to our control circuit. It is usually easier to cut the traces on the factory PCB and to use the PCB coil solder points to solder on the external leads.
The important features of this little motor is that it turns half of one revolution every second. It is driven by a 100 ms. 1.5 V. pulse every second. These succesive pulse must alternate in polarity. Looking like this on a scope:
The motor coil is a highly inductive element with a dc resistance of about 100 ohms. We can see here that the 1.5 V. AA cell does a great job of regulating. We see none of the overshoot or ringing we'd expect of an inductive net.
We should be able to drive this motor directly using two PSoC bit ports. We'd be driving the coil at 3.3 volts consuming 4 times the energy at the normal voltage. Let's code up a quick test:
It works! The clock advances once per second. Looking at one pulse more closely we can immediately spot a problem.
The inductance of the coil is causing quite a lot of overshoot and undershoot. This drives the pin voltages into dangerous territory. We can protect the pins using an H-bridege (four MOSFETs) as follows:
Ok, the PSoC pins are no longer exposed to out of range signals, but we are still driving 3 to 4.5 volts to the coild. This means that each pulse is consuming 4 times the power that it would be at 1.5 volts. We could drop the coil voltage by inserting a series resistor but that would not reduce the overall power./P>
We could also reduce the pulse duration to 25 ms, to 1/4 its original duration such that we use about the same amount of energy at 3 volts for 25ms as we would for 1.5 volts for 100 ms. Sounds good in theory, but... In order that these clocks run as long as possible, the motor is mechanically and electrically optimized to run with 100 ms. 1.5 volt pulses. 25 ms. higher voltage pulses do not work very well. There is too much inertia in the motors magnet to flip fast enough!
What we need is to generate something around 1.5 volts from a 3 to 4.5 volt source with as little power loss as possible. The best way is to use a hign efficiency switching step-down DC to DC converted. In this case I chose a 1.8 volt version for a couple of reasons. First 1.8 volts is a standard logic level and regulators are commonly avalable. Second, it get harder to find FETs that will switch voltages as low as 1.5 volts. At 1.8 volts it gets much easier. I chose the LM3671, and finalized on the follwing design using the CY8CKIT-143A PSoC device.
A voltage divider resistor ladder is used to reduce the battery voltage to something in the PSoCs A/D converter range such that the clock can report back the battery voltage. Both this divider and the regulator are powered via a PSoC pin so we can turn then off when not in use.
Looking at the pulse now we see that the pulse is much better regulated and of the right voltage. We still see undershoot when the regulator is turned off at the end of a pulse but that is inconsequential in terms of wasted energy, and now the clock runs smoothly without all rattling we heard running a 3 to 4.5 volts.
We have a working clock motor driver. Can we get it to run within our power budget?