Professional Documents
Culture Documents
Submitted by
GROUP-E2
NAME ROLL NO.
CHANDRAJEET PRATAP SINGH 16ME63R52
PAWAR MITESH ROHIDAS 16ME63R45
RINTU SASMAL 16ME63S02
TANMAY SAHA 16ME61R01
GOLU PATEL 16ME63R63
Top view
1
Side view
Front view
2
Components:
Serial No. Item Name Specification Quantity
1 Lead screw Length :65mm
Diameter :3mm 2
Pitch :3mm
2 Stepper motor Phase :2
Wire :4 2
Voltage : 4-9V DC/500 mA
Step angle :180
3 Servo motor Operating voltage: 4.8 V (~5V)
Operating speed : 0.1 s/60 degree 1
Weight : 9 gm.
Stall torque : 1.8 kgf·cm
4 Wooden ply 150mm×120mm×15mm 2
5 Aluminium sheet 5mm×5mm 1
6 Arduino UNO Single broad ATmega168 1
microcontroller
7 Motors driver Model :L293D 2
8 Breadboard 5.5cm×17cm 1
9 Jumper wires Model : 22AWG(with solid tip) 25(approx.)
10 Bolt Length :80mm
Diameter :5mm 8
11 Nut Hexagonal 5mm internal diameter 12
12 Pen holder 1
13 Pen 1
3
Working Principle:-
The assembly of motor and lead screw is mounted on the wooden ply as shown in
figure. The two axis are defining as the horizontal bed as x axis and vertical bed as
y axis.
The servo motor attached moves the horizontal bed in vertical direction giving
engagement and disengagement movement to pen.
4
MATLAB CODE
ALGORITHM
ARDUINO CODE
ALGORITHM
/* ARDUINO CODE */
#include <Stepper.h>
#include <Servo.h>
Servo servoMotor;
int angle = 0;
int dgre = 20;
int delayServo = 10;
int i = 0;
int maxStep = 250;
int count=0;
int delayStep = 5;
int a, b, l, m, x = 0, y = 0;
int zero = 240;
void setup(){
Serial.begin(9600);
servoMotor.attach(12);
}
void loop(){
while (Serial.available()>0){
setZero();
a=Serial.parseInt();
b=Serial.parseInt();
l=a-x;
m=b-y;
if (Serial.read() == '\n'){
1
if (l==0 && m==0){
for(angle=dgre; angle>0; angle--){
servoMotor.write(angle);
delay(delayServo);
}
}
while (count<abs(l)){
if (l>0){
stepperMotor1.step(1);
}
else {
stepperMotor1.step(-1);
}
count++;
delay(delayStep);
}
count=0;
while (count<abs(m)){
if (m>0){
stepperMotor2.step(1);
}
else {
stepperMotor2.step(-1);
}
count++;
delay(delayStep);
}
count=0;
if ((abs(l)+abs(m))>1){
for(angle=0; angle<dgre; angle++){
servoMotor.write(angle);
delay(delayServo);
}
}
Serial.println(1);
}
x=a;y=b;
Serial.flush();
}
}
2
void setZero(){
while (i<1){
for(angle=dgre; angle>0; angle--){
servoMotor.write(angle);
delay(delayServo);
}
count=0;
while (count<zero){
stepperMotor1.step(-1);
count++;
delay(delayStep);
}
count=0;
while (count<zero){
stepperMotor2.step(-1);
count++;
delay(delayStep);
}
count=0;
i++;
}
}
3
%% MATLAB CODE
function final_arduino(im_read)
tic;
imageMatrix = imread(im_read);
[a,b,c] = size(imageMatrix);
compMatrix = 80*ones(a,b,c);
BnWMatrix = imageMatrix>compMatrix;
BnWMatrix = 255*BnWMatrix;
[a,b,~] = size(BnWMatrix);
image(BnWMatrix);
matrix1 = zeros(a*b,2);
inc = 1;
x = 1; y = 1;
4
f=f+1;
end
end
matrix=matrix(1:f,:);
end
5
%% matrix1 size reduction
compMatrix=ones(a*b,2);
compMatrix=matrix1>=compMatrix;
[d,~]=size(compMatrix);
f=0;
for i=1:d-1
if compMatrix(i,1)||compMatrix(i+1,1)==1
f=f+1;
end
end
matrix1=matrix1(1:f,:);len=f;
%% Arduino control
arduino=serial('COM5','BaudRate',9600);
fopen(arduino);
try
for i=1:len
MAT=mat2str(matrix1(i,:));
try
fprintf (arduino , '%s\n' , MAT(2:end-1));
fprintf ('%d ',i);
fprintf ('%s\n', MAT(2:end-1));
y=fscanf(arduino,'%s');
BnWMatrix(matrix1(i,1),matrix1(i,2),3)=255;
BnWMatrix(matrix1(i,1),matrix1(i,2),1:2)=0;
pause(.001)
image(BnWMatrix)
catch ME
fprintf('ERROR: %s\n', ME.message);
break;
end
end
catch ME
fprintf ('ERROR: %s\n', ME.message);
end
fclose(arduino);
if i==len
fprintf 'DONE! GOOD JOB!\n';
else
fprintf 'Some error occurred\n';
end
toc;