Arduino uno R3 stepper motor control

neksmerj:
I feel like a kid in the candy shop

That's great. Now you should spend a bit of time working through some of the Arduino examples so that you learn how code is constructed.

Sorry - I don't use Windows so I don't know exactly where your programs (sketches) are stored. If you click the preferences button in the Arduino IDE I think it tells you.

...R

neksmerj:
If you had the time to look at my project and write a tutorial for dummies,

If you can write an outline of what the tutorial should cover I will think about it.

...R

Hi Robin2,

Thank you for thinking of writing up a tutorial re control of stepper motors, and in particular, a camera slider. As soon as I have time, I will outline how I think the project should work.

I am working through the Arduino worked examples, firstly "blink" that tests the board, so far so good.

Many thanks in advance,

Ken

neksmerj:
control of stepper motors, and in particular, a camera slider

This is a common subject on the Forum. Have you searched for other Threads on the subject. Use Google - for example camera slider site:arduino.cc

...R

Hi Robyn2,

I have searched for other camera slider projects, and to me, they seem quite complex. They probably aren't that complicated, just to my inexperienced brain.

I'm going to use the same hardware as this one Motion Control With Arduino: Motorising a Camera Slider

HARDWARE

For me I just want a track fitted with a carriage, all openbuild stuff. At one end a nema17 stepper motor, the other, an idler pulley. The carriage will be driven forwards and backwards with a toothed belt.

ELECTRONICS

I would like to use an Arduino uno R3 board fitted with an Adafruit stepper motor controller.
A 3-position switch, or two pushbuttons, will drive the carriage in one direction or the other until a limit switch is triggered. A potentiometer will control speed.

With the 3-position switch midway, no power will be sent to the motor and the carriage can be pushed to one end or the other.

That's about it unless someone can suggest some improvements.

The whole kit and caboodle will be used in the field, and hence, be powered by a decent 12v battery.

AFTER THOUGHT

I'm just wondering whether the carriage should stop when a shot is being taken.

I have no idea how this could be done.

Ken

neksmerj:
I have no idea how this could be done.

This is the problem. I can try to help you sort out how to do things but you have to have something that forms the basis for a question.

What you have described seems eminently feasible. Are you confident that you can do the mechanical construction?

One of the links I gave you earlier has code to make a stepper move back and forth in response to push buttons.

Most stepper drivers have ENABLE pins which you can activate to de-power the motor to allow it to freewheel.

Stepper motors are inefficient. I hope you are planning for a big 12v battery.

...R

Hi Robin2,

I wont have any trouble with the mechanical side of things, I've tinkered with mechanical things all my life.

Lets forget about stopping the carriage whilst a shot is taken. I can't see that it will make much difference. I'm not a photographer, this project is for my son who's right into it.

Help with driving the carriage forwards and backwards at variable speeds, would be appreciated.

I shall look back through some of your replies to look for stepper motor control ideas.

Thanks,

Ken

neksmerj:
I shall look back through some of your replies to look for stepper motor control ideas.

Sorry to keep on about it, but maybe now you can understand why I am a little frustrated that you did not take account my replies when they were new.

If you study the code I have written you should understand how different speeds are achieved by changing the interval between steps.

...R

Hi Robin2,

I'm the one who's frustrated, I haven't learned how to read a sketch if there are few comments.

With respect to your thread "Simple Stepper Program" it's all double dutch to me.

For starters there's no comments to say what each step is doing, and no schematic diagram.

Without any knowledge, I'm lost as mentioned earlier.

This is why I'm asking for a tutorial that even a dummy like me can follow.

Ken

Hi Robin2,

All of the above but delete the Adafruit stepper motor controller and substitute it for the
Easy driver board, cheaper option I think.

Ken

I am using the Pololu A4988 stepper drivers. That web page has a lot of useful information including a wiring diagram.

I wrote my Simple Stepper Program Thread for people who already have a basic understanding of stepper motors. Wikipedia has a good info.

By the way I have just realized that instead of 2 separate programs in that Thread I had repeated the first program (nobody seems to have noticed). I have now corrected that and I hope that has not been the cause of your confusion. Feel free to slap my wrist.

I don't think I can provide a teaching-from-nothing introduction. In any case it would just be duplicating info that is widely available elsewhere.

I wrote my demo code with what I hope are meaningful names for variables rather than comments. I hope they make sense for someone who already knows the general concept of stepper motors.

