Firefly Ice: Power Measurements

The first power measurements for the Firefly Ice prototype PCBA look really good.  Very low power means small batteries can be used while still getting great battery life.

Sleep Mode

Average power consumption for the PCBA with the real time clock and watchdog timer running (everything else in sleep mode) was measured at 2.7uA.

Plus Accelerometer

Average power consumption for the PCBA with the real time clock, watchdog timer, and accelerometer running (everything else in sleep mode) was measured at 6.0uA.  The accelerometer was running at 25Hz in low power mode.

Battery Life

To relate the 6.0uA to battery life:

  1. A CR2032 240mAh coin cell battery would last 4.5 years.
  2. A  40mAh rechargeable lithium polymer battery would last 9 months.

Of course a typical application will need to use other devices on the PCBA, such as the Bluetooth 4.0 low energy radio, LEDs, CPU, etc.

Activity Monitoring Scenario

Consider a simple activity monitoring scenario.  The radio sleeps 90% of the time, is in discovery mode 5% of the time, and connected 5% of the time, adding 2.4uA.  The CPU usage averages 10,000 instructions per second adding 2.8uA.  Two LEDs are illuminated for 30 seconds a day adding 3.5uA.  This along with the CPU and accelerometer usage of 6.0uA, brings the total average current to 14.7uA.  The CR2032 battery would last about 1.8 years and the 40mAh battery would last about 3.5 months.

activity-monitoring-current

Balance

Two of the primary design challenges for body worn sensors are size and battery life.  Those are opposing forces – smaller size means smaller batteries and lower battery life.  One of the keys to a good design is to find the right balance for your application.  For certain applications where the duty cycles are low it is certainly possible, with a good design, to have a very low overall average current which enables long life when using small batteries.

Firefly Ice: Getting Started with Firmware Development

Compiling the Firmware

The Firefly firmware uses freely available libraries and tools.  To get setup for building the Firefly Ice firmware you will need the following:

  • GNU Tools for ARM Embedded Processors
  • EnergyMicro CMSIS Software
  • Firefly version of the EnergyMicro CMSIS USB Software
  • Firefly Ice Firmware

The following commands can be used in the Mac OS X terminal to download and extract all of the above:

curl -O https://launchpadlibrarian.net/135590305/gcc-arm-none-eabi-4_7-2013q1-20130313-mac.tar.bz2
tar jxf gcc-arm-none-eabi-4_7-2013q1-20130313-mac.tar.bz2
export PATH=`pwd`/gcc-arm-none-eabi-4_7-2013q1/bin:$PATH

curl -O http://cdn.energymicro.com/dl/packages/EM_CMSIS_3.0.2.zip
unzip -d energymicro EM_CMSIS_3.0.2.zipgit clone https://github.com/denisbohm/energymicro-usb.git
git clone https://github.com/denisbohm/firefly-ice-firmware.git
cd firefly-ice-firmware
mkdir obj bin

Finally, from within the firefly-ice-firmware directory you can build the firmware using make:

make

The resulting FireflyIce.elf binary file can be found in the bin directory.

Loading the Firmware

It’s time to get the hardware setup.  In addition to a Firefly Ice PCBA, you will need the following:

Connect everything together, plug the USB cable from the ARM-USB-TINY-H into your Mac, and plug the USB cable from the Firefly Ice into any USB port for power.

connections

The Firefly Flash production software will be used to load the compiled FireflyIce.elf binary into the Firefly Ice PCBA.  Download and run FireflyFlash.zip (it should automatically unzip when downloaded by Safari).

FireflyFlash

Click on “Select firmware ELF file…” and select the FireflyIce.elf file that you compiled in the steps above.  Click “Program” and in a few seconds the indicators on the Firefly Ice should indicate that the firmware is running.

Debugging the Firmware

The Firefly Flash software acts as a gdb remote target for debugging.  To start debugging with gdb:

arm-none-eabi-gdb

then enter the following gdb commands:

target extended-remote tcp:127.0.0.1:9000
set architecture armv3m
file bin/FireflyIce.elf

Now you can use gdb commands for debugging.

Alternatives

The process above is one way to build, run, and debug Firefly Ice.  But it isn’t the only option.  For example, a project file for the Rowley Associates CrossWorks for ARM development system is included in the Firefly Ice firmware repository as well.  CrossWorks runs on Windows, Linux, and the Mac.

Any ARM Cortex-M3 gcc distribution could be used for compiling.

