group 8 matt mcnealy (ee) scott martin (ee) andrew lee ( cpe ) josh hamby (ee)

52
Group 8 Matt McNealy (EE) Scott Martin (EE) Andrew Lee (CpE) Josh Hamby (EE) Workout Buddy A muscle fiber stimulation sensor and data logger

Upload: nitza

Post on 24-Feb-2016

37 views

Category:

Documents


0 download

DESCRIPTION

Workout Buddy A muscle fiber stimulation sensor and data logger. Group 8 Matt McNealy (EE) Scott Martin (EE) Andrew Lee ( CpE ) Josh Hamby (EE). Goals & Objectives. To design and implement a device that will allow weight lifters to monitor and track their progress electronically. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Group 8 Matt McNealy (EE) Scott Martin (EE) Andrew Lee ( CpE ) Josh Hamby (EE)

Group 8Matt McNealy (EE)Scott Martin (EE)

Andrew Lee (CpE)Josh Hamby (EE)

Workout BuddyA muscle fiber stimulation sensor

and data logger

Page 2: Group 8 Matt McNealy (EE) Scott Martin (EE) Andrew Lee ( CpE ) Josh Hamby (EE)

Goals & Objectives To design and implement a device that will allow

weight lifters to monitor and track their progress electronically.

To build a sensor system that: Measures the electric potential generated by certain muscle

groups. Detects the angle of body part being exercised.

To learn about wireless technology, medical devices and programming microcontrollers.

To find points of over exertion in any particular exercise and improve on underworked muscle groups.

Page 3: Group 8 Matt McNealy (EE) Scott Martin (EE) Andrew Lee ( CpE ) Josh Hamby (EE)

Work Allocation

Sensor circuit: Operating time: 3 hours. Operating voltage: 2.8-3.7V Powered by polymer lithium

ion battery Dimensions: 2.1” x 2.3” Measure S-EMG ranging from

0.02-5mV. Capability of measuring a full

360 degree range of motion in three dimensions.

Communicate with the control module up to 3 meters.

Must secure to the body via velcro strap.

Control module: Operating time: 3 hours. Operating voltage: 3.3V Powered by a 9V lithium

battery. Dimensions: 3” x 2.6” Wirelessly receive data

from the sensor circuit. Automatically count

repetitions and sets. Display data on the LCD

screen. Write data to a micro-SD

card.

ScottParts acquired and researched:Microcontroller programmingControl Unit Design Matt

Parts acquired and researched:Power system

Filters

Parts acquired and researched:Wireless interfacemicroSD interface

Andrew Parts acquired and researched:PCB design and assembly

EMG/EKG detection Accelerometer

JoshDocumentation

PrototypingBudget

Research & Design

Page 4: Group 8 Matt McNealy (EE) Scott Martin (EE) Andrew Lee ( CpE ) Josh Hamby (EE)

Specifications and Requirements

Sensor circuit: Operating time: 6.5 hours. Operating voltage: 3.7V Powered by polymer lithium

ion battery Dimensions: 2.1” x 2.3” Measure S-EMG ranging from

0.02-5mV. Capability of measuring a full

360 degree range of motion in three dimensions.

Communicate with the control module up to 15 meters.

Must secure to the body via Velcro strap.

Control module: Operating time: 34

hours. Operating voltage: 3.3V Powered by a 9V lithium

battery. Dimensions: 3” x 2.6” Wirelessly receive data

from the sensor circuit. Automatically count

repetitions and sets. Display data on the LCD

screen. Write data to a micro-SD

card.

Page 5: Group 8 Matt McNealy (EE) Scott Martin (EE) Andrew Lee ( CpE ) Josh Hamby (EE)

Block DiagramSensor Unit

Page 6: Group 8 Matt McNealy (EE) Scott Martin (EE) Andrew Lee ( CpE ) Josh Hamby (EE)

Block DiagramControl module

