Robotics: Project Interactive Treadmill

Peter McGovern D17124525 DT009 year 3 D.I.T

Abstract:

My project was to design and build a user friendly treadmill that could be used by a diverse range of people of varying fitness levels and ages.I have been a regular user of gym equipment and found that treadmills could be made much more interactive with the user by monitoring the users heart rate after the user had entered their vital statistics into the machine.

By monitoring the users heart rate the treadmill could be adjusted to suit their vital statistics and desired treadmill session goals.What this would entail would be if their heart rate got excessively high for their fitness level the speed of the treadmill would automatically slow down or gradually stop.This in my opinion would be a great advantage to people in avoiding injuries and not placing their heart under excessive stress.

I envisioned that the best users of this treadmill would be people recovering from medical issues or ongoing medical problems.

Example a middle aged man recovering from a heart attack.This man under medical supervision would be advised to take up regular exercise to strengthen his heart muscle but only under strict supervision.The man would use the treadmill in a supervised environment and the treadmill would be calibrated to give him a safe controlled work out.His heart rate would be constantly monitored and the readings collected to aid his recovery prevent injury and also give him a future of enhanced fitness levels.

To achieve my goal of an interactive treadmill i decided to build a miniature version of a treadmill and test it out in simulated conditions.

oldertreadmill

Design and Build:

As my project was going to be a miniature i needed it to be both portable but also of a size that could be easily observed and tested.The dimensions i chose were 34 cm long by 10 cm wide by 15 cm high.With the addition of the motor placed at the side the width would be 15 cm wide.

Components Used:

Arduino Nano,                             Breadboard,                        5 Volt DC Motor,                                Driver Chip SN 754410,              3 Green LED lights,            3 breadboard switches,                  Colour sensor TCRT5000,           Capacitor 220uF 35v,         3 resistors 10000 Ω,                         3 Resistors 1000 Ω,                      Connectors,                         Cables 0.75 mm,

Treadmill Components:

Plastic 5mm,                                 Cardboard 5mm,                 Round pipe pvc 20 mm,                Rubber tube 6 cm width,           2 Metal bars round 4 mm,

Build:

I decided that i wanted my treadmill to be lightweight but sturdy and i chose plastic for the frame as opposed to cardboard as i did not believe this to be rigid enough for multiple testings.I proceeded to cut out some plastic sheets into my required dimensions.

Plastic Frame

20181124_174641.jpg

Next i cut up plastic pvc pipe 20 mm to use to rotate my treadmill belt.

20181124_192502

Finally i glued these components together.

20181126_190720.jpg

Next was to build a control panel out of cardboard containing the 3 Led lights and 3 switches.

20181124_174554

3 Switches

20181129_144926.jpg

Built Treadmill

20181129_115817.jpg

Breadboard Components inserted

20181214_125354.jpg

Operation of Treadmill:

State Machine

State                     Description                       Actuators                   State Transitions                      1                            Red switch on               Set motor speed off     Colour  sensor


2                           Yellow switch on          Set motor speed slow   Colour sensor


3                            Green switch on           Set motor speed full     Colour sensor


This was my initial procedure for my Treadmills operating principle but unfortunately i could not proceed with this plan so i altered my procedure.

Altered Operating Procedure:

State                    Description                         Actuators                 State Transitions                      1                           Red switch on                  Stop motor           Green led on


2                           Yellow switch on             Slow motor         Green led on


3                           Green switch on              Full speed motor Green led on


The new procedure would control the treadmill speed by means of the switches only,and each time a different switch was switched a different LED would illuminate.

 

                                               Arduino Nano Code

//                                                                                                                                                                  //  Peter McGovern  Interactive Treadmill                                                                                      //  Last updated  18/12/2018                                                                                                                  //

int  stopButton  =  12;  //  stop                                                                                                                int  slowButton  = 11;  //  slow                                                                                                              int  fastButton  =  10;  //  fast

int redLed  =9;            //  stop                                                                                                                  int yellowLed  = 8;     //  slow                                                                                                                int greenLed  =  4;     //  fast

int  motorSpeedPin  =  5;                                                                                                                      int  motorForwardPin  =  6;                                                                                                                  int  motorReversePin   =  7;

int state  =  1;

//  The setup routine runs once when the power is switched on.////////////////////////////////////////////

