This is a big ask, stepper controller with keypad and switches

Hello humans that are much smarter than I, I have a project i am working on/would like to do that is an Arduino based stepper motor controller that i would personally like to use to on a rotary table for a milling machine, turning it into power feed and 'cnc' (to a degree)... but bigger picture than that, i would like to make this project 'open source' in nature for other people to use and to easily add motion control to their own projects, and i would like to make this whole thing a youtube video with instructions, code, components with links to buy, and wiring diagrams as i feel this could be used by many people for many purposes...

The reason i am here is upon quite of few hours of trying to start putting code together, i am way over my head and am basically looking for someone to volunteer their knowledge base and time for the benefit of the community and take my ideas and write the code to make it all work... i am by no means someone who knows how to code, rather, for the most part, i can take code others have written, interpret it enough to be dangerous and piece together some code to work minimum viable, definitely not the right way... i am at a time in my life where "just learn to code yourself" isn't really on the table time wise/cognitive load wise, and farming this portion out to someone else that much more knowledgeable than i is the right play. all that said, if you do decide to volunteer your time, you would absolutely be credited for your work in the project.

Now i realize that is a big ask, but i have all of the rest of the project 'done'... i have all of the components, the user interface laid out (switches, keypad, and display) along with the 20x4 display laid out (got code to make it work and have it displaying the information i want in the locations i want) and i have a thought out idea of what i would like to code to do... basically, ive taken time to put a game plan together, but i just don't know the clever language n fancy grammar to peck into a keyboard to make the ole Arduino brainbox do what i want...

If you'd be willing to lend a hand to a simpleton like myself, i think a private message would be the best way to move forward one on one, since this is already way long winded and would turn into a communication nightmare between a handful of people right off the bat, and so i can explain in much more detail what my idea is, along with pictures and diagrams, and better communication (phone, webcam, whatever works for you... speak English(obviously) east coast US time zone)...
If anyone decides to humor me, thank you in advance

I will say that typically these are public fora, and there are some real heavies here who can def advise and help you.

I think putting up all what you might share privately is no more work for you, and might force you to be a bit more careful and formal than a private chatting type interaction.

Since your end goal is open source/serve the community, whoever you may mean by that, please stay here, reveal all and enjoy the pesky feedback which will draw you out and help you think of things, hard as it may be to imagine, that you might be overlooking.

a7

that is very fair, i just didnt want it to be too much seeing as it was already long and a big ask, attached is a rough idea and layout for what im going for...

4x4 keypad, 20x4 display, mega, a pot, 3 on/off switches, and one momentary 3 position switch (middle off, on left, on right)... not in the pic would be 3 wires going to stepper driver( ground, step, and direction)

with the mode switch in 'manual', have the speed pot, direction, feed, and jog switches active, to control stepper motor manually, starting and stopping only by human input to the manual switches, and either feed constantly with the speed from the pot in the direction of the 'direction switch' chosen and stop when the feed switch is turned off, or use the momentary jog switch to momentarily feed cw (clockwise) or ccw

with mode switch in 'cnc', have the speed pot, direction, and keypad active to only move the stepper motor the amount on the screen by hitting enter/go... enter what angle to move or to move to (depending on being in incremental or absolute mode)... on the keypad, numbers input numbers, '*' to be neg sign, "#" to be decimal point, "A" to switch between absolute and incremental mode, "B" to zero out current position, "C" to clear input section (cursor), "D" to be enter/go

my usage case has values in degrees (rotation) , but would like to have the code easily editable by end user to also be able to display linear motion (xx.xxx inch or xxx.xx mm) which would change amount of digits and decimal location on display and in calculations

for the end user, would also like a dedicated 'calibration' line to be able to calibrate stepper motor relative to arduino display degrees, inches or mm (line that defines steps per revolution of the motor, or steps per degree of machine rotation/steps per distance unit moved).

would like speed %, direction, and current position status always live up to date on display

speed pot needs to change speed of motor even if motor is running

a few other nit picky things as far as the 'cnc' side of things as far as how the positive and negative numbers input work and correlate to cw/ccw

original post wasnt meant to seems secretive, just trying to not be confusing or super long winded and drawn out... i appreciate pesky feedback because thats some of best ways to learn (by being wrong)...

again, i appreciate any advice/help given

What have you tried, code wise?

Can you read the keypad and display the output in serial monitor? Can you enter multi digit numbers and display in serial monitor?

Can you read the LCD display? Can you send data to the display and control where things are printed?

Do you know how to wire the switches and read them? Same with the pot?

What stepper drivers do you have? What power supply for the steppers? Can you control the steppers. Are you using a library like AccelStepper or MobaTool stepper to help with stepper control?