Page 7: Group 8 Matt McNealy (EE) Scott Martin (EE) Andrew Lee ( CpE ) Josh Hamby (EE)

Signal Acquisition & Processing

Processing of the signal enables the user to maximize their workout experience.

Page 8: Group 8 Matt McNealy (EE) Scott Martin (EE) Andrew Lee ( CpE ) Josh Hamby (EE)

EMG Requirements

Amplifier: Gain of 1000+ High CMRR >95 db for frequencies 10 – 500

Hz Input impedance = 10 x electrode impedance

Skin Preparation: Cleaned and freed of dry skin cells Centered on the belly of the muscle 2 Electrodes 2 cm center to center

Page 9: Group 8 Matt McNealy (EE) Scott Martin (EE) Andrew Lee ( CpE ) Josh Hamby (EE)

Instrumentation Amplifier

INA122P-ND Voltage supply: 2.2

– 36 VDC Supply current: 60 -

85 μA CMRR: 83 - 96 db Gain: 1-10000 Input impedance:

10^10 ohm Digikey: $5.56

AD626AN-ND Voltage supply: 2.4 -

10 VDC Supply current: 230 -

290 μA CMRR: 66 - 90 db Gain: 1-100 Input impedance:

200 k ohm Digikey: $7.46

Page 10: Group 8 Matt McNealy (EE) Scott Martin (EE) Andrew Lee ( CpE ) Josh Hamby (EE)

Triple Axis Accelerometer MMA7260Q :

Power supply: ○ 2.2 - 3.7 VDC○ 500 - 800 μA

Selectable sensitivity: ○ 1.5g = 800 mV/g○ 2g = 600 mV/g○ 4g = 300 mV/g○ 6g = 200 mV/g

Sleep mode option Sparkfun: $19.95

Page 11: Group 8 Matt McNealy (EE) Scott Martin (EE) Andrew Lee ( CpE ) Josh Hamby (EE)

MMA7260Q Orientation

Page 12: Group 8 Matt McNealy (EE) Scott Martin (EE) Andrew Lee ( CpE ) Josh Hamby (EE)

Atmel Atmega 328P 8 bit MCU running at 16 MHZ with XTAL Serial Communication via UART, I2C, SPI 6 channel 10 bit Analog to Digital Converter 3 Timers, 6 PWM channels Free C Compiler and Development Tools $4.30 @ Digikey

Page 13: Group 8 Matt McNealy (EE) Scott Martin (EE) Andrew Lee ( CpE ) Josh Hamby (EE)

Setting the Processor speed The clock must be at a specific

frequency in order to set the correct sampling rate to sample data from the EMG sensor. The clock value was chosen to ensure the highest sampling resolution possible that the Atmega 328 can support.

Page 14: Group 8 Matt McNealy (EE) Scott Martin (EE) Andrew Lee ( CpE ) Josh Hamby (EE)

Development Environments AVR Studio is an Integrated Development

Environment for writing, compiling, simulating, and debugging

AVRDUDE is an open source utility to download/upload/manipulate the ROM and EEPROM

Page 15: Group 8 Matt McNealy (EE) Scott Martin (EE) Andrew Lee ( CpE ) Josh Hamby (EE)

AVRlibc and AVRlib

AVRlibc is the Standard C Library for AVR microcontrollers and provides basic functions like printf, stdio calls, math functions, plus some AVR-specific functions

AVRLib provides functions for conventional tasks such as writing to LCD’s and SD cards and reading from buttons and encoders

Page 16: Group 8 Matt McNealy (EE) Scott Martin (EE) Andrew Lee ( CpE ) Josh Hamby (EE)

Sensor Software Block Diagram

The software on the sensor is a while() loop that

continuously samples the

voltages on the accelerometer

and EMG sensor input pins

Page 17: Group 8 Matt McNealy (EE) Scott Martin (EE) Andrew Lee ( CpE ) Josh Hamby (EE)

Analog to Digital Conversion

Using highest possible Sampling Frequency 125kHz

