Posture Regulator using .NET Gadgeteer Accelerometer from Seeed Studio

People who work in technology often spend many hours at the computer, which can make it difficult to maintain good posture.  I’ve been advised by a physical therapist to keep my chest high with my head and neck upright.  The problem is that fatigue tends to make me slouch. Then my neck is out of alignment, leading to some unpleasant grinding of vertibrae and tension in the shoulders.

The .NET Gadgeteer device in this example uses the Seeed accelerometer module, which can be calibrated with a single function to set the base position that should be maintained.  I use a relay module, also from Seeed Studio, to activate a beeper when the Z axis of my posture varies too far from the calibrated normal.

The accelerometer is similar to the sensor in a cell phone that detects whether the phone is in the horizontal or vertical orientation.  The methods that the Seeed module supports are more than adequate for this application.  There is a method to calibrate the position from which variation is measured.  Monitoring the Z axis of the variation is sufficient to detect the kind of slouching I’m trying to avoid.  For this prototype I simply attached the accelerometer to my sweater with a safety pin, as shown in the following photo.

Accelerometer on the Slouch

Accelerometer on the Slouch

The rest of the hardware is shown in the following illustration. Clearly, it would be better to use a transistor or smaller relay and omit the display monitor if the user is going to take the device to work or travel with it.  The Display T35 module by GHI Electronics was useful while I was watching the output to determine what needed to be monitored to keep me sitting up straight.

.NET Gadgeteer Posture Regulator Hardware

.NET Gadgeteer Posture Regulator Hardware

The relay module from Seeed Studio includes four relays on a .NET Gadgeteer printed circuit board.  It provides three connection screws for each relay.  The connectors are labled 1NO, 1COM, 1NC etc.  NO is an abbreviation for normally open and NC for normally closed.  The common line is used in both kinds of circuits.  So, in this example, I used a normally-open circuit with a beeper and battery.  To close the cicuit, simply set the relay member to true.  The following code block includes a conditional statement that closes the circuit if the Z axis is less than 1.0, and the beeper prompts me to sit up straight.

    if (acceleration.Z < 1)
    {
        display.SimpleGraphics.DisplayText("Leaning forward",
            Resources.GetFont(Resources.FontResources.NinaB), GT.Color.Red, 25, 25);
        relays.Relay1 = true;
    }
    else
    {
        relays.Relay1 = false;
    }

Here’s another picture of the beeper circuit with the relay module.

Beeper Circuit with Relay

Beeper Circuit with Relay

The following code block shows the complete Program.cs file that implements the application.

using System;
using Microsoft.SPOT;

using GT = Gadgeteer;
using Gadgeteer.Modules.Seeed;
using Gadgeteer.Modules.GHIElectronics;

namespace PostureAccelerometer
{
    public partial class Program
    {
        void ProgramStarted()
        {
            button.ButtonPressed += new Button.ButtonEventHandler(button_ButtonPressed);
            button1.ButtonPressed += new Button.ButtonEventHandler(button1_ButtonPressed);
            accelerometer.ContinuousMeasurementInterval = new TimeSpan(0, 0, 0, 0, 200);
            accelerometer.MeasurementComplete +=
                new Accelerometer.MeasurementCompleteEventHandler(accelerometer_MeasurementComplete);
            Debug.Print("Program Started");
        }

        void button_ButtonPressed(Button sender, Button.ButtonState state)
        {
            if (button.IsLedOn)
            {
                accelerometer.StopContinuousMeasurements();
                button.TurnLEDOff();
            }
            else
            {
                accelerometer.StartContinuousMeasurements();
                button.TurnLEDOn();
            }
        }

        void accelerometer_MeasurementComplete(Accelerometer sender, Accelerometer.Acceleration acceleration)
        {
            display.SimpleGraphics.Clear();

            if (acceleration.Z < 1)
            {
                display.SimpleGraphics.DisplayText("Leaning forward",
                    Resources.GetFont(Resources.FontResources.NinaB), GT.Color.Red, 25, 25);
                relays.Relay1 = true;
            }
            else
            {
                relays.Relay1 = false;
            }

            display.SimpleGraphics.DisplayText("X: " + acceleration.X.ToString(),
                Resources.GetFont(Resources.FontResources.NinaB), GT.Color.Green, 20, 50);
            display.SimpleGraphics.DisplayText("Y: " + acceleration.Y.ToString(),
                Resources.GetFont(Resources.FontResources.NinaB), GT.Color.Green, 20, 75);
            display.SimpleGraphics.DisplayText("Z: " + acceleration.Z.ToString(),
                Resources.GetFont(Resources.FontResources.NinaB), GT.Color.Green, 20, 100);
        }

        void button1_ButtonPressed(Button sender, Button.ButtonState state)
        {
            accelerometer.Calibrate();
        }
    }
}

There is one more factor in sitting posture that needs to be correct to ease the strain on the spine and neck: the knees should be lower than the hips.  This is not difficult to maintain if the chest and neck position are correct.

There is now another implementation of this device that uses a LED alert instead of the buzzer.  See Posture Regulator with LED Alert – Silent.

