User avatar
hootie
Posts: 90
Joined: Sun Apr 10, 2016 1:31 pm

Anyone good at driving stepper motors

Fri Apr 29, 2016 12:20 pm

Is there anyone here that has allot of experience driving stepper motors with a Raspberry PI. I am using a Raspberry Pi 3 and am using PicoBorg's to run the steppers. I currently have 3 steppers all doing different things, in a different sequence. I'm using the PicoBorg's because of the 5 amps they put out. I have two NEMA 23's running at 2.8 amps, and one NEMA 34 running at 5 amps (puts out 1841 oz.in torque). I will be probably be adding 2-3 NEMA 17 Steppers at some point. I know I can drive them with Python. I have to setup the HMI TFT, and then setup up the sequence for the motors.

I'm willing to pay for the right knowledge. I'm so busy with the mechanical part of my project... I need some help with the programming. Don't laugh... but I developed programs for the Nuclear industry for the last 12 years... so, I know how to program. Python is new to me... but, I have been coming up to speed. I just don't have the time to do two things at once. Let me know if anyone has any interest in helping me.

henryhanselscott
Posts: 107
Joined: Sun Jan 18, 2015 1:31 pm

Re: Anyone good at driving stepper motors

Fri Apr 29, 2016 12:48 pm

I am interested in where this goes as well. It would be nice to see a fully pi/simple driver solution. I run lots of steppers in the manufacturing automation world. When doing multi axis motion control, I generally use smart stepper drivers that can receive direction commands via the host comm port (PLC or pi) that way I can effectively control each axis independently. I do not know a way for the pi to handle all axis at the same time without causing critical step errors. Another solution that I have used, have the host controller talk to a pic micro, then the micro drives the stepper via a simple amp. You can have as many micros as steppers in the system and therefore accomplish smooth error free motion. As with all steppers, they must be properly sized for the application or they will loose steps. Being open loop, the controller may not realize this unless you are using some type of feedback or sensor input.

Henry

mung
Posts: 506
Joined: Fri Nov 18, 2011 10:49 am

Re: Anyone good at driving stepper motors

Fri Apr 29, 2016 1:05 pm

I thought I should make a post as I was not sure what allot ment, I has some experience with raspberries, but not sure what you are growing, everyone tells me servos are better!
hootie wrote: Don't laugh... but I developed programs for the Nuclear industry for the last 12 years... so,
:lol:

User avatar
hootie
Posts: 90
Joined: Sun Apr 10, 2016 1:31 pm

Re: Anyone good at driving stepper motors

Fri Apr 29, 2016 1:46 pm

Hey, you're laughing at me. Don't worry... I can laugh at myself just as much :D

I need the torque of the stepper motors. Otherwise I'd look at the servos.

My project is pretty interesting. I'm working on a product that has two ranges of technology and cost.
On the low end... you need 11 manual tools at approx. $180 to do what I want to do. At the high end... the base automated machine starts at around $65k and does what the 11 manual tools do, but all automated (CNC)

I am developing an automated machine... not so much CNC, but completely automated that will do what the $65k machine will do, but at a price in the range of $3k - $5k. Ultimately, I'd like to make it fully CNC.... but that would be once this product hits the ground, hopefully running!!!

Steppers are commonly used with Raspberry Pi's... but honestly, there's a ton of boards out there for them that work with the Pi. Selecting them is tough. I bought an Ingenia HYDRA for $350, but it only does one stepper. I bought a couple of Adafruit boards, but they are only good for 2.5 amps and a couple of steppers. I finally ordered a few PiciBorgs (waiting for them) because their good for 5 amps which is my requirement.

Running all of this off an HMI TFT Official Raspberry Pi screen for now. I see that it can be programmed with Pi, but there are also third party software to do the job. I want a really nice interface... If I manage to end up having to do this all myself... I will create a how to on the whole project of using the steppers. What's out there falls a bit short as far as I'm concerned. I found one that someone here or elsewhere pointed me to that is pretty good.

http://blog.scphillips.com/posts/2012/1 ... per-motor/

mung
Posts: 506
Joined: Fri Nov 18, 2011 10:49 am

Re: Anyone good at driving stepper motors

