Take 2, DC motor control

Can we assume that you have actually used a mill with a commercially built power feed? You need to have a way to manually move the table as well as have it motorized. Have you measured the torque need to move the table, both ways, with a load on the table?

Never used commercial setup etc. But, the other end of the table still has the hand wheel. As for torque...couple things

  1. The mill is quite old and the gibs arent exactly perfect so the table moves with relative ease.
  2. It's just me and my dad trying stuff out.

Thanks for the suggestions!

That is a very nice setup!

We're not looking to perform any automated milling. Just looking to move the table back and forth when there are repeat passes required. I recently refaced the build plate on my resin printer. Turned out to not be so flat...
So, whipped out the mill and went to work. There will be naysayers that remind me that this is in fact automation. But not fully. Still have to do a lot of manual manipulation before engaging table drive.

See pics.



Mine isn't automation either, I just find steppers easy to use and GRBL, though originally designed for CNC is a convenient way to generate the pulses. I've got an old smartphone in the workshop (no SIM) that I run GRBL Controller on to have a user interface. I mainly just use jogging which uses buttons, occasionally write some Gcode but not generally not needed.

When I bought into my previous company, I quickly saw the need for a shop. I bought the largest mill/drill that Grizzly offered as I need the table length for some tooling plates. I bought the motorized feed for one end, just like you are doing. Seldom used it for any actual milling.

But consider adding microswitches to the front of the table and stops to act as safety stops for table over extending.

Absolutely plan to add limit switches.......someday. But gotta get er going first. I'd prefer to use the stepper slew gear setup. The cnc shield has more pinouts for end stops and the like. But couldnt get anyone to bring it down to my level to understand. Larry has been a treat to work with. Just need that pesky arduino code now...

Sounds awesome. Hope to get there eventually.

Measure the resistance between the two outside terminals of the potentiometer.

Adjust the potentiometer to middle position.

Measure the resistance from the middle terminal to an outside terminal.

What did you measure ?

Outside to outside 4.5kohm, no change on turn knob. Mid to right 0-4.5kohm turning knob end to end. Mid to left same as before but 4.5-0 turning knob.

Back of the pot labeled 4k7A FWIW

No.

With the potentiometer set to the middle of the range, what is the resistance from the middle terminal to an outside terminal ?

Ok. Pot set to middle. Measure from center term to outside term 1 = 2306ohms. Measure from middle term to other outside term 2 = 2382 ohms. Not much for markings so best guestimate of center.


.

I did manage to design the gear interface part thing. The end result will be a thick disc that has 6-32 machine screws that protrude and engage the gear.

That potentiometer is linear, that's what you need.

As discussed, will you be wanting limit switches ?

BTW

Read through this post:

Good tip! Thanks

Limit switches someday but if i can get the code now that wouod be great. I can just jump the 2 pinout locations for normally closed or nothing for normally open.

Worst case, if this doesn't work on the mill I can use it on my snow thrower project. Motorized chute control. Already installed the lights. Push joystick button, bam, lights.




c9

This should be close:



// https://forum.arduino.cc/t/take-2-dc-motor-control/1056594

//
//  Version   YY/MM/DD      Comments
//  =======   ========      ========================================================
//  1.00      22/11/22      Running code
//  1.10      22/11/22      Added comments
//

#define STOP                false
#define RUN                 true

#define ENABLED             true
#define DISABLED            false

#define LEDon               HIGH
#define LEDoff              LOW

#define RelayOFF            HIGH
#define RelayON             LOW

#define PUSHED              LOW
#define RELEASED            HIGH

//********************************************^************************************************
//Using the L293N motor driver
const byte heartbeatLED   = 13; //LED toggles, gives the user an indication that code executiing
const byte motorLED       = 12; //when the motor is moving this LED is ON
const byte ePin           = 9;  //to ENA on L293N PWM motor speed control
const byte pin2           = 7;  //to IN2 on L293N
const byte pin1           = 6;  //to IN1 on L293N
const byte leftLimit      = 4;  //limit switch   +5V---[50k PULLUP]---Pin4---[N.O Switch]---GND
const byte rightLimit     = 5;  //limit switch   +5V---[50k PULLUP]---Pin4---[N.O Switch]---GND

const byte potPin         = A0; //motor speed adjust

bool leftFlag             = RUN;
bool rightFlag            = RUN;

byte lastLeftLimit        = RELEASED;
byte lastRightLimit       = RELEASED;

int motorSpeed;

const int window          = 25;
int centerLow             = 512 - window;
int centerHigh            = 512 + window;

//TIMER stuff
unsigned long heartbeatMillis;
unsigned long checkSwitchesMillis;
unsigned long updateMotorMillis;

