You are on page 1of 9

Indu Shekhar Kumar ME 2900 Prototype report 4/18/14

This prototype was an attempt at making a propulsion mechanism for a toy boat. The mechanism would propel as well as navigate the boat with the help of a wired touch screen. There were two main functions of the prototype, propulsion and turning. To attain high speed propulsion the DC motor was chosen, as it can operate at high speeds, however for the turning mechanism a motor was needed which could turn in either direction with one touch on the touch screen. To achieve this, the continuous servo motor was used. This motor has great flexibility in degree of rotation and direction. A touch screen was used as the sensor, as it was similar to a keyboard controller. Moreover, in this age of smart phones, controlling a toy boat with a touch screen would be something unique. This prototype comprises of two actuators, which result in full mobility in all possible directions. The touch screen had four different operations incorporated into its four quadrants.
Turn Left: (moves servomotor counterclockwise) Turn Right: (moves servomotor clockwise)

Brake: (slows down the DC motor)

Accelerate: (speeds up the DC motor)

The topleft quadrant of the touch screen is used turn the boat left. Similarly, the topright quadrant is used to turn the boat right. The motion of the servo motor is activated by touching in the appropriate quadrant. However, the bottom two quadrants respond to touch as well as pressure. The bottom-left quadrant is responsible for braking and right for accelerating. The harder you press the bottom quadrants faster the operation is performed. In other words, the DC motor increases in speed the harder you press the bottom-right quadrant and it decreases in speed when you press the bottom-left quadrant. One, more thing that this prototype includes are the LEDs. The green LED lights up to indicate that the motor is accelerating and the red LED lights up to indicate braking. The brightness of the LEDs is directly proportional to the pressure applied in the respective quadrants. The button seen in the figure below is used to stop the functioning of all LEDs and motors.

Circuit Diagrams:Touch Screen Circuit:Pin A4 Pin A3 Pin 6 Pin 7 XY+ X+ YTouch Screen

DC Motor Circuit: -

LED Circuit:(Red LED)

5V

Pin 2 Pin 11 +

1K 1K (Green LED)

0V 0V

Pin 3

320 B

E 0V

Button Circuit: 0V 5V

Servo-Motor Circuit: Black 5V Pin 9 Red White Servo Motor

A unique feature of this prototype is the proportionality of applied pressure to the speed of DC motor and also to the degree of rotation of servo-motor. Thus all the controls on the prototype are continuous as opposed to being quantized (on or off). They are many varying values of output that can be given by controlling the amount of pressure. Thus in real time the boat can be driven in a wide variety of speed and can be positioned at any angle. The following lines of code demonstrate this ability for acceleration: if(p.x>512 && p.y>=512) { //accelerating if (p.z > MINPRESSURE && p.z < MAXPRESSURE) { speed = map(p.z,MAXPRESSURE,MINPRESSURE,0,255); if (speed >=speedo && speed <= 255) { analogWrite(motorPin, speed); digitalWrite(redPin, HIGH); analogWrite(greenPin, 0); } speedo=speed; Serial.print("Speed = "); Serial.print(speedo); Serial.println("mph"); } The terms p.x and p.y are the x and y coordinates of the point touched on the touch-screen. Thus the If statement defines the quadrant for acceleration. The term

p.z measures the pressure applied on the touch screen. The term speed converts the value of applied pressure (10-1000) to output voltage of PWM pin. Many improvements could have been implemented in this prototype, which would have made it more aesthetically pleasing and also more autonomous. A frame of a toy boat could be added with paint. Moreover, adding a range finder could have made it stop as it was nearing collision with an object.

Arduino Code:int motorPin = 3; int buttonPin=12; int buttonPinr=13; int redPin=2; int greenPin=11; float time1; int speedo; int speed;\ int servoPin = 9; int angle = 0; // servo position in degrees #include <stdint.h> #include "TouchScreen.h" #include <Servo.h> Servo servo; // These are the pins for the shield! #define YP A3 // must be an analog pin, use "An" notation! #define XM A4 // must be an analog pin, use "An" notation! #define YM 7 // can be a digital pin

#define XP 6 // can be a digital pin #define MINPRESSURE 10 #define MAXPRESSURE 1000 TouchScreen ts = TouchScreen(XP, YP, XM, YM, 300); void setup() { pinMode(redPin,OUTPUT); pinMode(greenPin,OUTPUT); pinMode(buttonPin,OUTPUT); pinMode(buttonPinr,INPUT); pinMode(motorPin, OUTPUT); Serial.begin(9600); time1=millis(); digitalWrite(buttonPin,HIGH); speedo=0; servo.attach(servoPin); } void loop() {

TSPoint p = ts.getPoint(); if(p.x<=512 && p.y>=512) { //braking if (p.z > MINPRESSURE && p.z < MAXPRESSURE) { Serial.print("Speed = "); Serial.print(speedo); Serial.println("mph");

speed = map(p.z,MINPRESSURE,MAXPRESSURE,0,255); if (speed >=speedo && speed <= 255) { analogWrite(motorPin, speed); analogWrite(greenPin, speed); analogWrite(redPin, 0); } speedo=speed;

} } if(p.x>512 && p.y>=512) { //accelerating

if (p.z > MINPRESSURE && p.z < MAXPRESSURE) { speed = map(p.z,MAXPRESSURE,MINPRESSURE,0,255); if (speed >=speedo && speed <= 255) { analogWrite(motorPin, speed); digitalWrite(redPin, HIGH); analogWrite(greenPin, 0); } speedo=speed; Serial.print("Speed = "); Serial.print(speedo); Serial.println("mph");

} } if(p.y<512 && p.x>512) { //turning right angle=map(p.z,0,1023,0,180); servo.write(angle); delay(1500); } if(p.y<512 && p.x<=512) { //turning left angle=map(p.z,0,1023,180,0); servo.write(angle); delay(1500); } //stopping motor if(digitalRead(buttonPinr)==LOW) { analogWrite(motorPin,0); analogWrite(greenPin,0); analogWrite(redPin,0); delay(10000); } }

Video Link: https://www.youtube.com/watch?v=hWDWr5TCtuw

You might also like