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 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