//                                       s e t u p ( )
//********************************************^************************************************
void setup()
{
  Serial.begin(9600);

  pinMode(leftLimit, INPUT_PULLUP);
  pinMode(rightLimit, INPUT_PULLUP);

  pinMode(heartbeatLED, OUTPUT);
  pinMode(motorLED, OUTPUT);

  pinMode(pin1, OUTPUT);
  pinMode(pin2, OUTPUT);
  pinMode(ePin, OUTPUT);

  digitalWrite(pin1, LOW);
  digitalWrite(pin2, LOW);
  digitalWrite(ePin, LOW);


  //Arduino UNO R3 pin 9 PWM frequency of 30.64 Hz
  TCCR1B = TCCR1B & B11111000 | B00000101; // for pin 9 PWM frequency of 30.64 Hz

} //END of   setup()


//                                        l o o p ( )
//********************************************^************************************************
void loop()
{
  //*********************************                         heartbeat TIMER
  //is it time to toggle the heartbeatLED (every 500ms)?
  if (millis() - heartbeatMillis >= 500ul)
  {
    //restart this TIMER
    heartbeatMillis = millis();

    //toggle the heartbeatLED
    digitalWrite(heartbeatLED, !digitalRead(heartbeatLED));
  }

  //*********************************                         checkSwitches TIMER
  //is time to check our switches ?
  if (millis() - checkSwitchesMillis >= 50ul)
  {
    //restart this TIMER
    checkSwitchesMillis = millis();

    checkSwitches();
  }

  //*********************************                         updateMotor TIMER
  //is time to up date the motor speed ?
  if (millis() - updateMotorMillis >= 50ul)
  {
    //restart this TIMER
    updateMotorMillis = millis();

    int potPosition = analogRead(potPin);

    //********************                                      at center
    //are we at the center position ?
    if (potPosition > centerLow && potPosition < centerHigh)
    {
      //motor is turned OFF
      analogWrite(ePin, LOW);

      digitalWrite(pin1, LOW);
      digitalWrite(pin2, LOW);

      digitalWrite(motorLED, LEDoff);
    }

    //********************                                      above center
    //are we above center position ?
    if (potPosition >= centerHigh)
    {
      //is the limit switch okay ?
      if (leftFlag == RUN)
      {
        motorSpeed = map(potPosition, centerHigh, 1023, 0, 255);

        analogWrite(ePin, motorSpeed);

        //move the motor CCW
        digitalWrite(pin1, HIGH);
        digitalWrite(pin2, LOW);

        digitalWrite(motorLED, LEDon);
      }

      //************
      else
      {
        //the limit switch is operated
        //motor is turned OFF
        analogWrite(ePin, LOW);

        digitalWrite(pin1, LOW);
        digitalWrite(pin2, LOW);

        digitalWrite(motorLED, LEDoff);
      }
    }

    //********************                                      below center
    //are we below center position ?
    if (potPosition <= centerLow)
    {
      //is the limit switch okay ?
      if (rightFlag == RUN)
      {
        motorSpeed = map(potPosition, centerLow, 0, 0, 255);

        analogWrite(ePin, motorSpeed);

        //move motor CW
        digitalWrite(pin1, LOW);
        digitalWrite(pin2, HIGH);

        digitalWrite(motorLED, LEDon);
      }

      //************
      else
      {
        //the limit switch is operated
        //motor is turned OFF
        analogWrite(ePin, LOW);

        digitalWrite(pin1, LOW);
        digitalWrite(pin2, LOW);

        digitalWrite(motorLED, LEDoff);
      }
    } //END of motor control
  }


  //*********************************
  //other non blocking code goes here
  //*********************************


} //END of    loop()


//                               c h e c k S w i t c h e s ( )
//********************************************^************************************************
void checkSwitches()
{
  byte currentState;

  //*********************************                         leftLimit
  currentState = digitalRead(leftLimit);

  //did this switch change state ?
  if (lastLeftLimit != currentState)
  {
    //update to the new state
    lastLeftLimit = currentState;

    //is this switch pushed ?
    if (currentState == PUSHED)
    {
      leftFlag = STOP;
    }

    else
    {
      //switch was released
      leftFlag = RUN;
    }

  } //END of this switch

  //*********************************                         rightLimit
  currentState = digitalRead(rightLimit);

  //did this switch change state ?
  if (lastRightLimit != currentState)
  {
    //update to the new state
    lastRightLimit = currentState;

    //is this switch pushed ?
    if (currentState == PUSHED)
    {
      rightFlag = STOP;
    }

    else
    {
      //switch was released
      rightFlag = RUN;
    }

  }//END of this switch

} //END of   checkSwitches()

//********************************************^************************************************


You obviously do not live in Florida. :cold_face: