26
1 EC 2008-12, CEAL 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:-......./......./............

Xy Bed Pro Report (2)

Embed Size (px)

Citation preview

Page 1: Xy Bed Pro Report (2)

8/6/2019 Xy Bed Pro Report (2)

http://slidepdf.com/reader/full/xy-bed-pro-report-2 1/26

Page 2: Xy Bed Pro Report (2)

8/6/2019 Xy Bed Pro Report (2)

http://slidepdf.com/reader/full/xy-bed-pro-report-2 2/26

2

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 f or the award

of  the Degree of  Bachelor of  Technology, by  COCHIN UNIVERSITY OF SCIENCE

AND TECHNOLOGY. 

Asst. Prof   SUNIL .T.T  Smt. ANURADHA .P.V

Project Guide HOD , EC&E

Page 3: Xy Bed Pro Report (2)

8/6/2019 Xy Bed Pro Report (2)

http://slidepdf.com/reader/full/xy-bed-pro-report-2 3/26

Page 4: Xy Bed Pro Report (2)

8/6/2019 Xy Bed Pro Report (2)

http://slidepdf.com/reader/full/xy-bed-pro-report-2 4/26

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

Page 5: Xy Bed Pro Report (2)

8/6/2019 Xy Bed Pro Report (2)

http://slidepdf.com/reader/full/xy-bed-pro-report-2 5/26

Page 6: Xy Bed Pro Report (2)

8/6/2019 Xy Bed Pro Report (2)

http://slidepdf.com/reader/full/xy-bed-pro-report-2 6/26

6

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.

Page 7: Xy Bed Pro Report (2)

8/6/2019 Xy Bed Pro Report (2)

http://slidepdf.com/reader/full/xy-bed-pro-report-2 7/26

7  

¡   2008-12 ¢ 

¡  

  £  

¤  

 BLOCK G M

Bloc Diagram Explanation

The main functional component ¥   of  this project are Arduino- ¦    uemilanove,L §   98 H

Bridge, Three Stepper motors,  P ̈  for sending co-ordinates via serial port and the

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

Page 8: Xy Bed Pro Report (2)

8/6/2019 Xy Bed Pro Report (2)

http://slidepdf.com/reader/full/xy-bed-pro-report-2 8/26

8

EC 2008-12, CEAL

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

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

running the motor. 

FEATURES

y  OPERATIN   SUPPLY VOLTA   E UP TO 46 Vy  TOTAL DC CURRENT UP TO 4 Ay  LOW SATURATION VOLTA   Ey  OVERTEMPERATURE PROTECTIONy  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 thatconvert 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 gneticpole.

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

Page 9: Xy Bed Pro Report (2)

8/6/2019 Xy Bed Pro Report (2)

http://slidepdf.com/reader/full/xy-bed-pro-report-2 9/26

9

EC 2008-12, CEAL

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

made exclusively for Arduino. It has three L2    ICs and 24 1n4007 fly-back diodes,     

for each L2    .these are used to prevent the back emf generated at the motor coils

from reaching the L2    . It also has three .01uf and three 1000uf capacitors to filter

out any spikes in the power supply.

Page 10: Xy Bed Pro Report (2)

8/6/2019 Xy Bed Pro Report (2)

http://slidepdf.com/reader/full/xy-bed-pro-report-2 10/26

10

EC 2008-12, CEAL

CIRCUIT DIAGRAM

Page 11: Xy Bed Pro Report (2)

8/6/2019 Xy Bed Pro Report (2)

http://slidepdf.com/reader/full/xy-bed-pro-report-2 11/26

11

EC 2008-12, CEAL

PCB LAYOUT

Page 12: Xy Bed Pro Report (2)

8/6/2019 Xy Bed Pro Report (2)

http://slidepdf.com/reader/full/xy-bed-pro-report-2 12/26

12

EC 2008-12, CEAL

PCB layout with topsilk and top copper

PHOTOGRAPHS

Page 13: Xy Bed Pro Report (2)

8/6/2019 Xy Bed Pro Report (2)

http://slidepdf.com/reader/full/xy-bed-pro-report-2 13/26

Page 14: Xy Bed Pro Report (2)

8/6/2019 Xy Bed Pro Report (2)

http://slidepdf.com/reader/full/xy-bed-pro-report-2 14/26

14 

EC 2008-12, CEAL

Page 15: Xy Bed Pro Report (2)

8/6/2019 Xy Bed Pro Report (2)

http://slidepdf.com/reader/full/xy-bed-pro-report-2 15/26

15 

EC 2008-12, CEAL

PROGRAM 

long speed=4; //variable controlling the time delay b/w the steps 

f loat xscale =1,yscale=1; //multiplier of  steps 

int yc10,xc10,xc100,yc100,yc1,xc1,xc,yc; //co-ordinate storage

int xf lag,yf lag,limitf lag; //three f lags 

int buff[] = { 0,0,0,0,0}; //buff er to receive and store serial data 

int i=0,j=0,k=0,runxy=0,z,qf lag=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

{

f or (int i=0; i < 4; i++) // shif ting the buff er one byte to lef t as to make way f or //the next incoming

byte

{

buff[i] = buff[i + 1]; 

}

buff[4] = Serial.read(); //the received byte is stored at 5th pos in buff er

if (buff[4]=='P'||buff[4]=='p') //joystick simulation through keyboard

{

multimove(); 

qf lag=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 f ormat 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 

Page 16: Xy Bed Pro Report (2)

8/6/2019 Xy Bed Pro Report (2)

http://slidepdf.com/reader/full/xy-bed-pro-report-2 16/26

Page 17: Xy Bed Pro Report (2)

8/6/2019 Xy Bed Pro Report (2)

http://slidepdf.com/reader/full/xy-bed-pro-report-2 17/26

17

EC 2008-12, CEAL

}

}

void clearf lags()

{

xf lag = 0; //if we h ave ran the motors reset the f lags 

yf lag = 0; //restore the original position run mots in anti clk wise dir

limitf lag=0; 

}

void release()//to stop the current f lowing 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))

{

limitf lag=1; 

}else {

limitf lag=0; 

Serial.println("\nLimit exeeded"); 

Serial.println("try below 700X150Y"); 

delay(300); 

}

}

void xswitch(int speed,int dir) //generates a stepping pulse f or x direction 

{ // two motors have to be pulsed diff erently 

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; 

Page 18: Xy Bed Pro Report (2)

8/6/2019 Xy Bed Pro Report (2)

http://slidepdf.com/reader/full/xy-bed-pro-report-2 18/26

18

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;//0x28PORTC=B00001001;/* 09 */

PORTB = B00000110; 

delay(speed); 

break; 

case 1: 

PORTD=B00101000;//0x18

PORTC=B00000101;/* 05 */

PORTB = B00001010; 

delay(speed); 

Page 19: Xy Bed Pro Report (2)

8/6/2019 Xy Bed Pro Report (2)

http://slidepdf.com/reader/full/xy-bed-pro-report-2 19/26

Page 20: Xy Bed Pro Report (2)

8/6/2019 Xy Bed Pro Report (2)

http://slidepdf.com/reader/full/xy-bed-pro-report-2 20/26

20

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

Page 21: Xy Bed Pro Report (2)

8/6/2019 Xy Bed Pro Report (2)

http://slidepdf.com/reader/full/xy-bed-pro-report-2 21/26

21

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; 

Page 22: Xy Bed Pro Report (2)

8/6/2019 Xy Bed Pro Report (2)

http://slidepdf.com/reader/full/xy-bed-pro-report-2 22/26

22

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 shif t stat to right

if ((!bitRead(prestat,0))&&(bitRead(curstat,0))){

pin5=1; 

}

switch(pin5)

{

case 0: 

yswitch(speed,1); 

break; 

Page 23: Xy Bed Pro Report (2)

8/6/2019 Xy Bed Pro Report (2)

http://slidepdf.com/reader/full/xy-bed-pro-report-2 23/26

23

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 shif t 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); 

}

Page 24: Xy Bed Pro Report (2)

8/6/2019 Xy Bed Pro Report (2)

http://slidepdf.com/reader/full/xy-bed-pro-report-2 24/26

24 

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.

Page 25: Xy Bed Pro Report (2)

8/6/2019 Xy Bed Pro Report (2)

http://slidepdf.com/reader/full/xy-bed-pro-report-2 25/26

25 

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 it·s 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 .

Page 26: Xy Bed Pro Report (2)

8/6/2019 Xy Bed Pro Report (2)

http://slidepdf.com/reader/full/xy-bed-pro-report-2 26/26

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

arduino-shield-pcb/  

18. www.zerovolt.com