void  setup ()                                                                                                                                            .

{

//   Digital outputs for LED

pinmode (redLED,  output) ;                                                                                                                pinmode (yellowLED,  output) ;                                                                                                          pinmode (greenLED,  output) ;

//  Digital outputs  for  motor

pinmode (motorSpeedPin,  output) ;                                                                                                  pinMode (motorForwardPin,  output) ;                                                                                            pinMode (motorReversePin,   output) ;

//   Digital  inputs  for buttons

pinMode (stopButton,  input) ;                                                                                                            pinMode (slowButton,  input) ;                                                                                                          pinMode (fastButton,    input) ;

//   Open  serial  port  to  display  colour  readings  on  screen                                                     serial .begin (9600) ;

}

//   Simple  version                                                                                                                                  void  loop ()                                                                                                                                              {                                                                                                                                                                       if   (state  ==  1)  //  STOP                                                                                                                         {                                                                                                                                                                    //   Actuators                                                                                                                                           digitalWrite (motorForwardPin,  LOW) ;                                                                                           digitalWrite (motorReversePin,   LOW) ;                                                                                           digitalWrite (redLED,   HIGH) ;                                                                                                           digitalWrite (yellowLED,   LOW) ;                                                                                                       digitalWrite (greenLED,   LOW) ;

//   Change  state ?                                                                                                                                   if    (digitalRead (slowButton)  ==  1)  state  =  2 ;                                                                             if    (digitalRead (fastButton)    ==  1)  state  =  3 ;                                                                         }                                                                                                                                                                 else  if  (state  ==  2)  //  SLOW  FORWARD                                                                                         {                                                                                                                                                                     //  Actuators                                                                                                                                            digitalWrite (motorForwardPin,   HIGH) ;                                                                                        digitalWrite (motorReversePin,     LOW) ;                                                                                        analogWrite (motorSpeedPin,    255) ;                                                                                                digitalWrite (redLED,   LOW) ;                                                                                                            digitalWrite (yellowLED,   HIGH) ;                                                                                                      digitalWrite (greenLED,   LOW) ;

//   Change  state ?                                                                                                                                    if   (digitalRead (stopButton)  ==  1)  state  =  1 ;                                                                                if   (digitalRead (fastButton)   ==  1)  state  =  3 ;

}                                                                                                                                                                  else  if  (state  ==  3)  //  FAST  FORWARD                                                                                            {                                                                                                                                                                     //  Actuators                                                                                                                                            digitalWrite (motorForwardPin,   HIGH) ;                                                                                        digitalWrite (motorReversePin,    LOW) ;                                                                                          analogWrite (motorspeedPin,   255) ;                                                                                                digitalWrite (redLED,   LOW) ;                                                                                                            digitalWrite (yellowLED,   LOW) ;                                                                                                      digitalWrite (greenLED,   HIGH) ;

//   Change  state ?                                                                                                                                    if   (digitalRead (stopButton)  ==  1)  state  =  1 ;                                                                                if   (digitalRead (slowButton)  ==  1)  state  =  2 ;                                                                           }                                                                                                                                                                 else  if  (state  ==  10)                                                                                                                             {                                                                                                                                                                     while (1)                                                                                                                                                   {                                                                                                                                                                      //  forward  fast                                                                                                                                       digitalWrite (motorForwardPin,   HIGH) ;                                                                                         digitalWrite (motorReversePin,    LOW) ;                                                                                         analogWrite (motorSpeedPin,   255) ;                                                                                                 digitalWrite (redLED,   LOW) ;                                                                                                             digitalWrite (yellowLED,   LOW) ;                                                                                                       digitalWrite (greenLED,   HIGH) ;                                                                                                       delay (2000) ;

//  reverse  slow                                                                                                                                       digitalWrite (motorForwardPin,   LOW) .                                                                                         digitalWrite (motorReversePin,   HIGH) :                                                                                         analogWrite (motorSpeedPin,   100) ;                                                                                                 digitalWrite (redLED,   LOW) ;                                                                                                             digitalWrite (yellowLED,   HIGH) ;                                                                                                     digitalWrite (greenLED,   LOW) ;                                                                                                         delay (2000) ;

