Pages

Wednesday, May 22, 2013

Updates and Diagrams

Update: Final Presentation

Jog Mode
Acceleration can be shown by the increase in amps, which is displayed on the generator. 

Block Diagram of Final Project Overview


Update: Week 9
  • Even though the gearing system has been running smoothly, we decided to design a whole new gear design to add more torque
    • At the moment, it takes the max speed just to get the wheel to spin, and we have to gradually decrease the speed to start running the program, it's a complication we are trying to fix
  • That involves a new construction of the gear holding system!
  • Added a new "setting" to the program, just a standard walking pace
  • Made touch-ups on previous "settings" to fix any flaws or sources of complications
 [Figure Above: Taking apart the previous gearing system]

[Picture Above: Getting help from the TA]


Update: Week 8
Design new support for gears. Goal to increase torque by 6x using NXT gears.
Improve program to take in input for male/female jog or sprint
     Improve the error tolerance so bad input will be rejected
     More speeds variation in program
The motor gear system is successful.
 
[Halvor describing the Motor-Bee Wiring]


[First successful run of gears and motor base]
      
Update: Week 7
Test motor run through laptop: success
Hamster and gear run: failure
     Not enough torque, need to design new gear placement system
Needed to go to woodshop to recut Motor-Base
Reprogram data
--------------------------------------------------------------------------------------------------------------------------
#include <string> //used for strings
#include <iostream> //used for cout
//#include <fstream> //used for the file input/output //used for the strings
#include <unistd.h>
#include <cmath> //basic math functions
#include <cstdlib> //used for the random values

#include "mt.h"
#include "windows.h"

double idealHeartrateMin; //what the minimum ideal heartrate is
double idealHeartrateMax; //what hte maximum ideal heartrate is
int currentHeartrate = 60; //what the users current heartrate is
int age; //users age
int constant; //a constant that is dependant on the users gender
int gender; //a number representing a users gender
int maxSafeHeartrate = 200; //max safe heartrate for a person
int slowSpeed; //speed motors go when set to slow
int fastSpeed; //speed motors go when set to fast
std::string jogging; //variable for what exercide the user wants

void volitility(); //function to simulate randomness in the heartrate
void heartrateChanger(); //function to decide whether to increase or decrease heartrate based on treadmill speed

HINSTANCE BeeHandle= LoadLibrary("mtb.dll"); //loading DLL for motor board
Type_InitMotoBee InitMotoBee; //
Type_SetMotors SetMotors; //
Type_Digital_IO Digital_IO; //

