Introduction top
" A bioelectrical impedance based body fat scanner."
For our final project, we have decided to use the microcontroller provided to make a device which would measure body fat percentage of one's body. The basic principle behind this project is known as bioelectrical impedance analysis. This technique uses a small alternating current flowing between two electrodes attached to skin surface to determine impedance. By determining the opposition to the electric current through body tissues, we can estimate the water content of the human body and use it to estimate fat-free body mass. The IV response characteristics of these tissues can provide a good estimation of percentage body fat.
High Level Design top
Rationale and Source of Our Project Idea
It has always been easy to record one's weight loss. However, it is more tedious to measure one's body fat percentage. Certain methods include skin calipers and hydrostatic underwater weighing which are not simple. One can also roughly estimate their body fat percentage by looking in the mirror. However bioelectrical impedance analysis provides a quick and easy method to estimate one's fat content. The inspiration of this project is to promote personal health and to track workout progress.
Background Information
The measurement is best taken when the electrodes are placed at the wrist and the contralateral ankle. When measuring the impedance of the cellular tissue, we model it as a resistor in parallel with a resistor and capacitor in series. In this model the single resistor represents the extracellular path and the resistor and capacitor in series represents the intracellular path. This model shows a change in impedance with respect to the frequency of the AC current. By injecting an AC current through one's body and measuring the voltage across the electrodes, we can easily find the instantaneous impedance. This project requires a current to go through one's body which is dangerous so it is imperative to generate a small AC current through the two electrodes, possibly on the order of 10 μA. Since the nature of this measurement heavily depends on how hydrated the body is, there are optimal conditions when using device. The person should: not drink alcohol within 48 hours of the measurement, not engage in moderate or vigorous physical activity within 12 hours of measurement, not eat or drink anything within 4 hours of measurement, urinate within 30 minutes of measurement. Even under these conditions, it is possible to overpredict body fat in more lean bodies and underpredict body fat in obese bodies. In order to calibrate and test the accuracy of our results, we will compare with the skin caliper method of measuring body fat.
Logical Structure
Hardware and Software Tradeoffs
For this project, a certain amount of hardware complexity was required in order to achieve basic functionality,
and couldn’t be translated into software. One piece that could have simplified hardware complexity would be to use a
555 timer or other oscillator to generate the signal input to the subject rather than the microcontroller. This
oscillator could be powered off of the same power source as the rest of the biological side of the circuit, eliminating
the need for the input signal isolation. However, this increases the difficulty of adjusting frequency. For this reason
, we opted to use the microcontroller to generate signal rather than doing it with other hardware. While this increased
hardware complexity, we felt that the ease of signal control granted by the MCU was worth the tradeoff.
The other major hardware/software tradeoff was in taking user input. Currently, the setup takes user input from a
computer UART terminal. The more hardware based alternative would be to take user input from a keypad. While a keypad
improves device portability, it is also a less intuitive input method and would restrict the software to a state
machine based design.
Standards
ISO/IEEE 11073 is the family of standards which refers to personal health device communication. They are designed
to help healthcare product developers create devices to promote disease management, health, and fitness for global
benefit. Under this group of standards, part 10420 refers to device specialization for a body composition analyzer.
This standard covers devices that measure body impedances.
The EN60601-1-2 standard defines the levels of immunity to electromagnetic interferences and the maximum
levels of electromagnetic emissions for medical devices. For example, cellphones may generate strond electromagnetic
fields near the medical device.
Relevant Patents
A couple of notable patents were found pertaining to our project. The first is US 661816 B2, “Bioelectrical impedance measuring apparatus” and the second is EP 15651505 A1, “Multifrequency bioimpedance determination”. The first patent involve s a method for using personal data input to assist the bioelectrical impedance analysis. The second patent involves applying current sources of different frequencies in order to measure different body characteristics in order to estimate body fat composition. Our project is a simpler design which calculates body fat percentage with user input parameters and single frequency current source to determine body fat percentage.
Hardware top
Isolating signal from MCU
In order isolate the user from the 110 V ground line from the MCU power supply to guarantee user safety, the circuit in Figure 3 is used. The linear optocoupler (IL 300) is fed back into a control amplifier which determines the output of the LED in the IL 300. This controls the behavior of the photodiodes in the optocoupler to follow the input signal. By setting the two resistors (R1 and R2) equal to each other, we obtain a unity gain so the output signal equals the input signal. Since the purpose of this circuit is to isolate the input signal to the user, we must be sure to use the rails from the microcontroller unit on one side of the optoisolator and a separate set of power rails for the other side.
Get Voltage across two electrodes
The first stage of this circuit is the current source that takes in the isolated 50 kHz signal and generates a 10 uA current source at 50 kHz frequency. The resistor from the negative terminal to ground (R3) is in parallel with the human impedance which forms a divider. This allows us to choose R3 so that the we can always get the correct constant current across the electrodes. The second stage of this circuit is the voltage subtractor which gives us the voltage across the electrodes (represented by the resistor labelled as human impedance). By making resistors R4=R5=R6=R7, the circuit behaves as a unity gain differential amplifier so the output of this amplifier is simply the voltage difference of the two electrodes.
Split 9V battery supply
In order to generate the +4.5 V and -4.5 V rails, the circuit in Figure 5 was used. The 9 V battery is essentially split into the two rails through the voltage divider (the two 100 kOhm resistors) with the output of the operational amplifier acting as our virtual ground. The 1 uF capacitor removes noise in power rails. This way, these isolated rails can be used for the IL 300 (linear optocoupler) and the human impedance circuit.
Isolating Signal Back to the MCU
The isolating circuit is the same as the one used previously. We need to use the power rails of the microcontroller unit to provide a stable signal for the ATMEGA1284. Resistors R9 and R10 are equal to each other to ensure unity gain since we want the output to be the same as the input. We need a low pass filter was used to smooth out the signal so the microcontroller can perform calculations on the data from the signal.
Software top
Overview
The software component for this project consisted of two parts - a realtime system for user input and bioelectrical voltage analysis, and a MATLAB script to create a regression curve correlating body impedance and user body fat.
I/O System and TinyRealTime
The C code running on the microcontroller utilized the TinyRealTime kernel in order to run 3 tasks concurrently in real time. The three tasks included a body fat calculation task, an LCD printing task, and a serial communication task. Each task other than the user input loop had a specified release and deadline time, such that fat calculation ran ~25 times a second, and LCD communication ran ~5 times per second. These rates were chosen such that those tasks executed often enough to be observed easily by the user. The user input loop was not scheduled at certain times – rather, it executed when the user pressed enter in the UART terminal, which allowed for a faster and more intuitive user experience than scheduling the task. All shared variables in the program were protected using a single semaphore, SEM_SHARED, which allowed only one task to hold the semaphore at any given time. This prevented the variables from being overwritten while in use by a different task, which would hurt the correctness of the program execution. The idle task is initialized with a stack size of 80 bytes, which creates a stack for each task that is large enough that the tasks do not overwrite each other’s stacks. Additionally, the given trtSettings.h file was modified to work with the 16 MHz crystal of the ATMega1284P rather than a 20 MHz crystal.
The program took user input from a UART terminal using PuTTY, set to 9600 baud rate to match the transmission rate of the microcontroller. At the command line, the user was able to enter three parameters: weight, age, and gender. Weight was required to be in pounds, and gender used a binary encoding, 0 for female and 1 for male. With this system, the user could change parameters at any time during program execution, giving a significantly faster response time than a state machine based approach.
Body Fat Calculation
In order to collect body fat measurements, we required a 50 kHz signal to pass through the body. Using timer 0, we set the prescaler to divide by 8, the output compare register to 20, and enabled interrupt on overflow. These settings would cause timer 0 to run at 2 MHz, and trigger the overflow interrupt at every 20 ticks. By toggling pin B3 in the timer 0 overflow interrupt, pin B3 output a square wave with a frequency of 50 kHz. Additionally, this frequency would be easily customizable for potential multi-frequency analysis - by simply modifying the output compare register, one could easily generate dfferent frequencies of square waves.
The other important piece of software setup required turning on an ADC input, to retrieve the output voltage from the circuit. The ADC was set to be left adjusted, and compared to AVcc, which was hooked up to the 5 volt Vcc of the microcontroller. The output voltage from the circuit was connected to the ADC at pin A0, and was read every time the body fat calculation task was executed. Since the regression equations used to calculate body fat utilized the ADC conversion of voltage as one of their parameters, the value read from the ADC was simply used directly to calculate body fat. As a design note, the original software design sampled the ADC input, and kept track of when the input voltage repeated, in order to determine signal rise time. The signal rise time was used to calculate the imaginary, reactance component of the subject's body. When we determined that there was no discernable change in accuracy, we decided to eliminate this component from the calculation in order to preserve speed of execution. The low-passed output signal from the body provided the real, resistive component of the signal.
MATLAB Script and Data Processing
A major part of being able to determine body fat involved determining how the impedance information collected from the circuit related to the subject's body fat. To create the body fat equations, we used the volunteer body fat, voltage, age, and weight data. This data was passed to the MATLAB function mvregress, which outputs a vector of coefficients that weight the independent variables (age, weight, and voltage) in order to closely match the collected dependent variable (body fat). Data sets for male and female test subjects were run separately, in order to create distinct equations for each gender, and for simplicity, the ADC input value was used instead of raw voltage. The advantage of this approach is that the MATLAB script utilizes the built-in multivariate regression function to relate several independent variables to one dependent variable, and the script can be re-run to obtain a new regression equation as the data set is expanded. The regression equations obtained were:
Males: body_fat = 0.0923 * weight + 0.1605 * age - 0.0263 * voltage
Females: body_fat = 0.1871 * weight + 0.5800 * age - 0.0920 * voltage
Results top
Safety
The greatest concern of any bioelectrical system is for the safety of the user. In this system, the greatest safety risk posed to the user lay with passing electrical current through the body. Since we needed to pass current through as much of the body as possible, current passed through vital organs ike the heart, which required us to be very careful with how much current we were passing, Generally, from our research, we learned that current through the body for bioelectric impedance analysis is limited to the microamp range, and we decided to shoot for ~10 uA as the output from our current source to the subject. In practice, we achieved a consistent amplitude of approximately 12 uA for the signal passed into the user, which fit our safety requirements. Additionally, all users that tried the device reported no discomfort or strange sensation from the current being passed through the electrodes to their body.
Accuracy
The accuracy of the device was found to be reasonable within a certain range, but poor outside that range, due to the calibration data that we collected to create the regression equations. In order to make the body fat equations, data was collected from 12 subjects - 7 male, and 5 female. All subjects were within the ages of 20-22, with an average age of 21. Since there was little to no variation in age, the algorithm wuld only work well on people in that age range. Within males, there was little deviation in weight as well - 5 of the 7 male subjects weighed between 160 and 170 pounds. Females also had similarly restricted weight range. With a greater range of test subjects, accuracy can be greatly improved. Over all test subjects, the device's body fat prediction was higher than the caliper-measured body fat by .5 percentage points. This translates to an average percent error of 15%, which was higher than our goal of 10%. This increased error can be accounted for by test subjects who significantly differed in weight or body composition from the average test subject. The average percent error for male subjects was 20%, while average percent error for female subjects was approximately 8.4%, which can be accounted for by the presence of outliers in the data. Excluding outliers, average percent error for males was 9.2%. A larger test population that is more representative of the variation in human body composition would result in significantly greater accuracy.
Conclusions top
Results vs. Expectations
The expectation at the start of the project was that the device would be safe, use a signal of ~10 μA and 50 kHz to determine body impedance, and predict body fat within a 10% error margin. The final circuit, while differing in certain respects from the original design, did achieve the safety and signal goals, while it conditionally achieving the accuracy goal. The device operated at a safe current and did not harm any of our test subjects. Our input signal to the user is approximately 12 μA, which is quite close to our goal of 10 μA, and is still safe to pass through a user’s body mass.
For our accuracy goal, we were able to achieve body fat prediction within a 10% error margin for subjects matching our test samples, but we had poor accuracy outside that fairly specific range of weights and body compositions. Given the small concentration of test subjects, we are pleased with the accuracy for the tested range, but there is significant room for improvement in accuracy for more body types.
Future Changes
This project provides many opportunities for future extensions. One extension would be to improve accuracy by implementing multi-frequency bioimpedance analysis. Each different frequency provides a different weighted sum of total body water and fat free mass, so by analyzing on multiple frequencies and comparing resistance and reactance measurements from each frequency, it is possible to obtain a more accurate result, as well as other metrics like hydration, muscle mass, and bone mass. This extension might be implemented by switching the software to a state-machine based approach, and modifying timer 0 to generate different wave frequencies.
Another possible extension would be to miniaturize the device and make it portable – this could allow for health conscious users to take it with them to the gym, for example. Modifying the device to work with conductive handles rather than electrodes would increase ease of use. In addition to the other changes, a logging system and linked application could be added to track body composition and hydration changes.
Intellectual Property Considerations
The hardware was all derived from several sources. The optocoupler circuits and the intuition behind them were based
from application circuit provide in the IL 300 data sheet. Our 10 uA current source is a modified non-inverting
amplifier which Bruce Land helped us with. Bruce also helped us develop the split supply for the 9 V battery.
Our software was mainly written by us with the exception of the Tiny Real Time (TRT) and trtUART libraries. TRT was
written by Dan Henriksson and Anton Cervin which were modified by Bruce Land to cater towards his ECE 4760 course.
trtUART was written by Joerg Wunsch.
Ethical Considerations
Our project adheres to the IEEE Code of Ethics. We have both assisted each other in the development of this device in a professional matter. Since our device uses collected data from volunteers In order to calibrate our device, we must acknowledge that body fat percentage and obesity are sensitive matters. We must consider the stigma and discrimination against obese people and we have agreed to keep the collected data anonymous and unreleased to the general public. We have not bribed any of the participants as they are all volunteers. Each volunteer has agreed to be tested by our device and was taught how to use the calipers in order to perform a three point skin-fold analysis. We treated all volunteers without discrimination against race, religion, gender, disability, age, national origin, sexual orientation, gender identity, or gender expression. We do not use user data in an unintended manner, and we do not profit from the use of their data. All test subjects were given a verbal confirmation that their data would be not be used in any manner without their permission. No individual was harmed or injured by our device as we made certain the safety considerations with passing a current through a human. A 10 uA current source is well below the maximum current a human can handle. We also agree that all the claims and estimates provided are honest and realistic and were given to improve the understanding of technology.
Legal Considerations
Our project does not violate any legal considerations. All external libraries (trtUART and TRT) were properly licensed, and all materials used were purchased by us or taken from lab or as scrap with permission. All test subjects volunteered with no expectation or compensation, and we are not publishing any potential identifying data on this page, nor are we profiting from their participation in our project.
Acknowledgements
We would like to thank our instructor, Bruce Land, for his teaching and guidance throughout this project, and througout the ECE 4760 course. We would also like to acknowledge Dan Henriksson, Anton Cervin, and Joerg Wunsch, for their work on the software libraries we used in this project. Finally, we would like to thank our test subjects, who patiently underwent the testing process and agreed to let us use their sensitve data.
Finally, a public acknowledgement to the following testing volunteers who asked to be publicly acknowledged:
- Shiva Rajagopal
- Jake Streb
- Richard Quan
References top
Datasheets
MEGA1284 Datasheet
IL 300 Linear Optocoupler
IL 300 Application Note
LF353-N Operational Amplifier
References
Body Impedance Assessment
Determination of Body Composition
Bioelectrical Impedance Analysis
Current Source for Bioimpedance Application
Principles and Methods of Bioelectrical Impedance Analysis
Voltage Subtractor
Obesity Stigma: Important Considerations for Public Health
IEEE Code of Ethics
Appendices top
A. Schematics
B. Division of Labor
Samir Borle | Peter Li |
---|---|
Overall Hardware Design | Overall Hardware Design |
Overall Software Design | Hardware Schematics |
Bioimpedance Analysis Research | Bioimpedance Analysis Research |
Software Debugging | Circuit Board |
Analyzed Sample Data | Obtained Volunteers |
Website | Website |
C. Parts List and Costs
Part | Vendor | Cost/Unit | Quantity | Total Cost |
---|---|---|---|---|
ATMega1284P | Lab Stock | 1 | $5 | $5 |
MCU Power Supply | Lab Stock | 1 | $5 | $5 |
White Boards | Lab Stock | 2 | $6 | $12 |
LCD (16 x 2) | Lab Stock | 1 | $8 | $8 |
10k Potentiometer | Lab Stock | 1 | $0 | $0 |
Wire | Lab Stock | 2' | $0 | $0 |
Capacitor | Lab Stock | 1 | $0 | $0 |
Resistors | Lab Stock | 12 | $0 | $0 |
LF 353N | Lab Stock | 3 | $0 | $0 |
IL 300 (Linear Opto-isolator) | Lab Stock | 2 | $4 | $8 |
Single Use Electrode | Lab Stock | 2 | $0 | $0 |
Electrode Gel | Lab Stock | 1 | $0 | $0 |
9 V Battery | IEEE Spare Part | 1 | $2 | $2 |
9 V Battery Adapter | Lab Stock | 1 | $0 | $0 |
Desktop Computer | Lab Stock | 1 | $0 | $0 |
Serial Cable | Lab Stock | 1 | $0 | $0 |
TOTAL: | $40.00 |