Difference between revisions of "Workshop"

From MAGEEC
Jump to: navigation, search
(Software Requirements)
(Software setup)
Line 71: Line 71:
 
==Software setup==
 
==Software setup==
  
TODO library prerequisites
+
The first thing to do is to flash the STM32F4DISCOVERY board with the firmware required to take energy measurements. This firmware sets up the ADCs, USB and other peripherals, so that the board can talk to the host machine via USB. It performs the accumulation and conversion of the analog energy values coming from the power measurement shield.
 +
 
 +
    git clone https://github.com/jpallister/stm32f4-energy-monitor
 +
    git checkout pyusb
 +
 
 +
Then configure and compile specifying that we want to compile ARM firmware:
 +
 
 +
    ./configure --host=arm-none-eabi
 +
    make
 +
 
 +
This will produce a file 'energy_monitor' in src/firmware/.
  
 
TODO flashing the energy monitor
 
TODO flashing the energy monitor

Revision as of 13:13, 12 January 2014

The MAGEEC project has designed a board for high frequency measurement of energy usage. This workshop will guide you through setting up and using the MAGEEC energy measurement boards.

At its simplest, the power measurement shield works by sampling the voltage drop across a resistor wire inline with a power supply. It is implemented as a shield for a ST Microelectronics STM32F4 Discovery board. The STM32F4 is used to process the raw data and pass it out over USB. The shield can measure up to three external targets simultaneously, as well as measuring its own energy usage.

The hardware is a fully open design by Dr Simon Hollis of Bristol University. It may be downloaded from GitHub: https://github.com/mageec/powersense-shield.

Image of the Energy Monitor


Software Requirements

Skip this section if you are running from the MAGEEC live CD.

This section sets up the packages required to compile the firmware for the energy monitor board, run the python scripts to communicate with the board and toolchain to compile for an arduino target board.

Install packages required to build the firmware for the energy monitor board

   add-apt-repository ppa:terry.guo/gcc-arm-embedded


If on Ubuntu 13.10, the following is required

   sed -i 's/saucy/raring/' /etc/apt/sources.list.d/terry_guo-gcc-arm-embedded-saucy.list


Install an ARM toolchain

   sudo apt-get install gcc-arm-none-eabi


If the target board is a shrimping kit / arduino / AVR

   sudo apt-get install gcc-avr  gdb-avr avr-libc avrdude arduino  


Install other libraries needed

   sudo apt-get install git python-numpy python-scipy build-essential python-pip
   sudo pip install pyusb


The following udev rules will need to be install, to use the board without being root

   https://github.com/jpallister/stm32f4-energy-monitor/blob/pyusb/53-energy-monitor.rules
   https://github.com/jpallister/stlink/blob/master/49-stlinkv2.rules

Connecting the hardware

First mount the shield as shown in the following image. There will probably be a jumper supplied with the STM32F4, which will need removing, with the pins slotting into a socket on the underside of the shield.

Energymonitor2.jpg

For each measurement point there are two headers. One 4x1 offering pins labelled GND, OUT and IN (more on the 4th one later) and one 5x2 for selecting an inline resistor (see below).

Photo of the pinheaders to select resistor and accept voltages

The target power supply should be intercepted, and wired to the IN pin, with the OUT pin then connected to the power supply on the target board. GND should be connected to ground on the target board. Power supplies up to 5V are supported. Although the voltage drop is sufficient to give the current measurement, a GND connection (not shown in the above picture) is needed to get an absolute voltage measurement.

The 4th pin next to IN is a jumper to bypass an inductor. Sometimes the only way to intercept the power supply on a target board is to cut out the inductor. In this case, remove the jumper to use the inductor on the shield instead. The target device can be powered from the shield if desired. In this case IN should be connected to the 3.3V or 5V supply on the shield (the above shows this, with the brown wire picking up the 3.3V supply). A maximum of 100mA draw is available in total.

The configuration of the resistors

The choice of resistor depends on the target maximum power consumption. Values of 0.05Ω, 0.5Ω, 1Ω and 5Ω are provided (the 5th slot is unused and can be used to supply your own resistor). The objective is a maximum 50mV drop.

Software setup

The first thing to do is to flash the STM32F4DISCOVERY board with the firmware required to take energy measurements. This firmware sets up the ADCs, USB and other peripherals, so that the board can talk to the host machine via USB. It performs the accumulation and conversion of the analog energy values coming from the power measurement shield.

   git clone https://github.com/jpallister/stm32f4-energy-monitor
   git checkout pyusb

Then configure and compile specifying that we want to compile ARM firmware:

   ./configure --host=arm-none-eabi
   make

This will produce a file 'energy_monitor' in src/firmware/.

TODO flashing the energy monitor

Using the software

TODO command line utility to read power data

TODO python scripting

Challenges

This section gives some examples for you to try out with the energy measurement kit.

Persistence of Vision

This uses one of the shrimping.it persistence of vision kits.

TODO energy required for different messages TODO compiler options exploration TODO interrupt driven version

Sorting

Try different sorting algorithms. Which is most energy efficient?

BEEBS

We use the a benchmark suite called BEEBS for our research. Try running some of these benchmarks on different hardware targets, with different clock speeds. Which takes the least energy?