using namespace std;;
int main() //the main function
{
InitMotoBee = (Type_InitMotoBee)GetProcAddress( BeeHandle,"InitMotoBee"); //initializing motor board
SetMotors =(Type_SetMotors)GetProcAddress(BeeHandle,"SetMotors"); //
Digital_IO =(Type_Digital_IO)GetProcAddress(BeeHandle,"Digital_IO "); //
InitMotoBee(); //
// while(InitMotoBee())
// {
while(gender < 1 || gender > 2) //ensures you enter a proper number for your gender
{
cout << "Enter 1 for man, 2 for woman" << endl; //asking for the gender
cin >> gender; //input for your gender
}
if(gender == 1) //for men
{ //
constant = 220; //set constant to 220
}
else if(gender == 2)//for woman
{ //
constant = 226; //set constant to 226
}
while(age <= 0) //makes sure age is a postitive number
{
cout << "Please enter your age (years)" << endl; //asks for the age
cin >> age; //input for the age
}
idealHeartrateMin = ((constant - age) * 0.5); //figures out what the ideal minumum heartrate is for excercising
idealHeartrateMax = ((constant - age) * 0.85); //figures out what the ideal maximum heartrate is for excercising
cout << "Your ideal heartrate is between " << idealHeartrateMin << " and " << idealHeartrateMax << endl; //tells the user what the ideal heartrate average is
cout << "Would you like the standard excercise of jogging? (as opposed to sprinting)" << endl; //prompts user what they want to do
cin >> jogging; //users answer if they want to jog
while(jogging == "yes") //loop for being on the treadmill
{
while(currentHeartrate > maxSafeHeartrate) //loop for when heartrate exceeds max
{
cout << "Heartrate is too high! Shutting down treadmill and calling 911!" << endl; //announces treadmill is shutting down
SetMotors(0, 0, 0, 0, 0, 0, 0, 0, 0); //shuts of motor
sleep(10); //pauses program for 10 seconds so user can read message
return 0; //terminates program
}
while(currentHeartrate < idealHeartrateMin) //loop for while the heartrate is too low
{
cout << "Your heartrate is " << currentHeartrate << endl; //announces the current heartrate
cout << "Treadmill is set to fast." << endl; //anounces that the treadmill is speeding up
SetMotors(1, slowspeed, 0, 0, 0, 0, 0, 0, 0); //turns motor 1 on at slow speed
heartrateChanger(); //runs heartrate function to determine whether or not to decrease heartrate
volitility(); //runs volitility function to simulate randomness
currentHeartrate++; //increase heartrate by 1
sleep(1); //pauses the program for 1 seconds
}
while(currentHeartrate > idealHeartrateMax) //loop for while the heartrate is too high
{
cout << "Your heartrate is " << currentHeartrate << endl; //announces the current heartrate
cout << "Treadmill is set to slow." << endl; //announces that the treadmill is decreasing the speed
SetMotors(1, fastSpeed, 0, 0, 0, 0, 0, 0, 0); //turn on motor 1 at fastspeed
treadmillSpeed = 1; //sets speed motors should run at
heartrateChanger(); //runs heartrate function to determine whether or not to decrease heartrate
volitility(); //runs volitility function to simulate randomness
currentHeartrate--; //decreases heartrate by 1
sleep(1); //pauses the program for 1 seconds
}
while(currentHeartrate >= idealHeartrateMin && currentHeartrate <= idealHeartrateMax) //for when heartrate is between ideal levels
{
cout << "Your heartrate is " << currentHeartrate << ". This is in the optimal range; maintaining treadmill speed." << endl; //announces that the treadmill is going to remain constant
volitility(); //runs volitility function for simulated randomness
sleep(1); //pauses the program for 1 seconds
}
}
if(jogging == "no") //loop for if they dont want to jog
{
cout << "Treadmill is at max speed!" << endl; //tells user motor is being set to max speed
SetMotors(1, 225, 0, 0, 0, 0, 0, 0, 0); //sets motor to max speed
while(currentHeartrate < maxSafeHeartrate) //continues until heartrate reachs mx
{
currentHeartrate += 4; //increases heartrate 4 beats per minute every loops
volitility(); //runs volitility function every loop to simulate rndomness
cout << "Your heartrate is " << currentHeartrate << endl; //tells user current heartrate
sleep(1); //pauses program for 1 second
}
cout << "Heartrate is too high! Shutting down treadmill and calling 911!" << endl; //once loop stops because heartrate is too high everything shuts down
SetMotors(0, 0, 0, 0, 0, 0, 0, 0, 0); //shuts down motor
sleep(10); //leaves program up so user can see what it says
return 0; //terminates program
}
cout << "I guess we aren't going to exercise after all..." << endl; //contingency for when the user enters something other than 'yes' or 'no'
sleep(5); //pauses program so user can see text
// }
return 0; //terminates program
}

void volitility() //function to simulate randomness in heartrate
{
currentHeartrate += (rand() %3)-1; //gets a random number between 0 and 2. It then subtracts one from that to get between -1 and 1. It then adds this to the current heartrate
}

void heartrateChanger() //function to decide whether or not the heartrate goes up or down
{
if(treadmillSpeed < slowSpeed) //for when treadmill is going slow
{
currentHeartrate--; //decreases heartrate by 1
}
else if(treadmillSpeed > fastSpeed) //for when treadmill is going fast
{
currentHeartrate++; //increases heartrate by 1
}
}
--------------------------------------------------------------------------------------------------------------------------