Writing in the Forum is necessarily different from a face-to-face experience where either or us can instantly interrupt the other if we don't understand something.

If you want to point out specific items in my code I will be happy to try to explain further.

...R

Hi Robyn2

Sounds like you have have pulled the pin on helping me.

With respect to your Simple Stepper Program, any chance you could include a wiring/schematic diagram?

From just the code, I can't tell how you control the motor ie, is it push button control for direction or software control. Is there a motor reversal routine in your code?

Ken

neksmerj:
Sounds like you have have pulled the pin on helping me.

I'm not sure if you mean I am doing more or less? Which would you prefer?

With respect to your Simple Stepper Program, any chance you could include a wiring/schematic diagram?

have you looked at the diagram on the Pololu page I gave you a link for?

From just the code, I can't tell how you control the motor ie, is it push button control for direction or software control. Is there a motor reversal routine in your code?

I don't know how to answer this. I'm quite sure you realize there is code to make the motor go in both directions - even if you can't identify where it is.

I can't help feeling that the problem is your lack of background knowledge about the basics of stepper motors and stepper motor drivers. There is loads of information on the web about that and I am not going to write duplicate stuff. I already suggested Wikipedia.

And, as I already mentioned, the Pololu page has a lot of info.

It would be much easier to help if you were asking questions like "I was reading BBB and it says XXXX in paragraph NN and I don't understand what it means".

...R

Hi Robyn2,

Thanks for all your help, though it's a pity a schematic is not forth coming for your easy stepper motor.

My lack of understanding is a problem, however, a series of tutorials has helped me a bit with the code.

I will go back over the driver board details you prefer.

Ken

neksmerj:
it's a pity a schematic is not forth coming for your easy stepper motor.

Well, there actually is one: it's on the link to the Pololu driver that Rob(with an "i" not a "y")n2 gave earlier. It shows exactly how to set it up, except it doesn't explicitly say Arduino since it's correct for any micro.

The 4988's input "step" and "dir" pins are called "stepPin" and "directionPin" as outputs in Robin2's sketch. The whole thing happens in software:

stepPin in pulsed HIGH/LOW for numberOfSteps, one sequence with directionPin as HIGH (= one direction) and another full sequence with directionPin LOW (= the other direction).

Why don't you give yourself a challenge, and see if you could rig a simple switch (say directionSwitch), whose value (HIGH or LOW) is then used as a flag for direction, so that you could output a HIGH or LOW in directionPin based on what you read from directionSwitch.

Hi JimboZA,

Thanks for correcting my spelling of Robin2.

With respect to the rest of your challenge, I'm not yet up to the stage of writing code, just beginning to get the gist of sketches via tutorials.

I have on order an Easy Driver board, hasn't arrived as yet. Have found a tutorial where speed and direction of a stepper motor is addressed plus wiring diagram. Have the Arduino uno R3 board and have been having a play.

Amazing piece of hardware.

Ken

neksmerj:
Have found a tutorial where speed and direction of a stepper motor is addressed plus wiring diagram.

Please post a link to it so I can learn the deficiencies in mine.

...R

Hi Robin2,

I wouldn't say there are any deficiencies in your thread, it's all at this end.

I found this tutorial re Arduino and EasyDriver employing 3 push buttons for forward, stop and reverse plus potentiometer for speed on the fly. Included also is a schematic diagram.

Ken

neksmerj:
With respect to the rest of your challenge, I'm not yet up to the stage of writing code, just beginning to get the gist of sketches via tutorials.

Well you have to start sometime! And if you have the Uno and a couple of led/resistor pairs, you can sort of mimic the direction thing. Read a switch (which if you don't have one can simply be a wire from an i/o pin which is either jabbed into a GND hole or not), and if the result is HIGH switch on led #1 and if it's LOW switch on a different one.

Or, if you like, draw a flow chart of the logic of what you want to do and code it in pseudo-code. Pseudo code is just words that you make up, which should reflect what you want to do, but needn't be correct in terms of the programming language's rules. So you could say something like:

read switchPin
if switchPin is high-
    set led1Pin high
    set led2Pin low.
otherwise-
    set led1Pin low
    set led2Pin high.

Hi JimboZA,

Your words make it sound so simple. It's a pity that the code for the Arduino is not written in english or basic.

How about some code to reflect your english steps?

Ken