Fri Apr 29, 2016 3:02 pm

I don't think here is the place to explain the intricacies of stepper control (rotor inertia, reactance, timing, cogging, etc.. blah).

You get the driver electronics required for the motors and the controller (rpi) interfaces with the drivers. What exactly are you asking, driver and motor compatability is a question you should ask your suppliers, check your spec sheets for the drivers to see what drive control logic is used and then workout if you need level converters (rpi is 3.3v).

I know you are making a 'leading question' but I am wondering why.

If you search for linux and cnc and stepper motor on google you will find?..............

Also why are you posting in the 'general' forum topic section, have a look in the 'automation' section maybe there you will find what you are looking for?

The rpi can probably get you only 5us step resolution without jitter unless you want to spend a lot of time hacking low level drivers. Try posting in the automation section or search for machinekit you maybe get better help if you target less general help forum.

User avatar
hootie
Posts: 90
Joined: Sun Apr 10, 2016 1:31 pm

Re: Anyone good at driving stepper motors

Fri Apr 29, 2016 3:20 pm

I can't move it to the automation forum. Maybe a moderator can. Why am I even asking the question? I don't think I'm alone in trying to figure out the easiest way. And... you don't always have to buy the driver with a stepper. You can run them straight off of some of the cool motor controllers out there. And asking the stepper motor companies for help? Yeah, they'll give you the specs... but that's it. Possibly the drivers they suggest.

I think there's allot of people who would like to see a simple example of how to drive a stepper motor from a Raspberry Pi. Apparently you're not one of them. So why bother replying at all? I always wonder why people take the time to post on something they just want to bash. I guess to much time on their hands.

User avatar
joan
Posts: 14756
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Anyone good at driving stepper motors

Fri Apr 29, 2016 3:32 pm

I don't think anyone has made a really serious attempt to drive multiple steppers from the Pi. The CNC guys seem to have jumped straight to an external hardware solution.

There is lots of code available (as you have linked) to drive a single hobby stepper which doesn't need anything sophisticated (indeed anything at all) in the way of ramps.

I doubt you'll find a lot at the moment to drive multiple steppers. I'm going to have a play. I have 5 of the inexpensive 28BYJ-48 hooked up to a B+ using ULN2003 drivers. I suspect it'll quickly prove to be either an impossible or an easy task. I just don't know which it is yet.

User avatar
hootie
Posts: 90
Joined: Sun Apr 10, 2016 1:31 pm

Re: Anyone good at driving stepper motors

Fri Apr 29, 2016 3:42 pm

From the research I've done... boards like the PicoBorg can handle two steppers at 5 amps.
You can stack them too. I think these... in conjunction with drivers for each stepper is the answer, and can be done with the Raspberry Pi. I think it's even simpler than I think.

One thing I've found... forums are the best place to find info. I use them often... and yeah, from time to time I post in the wrong place, might ask a question to technical for the forum I'm in. But, I ask for forgiveness... and a little bit of understanding. I ask questions so I can learn from those who have experience in areas I don't.

I licensed close to $1 million in software working out of my own house. I often used forums when I found myself stuck, or just wanted to know a better way of doing things.

So... I apologize to anyone thinks I'm wasting someone's time, or posting in the wrong forum. I've done that enough to accept my failings!!!

That said... I was a mechanical engineer for 20+ years, and a software developer for 12+ years. I have several patents, and have made enough money, that at 53 years old I can develop cool products just to keep busy. So I'm sorry for asking dumb questions, or posting in the wrong forum. If you aren't trying, you aren't accomplishing anything!!!

User avatar
hootie
Posts: 90
Joined: Sun Apr 10, 2016 1:31 pm

Re: Anyone good at driving stepper motors

Fri Apr 29, 2016 3:46 pm

And I don't mention $ to brag. My point is that without forums like this... I don't know how I could have succeeded to the level I did. Trust me... I've been way luckier than smart :(

You can only succeed at something if you try...

mung
Posts: 506
Joined: Fri Nov 18, 2011 10:49 am

Re: Anyone good at driving stepper motors

Fri Apr 29, 2016 3:57 pm

hootie wrote:I can't move it to the automation forum. Maybe a moderator can. Why am I even asking the question? I don't think I'm alone in trying to figure out the easiest way. And... you don't always have to buy the driver with a stepper. You can run them straight off of some of the cool motor controllers out there. And asking the stepper motor companies for help? Yeah, they'll give you the specs... but that's it. Possibly the drivers they suggest.

I think there's allot of people who would like to see a simple example of how to drive a stepper motor from a Raspberry Pi. Apparently you're not one of them. So why bother replying at all? I always wonder why people take the time to post on something they just want to bash. I guess to much time on their hands.
:lol:

Thanks, for your constructive critisism, I will try to use it to help my customer service and manners :D

I am not trying to bash you, I am trying to help you by showing you a more efficient way of finding the answers you seem to want.

I appologise for my terse reply, but, unfortunately everyone in this world has their own priorities, yes I have some time on my hands this afternoon, and I try to give advice and help the rpi forum, but you cannot expect others to spend a lot of time answering your individual question when your question has been answered before.

If you have worked in industry you should know how to do research and read technical specifications, I suspect you are either being very lazy otherwise you are just trolling.

You need to realise nothing is easy, you will need to spend some time reading and understanding how the systems involved work together and when you have a problem ask a specific well defined question that can be answered.

I myself do like to play the lazy chatty ill defined forum discussion game, it is sometimes fun, but I like to have a goal I can work towards.

Obviously you know your own goal, but I do not.

Now I suppose I can answer at the very least your first sentence, yes there are probably more than 1 people but less than 10 people on this forum that have allot of experience controlling stepper motors. Whether those people really know a lot about the physical characteristics of how stepper motors work I have no idea, computer control is a complex subject.

I doubt you will find anyone that will give you the amount of help and hand holding you appear to need for such a complex project as you describe and also the fact that you do not seem to have a well defined specification for your project makes it hard for anyone to quote to give paid help.

I don't like to admit this but it sometimes seems as though I know a bit about controlling stepper motors with the raspberry, but at the same time I realise that there is a huge amount of stuff that I know about but I do not fully understand or consider, probably because generally I do not need to consider certain aspects of a system.

I know that I only play with stepper motors, I mess with them as a hobby, I find it interesting to see how they work and how they fail and how I can control them. Unfortunately I would never feel confident to give advice on a commercial application as I am not qualified and I do not have the time.

I feel you are not giving enough details for anyone to advise you, I think if you are designing a machine you need to know things like how fast it needs to move and what sort of torque or force it needs to provide and finally the precision or accuracy required, from there you can specify motors and drivers and then workout what sort of realtime scheduling is required by the computer controlling the system.

All those things should be known before you can ask a question that can be answered.

Otherwise you should get on with experimenting to see what you can do with what you have or what you want to use, which is really a matter of play rather than engineering.

Sorry for being an ass, but if you just want to play, get on with it, search google and experiment and you will learn a lot and maybe achieve something great.

If you actually really want some paid commercial engineering help, write a decent specification, and give some sort of initial price to negotiate around. Maybe try freelancer.com

User avatar
hootie
Posts: 90
Joined: Sun Apr 10, 2016 1:31 pm

Re: Anyone good at driving stepper motors

Fri Apr 29, 2016 5:05 pm

You nailed it... I'm lazy and trolling.

That aside.... If I just used a PLC/HMI setup, I could do exactly what I want. And interestingly enough... I know exactly how to do it.

However... I like the Raspberry Pi. What I'm researching is its limitations. Not mine!
And interestingly enough... I don't think I'm the only one who would like to know more about using them with the Raspberry Pi.

But, this is obviously your forum... and I will move on.

User avatar
B.Goode
Posts: 9586
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: Anyone good at driving stepper motors

Fri Apr 29, 2016 6:08 pm

hootie wrote:But, this is obviously your forum... and I will move on.
No, this is not @mung's forum. You have no need to move on. You have had a potentially helpful reply from a regular contributor who may well be able to assist.

User avatar
hootie
Posts: 90
Joined: Sun Apr 10, 2016 1:31 pm

Re: Anyone good at driving stepper motors

Fri Apr 29, 2016 8:03 pm

I think allot of people have great input, and yes... I have one very good lead from the post. So the post wasn't in vein.

mung
Posts: 506
Joined: Fri Nov 18, 2011 10:49 am

Re: Anyone good at driving stepper motors

Fri Apr 29, 2016 8:39 pm

hootie wrote:I can't move it to the automation forum. Maybe a moderator can. Why am I even asking the question? I don't think I'm alone in trying to figure out the easiest way. And... you don't always have to buy the driver with a stepper. You can run them straight off of some of the cool motor controllers out there. And asking the stepper motor companies for help? Yeah, they'll give you the specs... but that's it. Possibly the drivers they suggest.

I think there's allot of people who would like to see a simple example of how to drive a stepper motor from a Raspberry Pi. Apparently you're not one of them. So why bother replying at all? I always wonder why people take the time to post on something they just want to bash. I guess to much time on their hands.
I was just reading the information leaflet for metronidazole and considering whether to post some weird irrelevant stream of consciousness post on a forum to entertain myself, so I came back and reread this thread. I am never very good at reading comprehension and sometimes miss things in posts, and maybe I missed something here.

So I often find myself wondering silly questions like what percentage of internet traffic is produced by AI bots or why do some people post obviously incorrect information on forums.

I sometimes spend insufficient time formulating my information output and allow misunderstandings to occur, so maybe I said the wrong thing before and also missed some of your posts hootie. I thought I should reply to this post as you say 'Apparently' I would like you to let me know what part of my reply made it appear that I did not want to see a simple example of how to drive a stepper motor?

I always try to improve my communication efficiency as and when errors and mistakes occur so your response will be very helpful and welcome.

mung
Posts: 506
Joined: Fri Nov 18, 2011 10:49 am

Re: Anyone good at driving stepper motors

Fri Apr 29, 2016 8:49 pm

joan wrote:I don't think anyone has made a really serious attempt to drive multiple steppers from the Pi. The CNC guys seem to have jumped straight to an external hardware solution.

There is lots of code available (as you have linked) to drive a single hobby stepper which doesn't need anything sophisticated (indeed anything at all) in the way of ramps.

I doubt you'll find a lot at the moment to drive multiple steppers. I'm going to have a play. I have 5 of the inexpensive 28BYJ-48 hooked up to a B+ using ULN2003 drivers. I suspect it'll quickly prove to be either an impossible or an easy task. I just don't know which it is yet.
Seriously joan?

I think you are probably one of the more advanced developers on this forum and I assume you have some inside knowledge of the broadcom chips, did you not write the pigio library?

There are quite a few direct gpio stepper control systems using the raspberry pi, linuxcnc/machinekit and I think a delta robot controller which was on the reprap forum, also I think I saw a couple on github. Obviously the picnc linuxcnc thread uses external mcu and spi communication but also people do use direct gpio using the standard driver.

I think some people were scared off by the memory refresh thing, but there are probably a few others experimenting.

high resolution precise gpio timing through the gpio is probably not as good as the beaglebone but good enough for most purposes the average hacker may want.

Most of the requirements are easy not impossible, but its the matter of linking everything together into something useable that takes time and effort.

Of course I could easily be wrong.

User avatar
joan
Posts: 14756
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Anyone good at driving stepper motors

Fri Apr 29, 2016 8:59 pm

Yes, I thought seriously.

How do the CNC people run multi-axis machines, say 3 or 4 steppers from the Pi? How do they schedule the steps?

mung
Posts: 506
Joined: Fri Nov 18, 2011 10:49 am

Re: Anyone good at driving stepper motors

Fri Apr 29, 2016 9:07 pm

hootie wrote:And I don't mention $ to brag. My point is that without forums like this... I don't know how I could have succeeded to the level I did. Trust me... I've been way luckier than smart :(

You can only succeed at something if you try...
Why bother mentioning $ at all then?

I am sorry to say this and unfortunately it is rude, but unfortunately it is also the truth as I see it, you mention lots of irrellevant things that serve no purpose to attaining the supposed goal you are purporting to ask help attaining. The size and current of your motors is irrelevant to weather raspberry pi will drive them. Whether you have money or not is irrelevant to your ability to accomplish the goal. Your poor spelling and grammar and poorly thought out posts make me feel you are just a school kid rather than who you say you are.

