X and Z Axis

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

// Z Axis Sketch

// James Rovere 2019 Z Axis


// A Digital Readout using a quaduture rotary encoder,an IC2 LCD display
// and a GT2-16 pulley, 16 teeth spaced 2 mm apart; .37" outside Diameter.
#include <Encoder.h>// Encoder library.
Encoder myEnc(2,3);// Connected to Digital pins 2 and 3.
#include <LiquidCrystal_I2C.h> //IC2 LCD library.
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);

void setup() {
lcd.begin(20, 4); // My display has 20 Columns, 4 Rows.
}
long oldPosition = -999;
void loop() {
const float Wv = (.1 * PI) / 600; // Math formula for .37" diameter pulley
//and 600 pulse/revolution encoder.

lcd.setCursor(7, 0); // (Column 7,ROW 0) (Column #0-19,Row #0-3)


lcd.print("Z Axis");
lcd.setCursor(2, 1);
lcd.print("inch");
lcd.setCursor(14, 1);
lcd.print("mm");
lcd.setCursor(8, 2);
lcd.print("<->");// Graphic symbols for a Z axis left and right travel.
long newPosition = myEnc.read();
if (newPosition != oldPosition)
lcd.setCursor (0, 0);
lcd.print (newPosition); // Display number of pulses, 1"~=1902.2 pulses.

lcd.setCursor(2, 3);
lcd.print(Wv * newPosition, 3);//Math formula * Encoder reading ,3 decimals
lcd.setCursor(9, 1);
lcd.print("|");// Graphic symbol to separate imperial and metric display.
lcd.setCursor(9, 3);
lcd.print("|");
lcd.setCursor(11, 3);
lcd.print(Wv * newPosition * 25.4, 2); // Formula to convert imperial
// and metric, 2 decimals.
}

// ______________________________________________________________________

// X Axis Sketch

// James Rovere 2019 Lathe X Axis


// A Digital Readout using a quaduture rotary encoder,an IC2 LCD display
// and a GT2-16 pulley, 16 teeth spaced 2 mm apart; .37 outside Diameter.
#include <Encoder.h>// Encoder library.
Encoder myEnc(2, 3);// Connected to Digital pins 2 and 3.
#include <LiquidCrystal_I2C.h> //IC2 LCD library.
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);

void setup() {
lcd.begin(20,4);// 20 Columns, 4 Rows.
}
long oldPosition= -999;
void loop() {
const float Wv =(.1 * PI)/600; // Formula to set the linear distance travelled in
one pulse.

lcd.setCursor(8,0); //(Column 8, Row 0)


lcd.print("X Axis");
lcd.setCursor(3,1);
lcd.print("inch");
lcd.setCursor(14,1);
lcd.print("mm");
lcd.setCursor(9,1);
lcd.print(":");
lcd.setCursor(9,2);
lcd.print("|");
lcd.setCursor(9,3);
lcd.print(":");
lcd.setCursor(3,2);
lcd.print("D");
long newPosition = myEnc.read();
if (newPosition != oldPosition)
lcd.setCursor (0,0);
lcd.print (newPosition);// Display pulse count.
lcd.setCursor(2,2);
lcd.print(Wv*newPosition*2,3);//Diameter multiply by 2, 3 decimal places
lcd.setCursor(0,2);
lcd.print("D");
lcd.setCursor(11,2);
lcd.print("D");
lcd.setCursor(11,3);
lcd.print("R");
lcd.setCursor(0,3 );
lcd.print("R");
lcd.setCursor(13,2);
lcd.print(Wv*newPosition*25.4*2,2);// mm Diameter multiply by 2, 2
//decimal places.
lcd.setCursor(2,3);
lcd.print(Wv*newPosition,3);// inch Raidius of workpiece.
lcd.setCursor(13,3);
lcd.print(Wv*newPosition*25.4,2);// mm Raidius of workpiece.

You might also like