Approximate resolution is 4.9 mV

The free running mode allows the control unit to continuously update the voltage received off the sensor and provide the user with a measurable output of intensity.

Page 18: Group 8 Matt McNealy (EE) Scott Martin (EE) Andrew Lee ( CpE ) Josh Hamby (EE)

USART FunctionsFILE usart_stream = FDEV_SETUP_STREAM(usart_putchar,

usart_getchar, _FDEV_SETUP_RW); This sets up the stream object that avr-libc uses for standard i/o.void usart_init(unsigned int baud) This function enables the receiver and transmitter, sets the frame

format, and sets standard i/o to use the USART stream.int usart_putchar(char c, FILE *stream) This function puts character to send into the USART i/o data

register and handles converting the newline character.int usart_getchar(FILE *stream) This function waits for the receive complete bit to be set in the

USART control register then gets the charaacter out of the data register.

Page 19: Group 8 Matt McNealy (EE) Scott Martin (EE) Andrew Lee ( CpE ) Josh Hamby (EE)

General Software Block Diagram:Control Unit

Starting with the Main(); block different functions are called depending on which state it is on while button is pressed.

State 1 calls free_mode();

State 2 calls free_mode(); with saving enabled.

State 3 calls credits();

Page 20: Group 8 Matt McNealy (EE) Scott Martin (EE) Andrew Lee ( CpE ) Josh Hamby (EE)

Control Unit Software Block Diagram

The main menu items are part of a state machine which call the functions free_mode(save_flag) and credits when the button is pressed while in a specific state. The save_flag determines whether or not createfile(fileName, file) gets called.

Page 21: Group 8 Matt McNealy (EE) Scott Martin (EE) Andrew Lee ( CpE ) Josh Hamby (EE)

Getting User Input – Rotary Encoder

3 Terminal Device to get sequential input 2 bit grey code provides 4 states for

MCU to read MCU must keep track of previous state. Debouncing via software delays or

hardware LPF’s Triggering via Interrupts or Polling

Page 22: Group 8 Matt McNealy (EE) Scott Martin (EE) Andrew Lee ( CpE ) Josh Hamby (EE)

Color LCD – 128 x 128 Nokia clone

LCD Logic - 3.3V @ 2-3mA LED Backlight - 7V @ 40-50mA (very bright) Full 4,096 Color Display Uses the Epson S1D15G10 or Philips PCF8833

Controller Active Display Dimensions: 1.2"x1.2” Two-wire serial SPI interface (clock and data)

Page 23: Group 8 Matt McNealy (EE) Scott Martin (EE) Andrew Lee ( CpE ) Josh Hamby (EE)

LCD Functions void LCDSend9Bit(int data); Breaks the 9th bit out into this special case so that we can use only 8-

bit variables in the main loop static void LCDInitIO() Sets up the data direction port and turns on inputs and outputs void LCDInitController()This function configures the Epson LCD controller void LCDClearScreen(int color)This function blanks the screen. void drawString(char *s, int fg, int bg, int x, int y)This function allows the writing of text to the screen with control over

the string to write, foreground and background color, pixel position in the x and y directions

Page 24: Group 8 Matt McNealy (EE) Scott Martin (EE) Andrew Lee ( CpE ) Josh Hamby (EE)

Wireless interface – TXM-900 Specifications

Operating voltage: 2.8–13 VDC Supply current: 14-17 mA Transmit frequency range:

902.62-927.62 MHZ Data rate: 100-56,000 bps Operating temperature range:

-30 to 85C

SIP Style Price: $29.45 from Digikey Part #: TXM-900-HP3-PPO-ND

SMD Style Price: $29.45 from Digikey Part #: TXM-900-HP3SPO-ND

Page 25: Group 8 Matt McNealy (EE) Scott Martin (EE) Andrew Lee ( CpE ) Josh Hamby (EE)

Wireless interface – RXM-900 Specifications

Operating voltage: 2.8–13 VDC