//  stop                                                                                                                                                       digitalWrite (motorForwardPin,   LOW) .                                                                                         digitalWrite (motorReversePin,    LOW) .                                                                                         analogWrite (motorSpeedPin,   255) ;                                                                                                 digitalWrite (redLED,   HIGH) ;                                                                                                           digitalWrite (yellowLED,   LOW) ;                                                                                                       digitalWrite (greenLED,   LOW) ;                                                                                                         delay (2000) ;                                                                                                                                       }                                                                                                                                                             }                                                                                                                                                              }

                                                     Testing

Testing: To test my treadmill i alternated between the different switches and it performed well to the arduino code.My yellow LED and Green LED stopped working after a few tests were conducted so i placed 3 green LED’s to the left of my treadmill to show the different stages of the treadmill in operation.Treadmill performs very well.

The first button red LED stops the treadmill

The second button yellow LED makes the treadmill run slow.

The third button green LED makes the treadmill run at full speed.

To watch my Treadmill in Operation please go to this address

                                              Video https://youtu.be/aKs171lDa00

 

20181214_125342.jpg

 

 

 

 

 

 

 

 

 

 

Modbus

Introduction: Modbus is a way of transmitting information over cables between electronic devices.The device supplying the information is called the Modbus Slave and the device requesting the information is called the the Modbus Master.Common uses would be for industrial electronic devices i.e instrumentation being controlled by a controller.My task was to receive a signal on my arduino from another arduino and control a servo motor placed on my breadboard with a potentiometer.

Components and Components uses: Driver chip Sipex 485,Breadboard,Arduino Nano,Servo Motor,Cables,Potentiometer and a Led light.

Driver Chip Sipex 485 is used to control motors they act as an interface between microprpcessors and the motor that needs to be controled.

Driver Chip Sipex 485

sipex2

Test of Circuit:  A signal was sent through the Master Arduino into my Arduino Slave and it firstly lit up my Led light after this i connected up my servo motor to the circuit and a signal was sent to my arduino and it worked as planned.

Image of my Modbus Circuit

20181011_160505 (2)

Outcome: Task was performed exactly as planned and modbus task was a success.

 

Serial Communications

Introduction: In this task i wanted to send a signal from one arduino to another arduino,the resulting signal would appear on the computer monitor and the signal would be sent by 2 cables.The data gets sent between the 2 cables one bit at a time and the receiving arduino decodes it into decimal numbers.

Components: Breadboard,2 cables and 2 Arduinos.

On the Arduinos they cables are connected as shown in diagram.

 

serial communications

 

Connections into my Arduino

 

20181018_162804.jpg

Arduino Code

 

20181018_165129.jpg

 

Signal Received

 

20181018_162807.jpg

Results: Circuit performed as desired and i received a signal from the other arduino as shown above.

Current Limiter

Introduction: In this task my objective is to limit the current to between 4 and 20 mA.

Components and Components uses:Resistors 100 Ω 150Ω1000Ω,Op amp LT1006,Transistor Q1 2N3904,Breadboard and a variable dc power supply up to 5 volts dc.

Components uses Op amp LT1006 is an electronic amplifier which means when a dc voltage is placed into it the amplifier can ramp up the output voltage called the gain to levels much higher than the input voltage.                                                                                      Transistor Q1 2N3904 is a transistor which means it can work either as a electronic switch or as an electronic amplifier for current.                                                                             Variable DC Supply comes from a portable voltage generator.

Building the Circuit: I placed the 100 and 150 Ω resistors in series and the 1000 Ω resistor between the 24 volt input and the collector.Pin 1 of op amp to base of transistor,pin 2 connected to the emitter.

Op – Amp connections

LT1006

Transistor

2N3904-NPN-General-Purpose-Amplifier

My Current Limiter Circuit

 

20181011_182514 (1).jpg

Testing my Circuit i placed 24 volts into the Vcc and 1 to 5 volts across the positive and negative here are my results in amps measured.

Voltage Input  Volts                Current mAmps                                                                                       1                                                 4.18                                                                                                         2                                                 8.0                                                                                                           3                                                 12.0                                                                                                         4                                                 15.04                                                                                                       5                                                 19.26

The circuit operated as desired and nearly a full 20 mAmps was achieved.

 

 

 

 

Stepper Motor

Introduction: In this task my objective was to control a Stepper Motor by using an arduino code to control it.

