Embedded Firmware Development Extremely System
The challenge System
System: tiny coin cell batteries power the wireless sensors from Disruptive Technologies. These batteries offer long life in terms of low self-leakage but don’t pack a punch in total energy. (Brief aside: This is beneficial in some cases, primarily when operating in potentially explosive atmospheres.)
The Varta CR1216 coin cell datasheet claims 27 mAh capacity and a self-discharge rate < 1% / year at room temperature to put the challenge in numbers. (Compare this to AA batteries that typically have 2000 to 3000 mAh capacity.)
So for a sensor to last 15 years on a CR1216 battery, it should not draw more than around 23 mAh (27 mAh minus potential self-discharge) over the whole 15 years. This means that the average current must be less than 175 nA! This average must include the wind spent on sensing, wireless communication, and static leakage.
In comparison, just the standby current of most wireless MCUs is much higher than this, even when doing nothing else than keep a timer running and (some of) the RAM content alive. For example, the CC1350 from Texas Instruments lists 700 nA as the typical current in the lowest available standby mode with a low-power clock running and full RAM retention. The EFR32FG14 from Silicon Labs claims 550 nA with a low-power clock running and 128 byte RAM retention. Even though these are very competitive numbers, we can not reach our goals based on this alone.
The Disruptive Technologies Solution
To overcome the challenge, the sensors from Disruptive Technologies include an ASIC that has been designed with an extreme focus on low power consumption.
This ASIC is responsible for time-keeping, capacitive sensing (for touch and proximity), external sensor read-out, and power management. It has an onboard CPU and a small RAM to assist signal processing, event detection, and sensor wake-up control.
The ASIC enables sensor operation on a fraction of the current target while keeping the wireless MCU entirely powered down most of the time. When the ASIC determines that the sensor must take further action (for instance, because of a sensor event or a timer timeout), it powers up the wireless MCU for further signal processing and communication with the cloud.
The patented technology that drives the ultra-low power capacitive sensing and timekeeping is the critical enabling factor for the combination of long battery life and small size that sensors from Disruptive Technologies offer.
Some Challenges With The Solution
#1 – Ram size System
Because all electronic circuits introduce leakage currents when powered, the number of powered courses at any given time needs to be minimized to minimize the current consumption. Therefore, only a meagre amount of RAM is available in the ASIC. The amount of RAM is enough to run a tiny proximity detection program or temperature logging program, but not both at the same time. On top of that, the CPU is custom-built, with only the strictly needed functionality and instruction set, so only fundamental signal processing can be done effectively and without filling the RAM.
#2 – Code verification System
To make the code for the ASIC as compact as possible, it is written in a Python-based assembly language. As a result, the wireless MCU can store multiple precompiled binaries for the ASIC in its flash and load them onto the ASIC to change the sensor function (proximity sensing, touch, temperature logging, etc.).
But apart from making compact code, writing code in a custom assembly language generates its own set of challenges in code verification. For example, how do you ensure that the code you write for a custom-made CPU does what you think it does without bugs?
#3 – Battery limitations System
The small battery is not capable of delivering much current. When the battery is old or cold, the battery can have an effective internal resistance above 1 ohm. This means that the battery voltage drops by more than 1 V if the sensor tries to draw 1 mA. The ASIC draws nowhere near this, but when the wireless MCU wakes up to communicate with the cloud, it will need much more than this.
Overcoming the challenges
#1 – Managing available energy
Since the battery potentially can have a very high internal resistance, as explained above, the sensor does not mainly rely on the battery for energy-intensive tasks. Instead, it uses a bank of capacitors for energy storage, and it uses the battery to charge this bank of capacitors slowly. It draws the bulk of its current from these capacitors whenever it needs to do something energy-intensive, like wireless communication. The firmware uses extensive supply voltage monitoring to ensure that the supply voltage is at an acceptable level. Suppose the sensor does not have enough charge to perform a particular task. In that case, it puts the MCU into a deep sleep mode to recover the lead on the capacitors before continuing. The resulting supply voltage for temperature measurement and transmission typically looks something like this when the battery is old or cold:
During the few milliseconds that the MCU is active, there are quick dips in the voltage, and the rest of the time, the sensor is just sleeping to recharge.
#2 – Energy-optimized wireless protocol
To further increase battery life, Disruptive Technologies’ sensors use a proprietary protocol that is highly optimized for high security and low energy footprint, called SecureDataShot™ (SDS). In addition, the protocol is designed such that a minimum amount of bits is required to transmit the data, minimizing the radio transmission time securely.
For our second generation Temperature Sensor to send a fully encrypted packet containing 30 temperature samples via SDS, a mere 17 bytes of packet payload is typically required.
#3 – Automated code verification
Continuous integration (CI) ensures that the firmware has the desired quality. Every commit to the source repository is run through an extensive suite of automated tests. The test suite consists of
- Generic unit tests
- Hardware dependent unit tests
- Automated top-level functional tests
- System-level integration tests
It is beyond the possibility of this blog post to go into detail about all of these. But one set of tests is worth mentioning in this context:
Because the CPU in the ASIC is a custom. CPU with its own instruction set and tailored control of clocks and peripherals. There are no pre-made tools readily available to do unit tests. Writing an emulator for the ASIC would be possible. But it would need to be rather complex and complete to give the proper quality assurances. And even then. It would be hard to prove that the emulator is accurate in all cases. So instead. The CI pipeline runs tests on actual sensor hardware. This is achieve via a multi-layer set of tests.
At the core of the ASIC, firmware verification is a unit test framework develop in-house specifically for the ASIC CPU. This framework allows a test to set input conditions like RAM variables. CPU registers, and flags. Run the unit under test and check relevant output states before returning pass/fail data to the wireless MCU. Input from peripherals can also be mock where need. The framework is lightweight enough to fit in the limited RAM. It is powerful enough to make it easy to complete testing of all logical branches and corner cases by running. The test repeatedly uses different stimuli.
#4 – Firmware release testing System
Because long battery life is crucial. Every firmware release goes through an even more extensive set of tests. Then the testing is perform as part of the CI process, here. The firmware image under test is load into different sensors. And put through many combinations of extreme conditions over several days. (And some tests even run for months): Temperatures from -40 to +85 °C, fresh batteries. Spent halfway or nearing end-of-life. Excellent or bad wireless communication conditions. Exercising all different operating modes and functionality. The current consumption of the sensor is a measure. All of this is to ensure that recent firmware changes did not unexpectedly alter the expected battery life. The real test is automate and requires only minimal human intervention.
Making the world’s smallest and most power-efficient wireless sensors requires innovative hardware and firmware design. Along with contemporary and innovative verification strategies. However, the results speak for themselves: A sensor line-up with unmatched specifications and a quality that we proudly stand behind.