Supply current: 16-21 mA Receive frequency range:

902.62-927.62 MHZ Data rate: 100-56,000 bps Operating temperature range:

-30 to 85C

SIP Style Price: $43.40 from Digikey Part #: RXM-900-HP3-PPO_-ND

SMD Style Price: $39.22 from Digikey Part #: RXM-900-HP3-SPO-ND

Page 26: Group 8 Matt McNealy (EE) Scott Martin (EE) Andrew Lee ( CpE ) Josh Hamby (EE)

Antenna JJB Series

The Electrical Specifications:○ Center Freq. 916MHz○ Bandwidth 30MHz○ Wavelength 1/4-wave○ Impedance 50 ohms○ Connection Direct solder

SP Series “The Splatch” The Electrical

Specifications: Center Freq. 916MHz Bandwidth 30MHz Wavelength 1/4-wave Impedance 50 ohms Connection Surface-mount

Model: ANT-916-SP Price: $2.08 from DigikeyModel: ANT-916-

JJB-xx

Price: $1.96 from Digikey

Page 27: Group 8 Matt McNealy (EE) Scott Martin (EE) Andrew Lee ( CpE ) Josh Hamby (EE)

Layout of Parts Sensor Unit

Data from the accelerometer and sensor units are fed into the ATmega328p MCU.

This data is streamed to the control unit via transmitter at 9600bps.

DATA

DATA

DATA

DATA

Page 28: Group 8 Matt McNealy (EE) Scott Martin (EE) Andrew Lee ( CpE ) Josh Hamby (EE)

Layout of Parts Control Unit

Data will be received by the receiver and fed into the ATmega328p MCU.

Data is then saved to the SD card in the FAT32 file system architecture. It will become a CSV file. (Comma-separated values)

The SD card can now be removed from the device and read on a computer .

9V10nF

On/Off

HP3RXM900

192021222324252627

282930313233343536

Splatch

1 2 3 4 5 6

1uF

AtmelAtmega

328

2918

462078

5321

22pF

22pF

23242526272819223031321291011121314151617

uSDSocket

12345678

CD1CD2D1D2

330 330

RotEnc

330

330

330

330

ISPProg

Reset

330Reset

Nokia Display

LP8345

DATA

DATA

Page 29: Group 8 Matt McNealy (EE) Scott Martin (EE) Andrew Lee ( CpE ) Josh Hamby (EE)

SD CARD MODULEFor our data logging we based our design off of CC Dharmani’s “SD Card Interfacing with ATmega 8/32 (FAT32 implementation)” project.

The circuit design was carefully adapted to work with our Atmega328p.

A standard SD card adapter was used in testing and prototyping.

We used his method of creating a FAT32 file.

More info at: http://www.dharmanitech.com/2009/01/sd-card-interfacing-with-atmega8-fat32.html

Page 30: Group 8 Matt McNealy (EE) Scott Martin (EE) Andrew Lee ( CpE ) Josh Hamby (EE)

SD MODULE cont..This schematic shows the integration of the SD card module into our design.

The SD card module requires 3.3-3.6v in order to write data to the micro SD card.

Page 31: Group 8 Matt McNealy (EE) Scott Martin (EE) Andrew Lee ( CpE ) Josh Hamby (EE)

SD Functions Void createFile(unsigned char *fileName,

unsigned char file[512]); Creates a file in FAT32 format in the root

directory. Unsigned char readFile(unsigned char flag,

unsigned char *fileName); Determines if filename is valid and returns a

flag. Unsigned char convertFileName(unsigned char

*fileName ); Converts filename into FAT format.

Unsigned long searchNextFreeCluster(unsigned long startCluster); Searches for the next free cluster in the root

directory.

Page 32: Group 8 Matt McNealy (EE) Scott Martin (EE) Andrew Lee ( CpE ) Josh Hamby (EE)

Simulator We initially wanted to implement

a simulator which would display various information of each workout saved on the SD card.

