Using PepperMill to turn a motor into a sensor

Nicolas Villar sent me a sample of the PepperMill, a new sensor board he and Steve Hodges designed at Microsoft Research in Cambridge, UK.  It’s a nifty little board.  You attach a DC motor and the board can an output voltage when the motor is turned,  and analog signals telling you the direction and speed of the motor.  It turns a DC motor into a rotary encoder, of sorts.

Wiring is very simple.  The motor connects to the two spring connectors at the top of the board.  Direction and Speed pins connect to two analog inputs on your microcontroller.  Ground connects to your microcontroller’s ground.  The motor generates voltage when you spin it.

To use it, plug the motor terminals into the grey connector and use the 3-way switch to select the maximum operating voltage of the motor (2.5/3.3/5.0). Set the second switch to CAL (Calibrate). Give the motor a quick turn, and you should see some of the LEDs light up briefly. Set the switch to RUN, and when you turn the motor the LEDs should give you some feedback about the direction and rate of turn.
DC motors rated at 6-12V with a gear ratio between 50:1 and 150:1 are good for applications where you want to turn the motor with your fingers (as you would a potentiometer or rotary encoder). Old cordless drills are another good source of geared DC motors. The board is rated at a max of 24V, so it’s good to check the maximum voltage generated by the motor before plugging it in.

The direction pin outputs close to 2V when the motor’s going one direction, and 0V when it’s going the other direction. To read this, use an analog input and look for a value. If its 0, it’s going one direction, and if it’s  above 0,it’s going in the other direction.

For more info or to get a board, contact Nic and Steve in Cambridge.

Here’s the circuit:

These images were made with Fritzing. Here’s the Fritzing sketch, here’s the part for the PepperMill, started by Nic, edited by me.

And here’s the code:

[include file="../../code/Arduino/PepperMill/PepperMill.pde" clean="true"]