Update: Week 6
Difficulties:
  •  Plugging in the equation into C++
  • Attaching the motor into the wood base
  • Drawing/calculating equations to give to the wood shop to have them cut it for us
  • Using the Motor-Bee CD while running LinuxMint




Update: Week 5
  • Now that we have a motor, we have to come up with a plan to secure the hamster wheel and the motor 
    • Construction of a base board, and potential motor wood-stand
  • Independent research on C++ and MotorBee 
    • Unable to move forward in this project until we learn the programs! 

Update: Week 4

Jithin and Halvor went to Radio Shack to purchase a motor. Purchased 1.5 - 3V Electric Motor. $5.00

Purchased saudering iron and wiring $15.00

Designed wooden base support for hamster wheel and sent to wood shop.

Update: Week 3

Ordered Motor Bee from PCControl Shop (UK) for $43.04 (after Euro conversion)

Ordered 8-Inch Hamster Wheel from Amazon $10

Researched Optimal Heart Rate:

Men:

Min: (220-age)*0.5

Max: (220-age)*0.85

Women:

Min: (226-age)*0.5

Max: (226-age)*0.85 error could be 15 beats higher or lower

Method 2

1. 220-age= Max heart rate

2. Max Heart rate - resting heart rate= HRreserve

3. 0.6*HRreserve+resting heart rate=min heart range

4. 0.8*HRreserve+resting heart rate= max heart range

5. (Min heart range+max heart range)/2=optimal heart beat

Website Link to calculate heart rate

Plan of Project:
Plan to gradually increase speed to reach the interval. If increase speed gradually, the heart can adjust to it. Then gradually decrease speed when reach the min value because the heart will keep working hard because the person running will be getting tired. Point to PROVE the concept.


Working of DC Motor


EHow for how a motor works: How Stuff Works: Elecric Motor

Update Week 2

Basic diagram and updates!

After hours of research, and comments from Reddit computer experts, we have decided to use a Motor-Bee and a motor instead of Raspberry Pi.

The most challenging aspect was finding a place to purchase Motor-Bee. We finally managed to find a place, even though the price was in Euros... 


We even found a site that provided us with a pdf Motor Bee Manual

Update plan: 

  • Use motor bee to run a motor that will be programmed with a powerful laptop/PC
  • Program written in C++ or C

Thursday, May 9, 2013

Week 1: Design Proposal

The "Running" Heart-Beat

Abstract


     When people exercise, it’s usually to tone their figure and staying fit. Sometimes, the most important muscle to be working out should be the heart. This project is about building a Bio-Sensing device that aids humans through exercise by adjusting speed of treadmill to achieve optimal heart rate.

     The person exercising chooses a level of heart rate he/she desires. An amateur person just starting to work out will have a dramatic change in heart rate in a short period of time. A professional athlete is able to run/walk for a long period of time without a major change to his/her heart rate. Using a chest heart-rate-monitor or bracelet watch to measure the heart rate, this data is then going to go into a computer/display. Based on the exercise level chosen, the program will automatically adjust the speed and duration of machine to customize to the heart rate desired.

     Each member will be in charge of a specific area of the project, but the project can only be done through the cooperation of the whole team. The main lead roles are builder, machine shop worker, programmer, project design and test, and project blogger.

     The biggest obstacle is programming the motor to adjust to the heart rate. Also, it will be difficult to demonstrate our concept on a hamster wheel when our purpose is for treadmill human exercising.

Introduction

     The motivation for this project is to invent something that will assist humans. While most projects are around handicap machine aids, our group decided to assist the everyday people in the form of healthy exercise for the heart. Our main goal is to be able to make a program that will correspond with the human’s heart rate and based on the exercising level, speed up/down the treadmill to give the heart the maximum workout. The most challenging aspect is being able to show our presentation on a moderate scale and the coding that will adjust the speed of treadmill.

