X-Y Plotter Final Writeup
For our final project, we built a remote controlled x-y plotter. Essentially an an expo marker is held in two tracks (an x-track and a y-track). The tracks are actuated in two directions by two continuous servos. A single accelerometer controls the direction of both motors. Additionally, two LEDs signal which (if any) motor is turning. We chose this project because in combined the mechanical design that we have practiced in our MEAM curriculum with the basic circuitry and arduino knowledge that we have gained in this course.
For the first demo day, we had designed and constructed all mechanical components of the plotter. We ran 1 servo in 1-direction to make sure that the basic design was capable of creating the movement that we wanted. For the final demo, we incorporated the “remote control” controlled by the accelerometer. We intended to use bluetooth to communicate between a set of buttons and the motors. However, after hours of troubleshooting we moved to the accelerometer-driven actuation.
There are 3 main subcomponents to our system. The frame with gears and racks, the motor actuation, and the code that controls the motors. The frame is a press fit box with two slots that are perpendicular to each other. The slots have racks attached to them that interface with the gears on the side of the frame. When the gear spins it creates linear motion in the rack and consequently the slots as well. Each slot can move back and forth in its respective direction (x or y) so that you get full range in the x-y plane. The second component of the system is the electronics. We have continuous servo motors that have gears on them that interface with the gears on the side of the frame. Each motor controls one of the directions of the printer. An accelerometer on a protoboard controls when the motors turn on and which direction they spin. We calibrated the accelerometer such that when the x or y values exceed a certain threshold the motors are activated. LEDs also activate depending on which motor is in use at that time. The last component is the code that drives the whole system. The code constantly checks the input from the accelerometer and checks the values against a threshold. If the threshold is passed it activates the motor in the appropriate direction (i.e. tilt to the left = moving the system to the left) and turns on the LED that goes with the motor being activated. The thresholds were manually determined by tilting the accelerometer and reading the value. There are thresholds for each direction you can tilt the accelerometer (front, back, left, right). If the values from the accelerometer are between the threshold values for either direction it turns the motor and LED off.
We were limited to sketching only in the x- and y-directions and were only able to actuate one motor at a time. If we were to incorporate some kind of z-axis, the marker could be lifted to plot non-continuous points and lines. If were able to move both motors at one time we could draw diagonal lines. We think that these improvements would allow our device to be sold as a toy. It could be seen as a modern etch-a-sketch and since it is is low-cost, kids could control it easily and it would not be expensive if it broke.
In terms of improvements, we would want to incorporate an IoT component that would be able to get a digital copy of what the user is plotting. We would also want to improve the mechanical components by creating a smoother interface between the rack and the gear by varying the pressure angle.
Arduino Code
include //Include the arduino Servo library
Servo servo1; //Initialize Servo objects Servo servo2;
int servoPin1 = 9; //Define pins for motors, LEDs and accelerometer int servoPin2 = 10; int led1 = 5; int led2 = 6; int yPin = A0; int xPin = A1;
int yVal = 0; //Define variables for x and y positions int xVal = 0;
void setup() { Serial.begin(9600); //begin serial communication
pinMode(yPin, INPUT); //Declare accelerometer pins as inputs pinMode(xPin, INPUT);
pinMode(led1, OUTPUT); //Declare LED pins as outputs pinMode(led2, OUTPUT);
}
void loop() { yVal = analogRead(yPin); //Read the accelerometer output xVal = analogRead(xPin);
//Controls y motor direction based on y axis tilt of accelerometer and also turns on red LED if motor is active if (yVal < 220) { servo1.attach(servoPin1); servo1.write(100); digitalWrite(led1, LOW); delay(500); } else if (yVal > 310) { servo1.attach(servoPin1); servo1.write(80); digitalWrite(led1, LOW); delay(500); } else if ((yVal > 220) && (yVal < 310)){ servo1.detach(); digitalWrite(led1, HIGH); }
//Controls x motor direction based on x axis tilt of accelerometer and also turns on green LED if motor is active if (xVal < 220) { servo2.attach(servoPin2); servo2.write(100); digitalWrite(led2, LOW); delay(500); } else if (xVal > 305) { servo2.attach(servoPin2); servo2.write(80); digitalWrite(led2, LOW); delay(500); } else if ((xVal > 220) && (xVal < 305)) { servo2.detach(); digitalWrite(led2, HIGH); } //Print out accelerometer values Serial.println(xVal); Serial.print("\t"); Serial.print(yVal); delay(500); }
Log in or sign up for Devpost to join the conversation.