Help with stepper code.

Hi there.

I have built a gantry crane that uses 2 stepper motors for control.
This will help understand what I am talking about

Dilemma 1
I have a code to power 2 stepper motors (in each direction) using pots, but have tried to modify it so I can use a 4 key touch pad to operate it
(Key 1, stepper 1, CW; Key 2 stepper 1 anticlockwise; key 3, stepper 2, CW; key 4, stepper 2 ACW. Outputs to go LOW if no key activated)

Dilemma 2
The stepper that winds the cable is much too slow, Am I able to speed it up?

I have butchered the code to death, so I will attach the code I am trying to modify which originally used pots to control speed and direction. I’m happy for the motors to run at full speed using keypad inputs.

(I have not used a library, as I could not get the steppers to reverse using them).

Any help with this would be highly appreciated.

gantry_crane.ino (8.82 KB)

I have a code to power 2 stepper motors

Code does not power stepper motors.

but have tried to modify it so I can use a 4 key touch pad to operate it

So, what's the problem?

The stepper that winds the cable is much too slow, Am I able to speed it up?

There are perfectly good Stepper libraries. Why not use one of them?

How are you powering the stepper motor? The Arduino is not providing the power.

(I have not used a library, as I could not get the steppers to reverse using them).

Then you were doing something wrong.

PaulS:
Code does not power stepper motors.
So, what's the problem?
There are perfectly good Stepper libraries. Why not use one of them?
How are you powering the stepper motor? The Arduino is not providing the power.
Then you were doing something wrong.

Code does not power stepper motors.
Apologies for my incorrect use of terminology

So, what's the problem?
as previously outlined, How do I convert attached code from pots to switches?

There are perfectly good Stepper libraries. Why not use one of them?
I would use them if I could, but have not been able to come up with a sketch using a library to suit my needs.

How are you powering the stepper motor? The Arduino is not providing the power.
The steppers are powered from a separate rail.

Then you were doing something wrong.
I know that,
have not been using Arduino for very long that's why I turned to the forum for help

There are perfectly good Stepper libraries. Why not use one of them?
I would use them if I could, but have not been able to come up with a sketch using a library to suit my needs.

So what did you try and what went wrong?

The steppers are powered from a separate rail.

You need to post a wiring diagram. Using 4 pins to drive a stepper motor usually means that you are also trying to power it. Typically, a stepper motor is connected to a shield or separate board, and only two pins (step and direction) are used, along with ground.

Do you know how to read the switches (digitalRead())? Setting direction and speed based on which switch was pressed is trivial

Controlling those motors with a ULN2003 driver is more complex than controlling bigger motors that use proper stepper motor drivers. Life will be much easier if you use one of the stepper libraries and leave it to deal with the complexities of the ULN2003.

The legend of Robert the Bruce and the spider is appropriate

...R

I have studied the spider.
I do believe I have it :slight_smile:
(when the spider failed he did not try to continuing the failed web, he started a new one from scratch).