Components and Components uses: 5V DC Power Supply,Stepper motor,Arduino nano,Breadboard and Cables.

Stepper Motor is dc electric motor brushless it is divided into an even number of positions and can be held at these positions by using the microcontroller.                              SN 754410 Chip is a motor driver chip which can drive 5 volts up to 36 volts and up to 1 amp supply.It is a quad half h-bridge which means it can control 4 motors at one time.

I connected up all the components on the breadboard and implemented the code on the arduino stepper motor code the motor worked exactly as predicted.

Arduino code

 

20181004_181005 (1).jpg20181004_180956 (1).jpg

Voltage in and voltage measured

20181004_170603 (1).jpg

 

Stepper motor connected to arduino

20181004_170553.jpg

Task Servo Motor

Introduction: In this task i connected a Servo Motor to an Arduino and also to my 5v dc power supply and controlled it by using a potentiometer.

Components and Components uses: Servo Motor,Arduino,Potentiometer,5v dc supply.

Components uses: Servo Motor is a motor that can turn 90 ° degrees in either direction and is controlled by Pulse Width Modulation through the Potentiometer.                                Potentiometer has three terminals and acts like a voltage divider and are used to control very small outputs.                                                                                                                                 Arduino these are microcontrollers that control sensors and motors by way of software programming.

Procedure: I connected up the components to my original 5 v dc supply and entered in the arduino code i obtained from the arduino library.The servo motor performed correctly and next i connected up the potentiometer this allowed me to control the servo manually and worked well.

Arduino Code

20181031_133618

Servo with Potentiometer

20181031_134039.jpg

Making a 5 volt power supply

Introduction: In my first task i am going to build an independent power supply of 5 volts from a bench power supply of 15 volts.

Components and Components uses:

Breadboard,Resistor,Cables 0.75mm,Heat sink,Rectifier.

Components uses:                                                                                                                                   The Rectifier converts AC voltage to DC voltage by means of diodes.                                         The Heat Sink a heat exchanger that takes too much heat in an electrical circuit and dissipates it,in this case its like a radiator.                                                                                        The Resistor offers electrical resistance in the circuit to reduce the current flow which helps protect the components.                                                                                                             The Breadboard is used to solder all the components to the cables and then to the individual components.

 

 

Building the Circuit: I soldered these components to the breadboard and then checked to see if i had 5 volts dc supply i did success.

20180920_175408 (1)

20180920_175347

 

Robotics Week 2

Intoduction to Kinematics Forward and Inverse Kinematics.

Kinematics is the study of how to describe the movement of objects i.e  angle of movement or the speed the object moves at.

An example of this is the movement of a robotic manipulator.The manipulator contains the following joints a revolute joint a prismatic joint and an end effector.The revolute joint can move along the x and y axis as shown and the prismatic joint moves in and out like an actuator or a ram as shown.The end effector is device at the end to pick up or move an object.

20181121_220926

Forward Kinematics : In order to work out the the angles and distance that the manipulator can move at we need to do some calculations.

Example: What is (x,y)? When S = 20° and L = 60 cm.

Answer = Cos of 20°  × 60 cm = 0.936 × 60  x = 56.38 cm.

Sin of 20° × 60 cm = 0.34 × 60 y = 20.52 cm.

Inverse Kinematics : In order to find x and y we do the inverse.

X = 30 cm   and Y = 15 cm. What is S and L ?

L = √ x² + y² = 33.54 cm.

S = sin−¹ (Y/L) = 26.54°

SCARA : Selective Compliance Articulated Robot Arm.

20181121_231552

Forward Kinematics Example :Given L1 and L2 (fixed) and S+E (variable)

Calculate (X,Y)

L1 = 30 cm   L2 = 20 cm  S = 10°  E = 30°

Robotics Week 1

Fitness Treadmill

Description: The treadmill will monitor the heart rate and respiratory rate of the user and depending on the users fitness level will adjust the speed of the treadmill for optimum speed for the users fitness.

When a person is using the treadmill a heart rate sensor and respiratory sensor will be placed on their person.As their heart rate increases during use the automated machine will monitor the heart rate and depending on a preset level the machine will either speed up or slow down the treadmills speed.This also applies to the respiratory sensor it will be placed on the person and depending on a preset level will either slow down or speed up the treadmill.

Applications/Uses: The primary function of this machine is to monitor a person to a high level while they are using this machine and to control the speed so any risks to a persons health and well being are greatly removed.The main users will be people recovering from heart complications under supervision of a doctor and people beginning a fitness regime and wanting to do it safely.

Prototype Demonstration: I intend to construct a miniature version of a treadmill and place the heart rate sensor and respiratory sensor on a person and use the sensor readings to vary the speed of the treadmill.

Required Materials: Miniature treadmill,Arduino Nano,Pulse Sensor SEN -11574 Spirometer Honeywell ASDX Series Silicon Pressure Sensor,Breadboard,LCD screen or a monitor.Speed sensor for treadmill motor.IR Sensor for measuring speed of motor controlling conveyor.

Robosumo Week 9

Robosumo Week 9

Robosumo Challenge

The big day arrived robot was functioning perfectly and compared to other robots ours was a good design.The structure was very solid there was little risk of damage and there was no vulnerable components placed in harms way of the other robots.

The challenge began and we lost our first bout as the robot was placed to close to the outer circle and one wheel was dangling over the side.The next contest was much better we pushed back our opponent and proceeded to the next challenger.The next opponent defeated our robot by pushing ours back it did so by having wider wheels this would appear to be our downfall.We proceded on to win two further bouts but were again pushed back by a robot with better traction.

Overall we finished Tenth the last opponent we lost to didn’t do much to defeat our robot it just span around in a circle but was judged to have won because it was closer to the centre than our robot.Our robot was seeking out the other robot and this was the reason it was not close to the centre of the table at the end of the contest.

Conclusion:

The entire project was a great success I learned more about coding.I learned a great deal about the sensors used and how to use them to the best of their abilities.I learned to place each component in the correct location and to make a record of all these components.I learned how to make a robot and to adapt it as different outcomes were required of the robot for the conditions and challenges it was placed under.

The design and capabilities of the robot were very good but unfortunately it was let down by the traction of the wheels ie the wheels were to thin to make the wheels wider this would have required a new design and I was happy with the design and functionality of the robot so I did not wish to redesign it.

I would like to thank my teammates Kenny Labour and Eedris Akinade for their teamwork and ideas and my instructor John McGrory for helping us out throughout the whole robot design and build.

 

//
// RoboSumo navigation example using rangefinder
//
void setup()
{
  pinMode(2, INPUT);  // rangefinder echo
  pinMode(3, OUTPUT); // rangefinder trigger
  pinMode(4, OUTPUT); // left motor forward
  pinMode(5, OUTPUT); // left motor reverse
  pinMode(6, OUTPUT); // right motor forward
  pinMode(7, OUTPUT); // right motor reverse
  pinMode(8, OUTPUT); // blue LED
  // A0 is left colour sensor
  // A2 is right colour sensor
  // Serial.begin(9600);
}
void loop()
{
  int colour_left, colour_right, object_detect;
  
  // Read colour sensors
  colour_left = analogRead(0); 
  colour_right = analogRead(2);
  // Use rangefinder to check for object
  digitalWrite(3, HIGH);
  delayMicroseconds(20);
  digitalWrite(3, LOW);
  while(digitalRead(2) == 0); // wait for start of echo
  delayMicroseconds(2000);
  if (digitalRead(2) == 0) object_detect = 1;
  else object_detect = 0;
  // Robot behaviour
  if (object_detect == 0)
  {
    digitalWrite(8, HIGH); // LED on
    motors(1, -1);
  }
  else
  {
    digitalWrite(8, LOW); // LED off
    motors(1, 1);
  }
  delay(100);
}
void motors(int left, int right)
{
  if (left > 0)
  {
    digitalWrite(4, HIGH);
    digitalWrite(5, LOW);
  }
  else if (left < 0)
  {
    digitalWrite(4, LOW);
    digitalWrite(5, HIGH);
  }
  else
  {
    digitalWrite(4, LOW);
    digitalWrite(5, LOW);
  }
  
  if (right > 0)
  {
    digitalWrite(6, HIGH);
    digitalWrite(7, LOW);
  }
  else if (right < 0)
  {
    digitalWrite(6, LOW);
    digitalWrite(7, HIGH);
  }
  else
  {
    digitalWrite(6, LOW);
    digitalWrite(7, LOW);
  }
}