hrpenley
Published

Minimill v1.0

Mini mill program, 3 axis with milling head and lathe, switchable from 3 axis manual mpg to full cnc - multi-controller (future)

IntermediateWork in progress403
Minimill v1.0

Things used in this project

Hardware components

Arduino Nano R3
Arduino Nano R3
×3
Rotary Encoder with Push-Button
Rotary Encoder with Push-Button
100 ppr 5v MPG hand wheel
×3
Rotary Encoder with Push-Button
Rotary Encoder with Push-Button
×3

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Soldering Station Power Supply, For Weller WX Soldering System
Soldering Station Power Supply, For Weller WX Soldering System
Any soldering setup will do
Inventr Welder
Any welder of at 100 Amps or better
Angle Grinder
Mill/Lathe
Access to a mill and lathe will be helpful and save you money
micrometer
Levels
Mastech MS8217 Autorange Digital Multimeter
Digilent Mastech MS8217 Autorange Digital Multimeter

Story

Read more

Schematics

Manual Control Board PCB

This board handles the Manual interface

Code

Manual control code, Version

Arduino
This code is for the 3 individual Nano's for manual control process
// Franken Mill 1.13.4
#include <Stepper.h>

// Rotary Encoder Inputs_Step control, hand-wheel control
#define CLK 2
#define DT 3
// Rotary Encoder Inputs_ multiplier
#define encoderOutA 5 // CLK
#define encoderOutB 6 // DT
#define SW 4
int vcounter = 10; // Set initial base multiplier to 10
int State;
int old_State;
int speedset; //speed adjust
//////////////////////////

int counter = 0;
int currentStateCLK;
int lastStateCLK;
String currentDir = "";
unsigned long lastButtonPress = 0;

//Steppers

// Number of steps per output rotation
const int stepsPerRevolution = 200;

// Create Instance of Stepper library
Stepper myStepper(stepsPerRevolution, 9, 10);

int lastcounter = 0;

void setup() {
  {
    pinMode (encoderOutA, INPUT);
    pinMode (encoderOutB, INPUT);
    Serial.begin (115200);
    //Read First Position of Channel A
    old_State = digitalRead(encoderOutA);
  }

  {
    // Set encoder pins as inputs
    pinMode(CLK, INPUT);
    pinMode(DT, INPUT);
    pinMode(SW, INPUT_PULLUP);
    // Read the initial state of CLK
    lastStateCLK = digitalRead(CLK);

    // set the speed:
    myStepper.setSpeed(1250);
    // initialize the serial port:
    Serial.begin(115200);
  }
}
void loop() {
  {
    State = digitalRead(encoderOutA);
    if (State != old_State)
    {
      if (digitalRead(encoderOutB) != State)
      {
        vcounter ++;
      }
      else {
        vcounter --;
      }
      Serial.begin(115200);
      Serial.print("Speed: ");
      Serial.println(vcounter);
    }
    old_State = State; // Check for change of state
  }

  {
    // Read the current state of CLK
    currentStateCLK = digitalRead(CLK);

    // If  state of CLK are different, then pulse occurred
    // React to first state change 
    if (currentStateCLK != lastStateCLK  && currentStateCLK == 1) {

      // If the DT state is different than the CLK state then
      // the encoder is rotating CCW so decrement
      if (digitalRead(DT) != currentStateCLK) {
        counter --;
        currentDir = "CCW";
      } else {
        // Encoder is rotating CW so increment
        counter ++;
        currentDir = "CW";
      }
      Serial.begin(115200);
      Serial.print("Direction: ");
      Serial.print(currentDir);
      Serial.print(" | Counter: ");
      Serial.println(counter);
      if (currentDir.equals("CCW")) {
        Serial.println("counterclockwise");
        //myStepper.step(-stepsPerRevolution);
        myStepper.step(((counter - lastcounter)*vcounter) * 5);
      } else if (currentDir.equals("CW")) {
        Serial.println("clockwise");
        myStepper.step(((counter - lastcounter)*vcounter) * 5);
      }
    }

    // Remember last CLK state
    lastStateCLK = currentStateCLK;
    // Remember last counter value
    lastcounter = counter;

    // Read the button state
    int btnState = digitalRead(SW);

    //If we detect LOW signal, button is pressed
    if (btnState == LOW) {
      //if 50ms have passed since last LOW pulse, it means that the
      //button has been pressed, released and pressed again
      if (millis() - lastButtonPress > 50) {
        Serial.println("Button pressed! Reset Speed to 10");
        vcounter = 10;
      }

      // Remember last button press event
      lastButtonPress = millis();
    }
  }
}

Credits

hrpenley
1 project • 1 follower

Comments