Go Down

Topic: Arduino uno R3 stepper motor control (Read 12316 times) previous topic - next topic

neksmerj

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

Robin2

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
Two or three hours spent thinking and reading documentation solves most programming problems.

neksmerj

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

neksmerj

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

Robin2

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
Two or three hours spent thinking and reading documentation solves most programming problems.

neksmerj

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

Robin2

#36
Nov 14, 2014, 01:18 pm Last Edit: Nov 14, 2014, 01:20 pm by Robin2
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?

Quote
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?

Quote
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
Two or three hours spent thinking and reading documentation solves most programming problems.

neksmerj

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.

http://www.youtube.com/watch?v=fsMg6F6yYlo

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

Ken

JimboZA

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.
Johannesburg hams call me: ZS6JMB on Highveld rep 145.7875 (-600 & 88.5 tone)
Dr Perry Cox: "Help me to help you, help me to help you...."
Your answer may already be here: https://forum.arduino.cc/index.php?topic=384198.0

neksmerj

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

Robin2

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
Two or three hours spent thinking and reading documentation solves most programming problems.

neksmerj

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.

http://www.schmalzhaus.com/EasyDriver/Examples/EasyDriverExamples.html

Ken

JimboZA

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.
Johannesburg hams call me: ZS6JMB on Highveld rep 145.7875 (-600 & 88.5 tone)
Dr Perry Cox: "Help me to help you, help me to help you...."
Your answer may already be here: https://forum.arduino.cc/index.php?topic=384198.0

neksmerj

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

JimboZA

Give it a bash yourself.

If you don't feel confident running it in case you pop something, at least type it up and see if it compiles. Compile only, with no upload, poses no danger the Uno. That way you'll know it's grammatically correct even if it falls over on the logic. Then post that and let someone here comment.

But here's some clues with no code, since I really think you'll benefit from trying to write it yourself.

Start with the BareMinimum sketch which gives you a skeleton setup() and loop(). Above setup() define any variables you would like to name. You might for instance decide to have one LED on pin 5 so you could use byte to set say myLedPin1 to be 5. Same for another led on a different pin, and ditto the switch.

Then in setup() use pinMode to set those leds' pins as outputs and the switch one as an input with pullup resistors.

In loop, use digitalRead to read the switch and digitalWrite inside an if / else to conditionally turn on the LEDs.

Time to get your feet wet, methinks: but as I say if you want comment before you hook stuff up, that's cool. At least get to the stage of sorting out compile errors like if you type "PinMode" when it should be "pinMode", for instance.
Johannesburg hams call me: ZS6JMB on Highveld rep 145.7875 (-600 & 88.5 tone)
Dr Perry Cox: "Help me to help you, help me to help you...."
Your answer may already be here: https://forum.arduino.cc/index.php?topic=384198.0

Go Up