Mentioning how rich you are illustrates
"point is that without forums like this... I don't know how I could have succeeded to the level I did."
" ????
a non sequitur

Define how you want to move your motors how many steps per second and how you want to control the motion parameters (gcode or some other program?).

I am definitly not an expert in motion control, and unfortunately I am rather too well educated in other ways, sorry for picking holes in everything, I am a paranoid person and something about your posts makes me feel you are not being truthful or do not know what you are talking about.

I don't really care if people joke and lie, I find it quite amusing sometimes. Everyone likes to play the fool now and again, but not sure if this is a joke where it is going.

Maybe I used too many smilies?? :lol:

Seriously, if you explain your problem a little better I will try and give some more pointers, but I am not really sure what your game is.

mung
Posts: 506
Joined: Fri Nov 18, 2011 10:49 am

Re: Anyone good at driving stepper motors

Fri Apr 29, 2016 9:09 pm

hootie wrote:You nailed it... I'm lazy and trolling.

That aside.... If I just used a PLC/HMI setup, I could do exactly what I want. And interestingly enough... I know exactly how to do it.

However... I like the Raspberry Pi. What I'm researching is its limitations. Not mine!
And interestingly enough... I don't think I'm the only one who would like to know more about using them with the Raspberry Pi.

But, this is obviously your forum... and I will move on.

WTF?????

My forum, I am always getting kicked out and threatened with being banned.

I thought this was YOUR forum?

mung
Posts: 506
Joined: Fri Nov 18, 2011 10:49 am

Re: Anyone good at driving stepper motors

Fri Apr 29, 2016 9:14 pm

B.Goode wrote:
hootie wrote:But, this is obviously your forum... and I will move on.
No, this is not @mung's forum. You have no need to move on. You have had a potentially helpful reply from a regular contributor who may well be able to assist.
Wow thanks B goode, I almost feel like I have an ally, which also unfortunately worries me as I maybe required to support you when someone invades Poland.
:)

mung
Posts: 506
Joined: Fri Nov 18, 2011 10:49 am

Re: Anyone good at driving stepper motors

Fri Apr 29, 2016 9:50 pm

joan wrote:Yes, I thought seriously.

How do the CNC people run multi-axis machines, say 3 or 4 steppers from the Pi? How do they schedule the steps?
I am not really sure how multi axis machines are run(I have never used any pro level equipment), but it seems if the gpio switch time is only a few ns different it does not really make much difference to a single motor step syncronisation.

i.e. step interval is 10μs calculating the next axis step takes only a couple of cpu cycles maybe 10νs so 1/100 of the step interval. In physical terms the response time of motor inertia and reactance makes that negligable.

But in the case of most situations all axis are computed and then written to the gpio register as a single word, so there is no difference in switch time on gpio pins?.

In the case of the dma driver used in linuxcnc/machinekit certain things are tuned with the realtime scheduling so that a precomputed buffer is used and very accurate pwm timing controls the gpio writing.

Timing is very important for steppers as an irregularly timed step can ruin motion(I have heard this but never done the maths properly), basically as rotors have inertia they continue spinning, if the coil is energised after the rotor has passed it will pull it backwards, at high speed this gets more important and means jitter will stall a motor.

If you are talking about the way the step generators work, that is a different matter that I could explain and involves an accumulator updated at the step interval and a pickoff value that tells when a step should occur. I doubt I could explain it very well though.

I don't really know about trajectory planning or most other aspects of linuxcnc.

Last time I tried it seemed possible to get synchronised 10 axis motion from linuxcnc with step interval (virtual base thread) of 5μs this maxes out most motors unless using stupidly high resolution microstep drivers.

User avatar
joan
Posts: 14756
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Anyone good at driving stepper motors

Fri Apr 29, 2016 10:07 pm

I'm not sure what you are saying.

Is the axis scheduling performed on the Pi and are Pi GPIO being used to send pulse/dir to the stepper motor drivers?

mung
Posts: 506
Joined: Fri Nov 18, 2011 10:49 am

Re: Anyone good at driving stepper motors

Fri Apr 29, 2016 10:45 pm