Any JTAG with SWD capability and the associated tool chain could be used for running and debugging.  For example, the Olimex ARM-JTAG-SWD in combination with the Olimex ARM-JTAG-20-10 can be used instead of the Rowley ARM SWD Adapter with the same tool chain as above.

References

Firefly Project Introduction

The slides from my Firefly Project Introduction for the Austin Hardware Startup Meetup are now available at slideshare:

Firefly Ice: Source Code Repositories

Lots of things coming together this week:

firefly-ice-assembled

  • The firmware to read the sensors and communicate via Bluetooth Low Energy & USB is working.
  • Development of cloud data storage and syncing has started.
  • 3D printed enclosure prototypes have arrived.
  • I’m presenting this project at the Austin Hardware Startup Meetup.

Source Code Repositories: Below are links to all of the current source code repositories for the software, firmware, hardware, and enclosure.

Data Storage Service

GitHub: Firefly Data Storage Service

Cloud data storage service in Ruby / Sinatra hosted on Heroku and Mongohq.

Sync Application

GitHub: Firefly Sync

Mac OS X application to sync data from devices to the data storage service.

Firmware

GitHub: Firefly Ice Firmware

Device firmware written in ‘C’ using gcc.

Schematics & Printed Circuit Board Layout

GitHub: Firefly Ice Electronics

Eagle schematics & printed circuit board layout files.  The schematics have annotations that can be used to generate BOMs for ordering parts and for assembly.  The printed circuit board layout has layers for documentation of assembly locations of all BOM parts.

Note that the current schematics are for the first build of 10 prototype PCBAs.  There will be some changes based on testing and tuning done with those prototype PCBAs.

Component Parts Library

GitHub: Firefly Eagle Library

The Eagle component parts library has all of the parts used by the Firefly Ice electronics.

Rhino 3D Enclosure

Thingiverse: Firefly Ice Enclosure

The Rhino 3D file has all the development enclosure parts as well as some other parts used as reference such as the cover pate, battery, screws, etc.

Orderable Custom Enclosure Parts

Shapeways: Firefly Ice

The Shapeways files are printable STLs of the main body of the enclosure as well as the battery cover.  The cover plate, screws, etc, are standard parts that need to be ordered separately.

Energy Micro USB Firmware

GitHub: Energy Micro USB Firmware

Energy Micro USB firmware with a few fixes (gcc compatibility and not using port F pin 5 for VBUSEN).

Production Tools

GitHub: Firefly Production Tools for Mac OS X

Includes Firefly Flash application for Mac OS X that can be used to program firefly devices and also provides a GDB server so that any GDB based debugger can be used for development.

ARM SWD Framework

GitHub: ARM Serial Wire Debug Framework

The ARM Serial Wire Debug Mac OS X framework will be used by the production tools for testing and programming boards during production.

Project Tracking

Pivotal Tracker: Firefly Ice

More will be coming as the project progresses:

GitHub: Firefly Ice iOS Test App

Firefly Ice: PCBA Checkout

The first Firefly Ice PCBA arrived May 29th.  So far the communication between all the chips on the board have checked out fine.  Still more testing to do, but things look really good.  The remaining PCBAs from this first build of 10 should be here this week.  Effort is now shifting to focus on the firmware development.

firefly-ice-pcba-top firefly-ice-pcba-bottom

Aside

fireflies

Here are some fun firefly facts that I collected a while ago…

Fireflies aren’t really flies and glowworms aren’t really worms. Fireflies (or lightning bugs) are soft-bodied beetles in the family Lampyridae.

Glowworms are actually young fireflies, the luminous larvae that squirm forth from firefly eggs. These grublike wonders live in the ground eating slugs and snails for almost two years until they metamorphose into pupa, and then fireflies.

Fireflies are mostly active at night when they zoom around flashing their taillights and eating nothing.

Fireflies use the light on their lower abdomen segments to attract mates. (Since glowworms don’t mate, no one knows exactly why they glow.) Fireflies of the same species recognize each other by the number of flashes used, the frequency of flashes and the color of the light.

Different species emit different colors of light such as green, amber, or yellow.

The light fireflies produce (or that any living organism produces) is called bioluminescence. It’s a chemical process in which luciferin reacts with oxygen in the presence of an enzyme called luciferase. Chemical energy from the reaction is transformed into light.

