caferacerkevPracticeMakesBetter
Published © GPL3+

Rotary encoder DRO. Inexpensive! fitted to RF30 Mill CNC,

I've done a CNC conversion to my RF30 mill. I still want to be able to use it manually. Easy enough on X &Y. I needed a DRO for the Z axis.

IntermediateShowcase (no instructions)1,580
Rotary encoder DRO. Inexpensive! fitted to RF30 Mill CNC,

Things used in this project

Hardware components

Enclosure for Arduino Uno
Enclosure for Arduino Uno
This item can be 3D printed.
×1
Arduino UNO
Arduino UNO
×1
Incremental Rotary Encoder Dc5-24V Wide Voltage Power Supply Shaft 6Mm
×1
I2C Serial 2004 20x4 LCD
Make sure it's the LCD with I2C fitted or purchase it separately and solder it on.
×1

Hand tools and fabrication machines

AXMINSTER ENGINEER SERIES ZX30M MILL DRILL
I already had a RF30 milling machine. They don't seem to be available in the UK at present. ZX30M is a similar machine.

Story

Read more

Custom parts and enclosures

Schematic for LCD I2C to Arduino

How to connect an LCD I2C to Arduino

Schematics

Encoder wiring diagram

Schematic for connecting the rotary encoder to the Arduino Uno. Provided by PracticeMakesBetter

Code

Z axis DRO

Arduino
This is a sketch based on Practice Makes Better's original sketch for a lathe DRO .This is only my second Arduino project and I'm no expert on Arduino sketches but this one works for me. A lot of sketches I have seen have the line :- LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); I couldn't get this to work and after doing some research there seems to be quite a few people having problems. I couldn't find a reason... I have re-written some of the original code and it works for me.
#include <Wire.h> 
#include <LiquidCrystal_I2C.h>
#include <Encoder.h>// Encoder library.
Encoder myEnc(2,3);// Connected to Digital pins 2 and 3.
LiquidCrystal_I2C lcd(0x27,20,4);  

void setup() {
  lcd.init();                      // initialize the lcd 
  lcd.backlight();
  
}
long oldPosition = -999;


void loop()
 {
  const float Wv = (.1 * PI*.9848) / 600; // Math formula for 20 tooth 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(5, 2);
  lcd.print("Z Axis DRO");// 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.
}

Credits

caferacerkev

caferacerkev

0 projects • 1 follower
PracticeMakesBetter

PracticeMakesBetter

0 projects • 12 followers

Comments