joan wrote:I'm not sure what you are saying.

Is the axis scheduling performed on the Pi and are Pi GPIO being used to send pulse/dir to the stepper motor drivers?
Axis scheduling??? not sure what that is?

I think I said I am not an expert in motion control, I assume you know more than me, especially about the rpi hardware.

I am starting to feel you are being facetious and playing with me :lol:

As said I really do not fully understand linuxcnc, I only wrote a driver for it that should function properly on the rpi.

The driver I wrote uses the rpi gpio pins to send step/dir signals, I.e. you just connect the motor stepper driver (a4988) directly to the rpi gpio.

In linuxcnc motmod is a realtime component i.e. it needs a realtime scheduler(in theory), it calculates paths which I think it does by dividing the path into short line segments and velocities. So it says for example move from x1 to x4 which is length 3 and do it in 2 seconds so it calculates that length three requires 600 motor steps, so every 1/300th of a second it makes a step.

All motion planning and step generation is done on the rpi and must be done at highest kernel schedule priority, the step generator only precomputes step and direction switching for one servo period (how many base period intervals until the next step can be switched on or off) the gpio is written out by dma at the base period frequency.

The last time I looked at this was about a year ago, when I got it working on the rpi2, but essentially the same thing has worked the same way since the original rpi model b.

I actually recently got a circuit board made that I am hoping to get time to test on a pizero and pi3, but find the code I last used seems to be taking a lot of archival work.

I will probably post something on the linuxcnc thread once I get things setup.


I thought I better edit this to say this is vast simplification, I missed out lots and there are lots of parameters in step generation that say things like how long a signal must stay on and/or off before it can change and delays before direction can change. Also the trajectory planner/motion controller calculates lots of things about acceleration and speed limits etc.. blah blah blah, basically most of it does not need to be understood only the parameters required by the stepgenerator. And the realtime thread only needs to have shceduling latency within that required by the servo thread


All this is going into far too much detail, and yet not enough detail to fully explain it.

All I really should have answered this thread with was the sentence 'try using linuxcnc, search the forum for the relevant thread'

:lol:


mung
Posts: 506
Joined: Fri Nov 18, 2011 10:49 am

Re: Anyone good at driving stepper motors

Fri Apr 29, 2016 11:10 pm

OMG super lol :lol:

I just got this message:
just for you.

Sent: 29 Apr 2016 22:09
From: hootie
To: mung
Apparently I can't reply to your dribble on my own post. Moderators must be blocking me.

You're posts are condescending and antagonistic. That tells me two things. You're immature, and you have an inferiority complex.
People with those traits always deny that they are those things... so don't waste your breath!

After reading your posts... I was under the impression that I should write at an 8th grade level for you to understand me. So excuse the lack of college level grammar, and or spelling. I'd have to translate it for you.

Here's the difference between us. I can get up every single day and decide what I want to do for the day. You get up each day for work so that you can pay your trailer rent.

People who think they know everything are annoying to those of us who do!

hootie
Yes I think you got that right hootie, I am definitly condescending, not sure about antagonistic, depends if you take me as a joke or not, I always try to make all my posts tongue in cheek yet actually say something useful or meaningful.

I came to the conclusion long ago that I have both an inferiority and superiority complex and that everyone else has also.

I am very poor and do find it hard to pay the rent, but I have an understanding landlord, and I never actually go to work.

I assume we are both joking, and hope this brings a smile to others faces, I know we are both assholes :lol:

Anyways I am a little annoyed that you cannot post on this thread anymore and hope that you will be allowed to again, your game was quite amusing, but I guess maybe things maybe are getting out of hand.

I should not have played the spelling and grammar nazi card, although spelling is important its not really worth starting a fight over.

Anyways start another thread if you want to play more, but try and ask better questions.

jdb
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 2238
Joined: Thu Jul 11, 2013 2:37 pm

Re: Anyone good at driving stepper motors

Fri Apr 29, 2016 11:37 pm

This thread irks me due to the sheer ratio of reports per post.

Closing because it appears to have devolved into pointless bickering rather than a constructive discussion.
Rockets are loud.
https://astro-pi.org

Return to “General discussion”