Close to 100% of the energy from the chemical reaction is given off as light. For comparison, a typical light bulb give off only 10% of its energy as light, while the rest is wasted as heat.

Fireflies control the rate of their light flashes by admitting air into the luminescent organs.

All known firefly species are bioluminescent as eggs and larvae, but some are adults are not.

Some Asian species are fully aquatic and live underwater.

Fireflies larvae are predators and feed mostly on earthworms, snails, and slugs. They can detect snail or slug slime trails and follow them to the prey. An anesthetic type substance is injected into the prey to immobilize it.

Firefly larvae live one to two years, spend about 10 days as a pupa, then live as adults for only a few days to a week.

Adult fireflies don’t bite, have no pincers, don’t attack, don’t carry disease, and are not poisonous.

Firefly larvae use their luminescence as a warning signal that communicates to predators that they taste bad because they have defensive chemicals in their bodies.

Adult fireflies use a species specific flash pattern to attract a member of the opposite sex.

In some species the female is wingless.

When fireflies are distressed they flash to warn others.

In some species, the female firefly mimics the flash of another species. When the male responds and comes to her to mate, she eats him instead.

There are about 2,000 known species of fireflies.

Fireflies are also known as Lighting Bugs.

SXSW 2013: Don’t Stop at Software: Make Hardware Too!

The slides from my SXSW 2013 Future 15 talk “Don’t Stop at Software: Make Hardware Too!” are now available at slideshare with presenter notes:

Firefly Ice: Development Enclosure

The Firefly Ice development enclosure is a very simple 3D printed enclosure that will be used to protect the PCBA while testing it out in real world scenarios.  This enclosure is easy to take apart for reprogramming the PCBA via the ARM SWD pads.  The custom parts are very inexpensive to produce in small quantities via 3D printing services such as Shapeways.

The renderings below show the Firefly Ice development enclosure along with some of the internal parts.  The PCB is represented by the green shape.  LEDs and Micro USB port are visible in the top view.  The coin cell battery option is visible in the bottom view.

firefly-ice-enclosure-top

Top View

firefly-ice-enclosure-bottom

Bottom View

Firefly Ice: Prototypes

Printed Circuit Board Assemblies

The first 10 Firefly Ice prototype printed circuit board assemblies (PCBA) have been ordered.  All the components have arrived and the printed circuit boards are currently being fabricated.  The complete PCBAs are scheduled to arrive in early April.  The hardware will then be tested for functional correctness and expected power consumption.  If revision is required, another prototype build will be started at the end of April.

Development Enclosure

A very simple 3D printed enclosure will be used to protect the PCBA while developing the device and testing it out in real world scenarios.  This enclosure will be very easy to take apart for reprogramming the PCBA via the ARM SWD pads.  These will be very inexpensive to produce in small quantities via 3D printing services such as Shapeways.

Software

Once the hardware is checked out, the development focus will shift to the firmware, data uploading app, and cloud storage.

Open Source Activity Monitor: Firefly Ice

The Firefly Activity Monitor project is developing an open source activity monitor. The electronics, mechanicals, firmware, uploading, and cloud storage are all open source.

The first design produced, the Firefly Ice, is intended to be a general purpose device that can be used to develop the whole flow through the basic system.  When all the hardware and software is complete for this first design then more variants will be produced.  Two new variants under consideration are a small low cost version and a very thin waterproof version.

The Firefly Ice has the following features:

Electronics

  • ARM Cortex-M3 Processor with 256KB Flash & 32KB RAM
  • Bluetooth Smart Radio
  • Full Speed USB
  • 3-Axis Accelerometer
  • 3-Axis Magnetometer
  • Temperature Sensor
  • Coin Cell or Rechargeable Lithium Polymer Prismatic Battery
  • LED Indicators (2 RGB + 8 Red)
  • 64KB Nonvolatile Storage
  • Real Time Clock
  • Very Low Power Sleep & Active Modes

Firmware

  • Calculates & Stores Activity Metric
  • Commands & Data Transfer Via Bluetooth & USB
  • Encrypted Communication
  • Connection Status Indication
  • Charging Status Indication
  • Diagnostics Log

App

  • Automatically Set Device Time
  • Transfer Activity Metrics to Cloud
  • View Activity Metrics Chart
  • Real Time Display of Accelerometer & Magnetometer Data

Cloud

  • Stores Activity Metrics
  • Push Notifications
  • Authorization
  • View Activity Metrics Chart
  • View Diagnostics Log