Deliverable 

     For the completion of the project, we will have to create the blueprints for a design that will wirelessly connect a heart rate monitor to a treadmill in order to maintain the speed needed to keep the optimum heart rate while exercising. We will create a prototype using a hamster wheel that will raise and drop the speed of the wheel depending on the heart rate. We will obtain a heart rate using the monitor while one of us runs on a treadmill. It then will be sent to a raspberry pi (single-broad computer). The raspberry pi will use an algorithm that we have written that will determine whether the wheel should speed up or slowdown in order to maintain the optimum heart rate.

Technical Activities

The technical challenges of the project are getting the heart rate data from a heart rate monitoring device to a computer called Raspberry Pi, creating a code that can interpret the data (figure out whether the heart is beating fast or slow), and getting the computer to adjust the speed of the treadmill based on the data from the heart rate monitoring device.

Transferring Data from Heart Rate Monitoring Device to Raspberry Pi 

The transfer of heart rate data from the heart rate monitoring device to Raspberry Pi will most probably be via a USB cable connected at the USB port of the device to the USB port of Raspberry Pi. The heart rate device has to have an inbuilt capability of reading the person’s heart rate and converting it into a number that will then be transferred to the computer.

Interpreting the Heart Rate Data

Once the data from the heart rate monitoring device is transferred to the computer, it has to be interpreted to figure out whether the person’s heart rate is normal, too fast, or at the optimum range. A code will be written using MATLAB R2012a that reads the incoming heart rate data in real-time and checks to see whether it is in the person’s predefined optimum heart rate range. If the heart rate is too slow, the code will be designed to increase the speed of the simulated treadmill and if the heart rate is too fast, the code should be able to decrease the treadmill’s speed.
3.3 Computer Adjusts the Speed of the Treadmill

Raspberry Pi has to be able to actually adjust the speed of the treadmill based on the incoming heart rate data. A second USB cable will be connected from Raspberry Pi to a USB port in the motor which is physically attached to the simulated treadmill. Once the heart rate data is interpreted by the code, if the heart rate is slower than the predefined optimum heart range, the code will send a message to the Raspberry Pi USB port which is connected to the motor to increase its output voltage by a certain amount that is to be determined experimentally, which will increase the speed at which the simulated treadmill runs. If the heart rate monitor is faster than the predefined optimum heart range, Raspberry Pi’s output voltage will be lower which means the motor will run at a slower speed thereby decreasing the speed of the simulated treadmill.

Project Timeline



Week
Task
1
2
3
4
5
6
7
8
9
10
Studying of circuits, coding, Motor-Bee, and heart rate simulator
x
x
x
x
x





Mechanical design

x
x
x
x
x




Electrical design


x
x
x
x
x



Coding


x
x
x
x
x
x


Testing




x
x
x
x
x

Final report preparation






x
x
x
x
Table 1: Design Project Timeline for “The Running Heart”

Facilities and Resources

We will need to use machine shop tools including a band saw, drills, and soldering irons. Along with this we will purchase a raspberry pi, SPI_3FETs Aristo-Craft Cermag motor, heart rate monitor, and a hamster wheel that will be needed for our prototype.

Expertise 
  • Familiarity with a specific software package 
  • Computer programming experience 
  • Knowledge of basic circuit theory 
  • Use of machine tools 
  • Knowledge in raspberry pi use 
  • Controlling electric motors by USB 
  • Knowledge of basic circuit theory 
  • Use of machine tools (band saw, drills, soldering irons, etc.) 
  • Basic programming knowledge 
Budget


Category
Projected Cost
Bio-sensor
$35
Processor
$51
Simulated Treadmill
$16.50
Pace Maker
$30.00
Plastic Materials
$10.50
TOTAL
$142.00
Table 2: Budget

Bio-sensor

We will use a heart rate monitor, attached to a chest strap that reads the heart rate when the person is running. The heart rates collected from this will then be transferred wirelessly to the processor so there can be adjustments to the treadmill’s speed.

Processor

