Large Stepper Linear Pot position

Hello!

Im new to Arduino, but I'm interested in seeing if this is possible to use the Arduino to control a large stepper with a linear potentiometer to turn the stepper on until it reaches a predetermined position set in the programming. For example, the arduino powers up, the unit finds "home" by a predetermed position", then precedes to rotate the stepper until it reaches the predetermined setpoint feedback from the pot.

Also would it be possible to change the speed as it reached different values on the pot? For example, (for easyness 1-100), Home is 0, setpoint is 100. Would i be able to slow the stepper at 80 until it reached 100?

Thanks!

Sure, no problem. The bigger the stepper, the bigger the driver...

Thats good to know, I have a DM2722A Driver with a 42HS6480 Stepper.

Is there any direction you could send me in for code using a 10k linear pot for such desires?

I have it wired up and coded using this video:

Ive been looking around and there doesn't seem to be anything on the topic of using a pot as a switch for position.

Thanks for the reply!

WillCNC:
I have it wired up and coded using this video:

Please post the program and tell us in detail what it actually does and what you want it to do that is different. It will make it much easier to focus on the parts you need help with rather than wasting time on things that you can do.

...R
Stepper Motor Basics
Simple Stepper Code

also look up the AccelStepper library

It's always good practise to set up, code and test each little system. Start reading the pot and make sure You control the happenings. The go for the stepper. Start making the stepper move in a way You understand. After that You can think of joining the two systems.
Buldning a system like this is not like turning pages in the cook book and finding a suitable recipe.

Thanks I don’t want to waste any of your times, I think I need to break the system down and understand each part. If i have any questions ill be sure to post.

This is the code im currently working with
#define DRIVER_STEP_PIN 7
#define DRIVER_DIR_PIN 6
#define POT_PIN A0

#define DEADZONE 50
#define MIN_DRIVER_PULSE_PERIOD_US 1000 //max speed
#define MAX_DRIVER_PULSE_PERIOD_US 3000 //min speed

enum Driver_pulse_state_enum {PULSE_IDLE, PULSE_HIGH, PULSE_LOW};

unsigned long time_now = 0;
uint16_t driver_pulse_hold_time_us = MIN_DRIVER_PULSE_PERIOD_US/2;
uint8_t driver_pulse_state = PULSE_IDLE;
int normalized_analog_value = 0;
uint8_t idle_flag = 1;

void setup() {
pinMode(DRIVER_STEP_PIN, OUTPUT);
pinMode(DRIVER_DIR_PIN, OUTPUT);

}

void loop() {
normalized_analog_value = analogRead(POT_PIN) - 512;

if(abs(normalized_analog_value)-DEADZONE < 0){
idle_flag = 1;
}
else{
idle_flag = 0;
}

driver_pulse_hold_time_us = map(abs(normalized_analog_value), DEADZONE, 512, MAX_DRIVER_PULSE_PERIOD_US, MIN_DRIVER_PULSE_PERIOD_US)/2;

if(!idle_flag && driver_pulse_state == PULSE_IDLE){
write_pulse_high();
}

if((micros() - time_now > driver_pulse_hold_time_us) && (driver_pulse_state == PULSE_LOW)){
write_pulse_high();
}

if((micros() - time_now > driver_pulse_hold_time_us) && (driver_pulse_state == PULSE_HIGH)){
write_pulse_low();
}
}

void write_pulse_high(void){
driver_pulse_state = PULSE_HIGH;

if(normalized_analog_value > 0){
digitalWrite(DRIVER_DIR_PIN, HIGH);
}
else if(normalized_analog_value < 0){
digitalWrite(DRIVER_DIR_PIN, LOW);
}

digitalWrite(DRIVER_STEP_PIN, HIGH);
time_now = micros();
}

void write_pulse_low(void){
digitalWrite(DRIVER_STEP_PIN, LOW);
time_now = micros();

if(!idle_flag){
driver_pulse_state = PULSE_LOW;
}
else{
driver_pulse_state = PULSE_IDLE;
}
}

The stepper stepper is wired like so, minus the push button.

You can improve the attaching of code using “code tags” </>, up to the left in this window.
Is there any problem with this code? You don’t tell and You don’t ask.
What do You want to happend and what’s happening? All is well?

The AccelStepper library can easily do what I think you want to do: move at speed from one point to another, decelerating when you get close to the end point.

As you use a stepper, you don’t need the feedback of the pot to know where you are - but of course you can use it to determine where you are, so you don’t need the home switch. In the end you just need to know how many steps from one end to the other, and tell the stepper (through AccelStepper) to which step to go, and the library takes care of the rest.

wvmarle:
As you use a stepper, you don't need the feedback of the pot to know where you are

I have the impression from the Original Post that the pot is not being used for feedback, rather it is to be used as a means for the user to indicate the position the stepper should move to.

...R

WillCNC

I am in the same boat. I don't know what you are seeking to accomplish in the end. But I understand what you are posting about. I am also a noob, but I understand the workings of CNC.

Here is a video that goes over what you are trying to do, I believe. Homing at the start of cycle.

I'd be interested to know what you are doing.