code wise, i have been able to take example codes and read all of the buttons on the keypad through serial monitor (basically verifying that is wired correctly) and in the picture in my last post, that is a picture taken with my phone of the display where i modified some example code to verify location and spacing of information on the display... knowing how to wire the switches for the arduino to be happy with would jus be a matter of if i need to add resistors to control floating readings, but the wiring for the pot, and stepper controller i do believe i have under control... pot would be just like the diagram, and as far as stepper controller pins, those should just be (3 wires) step (pulses telling the driver to move) and direction (cw or ccw) out to the stepper controller with a ground connection to complete the circuit, and the controller should handle the rest (and size of motor, motor controller etc will be dependent on whatever the end user is building)... for the sake of what im going for, everything downstream of the arduino outputting step and direction should be a separate topic as it would change depending on usage case...

on the programming side as far as stepper control, i think the answer to that should depend on whoever is writing the code and how familiar they are with the libraries... about the only thing i would add here is the ability to change acceleration values would be important for the sake of if someone was wanting to control something that had a lot of mass, being able to vary how fast the stepper motor came up to speed would prevent it from missing steps

There is maybe some useful information in this thread on another forum:
https://www.model-engineer.co.uk/forums/postings.asp?th=165373

My own approach uses a UNO + CNC shield, running GRBL which deals with all the acceleration, stepper config issues etc. Bluetooth link to GRBLcontroller on my phone. Runs both a rotary axis and the table drive on my mill.

those are pretty close to what im looking for, however not quite there... ill see if i can make sense of enough of that to get somewhere and see if i can modify that code enough to get where i want... upon first glance at that code though, im already lost without learning quite a few commands and what they do

so i have the manual side of this project functional... switches, pot, and stepper controller and stepper motor connected and its functional as to how id like it to work on the rotary table... to the best of my knowledge anyway... motor starts, stops, rotates both directions, and changes speed while running (slight delay due to the analog counter in between analog reads)... still very much a bumbling work in progress, but i figured id post this to see if there is any constructive nit picking to be had from people smarter than i (i know full well there has got to be, but i am teaching myself all of this and am only like 2 weeks into learning, and ive never done coding before, so please roast me proportionally to that :slight_smile: )

oh, and the keypad will input all 16 buttons just into serial monitor just fine if theres lines in the loop (tested it with another simple test program), but i havent gotten that far yet, just copied the setup over

#include <AccelStepper.h>
#include <Wire.h>                      
#include <LiquidCrystal_I2C.h>
#include <Keypad.h>      

LiquidCrystal_I2C lcd(0x27,20,4);
const byte ROWS = 4;
const byte COLS = 4;
char hexaKeys[ROWS][COLS] = {
  {'1','2','3','A'},
  {'4','5','6','B'},
  {'7','8','9','C'},
  {'*','0','#','D'}
};
byte rowPins[ROWS] = {46, 48, 50, 52};
byte colPins[COLS] = {38, 42, 40, 44};

const int mode = 28; //input pins from switches
const int feed = 30;
const int dir = 32;
const int jogcw = 34;
const int jogccw = 36;
const int speedpotpin = A1;
AccelStepper motor(1, 2, 3); //pin2 step, pin3 direction

void setup() {
  
pinMode( mode, INPUT_PULLUP );
pinMode( feed, INPUT_PULLUP );
pinMode( dir, INPUT_PULLUP );
pinMode( jogcw, INPUT_PULLUP );
pinMode( jogccw, INPUT_PULLUP );
motor.setMaxSpeed(1000000); 
motor.setAcceleration(100); 

lcd.init();                         //this section jus to put something on the screen, not actually doing anything yet
lcd.backlight();                
lcd.setCursor(0,0);           
lcd.print("CURRENT  INC  SPD%99");
lcd.setCursor(0,1);             
lcd.print("  POS    MOVE   CCW");
lcd.setCursor(0,3);             
lcd.print("000.0'  -000.0'");

//Serial.begin(9600);
}

void loop() {
//this section stolen from online to try and not slow down the arduino as to not constantly do analog read
static float current_speed = 0;         // Holds current motor speed in steps/second
static int analog_read_counter = 500;    // Counts down to 0 to fire analog read
static int analog_value = 0;              // Holds raw analog value.
if (analog_read_counter > 0) {
    analog_read_counter--;
  }
  else {
    analog_read_counter = 3000;
    // Now read the pot
    analog_value = analogRead(speedpotpin);
    current_speed = (analog_value * 5);
    // Update the stepper to run at this new speed
    motor.setSpeed(current_speed);
  }

if (digitalRead(jogcw) == LOW) 
motor.setSpeed(-(current_speed));
motor.runSpeed();

if (digitalRead(jogccw) == LOW)
motor.setSpeed(current_speed);
motor.runSpeed();

if (digitalRead(jogcw) == HIGH && (digitalRead(jogccw) == HIGH))
motor.setSpeed(0);
motor.runSpeed();

if (digitalRead(feed) == LOW && digitalRead(dir) == HIGH)
motor.setSpeed(current_speed);
motor.runSpeed();

if (digitalRead(feed) == LOW && digitalRead(dir) == LOW)
motor.setSpeed(-(current_speed));
motor.runSpeed();

if (digitalRead(feed) == HIGH)
motor.setSpeed(0);
motor.runSpeed();
}

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.