After finishing the mechanical part we go to the Automation of our printer. First, we realise that we have only a few days timing. So we need to use the days effectively otherwise we cant make our machine perfect. We forgot to take good images while designing and forming part of Machine. We have permission to use customs boards, so we are planned to use Ramps14 and Arduino Mega as our significant parts.
Arduino Mega
The Arduino MEGA ADK is a microcontroller board based on the ATmega2560. It has a USB host interface to connect with computers.It has 54 digital input/output pins (of which 15 can be used as PWM outputs), 16 analog inputs, 4 UARTs (hardware serial ports), a 16 MHz crystal oscillator, a USB connection, a power jack, an ICSP header, and a reset button.
Ramps1.4
Ramps is short for reprap Arduino mega pololu shield, it is mainly designed for the purpose of using pololu stepper driven board (similar to 4988 driven board). Ramps can only work when connected to its mother board Mega 2560 and 4988/DRV8825.
A4988 Stepper Driver
A4988 microstepping bipolar stepper motor adjustable current limiting, over-current and over-temperature protection, and five different microstep resolutions (down to 1/16-step). It operates from 8 V to 35 V and can deliver up to approximately 1 A per phase without a heat sink.
Major features of A4988 stepper driver is Simple step and direction control interface, Five different step resolutions: full-step, half-step, quarter-step, eighth-step, and sixteenth-step.Adjustable current control lets you set the maximum current output with a potentiometer, which lets you use voltages above your stepper motor’s rated voltage to achieve higher step rates.
Connection diagram
Programming part:
I need to test the stepper motor and how much steps it takes to complete one revolution. I connect ramps board to Arduino mega and connect the A4998 driver to X part of ramps 14 board.N ext connect all the 4 pins named 2A, 2B, 1A & 1B to the stepper motor. According to the schematic diagram, we find that stepping and direction pin of x is connected to 54 and 55 pins of mega and enable pin is connected to 38.
// Code is copied from :https://reprap.org/wiki/RAMPS_1.4 // code for check the working of sepper: // Code edited by Amith Gopakumar : #define X_STEP_PIN 54 #define X_DIR_PIN 55 #define X_ENABLE_PIN 38 char data = 0; //byte to receive and check data from computer void setup() { Serial.begin(9600);//Start the Serial port. pinMode(X_STEP_PIN , OUTPUT); pinMode(X_DIR_PIN , OUTPUT); pinMode(X_ENABLE_PIN , OUTPUT); } void loop() { if (Serial.available()) { //if there is data on the Serial buffer while (Serial.available() > 0) { //continues reading the values on the buffer. data = Serial.read(); Serial.print(data); if (data == '1') { forward(200); // if i recieves make single rotoation clock wise } if (data == '0') { backward(200); // if i recieves make single rotoation anti clock wise } } } } void forward(int number) { digitalWrite(X_DIR_PIN , HIGH); for (int i = 0; i <= number; i++) { digitalWrite(X_STEP_PIN , HIGH); _delay_us(500); digitalWrite(X_STEP_PIN , LOW); _delay_us(500); } } void backward(int number) { digitalWrite(X_DIR_PIN , LOW); for (int i = 0; i <= number; i++) { digitalWrite(X_STEP_PIN , HIGH); _delay_us(500); digitalWrite(X_STEP_PIN , LOW); _delay_us(500); } }
I wrote a program to control the machine using serial monitor.When I send numerical digit '1 ' through serial monitor, then Stepper needs to make the one complete cycle of forward revolution and for ‘0’ it makes backward. But it does not make a complete revolution. From that, I understand that Steps per revolution of the machine is not 200 we need to find.So when I search it, I found that by default, all stepper drivers A4988 come from china are in the 1 /16 microstepping. Which means total No.of steps required for 360 deg rotation = 200*16 = 3200. so I change the steps 200 to 3200 its works.
We purchased solenoid does not have enough power to make holes in paper so Aby gaves idea to use servo motor so that we can connect a pen to the servo motor and move up and down it makes holes.
Ramps1.4 have capacity to connect 4 servo motors , So i connect the servo motor and two stepper motor and Aby gives code to ontrol servo , i combined it and wrote a code to control all these using serially
Code for running Stepper forward ( x axis -which head moves )
void forward(int number) { digitalWrite(X_DIR_PIN , HIGH); // makes the motor direction in forward for (int i = 0; i <= number; i++) { digitalWrite(X_STEP_PIN , HIGH); _delay_us(500); digitalWrite(X_STEP_PIN , LOW); _delay_us(500); } }
Code for running Stepper backward( x axis -which head moves )
void forward(int number) { digitalWrite(X_DIR_PIN , LOW); // makes the motor direction backward for (int i = 0; i <= number; i++) { digitalWrite(X_STEP_PIN , HIGH); _delay_us(500); digitalWrite(X_STEP_PIN , LOW); _delay_us(500); } }
Code for running controlling servo to make holes ( x axis -which head moves )
void braille(void){ myservo.write(0); delay(100); myservo.write(50);First paper drwaing : How printer looks }
Code for running Stepper forward ( Y axis -which paper roller connected )
void forward(int number) { digitalWrite(Y_DIR_PIN , HIGH); // makes motor direction forward for (int i = 0; i <= number; i++) { digitalWrite(Y_STEP_PIN , HIGH); _delay_us(500); digitalWrite(Y_STEP_PIN , LOW); _delay_us(500); } }
Function to controll the actions
void loop() if(Serial.available()) { //if there is data on the Serial buffer while(Serial.available()>0) { //continues reading the values on the buffer. data=Serial.read(); Serial.print(data); if(data=='1') { braille();//if a one was received, makes a dot. forward(3200); } if(data=='0'){ forward(3200);// if a zero was received just advances. } if(data=='3'){//if a "3" was received, pull the paper to begin a new line. backward(3200);//return the car. } } } }
Below is the combined code for controlling the machine using serrial imput form serial monitor
// code is copied from Reprap // code for Aby michel : Servo part // edited by Amith gopakumar Nair #include <Servo.h> Servo myservo; #define Y_STEP_PIN 60 // Atmega pins #define Y_DIR_PIN 61 // Atmega pins #define Y_ENABLE_PIN 56 // Atmega pins #define X_STEP_PIN 54 // Atmega pins #define X_DIR_PIN 55 // Atmega pins #define X_ENABLE_PIN 38 // Atmega pins char data=0;//byte to receive and check data from computer void setup() { myservo.attach(11); // servo pin Serial.begin(9600);//Start the Serial port. pinMode(Y_STEP_PIN , OUTPUT); pinMode(Y_DIR_PIN , OUTPUT); pinMode(Y_ENABLE_PIN , OUTPUT); backward(0); } void loop() { if(Serial.available()) {//if there is data on the Serial buffer while(Serial.available()>0) {//continues reading the values on the buffer. data=Serial.read(); Serial.print(data); if(data=='1'){ braille();//if a one was received, makes a dot. // servo function forward(3200);//avances one time (four steps) } if(data=='0'){ forward(3200);// if a zero was received just avances. } if(data=='3'){//if a "L" was received, pull the paper to begin a new line. backward(3200);//return the car. } } } } void forward(int number){ digitalWrite(X_DIR_PIN ,HIGH); for(int i=0;i<=number;i++) { digitalWrite(X_STEP_PIN , HIGH); _delay_us(500); digitalWrite(X_STEP_PIN , LOW); _delay_us(500); } } void backward(int number){ digitalWrite(X_DIR_PIN , LOW); for(int i=0;i<=number;i++) { digitalWrite(X_STEP_PIN , HIGH); _delay_us(500); digitalWrite(X_STEP_PIN , LOW); _delay_us(500); } } void paperroll(int number){ digitalWrite(Y_DIR_PIN , LOW); for(int i=0;i<=number;i++) { digitalWrite(Y_STEP_PIN , HIGH); _delay_us(500); digitalWrite(Y_STEP_PIN , LOW); _delay_us(500); } } void braille(void){ myservo.write(0); delay(100); myservo.write(50); }
I along the Aby, Rinoy and Akhil checked the working of Machine using above code , Finally its working fine.
At that time Our instructor Yahu got a good solenoid and give to us, so we are now again on track. It gives energy to all of us while seeing the power which solenoid makes holes in paper.
Next is calculation part first I connect x-axis stepper to ramps and make a small mark on below of head and rotate stepper motor one cycle and make the mark on board bottom to head. Then I measure the distance between the two marks I found that for one cycle of rotation of the stepper motor head goes a distance of 3.1cm means 31mm. For 3200 steps x-axis head moves a distance of 31mm. After completing this, I go with the y-axis, in this part paper is moving forward for printing. We got a rod from HP printer with rubber covering which helps paper to move forward and backward .i measure diameter of the rubber covering and it seems 11.8mm so for I revolution of stepper motor rod covers a distance of 22/7*11.8mm = 37.05mm
After making the calculation we found that for 1mm movement of the X-axis head we need a step of 104 and for Y-axis 1mm movement step of 86 is needed. I go to Instructables website and read some CNC machine tutorials.
After completing the how many steps are taken to cover 1 mm distance for x and y-axis stepper motor. I gave that data to Akila she is working with Marlin firmware for machine operation.
About Marlin firmware
Marlin firmware is program that designed and developed for making 3D printers using Ramps board .Firmware is the link between software and hardware, it interprets commands from the G code file and controls the motion accordingly. We could use marlin firmware for any machines if we made some changes. We need to run two stepper motor and control on solenoid push-pull using G code. So first we download marlin firmware from this link.
Chnages made in Marlin fimrware is described below
#define BAUDRATE 115200
The serial communication speed should be as fast as it can manage without generating errors. In most cases, 115200 gives a good balance between speed and stability.End Stops :We need to configure the end stops in marline all the edit function are making on Configuration.h file. The main aim of end stops is to find the origin of the head we connect end stop on the right side of the machine.End stops are switches that trigger before an axis reaches its limit. In other words: It will prevent the head from trying to move out of its frame. The printer also uses end stops as a reference position. The Marlin firmware allows one to configure each limit switch individually.
#define X_MIN_ENDSTOP_INVERTING false // set to true to invert the logic of the endstop
Define the number of axis It is the total number of axis 2
#define NUM_AXIS 2
Axis steps per unit The stepper motor receives step by step moving command from the controller. The controller needs to know the steps/mm ratio to send the appropriate steps to reach the required distance. How many steps are needed to move an axis by 1 mm. here we use the calculations find Amith
DEFAULT_AXIS_STEPS_PER_UNIT {X,Y,Z,E1} #define DEFAULT_AXIS_STEPS_PER_UNIT { 104, 86, 4000, 500 } //104 stands for 1mm moement in x axis number of steps is 104 //and for y axis 1mm movement steps is 86 other values are not usefull to us
G-Code: Numerial control programming in which its changes depends on the machine and firmware.here we only need few codes to control our printer( marlin firmware )
Refer this link to know more about G-CODE
Our instructor Yahu already wrote a text to G-code creater and sender. so we use this to creat text to gcode. and send to machine.
How to make G-code for text to braille
First step we need to covert every text into 3x2 matrix and store it in jason format.and the jasonscript is sued by gcode generater to generate the gcode for text
for example A we store it as "a": [[1, 0], [0, 0], [0, 0]]
Yadu wrote a text to G-code creator and serially sender. That code works by saving some alphabets in the text.txt file, it reads the file and then generates G-code depends on that. I wrote a GUI that we can write the whatever we want on the given windows and Click on the save button it saves the text in the text.txt file. Then there is the button which named "print" click on that it executes the python code given by Yadu and send g-code to the machine..
Python GUI code
//created by : Amith G Nair : May 13,2018 from Tkinter import * import sys import os def save(): text = e.get() + "\n" with open("text.txt", "w") as f: f.write(text) # Write the input text to text.txt file def printer(): os.system('python text_to_braille.py') #executing the shell commands # execute the python code to covert text to g-code and send it serially master = Tk() master.title("Braille Printer") master.geometry('800x100') Label(master, text="Enter the text").grid(row=0) e = Entry(master,width=70) e.grid(row=0, column=10) Button(master, text='Save', command=save).grid(row=3, column=0, sticky=W, pady=4) Button(master, text='Print', command= printer).grid(row=3, column=1, sticky=W, pady=4) Button(master, text='Quit', command=master.quit).grid(row=3, column=3, sticky=W, pady=4) mainloop( )