We will use a Raspberry pi, which is a single-band computer that will hold our algorithm that will determine how fast or slow the wheel will have to spin. The Raspberry pi serves as computer to determine the code that will determine the speed necessary to obtain the optimal heart rate. Also we will use a SPI_3FETs expansion board that will allow a higher voltage to run through the raspberry pi. The SPI_3FETs is needed so the Raspberry pi is not overloaded with volts.

Simulated Treadmill

We will simulate the speeding up and down of the treadmill by using a hamster wheel and an Aristo-Craft Cermag motor. The motor will be attached to the wheel in order to speed up or slow down the wheel to show help the runner maintain the optimal hear rate. Also the motor will be attached to the processor using a USB cord that controls the motor.



Wednesday, April 24, 2013

Project Overview

Abstact:

     The goal of the project is to make a "treadmill" that adjusts speed based on optimal heart rate. The basis of this is to help lose weight more efficiently and promote healthiness.
     In order to achieve our goal, we will program a code using C++ that speeds up or slows down the "treadmill", which will be represented by a hamster wheel.  The code will ask for your gender and age and then plugs them into the appropriate equation for you in order to determine your optimal heart rate. Then every five seconds a random heart rate is ran through the code to show how the "treadmill" will react. If it is lower than the optimal heart rate the speed will increase, if it is higher the speed will decrease. In order to show that our code works, we will use a motor-bee with an electric motor. We will run the code through a computer connected to a Motor-bee that will be able to send different voltages through our electric motor. The electric motor will be glued to a block of wood and has a gear attached to the end of it that fits into the  wheel and spins it.

[Figure 1: Block Diagram of Technical Process of Program]

The main technical activity was writing the code that simulates a heartbeat, comparing it to a calculated ideal heart rate range, and adjusted treadmill speed accordingly. First the program must declare all variables and constants in addition to initializing the MotorBee board/loading the bee’s dynamic link library (DLL).
The program contains two sub functions: the first when run, adds a random number between -1 and 2 to the current heartbeat (this favors increasing as one’s heart rate tends to do over time when exercising), the second function when run, increases the heartbeat if the treadmill is set to fast, and decreases the treadmill if set to slow (the amount it increases is dependent on how far the treadmill speed is from the median up to a maximum of five).
First the program asks the user to enter their gender and age; from these it can calculate the ideal maximum and minimum heart rate for exercising. After stating those two rates, it starts the treadmill. If the heart rate is below optimal it speeds up and if it is above optimal, the program slows it down. The program constantly checks the heart rate every second so it can set the speed of the treadmill accordingly. If the heart rate is neither above the maximum nor below the minimum, it will keep a constant speed. If at any time the individual heart rate exceeds 200 the machine shuts down and calls 911.

The machine also contains some special features: one of which is the spring feature. It sets the treadmill to maximum speed and keeps it there until the user’s heart rate reaches unsafe levels at which point it shuts off. The treadmill will stay at the lowest speed setting so the user can have a slow peaceful walk. 

Monday, April 22, 2013

Project Timeline




Week
Task
1
2
3
4
5
6
7
8
9
10
Studying of circuits, coding, Motor-Bee, and heart rate simulator
x
x
x
x
x





Mechanical design

x
x
x
x
x




Electrical design


x
x
x
x
x



Coding


x
x
x
x
x
x


Testing




x
x
x
x
x

Final report preparation






x
x
x
x

Table 1: Design Project Timeline for “The Running Heart”

     To complete this project, a timeline was created. Before a project was even created, research was done to see what kind of program was needed, what software/circuits/machinery did we need to purchase or hand-make. General research was done for the first week, to come to a conclusion on the project. For weeks 2-5, each individual member studied diagrams on circuits, coding using C++, and review the guide for Motor-Bee. While we are learning how to code using C++ and connecting the MotorBee to the laptop, Annie and Sean were working on the Mechanical Design for the placement of the motor and hamster wheel. Electrical Design was the easy component, since our primary source of power is the laptop and a power generator (which we later eliminated because we got an additional motor). Coding was the hardest part. Many components were added with each week, and constantly edited with each test run.