Advertisement

, , ,

  1. #1 by Paul Mineau on March 9, 2012 - 8:26 PM

    awesome! I didn’t even think of how the Accelerometer could be used. now the beep of course will drive people nuts, and this is a good opportunity to iterate on the design. the user needs feedback of some kind that’s effective, could be a less abrasive sound, vibration, flashing light, etc. great thing about Gadgeteer is rapid prototyping is so easy the experiment is easy to do.

    • #2 by Michael Dodaro on March 9, 2012 - 8:45 PM

      Very easy to change the design to use a flashing LED. That way you could eliminate the relay completely.

  2. #3 by Mike Frith on March 10, 2012 - 2:31 PM

    This is definitely something I’m interested in. I’ve noticed my posture deteriorating over the years, partly due to being in front of the monitor 8 hours a day and partly due to racing bicycles. I wonder if I could use the blue tooth module to notify me through my headphones.

    Michael, is that a custom made prop for the T35?

    • #4 by Michael Dodaro on March 10, 2012 - 3:50 PM

      Right now the Blue Tooth module doesn’t have a working driver. GHI Electronics sells a Blue Tooth module: http://www.ghielectronics.com/catalog/product/312 , and they are asking the community to create the driver. Same for XBee module, which would be another candidate for your idea on the bike. But, I’m not sure my implementation of the accelerometer would work on a moving vehicle. That might require a different design.
      The prop for the display T 35 is just heavy art paper. I built it for a different demo and adapted for testing this one.

      • #5 by Mike Frith on March 10, 2012 - 4:46 PM

        I was thinking for the office/home office, not on the bike.

      • #6 by Michael Dodaro on March 10, 2012 - 5:28 PM

        Sorry to be dense. That’s what I get trying to do this on my phone on my day off.

      • #7 by paulmineau on March 10, 2012 - 6:39 PM

        it looks like fun being a part of this, http://xbee.codeplex.com/
        I think I’ll need to by the module from Ghi. Michael, do you know what else I’d have to by other than the GHI module?

      • #8 by Michael Dodaro on March 10, 2012 - 6:55 PM

        I have not kept up with that discussion, but a look at page 11 indicates they are getting close to having an XBee driver to test. Of course you need a Gadgeteer mainboard, power module, and a scenario that fits the XBee model. If you don’t have the Spider Kit, it is one way to get a collection of modules to start.

  3. #9 by John Kelleher on November 30, 2012 - 7:51 AM

    Michael,
    thanks for an interesting post on the posture regulator. The video helps to see how it all holds together. My colleague and I are working with .NET gadgeteer at the moment too but have a question I hope you may help us with. We need to generate a vibration and are not sure how to go about it – we’re .NET developers so electronics is new to us. We do have a Relay module and have considered connecting a motor to that. Would you have any advice?

    Thanks,
    John Kelleher
    Ireland (appsolo.com)

  4. #10 by John K on November 30, 2012 - 7:51 AM

    Michael,
    thanks for an interesting post on the posture regulator. The video helps to see how it all holds together. My colleague and I are working with .NET gadgeteer at the moment too but have a question I hope you may help us with. We need to generate a vibration and are not sure how to go about it – we’re .NET developers so electronics is new to us. We do have a Relay module and have considered connecting a motor to that. Would you have any advice?

    Thanks,
    John Kelleher
    Ireland (appsolo.com)

    • #11 by Michael Dodaro on November 30, 2012 - 9:01 AM

      If you already have a vibrator that you want to drive, the relay will probably work to activate it. The Seeed Studio relay used in this example will work with a battery or household AC voltage up to the limits it advertises. I’ve used it with household voltage to turn on and off lights over the Internet. I have several posts dealing with how to activate a relay. Search on ‘relay’ in the box above ‘Recent Posts’ and you’ll find several more examples.

      • #12 by John K on November 30, 2012 - 9:03 AM

        Michael,
        thanks for that but what constitutes a vibrator – would a simple servo motor work in this instance?
        Rgds,
        J

      • #13 by Michael Dodaro on November 30, 2012 - 9:08 AM

        What do you want to do with this thing? There are lots of devices that you can get in a hardware store that run on the right voltage, but when I search on vibrator, the stimulators returned are not something I’d want to hook up to household voltage. 😦

      • #14 by John K on November 30, 2012 - 9:10 AM

        Basically, I need something to provide haptic feedback – like a rumble pack in a games controller. The whole kit would typically be housed behind a plastic casing so I though a motor or solenoid could be used to ‘rattle’ against the housing.
        J

      • #15 by Michael Dodaro on November 30, 2012 - 9:19 AM

        I’m not much of a gamer, so I had to look up haptic feedback: http://electronics.howstuffworks.com/everyday-tech/haptic-technology1.htm
        It is new to me, but the relay will drive the electrical circuit of a motor or solenoid if you can design the mechanics of the device.

  1. Posture Correction « Philanthropy Cookbook
  2. kesintisiz güç kaynakları

Leave a Reply to Paul Mineau Cancel reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: