You are on page 1of 26

ARDUINO BASED X-Y BED

MINIPROJECT REPORT
Submitted in partial fulfilment of the requirements For the award of the degree of Bachelor of Technology In Electronics and Communication Engineering Of

COCHIN UNIVERSITY OF SCIENCE AND TECHNOLOGY


SUBMITTED BY
VINU V NAIR

REGISTER NO:-13093831

DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING COLLEGE OF ENGINEERING, ATTINGAL, THIRUVANANTHAPURAM

PLACE:-ATTINGAL DATE:-......./......./............

1 EC 2008-12, CEAL

COLLEGE OF ENGINEERING ATTINGAL, THIRUVANANTHAPURAM DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING

COCHIN UNIVERSITY OF SCIENCE AND TECHNOLOGY

BONAFIDE CERTIFICATE
This is to certify that the mini project entitled XY BED USING ARDUINO is a bona fide record of the work done by VINU V NAIR (13093831) of sixth semester B.Tech in Electronics and Communication Engineering, towards the partial fulfilment of the requirements as a part of the curriculum for the award of the Degree of Bachelor of Technology, by COCHIN UNIVERSITY OF SCIENCE AND TECHNOLOGY.

Asst. Prof SUNIL .T.T


Project Guide

Smt. ANURADHA .P.V


HOD , EC&E

2 EC 2008-12, CEAL

ACKNOWLEDGMENT
I would like to express my sincere gratitude to all those who helped in making of this project.

I am grateful to Prof BHADRAN . V , Principal and Mrs . ANURADHA . P. V , Head of Department , Dept. Of Electronics and Communication for her necessary help in fulfilment of this project.

I would like to express my heartfelt gratitude to our project guide Asst. Prof SUNIL .T.T for his valuable guidance, constant encouragement ,friendly subjection and creative suggestions on making this project. Also i would like to express my gratitude to Mr Shibu V, Mr AnandaKuttan for helping us at the various stages of this project

I am also grateful to all my friends and classmates for helping me to make this project.

.......................................................

3 EC 2008-12, CEAL

ABSTRACT
This project takes over the task of creating an X -Y BED, which is controlled using an Arduino shield. The x-y bed is a mechanical system which moves its mobile bed to a specified position in the two dimensional plane . Arduino manages all the communication and pulsing of the stepper motors.L298 h bridge ICs are used to drive the stepper motors of X and Y direction. The co-ordinate to which X Y BED has to be moved is sent to the Arduino from the PC over a serial communication link . If the co-ordinates are within the physical dimension of the XY bed, then the motors are driven. Alternatively XY BED can be controlled using the four keys of the keyboard A, W, S, D.

4 EC 2008-12, CEAL

CONTENTS
Bona fide Certificate Acknowledgements . ....................02 .....................................03 04

Abstract............................................................................................

Introduction............................................................. ... .................................06 Block diagram............................................................................. ....................08 Circuit diagram............................................... ................................................09 PCB layout......................................................................................................11 Photograph.....................................................................................................12 Program.................................................................. ........................................13 Application................................................................. ..................................... 17 Conclusion...................................................................................................... 18 References................................................................ ......................................19

5 EC 2008-12, CEAL

INTRODUCTION
This project takes over the task of creating an X -Y BED, which is controlled using an Arduino shield. The x-y bed is a mechanical system which moves its mobile bed to a specified position in the two dimensional plane . The specialty of this project is the use of Arduino, which is an open-source electronics prototyping platform, designed to make the process of using electronics in multidisciplinary projects more accessible. The hardware consists of a simple open hardware design for the Arduino board with an Atmel AVR processor and on-board I/O support. The software consists of a standard programming language and the boot loader that runs on the board. Arduino hardware is programmed using a Wiring-based language (syntax + libraries), similar to C++ with some simplifications and modifications, and a Processing-based IDE. The Arduino is interfaced to a motor control shield which houses three L298 ICs which are high current dual full bridges (stepper motor drivers) and other necessary components. L298 can handle supply voltage up to 46 V total dc current up to 4A . There are three different modes of operation for the XY bed. The X & Y co -ordinates are sent over a serial emulated usb cable connected between the pc and Arduino. The serial data is stored in a buffer and processed. If they contain a valid co -ordinate packet the mobile bed is moved to that co-ordinate. Also the bed can be controlled manually using four directional keys of the key board A, W, S, D. When W is pressed the X motors are run forward,and when S is pressed it is run backwards, similarly Y motor is also controlled by keys A and D. In short Our XY BED can be controlled in two ways 1. By sending a co-ordinate packet of the format xxxXyyyY (eg 700X150Y)to the port in which Arduino is connected. 2. by activating joystick mode by sending p or P to Arduino, the mobile bed can be controlled back ,forth, left, right by pressing the four keys in the key board A,W,S,D.

6 EC 2008-12, CEAL

BLOCK

Bloc Diagram Explanation


The main functional component of this project are Arduino- uemilanove,L 98 H mechanical system that converts the rotational motion of the motors to linier motion of the X and Y sections. Arduino Duemilanove Arduino is the Heart of this project. An Arduino board consists of an 8-bit Atmel AVR microcontroller (ATMEGA 328 in the case of Duemilanove). 16MHz crystal oscillator. It has 14 digital I/O pins, six of which can produce PWM signals. Arduino
7

Bridge, Three Stepper motors, P

for sending co-ordinates via serial port and the

2008-12

provides the control signals for clockwise and anticlockwise rotation of the stepper motors. It also receives Serial data from the PC and processes it for determining th e position of the X-Y bed. L298 H Bridge

y y y y y

L2

receives stepping pulses from the Arduino and provides high current drives for

running the motor.


FEATURES
OPERATIN SUPPLY VOLTA E UP TO 46 V TOTAL DC CURRENT UP TO 4 A LOW SATURATION VOLTA E OVERTEMPERATURE PROTECTION LO ICAL "0" INPUT VOLTA E UP TO 1.5 V (HI H NOISE IMMUNITY)

DESCRIPTION


The L2

is an integrated monolithic circuit in a 15 -lead Multiwatt and PowerSO20

packages. It is a high voltage, high current dual full -bridge driver de-signed to accept standard TTL logic levels and drive inductive loads such as relays, solenoids, DC and stepping motors. Two enable inputs are provided to enable or disable the device independently of the in -put signals. The emitters of the lower transistors of each bridge are connected together and the corresponding external terminal can be used for the connection of an external sensing resistor. An additional supply input is provided so that the logic works at a lower voltage. Stepper Motors Like the DC motor , Stepper Motors are also electromechanical actuators that convert a pulsed digital input signal into a discrete (incremental) mechanical movement are used widely in industrial control applications. A stepper motor is a type of synchronous brushless motor in that it does not have an armature with a commentator and carbon brushes but has a rotor made up of many, some types have hundreds of permanent magnetic teeth and a stator with individual windings . The stepper motor used here are bi polar s tepper motors, which has 2 coils and each one have to be energized in a specific sequence in order to run the motor so that there is a total of 4 wires for each motor. Bipolar motors have a single winding per phase. The current in a winding needs to be reversed in order to reverse a ma gnetic pole. PC Any program that can communicate with the serial port can be used for sending co ordinates to the Arduino, we use serial monitor of Arduino IDE and processing Program for serial communication
8 EC 2008-12, CEAL

Mechanical System The mechanical part of the X Y BED is based on a system of gear wheels and timing belts. The y axis block is pulled by two timing belts which are connected to geared stepper motors on either side of the XY BED. On the Y axis block another stepper motor pulls the mobile bed back and forth. Two micro switches are connected at origin position of the bed, which are used to reset the x and y blocks to the (0,0) position. Motor driver shield The shield can be mounted on top of the Arduino using special stackable connectors for each L2 .these are used to prevent the back emf generated at the motor coils
  

made exclusively for Arduino. It has three L2 from reaching the L2




ICs and 24 1n4007 fly-back diodes,

. It also has three .01uf and three 1000uf capacitors to filter

out any spikes in the power supply.

9 EC 2008-12, CEAL

CIRCUIT DIAGRAM

10 EC 2008-12, CEAL

PCB LAYOUT

11 EC 2008-12, CEAL

PCB layout with topsilk and top copper

PHOTOGRAPHS

12 EC 2008-12, CEAL

13 EC 2008-12, CEAL

14 EC 2008-12, CEAL

PROGRAM

long speed=4; //variable controlling the time delay b/w the steps float xscale =1,yscale=1; //multiplier of steps int yc10,xc10,xc100,yc100,yc1,xc1,xc,yc; //co-ordinate storage int xflag,yflag,limitflag; //three flags int buff[] = { 0,0,0,0,0}; //buffer to receive and store serial data int i=0,j=0,k=0,runxy=0,z,qflag=1,state,xstate,prestat=0,ystate; void setup() { Serial.begin(9600); //init serial communication at 9600 baud rate DDRB=B00001111; //port B pins 8-13 DDRC=B00001111; //analogue port DDRD=B00111100; //port D pin 0-7. <1-o/p> <0-i/p>(complemetry system in //pic i think!!) caliberate(); //reset xy bed if not at origin } void loop() { Serial.println("Enter the co-ordinates"); delay(500); while (Serial.available() > 0; //if there is serial data serial.available returns non //zero equal to no of bytes of recieved data else -1 { for (int i=0; i < 4; i++) // shifting the buffer one byte to left as to make way for //the next incoming byte { buff[i] = buff[i + 1]; } buff[4] = Serial.read(); //the received byte is stored at 5th pos in buffer if(buff[4]=='P'||buff[4]=='p') //joystick simulation through keyboard { multimove(); qflag=1; } if(buff[4]=='C'||buff[4]=='c') //manual calibration :press C if resetting is needed { caliberate(); } if (buff[4] == 'X') /*we have designed a protocol (i.e. an agreement b/w pc and Arduino) that the x co and y co are transmitted in the format xxXyyY eg:12X15Y sends 12 and 15 as x & y coordinates respectively*/ xc1 = buff[3]; //here we first receive 1 then 2,which is stored in 15 EC 2008-12, CEAL

//at the begining of the pgm. according to our protocol if the just receive byte is //X the previous bytes were x cos, xflag = 1; //so we store it in appropriate variables: flag set conforming reception of x co xc1 = xc1 - 48; //this is a tweak, consider we have sent 1 thorough the serial bus,now //Arduino receives not 1 but ascii code of 1 ie 49 xc10 = xc10 - 48; //so we need to decrement 48 to retrive the original data xc100=xc100-48; xc = (xc100*100)+(xc10 * 10) + xc1; //the actual xc value is calculated } if (buff[4] == 'Y') //The previous datas were the y coordinates { yc1 = buff[3]; yc10=buff[2]; yc100=buff[1]; yflag = 1; yc1 = yc1 - 48; yc10 = yc10 - 48; yc100=yc100-48; yc = (yc100*100)+(yc10 * 10) + yc1; } limitcheck(xc,yc); //check whether the co ordinates are within the physical limits of the bed if((xflag == 1) && (yflag == 1)&&(limitflag==1))//if all three flags are set we give go go for motors { runmotorxy(speed,xc,yc,0); Serial.println("X Y BED AT THE GIVEN CO-ORDINATES"); delay(2000); runmotorxy(speed,xc,yc,1); release(); //out low at all ports clearflags(); } delay(10); } Serial.println("RESETTING"); } void multimove() { Serial.print("\t\t\tJOYSTIC SIMULATION"); while(qflag==1) { z=Serial.read(); if(z=='w'||z=='W') xswitch(1,0); else if(z=='s'||z=='S') xswitch(1,1); else if(z=='a'||z=='A') yswitch(1,1); else if(z=='d'||z=='D') yswitch(1,0); else if(z=='q'||z=='Q') qflag=0; 16 EC 2008-12, CEAL

buff[2]&buff[3] xc10=buff[2]; xc100=buff[1];

//

while we receive 'X', due to the byte shifting

} } void clearflags() { xflag = 0; //if we h ave ran the motors reset the flags yflag = 0; //restore the original position run mots in anti clk wise dir limitflag=0; } void release()//to stop the current flowing through the coils by setting zero at all the outputs { PORTD=B00000000; PORTC=B00000000; PORTB=B00000000; } void limitcheck(int xc,int yc) //limit checker pgm { int xlim=725,ylim=150; if((xc*xscale<=xlim)&&(yc*yscale<=ylim)) { limitflag=1; } else { limitflag=0; Serial.println("\nLimit exeeded"); Serial.println("try below 700X150Y"); delay(300); } } void xswitch(int speed,int dir) //generates a stepping pulse for x direction { // two motors have to be pulsed differently if(dir==0) //one in clockwise and the other in anticlockwise direction { switch(i) { case 0: PORTD=B00011000;//0x28 PORTC=B00001001;/* 09 */ delay(speed); break; case 1: PORTD=B00101000;//0x18 PORTC=B00000101;/* 05 */ delay(speed); break; case 2: PORTD=B00100100;//0x14 PORTC=B00000110;/* 06 */ delay(speed); break; case 3: PORTD=B00010100;//0x24 PORTC=B00001010;/* 0A */ delay(speed); break; 17 EC 2008-12, CEAL

default: break; } } if(dir==1) { switch(i) { case 0: PORTD=B00010100;//0x24 PORTC=B00001010;/* 0A */ delay(speed); break; case 1: PORTD=B00100100;//0x14 PORTC=B00000110;/* 06 */ delay(speed); break; case 2: PORTD=B00101000;//0x18 PORTC=B00000101;/* 05 */ delay(speed); break; case 3: PORTD=B00011000;//0x28 PORTC=B00001001;/* 09 */ delay(speed); break; default: break; } } i++; if(i>3){ i=0; } } void xyswitch(int dir)//runs both x and y motors simultaneously { if(dir==0) { switch(k) { case 0: PORTD=B00011000;//0x28 PORTC=B00001001;/* 09 */ PORTB = B00000110; delay(speed); break; case 1: PORTD=B00101000;//0x18 PORTC=B00000101;/* 05 */ PORTB = B00001010; delay(speed); 18 EC 2008-12, CEAL

break; case 2: PORTD=B00100100;//0x14 PORTC=B00000110;/* 06 */ PORTB = B00001001; delay(speed); break; case 3: PORTD=B00010100;//0x24 PORTC=B00001010;/* 0A */ PORTB = B00000101; delay(speed); break; default: break; } } if(dir==1) { switch(k) { case 0: PORTD=B00010100;//0x24 PORTC=B00001010;/* 0A */ PORTB = B00000101; delay(speed); break; case 1: PORTD=B00100100;//0x14 PORTC=B00000110;/* 06 */ PORTB = B00001001; delay(speed); break; case 2: PORTD=B00101000;//0x18 PORTC=B00000101;/* 05 */ PORTB = B00001010; delay(speed); break; case 3: PORTD=B00011000;//0x28 PORTC=B00001001;/* 09 */ PORTB = B00000110; delay(speed); break; default: break; } } k++; if(k>3){ k=0; } 19 EC 2008-12, CEAL

} void yswitch(int speed,int dir)//RUNS Y DIRECTION ONLY { if(dir==0) { switch(j) { case 0: PORTB = B00000110; delay(speed); break; case 1: PORTB = B00001010; delay(speed); break; case 2: PORTB = B00001001; delay(speed); break; case 3: PORTB = B00000101; delay(speed); break; default: break; } } if(dir==1) { switch(j) { case 0: PORTB =B00000101; delay(speed); break; case 1: PORTB =B00001001; delay(speed); break; case 2: PORTB =B00001010; delay(speed); break; case 3: PORTB =B00000110; delay(speed); break; default: break; } } j++; 20 EC 2008-12, CEAL

if(j>3) { j=0; } } void runmotorxy(int speed,int xc,int yc,int dir)//FUNCTIONFOR SIMULTANEOUS RUNNING OF X AND Y //MOTORS { int xtotal,ytotal,comstep,remstep; xtotal=xc*xscale*4; ytotal=yc*yscale*4; comstep=0; remstep=0; if(xtotal>ytotal) { remstep=xtotal-ytotal; comstep=ytotal; runxy=1; } else if(ytotal>xtotal) { remstep=(ytotal-xtotal); comstep=xtotal; runxy=2; } else { comstep=xtotal; remstep=0; runxy=0; } if(dir==0) { while(comstep>0) { xyswitch(0); comstep--;

} while(remstep>0) { switch(runxy) { case 1: xswitch(speed,0); break; 21 EC 2008-12, CEAL

case 2: yswitch(speed,0); break; } remstep--; } } else if(dir==1) { while(comstep>0) { xyswitch(1); comstep--; } while(remstep>0) { switch(runxy) { case 0: break;// no operation case 1: xswitch(speed,1); break; case 2: yswitch(speed,1); break; } remstep--; } } } void ycaliberate(int speed) { int curstat,prestat,stat,pin5=0; while(pin5==0) { prestat=0; stat=PINC; curstat=stat>>4;//bit shift stat to right if((!bitRead(prestat,0))&&(bitRead(curstat,0))) { pin5=1; } switch(pin5) { case 0: yswitch(speed,1); break; 22 EC 2008-12, CEAL

case 1: pin5=1; break; } } } void xcaliberate(int speed) {//connect x switch to pin 6, y switch to pin 5 of analog port int curstat,prestat,stat,pin6=0; while(pin6==0) { prestat=0; stat=PINC; curstat=stat>>4;//bit shift stat to right if((!bitRead(prestat,1))&&(bitRead(curstat,1))) { pin6=1; } switch(pin6) { case 0: xswitch(speed,1); break; case 1: pin6=1; break; } } } void caliberate() { state=PINC; state=state>>4; if((!bitRead(prestat,1))&&(bitRead(state,1))) { xstate=1; } if((!bitRead(prestat,0))&&(bitRead(state,0))) { ystate=1; } if((xstate!=1)&&(ystate!=1)) { xcaliberate(speed); ycaliberate(speed); } }

23 EC 2008-12, CEAL

APPLICATIONS
The XY bed we have created here can be used for many applications. It is a fundamental model of a CNC machine, which is used for drilling and mining purpose.

1. It can be used as a PCB drilling machine by attaching a PCB holder to the mobile bed and connecting a drilling head in a suitable position. An automated PCB drilling machine can be made with the help of MATLAB which processes a PCB layout and finds the co ordinates and drills the pcb automatically. 2. It can be used as a two dimensional plotter by connecting a plotter head to the mobile bed 3. It can also be used in applications such as vinyl sign cutting or cutting any suitable materials with the help of a cutting head.

24 EC 2008-12, CEAL

CONCLUSION
We have designed an XY BED controlled by an Arduino, which has many practical applications as mentioned above.

Our XY BED can be controlled in two ways 1. By sending a co-ordinate packet of the format xxxXyyyY to the port in which Arduino is connected.

2. By activating joystick mode by sending p or P to Arduino, the mobile bed can be controlled back, forth, left, right by pressing the four keys in the key board

By doing this project we have gained a lot of knowledge about Arduino, making a shield for Arduino, stepper motors, and its driving circuits also about the issues and challenges while designing a mechanical model. We were also effective in reusing discarded printer parts in making this project, thus helping to reduce e waste. We were also amazed by the reliability and ease of use of Arduino .

25 EC 2008-12, CEAL

REFERENCES
1. www.arduino.cc 2. www.wikipeadia.com 3. www.atmel.com 4. www.keralalinux.com 5. www.compizspec.blogspot.com 6. http://www.seattlerobotics.org 7. http://www.pyroelectro.com/ 8. www.rhydolabsz.com 9. www.robokits.co.in/ 10. http://www.st.com 11. http://www.electronics-tutorials.ws/ 12. http://www.stepperworld.com/ 13. http://www.tigoe.net 14. www.virtualbreadboard.com/ 15. www.labcenter.com/ 16. http://www.krisbarrett.com/2008/09/03/make-a-custom-arduino-shield/ 17. http://aaroneiche.com/2010/06/24/a-beginners-guide-to-making-anarduino-shield-pcb/ 18. www.zerovolt.com

26 EC 2008-12, CEAL

You might also like