Due to unforeseen programming issues with the control unit and lack of time we unable to implement more than one exercise.

We have left it up to the user to take the data stored on the SD card and use it at their discretion.

Page 33: Group 8 Matt McNealy (EE) Scott Martin (EE) Andrew Lee ( CpE ) Josh Hamby (EE)

CSV file The CSV file saved on the SD card can be

opened and read. The SD card will contain from each

workout:○ X-axis○ # of repetitions○ Z-axis○ EMG signal

Format: 126,0,200,5, 125,0,201,5, ....................

Used to keep track of the effectiveness of the user’s workouts.

Page 34: Group 8 Matt McNealy (EE) Scott Martin (EE) Andrew Lee ( CpE ) Josh Hamby (EE)

CSV file (Excel)

Opening the CSV file in Excel Graphing the data in Excel

0

50

100

150

200

250

300

1 3 5 7 9 11 13 15 17 19 21

Series1Series2

Series3Series4

It is up to the user how he/she would like to use the data. For example, the CSV file can be easily opened using Excel and a graph can be made using the values stored.

The columns are the X-Axis, Repetitions, Z-Axis and EMG signals respectively.

Page 35: Group 8 Matt McNealy (EE) Scott Martin (EE) Andrew Lee ( CpE ) Josh Hamby (EE)

Power SystemSensor unit

Requirements Generate sufficient electricity to keep the unit

running for 3 hours. Environmentally friendly Length of charge Determining factors: Availability, capacity, &

size

Page 36: Group 8 Matt McNealy (EE) Scott Martin (EE) Andrew Lee ( CpE ) Josh Hamby (EE)

Operating Voltages (1) MMA7260Q – 3.7 (1) Atmel ATmega328 – 3.7V (1) TXM-900-HP3 – 3.7V (2) INA122 Instrumentation amplifier

– 3.7V Total Power Consumed: 370mW CR2032 3V lithium button cell battery

was used initially, but the accelerometer did not function properly due to a dropout voltage across the battery of 500mV. Minimum voltage for the accelerometer is 2.7V Capacity: 225mAh. Radius=20mm

,height=3mm

Power SystemSensor unit

Device Power Consumption

(mW)MMA7260Q

Accelerometer1.8

ATmega328 0.9

INA122 0.3

TXM-900-HP3 39.2

Page 37: Group 8 Matt McNealy (EE) Scott Martin (EE) Andrew Lee ( CpE ) Josh Hamby (EE)

Power SystemSensor unit

Powered by a rechargeable 3.7V lithium-ion battery. Has a capacity of

650mAh. Running time of 6+

hours before needing a charge.

Page 38: Group 8 Matt McNealy (EE) Scott Martin (EE) Andrew Lee ( CpE ) Josh Hamby (EE)

Power SystemControl module

Operating Voltages (1) Nokia display – 3.3V (1) Atmel ATmega328 – 3.3V (1) RXM-900-HP3 – 3.3V (1) uSD – 3.3V Demands 340mA Total power consumption of 1.112

W Powered by the Ultra life 9V

battery Chemistry: Lithium Capacity: 1.2 A*h Can run the module for 4 hours

before replacement is needed.

Device Power Consumption

(mW)uSD 3

ATmega328 0.9

RXM-900 15

Nokia LCD

900

Page 39: Group 8 Matt McNealy (EE) Scott Martin (EE) Andrew Lee ( CpE ) Josh Hamby (EE)

Power SystemControl Unit

Page 40: Group 8 Matt McNealy (EE) Scott Martin (EE) Andrew Lee ( CpE ) Josh Hamby (EE)

Final DesignControl module

Page 41: Group 8 Matt McNealy (EE) Scott Martin (EE) Andrew Lee ( CpE ) Josh Hamby (EE)

Final DesignSensor unit

Page 42: Group 8 Matt McNealy (EE) Scott Martin (EE) Andrew Lee ( CpE ) Josh Hamby (EE)

Testing For EMG Signals Obstacles:

Noise from lab equipment (60Hz hum) Used a 9V battery to

power the circuit Noise artifacts from

movement of body, RF, and cables Active filters may enable

more accurate readings but it was decided to use passive filters for RF and rely on the difference amplifier to discard noise from the body.

Page 43: Group 8 Matt McNealy (EE) Scott Martin (EE) Andrew Lee ( CpE ) Josh Hamby (EE)

Testing The MMA7260Q

X-axis = verticalZ-axis = horizontal

X-axis = horizontalZ-axis = vertical

Page 44: Group 8 Matt McNealy (EE) Scott Martin (EE) Andrew Lee ( CpE ) Josh Hamby (EE)

Testing – Hardware Design Sensor / Digital

The FT232RL serial to USB converter was used to monitor values being sampled by the MCU by displaying them on a PC in a terminal window.

The accelerometer pins for SLEEP, GS1 and GS2 were wired to Vcc, GND and GND during testing but were moved to the pins PB0, PB1 and PB2 to offer

additional configuration flexibility. 8 bits of resolution on the ADC pins connected to

the accelerometer and to the EMG sensor provided 0 - 255 values between GND and VCC. It was

unnecessary to use 10 bits.

Page 45: Group 8 Matt McNealy (EE) Scott Martin (EE) Andrew Lee ( CpE ) Josh Hamby (EE)

Testing – Hardware Design Control Unit The FT232RL serial to USB converter was used to

monitor values being transmitted from the sensor to the control unit MCU .

The SPI interface from the MCU to the LCD had to run at 3.3V, wouldn’t work at 5V.

Wireless reception improved from a few feet to 60 ft once the design was moved from a breadboard to the PCB with ground plane.

MicroSD circuit worked well without modifications

Page 46: Group 8 Matt McNealy (EE) Scott Martin (EE) Andrew Lee ( CpE ) Josh Hamby (EE)

Testing the Control Unit Andrew

troubleshooting the microSD circuit.

Page 47: Group 8 Matt McNealy (EE) Scott Martin (EE) Andrew Lee ( CpE ) Josh Hamby (EE)

Testing/Implementation – Software Design Sensor The sensor software is implemented as designed;

a loop samples the voltages on the sensor input pins and then those values are put into a datastream which is transmitted to the control unit microcontroller.

Troubles with processing the serial data on the control unit were solved by adding some “padding”, or unused characters to the data stream.

Page 48: Group 8 Matt McNealy (EE) Scott Martin (EE) Andrew Lee ( CpE ) Josh Hamby (EE)

Testing/Implemtation – Software Design Control Unit The various functions for controlling the LCD and

writing to the microSD card worked well independently as designed.

The algorithm for reading off the encoder inputs has room for improvement, does not always record correct state for unknown reasons.

The implementation we used to transfer data to the control unit caused issues related to timing which were difficult to track down. These issues interfered with the LCD drawing functions and required us to scale back the UI.

Page 49: Group 8 Matt McNealy (EE) Scott Martin (EE) Andrew Lee ( CpE ) Josh Hamby (EE)

Implemented User Interface Block Diagram

The UI is implemented using a state machine with each of the display screens being a different state.

Page 50: Group 8 Matt McNealy (EE) Scott Martin (EE) Andrew Lee ( CpE ) Josh Hamby (EE)

Possible improvements

Use a buffer to store the data packets on the sensor side so that a more modular design can be used on the control unit side.

Create a better method of data logging. Reduce power consumption. Reduce size of circuits. Utilize internal memory and USB interface. Implement a heart rate monitor.

Page 51: Group 8 Matt McNealy (EE) Scott Martin (EE) Andrew Lee ( CpE ) Josh Hamby (EE)

Budgeting Fully funded

by the V.A. Contributions

by SignTek.

Page 52: Group 8 Matt McNealy (EE) Scott Martin (EE) Andrew Lee ( CpE ) Josh Hamby (EE)

Questions?