Author Topic: Motion Controller Design  (Read 5221 times)

Offline sparky961

  • Hero Member
  • *****
  • Posts: 764
  • Country: ca
Motion Controller Design
« on: December 12, 2015, 09:44:45 PM »
Motion control has always been of great interest to me.  The one question I've never been able to find an answer to though is exactly how multiple axes are synchronized in a motion controller.

Let's say we have a typical 3-axis machine and we're performing linear motion combining all 3.  Does one central controller dynamically figure out the position of each axis in tiny steps, commanding them to each of those steps as time moves on?  Or is there a way to "queue" the motion of each axis then tell them all to "go" at the same time.

Perhaps a naive question, but I think I've always been attempting the latter and I've begun to think it may be the wrong way to approach the problem.

I'd appreciate well-documented code examples, technical papers on the subject, or first hand experiences.

Offline Imagineering

  • Jr. Member
  • **
  • Posts: 52
Re: Motion Controller Design
« Reply #1 on: December 13, 2015, 02:30:03 AM »
I think, and I may very much be wrong, that a CNC Controller such as Mach3, utilises an Algorithm which calculates the required speed for each Stepper Motor concurrently to finish moving at the same Point at the same time.
Evidence or Documentation I have neither.

.

Offline Bluechip

  • Madmodder Committee
  • Hero Member
  • *****
  • Posts: 1492
  • Country: england
  • Derbyshire UK
Re: Motion Controller Design
« Reply #2 on: December 13, 2015, 02:52:08 AM »
Never worked on CNC but as far as I know all robotic/handling systems do.

Here is a short 'Tube video of a machine I worked on.

Just about possible to see a linear motion of the gripper obtained by the interaction of two rotary motions. ( aml/2 )

http://www.bing.com/videos/search?q=aml%2f2&view=detail&&&mid=9BA298CED915B9B7D1019BA298CED915B9B7D101&rvsmid=9BA298CED915B9B7D1019BA298CED915B9B7D101&fsscr=0

And another  ( AML/J ) P.S. Turn the sound off !! 'kin irritating racket !!

http://www.bing.com/videos/search?q=aml+j&view=detail&&&mid=1D75267255F6E53703981D75267255F6E5370398&rvsmid=1D75267255F6E53703981D75267255F6E5370398&fsscr=0

Dave
I have a few modest talents. Knowing what I'm doing isn't one of them.

Offline chipenter

  • Hero Member
  • *****
  • Posts: 658
  • Country: gb
Re: Motion Controller Design
« Reply #3 on: December 13, 2015, 03:31:14 AM »
Have a look at Arduino it's open source with lots of articals , Mine is a fairly old computer and the com port baud rate is 19200 a second , so from one instruction to the next is a not notisable by eye .
Jeff

Offline PekkaNF

  • Hero Member
  • *****
  • Posts: 1647
  • Country: fi
Re: Motion Controller Design
« Reply #4 on: December 13, 2015, 12:00:49 PM »
You need to google a bit more this article has few concepts at the begining:
http://www.hsmworks.com/docs/hsmworks/2012/en/#StrategyMultiAxisContour

You can think that (tool path) contour is made out of discrete vectors. Blocks like on highschool math books. This is a table of individual axis setpoints. Then servos try their best to make it happen in real life.

In real life that would not work, because on corners and such places one axis would have a zero acceleration and the other(s) infinity.

Therefore those "blocks" are adjusted to keep each axis speed and acceleration within real life limits.

In reallity it is a bit more complicated. Both tool path calculations and control loop to keep everything under control.

Bit like a journey. It's good to to have a plan, but if you follow your initial plan very carefully eyes shut, you are on ditch pretty soon.

Pekka

Offline sparky961

  • Hero Member
  • *****
  • Posts: 764
  • Country: ca
Re: Motion Controller Design
« Reply #5 on: December 13, 2015, 12:06:28 PM »
I think, and I may very much be wrong, that a CNC Controller such as Mach3, utilises an Algorithm which calculates the required speed for each Stepper Motor concurrently to finish moving at the same Point at the same time.
Evidence or Documentation I have neither.

This would definitely be the easiest way to do it, and the way I've been trying to get working for .... well, far too long without satisfactory results.  Mach3, as I know it, is for the most part an open loop controller.  There may be some objections to this but even on the forum there are plenty of references to this fact.  It is also designed primarily with stepper motor systems in mind.  My goal is a well-functioning servo system.

Despite the ease of figuring out motion ahead of time and trusting that it will happen as commanded, I'm not that optimistic.  I want to make a system that knows when something goes wrong and either tries to correct it or aborts.  Lofty goals, I know.

Have a look at Arduino it's open source with lots of articals , Mine is a fairly old computer and the com port baud rate is 19200 a second , so from one instruction to the next is a not notisable by eye .

My latest development platform has been a trio of Teensy3.0 boards.  They are tied into the mess of Arduino commercialization and oversimplification but perhaps without some of the hype (micro rant = off).  I've been thoroughly impressed with their capability for such a small package and form factor but have run into a wall with the limitations of USB latency.  Not to mention the difficulty of synchronizing multiple axes due to my modular approach.  This is why I've begun to favour the central controller that knows what each axis is doing and is able to control each of them "simultaneously".

My development efforts haven't been in vain though.  I have a great base for playing with USB controlling external hardware and controlling the position of one servo with encoder feedback..... but this doesn't get me to the finish line: full synchronization of 3 or 4 axes.

Offline sparky961

  • Hero Member
  • *****
  • Posts: 764
  • Country: ca
Re: Motion Controller Design
« Reply #6 on: December 13, 2015, 12:13:17 PM »
You need to google a bit more this article has few concepts at the begining:
http://www.hsmworks.com/docs/hsmworks/2012/en/#StrategyMultiAxisContour
...
Bit like a journey. It's good to to have a plan, but if you follow your initial plan very carefully eyes shut, you are on ditch pretty soon.

Good info.  Also a good analogy for my past development efforts.  I think it's time to take a slightly different path.  (Pun intended).

Offline Joules

  • Hero Member
  • *****
  • Posts: 836
  • Country: gb
Re: Motion Controller Design
« Reply #7 on: December 13, 2015, 12:55:08 PM »
Linuxcnc communicates step direction signals in parallel, so all axis can move in harmony no timing problems in that aspect.  USB to step direction usually buffers the serial data, then presents it also in parallel.  Fancy controllers and servo systems are more complex/expensive and outside my comfort zone.
Just get doing and make swarf, you can decide what its going to be later.   :thumbup:

Offline sparky961

  • Hero Member
  • *****
  • Posts: 764
  • Country: ca
Re: Motion Controller Design
« Reply #8 on: December 13, 2015, 04:13:56 PM »
Any suggestions for a development environment for my next creative push?  My current thought is to divide the system into 2 processors. 

The first doesn't have any timing critical responsibilities and would handle all the mundane stuff like user IO, display, external communication, storage, etc.  A high powered off-the shelf solution like Raspberry/Banana Pi or maybe an Arduino SBC would be cost effective and well suited.

For the second one the choice is a bit harder.  I'm thinking 200+ MHz clock speed to get the kind of cycle times I'll need for very fine-grain control of motion.  It will need to be all from scratch or run a good RTOS - no fancy operating systems using up cycles on this one.  IO will be quite extensive with an estimated 100 digital I/O pins, though not all of them are time critical.  Some sort of simple MUX or BUS could be devised for the slow signals.  I'd prefer, however, to limit external components even if this means overkill on the processor.

Characteristics that could sway me toward a particular uC or board:
- Motorola/Freescale architecture (familiarity)
- Arduino (slight familiarity, ubiquity - seems to be all the rage, but for how long?)
- Hardware quadrature decoders
- Hardware PWM or D/A
- Existing reference designs

I'm using 6 axes as a basis for design but I'd be very pleased if I were to have success with 3 and thrilled with full coordinated motion of 4 axes.  That's going to be how I proceed with the software/firmware but I'd rather not have the hardware impede future development.  On the same note by the time I get to that point there's going to be much better hardware around so I might just ignore the other axes.  Oh, and really - who the heck has a 6 axis machine to play with?

Working block diagram attached.  Did I miss anything obvious?

Offline MrSleepy

  • Jr. Member
  • **
  • Posts: 12
Re: Motion Controller Design
« Reply #9 on: December 17, 2015, 10:13:47 AM »
Smoothie is the open source motion controller firmware for Arm cortex cpus (originally a grbl port)... which runs on the smoothie board

A basic description of how it decodes gcode and creates and plans moves is here...
http://smoothieware.org/howitworks

the source code is available on github
https://github.com/Smoothieware/Smoothieware/archive/edge.zip

Rob

Offline efrench

  • Jr. Member
  • **
  • Posts: 96
Re: Motion Controller Design
« Reply #10 on: December 17, 2015, 03:10:46 PM »
I'm using a Smoothieware board in my 3d printer.   They have recently added support for servos, but I haven't read anything about how well the servo code works.

I would be more inclined to say LinuxCNC via MachineKit would be a better fit for what you're doing:http://www.machinekit.io/  It will run on a lot more platforms and there is plenty of support.  My next machine will most likely be using this.

Offline sparky961

  • Hero Member
  • *****
  • Posts: 764
  • Country: ca
Re: Motion Controller Design
« Reply #11 on: December 17, 2015, 08:42:37 PM »
I would be more inclined to say LinuxCNC via MachineKit would be a better fit for what you're doing:http://www.machinekit.io/  It will run on a lot more platforms and there is plenty of support.  My next machine will most likely be using this.

At this point I'm not interested in using anyone else's project, except for ideas.  I've been through some of the EMC/LinuxCNC code and it's quite the mess.  I've also used it in the past and getting things to work well is like having a second job.  I'd rather spend that time developing something myself.

There is some good info on the design of the Smoothie, which I've filed away for future reference.

Just in quick reading it seems like it linearizes curves into short line segments.  Is this noticeable in your prints?

Offline efrench

  • Jr. Member
  • **
  • Posts: 96
Re: Motion Controller Design
« Reply #12 on: December 18, 2015, 12:55:36 PM »


I can't see any segmentation in the prints, but if you were working in aluminum with a nice rigid setup, you might.



Offline chipenter

  • Hero Member
  • *****
  • Posts: 658
  • Country: gb
Re: Motion Controller Design
« Reply #13 on: December 18, 2015, 02:08:09 PM »
I found this in Teacup firmwhare it's way over my head , but it may help .
Jeff

Offline sparky961

  • Hero Member
  • *****
  • Posts: 764
  • Country: ca
Re: Motion Controller Design
« Reply #14 on: December 18, 2015, 04:25:24 PM »
I found this in Teacup firmwhare it's way over my head , but it may help .

Very nice.  Thanks.

Just a quick scan of the first few pages and it looks quite similar to Bresenham's (sp?) algorithm, which I used to be familiar with.  It does, however, go into much more detail and over my head with the math too.  It does have nice code examples though, which means I don't need to understand the equations. :)

Offline sparky961

  • Hero Member
  • *****
  • Posts: 764
  • Country: ca
Re: Motion Controller Design
« Reply #15 on: December 21, 2015, 08:25:24 PM »
<SIGH>  What a way to start off, eh?

Not four days ago I may be quoted as saying "At this point I'm not interested in using anyone else's project, except for ideas".  What a long time four days is.

-WARNING-
The following text may contain any or all of, but not limited to the following: disappointment, self deprecation, resignation, self-torture, trepidation, skepticism, optimism, and excitement.  Not to mention all of the things I haven't mentioned.

-----

So, it's like this... I've done a bit of soul searching about this (literally) years-long pursuit of mine to make my own servo controller.  After getting back into this project and realizing just how far away I am from a safe and well-functioning system, I got to asking myself exactly why I'm doing this.  Is it actually because I want to design and build a "better" motion controller - despite the fact that there are so many existing already?  Or do I just want a small CNC mill/lathe to call my own?  Yup... big realization moment it was indeed.  Turns out I'm pretty sure it's the latter.

Designing and building all of the system would be incredibly satisfying.  But alas I have a full time job and like to spend a good portion of my time pursuing outdoor activities while I'm younger and physically able.  Thoughts of selling the system inevitably creep into the damp corners of my brain.  Just like all the other things I thought I could make and sell that I never did.

I am, and always have been torn on how much effort to put into my already limited Mill/Drill/Lathe - which admittedly is much more of a Drill/Lathe than anything else.  It's not completely useless, just not as useful as I'd dreamed it would be.  When I add up the cost of purchasing components to do a CNC conversion, I wonder if it isn't a case of throwing good money after bad. 

Under computer control, will I be happy with the mechanical limitations?  My hope in this case is that the repetition of taking light and small cuts on less-than-ideal setups will be taken care of by the NC.  Metric graduations on the leadscrew dials, which don't lock reliably are no longer a problem.  Eventually with all of the right gear in place, tapping and threading will be (oh man, I hope) effortless.

What do I need to make this happen?

Servos & Drives
Already got 'em.  Though I don't have the exact specs, I know they are BLDC with 4k PPR quadrature encoder.  I'm not sure what NEMA frame size they are, but they seem to have plenty of power to turn the screws on my little machine.  I got them used, fortunately with the drivers, so my knowledge on them is limited.  The drives take +/- 10V analog in, which appears to be industry standard.

Brackets, Belts, and Pulleys
Check.  I've had the machine under stepper control in the past with very unsatisfactory results.  I suspect the steppers were underpowered.

MPG
Check.  I was given a non-functional Tosuku pendant off an industrial CNC CO2 laser from where I used to work.  A bit of surgery found and fixed the problem and it works very well now.  I even have this working with MACH3 at the moment.

Computer & Monitor
Check.

Power Supply
Check .... maybe.  Might need to upgrade to something with more oomph, but should be ok to start.

Motion Controller
Ah heck... now I remember where the problem was!

So a nod to eFrench (and perhaps an apology), who's idea I quickly shut down four days ago, for reminding me of LinuxCNC.  Although I have many worries about the configuration and implementation, I'm thinking with some patience, perseverance and purchases I might just be able to make this work.  The time taken to set it up will be far less than my former development path.  This much can be guaranteed.

STAGE 1 includes:
- LinuxCNC
- Mesa 5I25  Superport FPGA based PCI Anything I/O card
- Mesa 7I77 Analog servo interface plus I/O daughtercard
- Limit switches of some sort

If I get all of the above working, I'm going to soon want STAGE 2:
- Encoders for each spindle (lathe, mill)
- VFD for each spindle (or maybe switch one between the two motors with a relay or whatever)  [Are there VFD's out there for 3/4HP 120V single phase capacitor-start A/C motors?  If not I'd have to swap those too... $$$  Honestly, they're pretty crappy motors anyway]

I'm ballparking about $600 CAD for STAGE 1 purchases, given the poor exchange rate at present.  I'd wait if I knew anything about economics and predicting the future.  I have no idea about the cost of STAGE 2, though I seem to recall seeing VFD's for about $100 or so - not sure the currency or accuracy.

So, what am I neglecting?  Someone please tell me if I'm insane to keep at this.  This is in the realm of "hobby", not commercial, so I can't write off expenses or justify anything through ROI.  I suppose in the worst case scenario that LinuxCNC doesn't work out for me, I should have some solid hardware to continue with my own development efforts.  In fact, there's nothing stopping me from doing that if I change my mind in the future.  Would you listen to me trying to justify this already?  Man.... what a guy...

Offline sparky961

  • Hero Member
  • *****
  • Posts: 764
  • Country: ca
Re: Motion Controller Design
« Reply #16 on: December 24, 2015, 02:19:35 PM »
<chirp> <chirp>

What is that?  A cricket?  Good post to clear the room, I suppose.  Better fodder for CNCZone perhaps?  I do hate that forum....

Offline DMIOM

  • Hero Member
  • *****
  • Posts: 667
  • Country: gb
  • Isle of Man
Re: Motion Controller Design
« Reply #17 on: December 24, 2015, 06:14:32 PM »
Don't flit Sparky - please keep posting here, they're all MadMods!

Offline sparky961

  • Hero Member
  • *****
  • Posts: 764
  • Country: ca
Re: Motion Controller Design
« Reply #18 on: February 25, 2016, 11:10:23 PM »
Over the Christmas holidays I decided to go ahead and get the Mesa 5i25 and 7i77 boards to continue my efforts toward a servo-controlled cnc machine.  I was annoyed to find that they were out of stock at the time, so I just kept checking back until the web site showed stock.  When they finally did, I ordered the kit containing the cards and a cable that was guaranteed to work.  The last thing I need is for something stupid like a crappy cheap cable to impede my progress!

They arrived early this week, and after just about choking on the amount of customs brokerage fees I had to pay, I got to work learning and plugging things in.  The learning curve is pretty steep, but having an electronics and programming background, CNC knowledge, and online forums to help along the way has kept be going.

I have a thread going over at the LinuxCNC forum if anyone is interested in following along.

https://forum.linuxcnc.org/forum/27-driver-boards/30453-mesa-5i25-7i77-first-steps

If you just want the quick version, I've got the internal hardware installed in the computer and power applied to the external board.  LEDs blink when commanded to do so.  I've hooked up one of the servo's encoders and it correctly shows 4000 counts per revolution as I manually turn the shaft.

I'm beginning to think about what to do with all the electronics and wiring when I'm done.  I'd like to put everything into a purchased or build enclosure and was thinking to maybe use DIN rails and various plastic widgets to help organize the wiring and connections.  There appears to be a dizzying selection of DIN components though and I have no idea where to start.  Is there something like "An Idiot's Guide to DIN Rails" somewhere?

Offline PK

  • Sr. Member
  • ****
  • Posts: 250
  • Country: au
Re: Motion Controller Design
« Reply #19 on: February 26, 2016, 12:38:48 AM »
We used a MESA 5i20 board for this:
<a href="http://www.youtube.com/watch?v=3g9bU17gxf4" target="_blank">http://www.youtube.com/watch?v=3g9bU17gxf4</a>

The black box has six PWM amplifiers that we built, a couple of stepper drives and some IO.
We've made a bit of progress with the Linux CNC setup since then, we can now teach it properly by just moving the arm and hitting a key.


Offline sparky961

  • Hero Member
  • *****
  • Posts: 764
  • Country: ca
Re: Motion Controller Design
« Reply #20 on: April 14, 2016, 10:25:02 PM »
A bit of a bump and status update to this thread....

The guys over at the LinuxCNC Forum have been instrumental in helping to get things up and running quickly.  I've been happily surprised by their willingness, patience and thoroughness to help out with what must sometimes be frustrating "noob" questions.

I've attached two pictures below showing the current state of things.  Don't laugh!  Well, ok... go ahead.  Every time I look at my cardboard box control panel I think of the magical adventures that were spawned by the arrival of a new kitchen appliance - or rather, the box it arrived in.

This is a prototyping stage, so it's all good.    I want to keep things neat and tidy enough to work on it without frustration, but without getting too wrapped up in organization, planning, and looks.

Current status is that I have a single axis machine (Rotary "A" axis) with working MPG/pendant.  Just this evening I wired up physical power and e-stop circuits and associated relays.  LinuxCNC is also aware of the status of the latter.

I have a lot more wiring to run for the remaining 3 axes, their limit switches (which I'm impatiently waiting to receive from China), and remaining buttons on the control panel.  After all 4 axes and the control panel works the way I want, I'll be transferring everything to a custom sheet metal enclosure.  I think that would complete what I previously referred to as STAGE 1.

Offline nrml

  • Full Member
  • ***
  • Posts: 162
  • Country: gb
Re: Motion Controller Design
« Reply #21 on: May 03, 2016, 09:07:24 AM »
How is your project coming along? I see that you have already committed to the MESA route. If you are still wavering, I was going to suggest developing a custom cape to run Linux CNC on a beagle bone black. I am supporting the Necitech kickstarter project. I would love to have a more capable version that supports encoder feedback. There is a little niche in the market there waiting to be filled.

Offline sparky961

  • Hero Member
  • *****
  • Posts: 764
  • Country: ca
Re: Motion Controller Design
« Reply #22 on: May 03, 2016, 10:50:44 PM »
My dealings with Mesa (the company) were less than optimal.  The email communication, though relatively quick, was also very short and not near as thorough as I'd have hoped.  When I did, nevertheless, decide to purchase this setup, the next few weeks were filled with repeatedly checking to see whether the boards were in stock.  As soon as I saw that they were, I placed an order through the web site.

If you aren't completely turned off already, you can rest easy knowing that there's another web site that seems to have much better stocking and (I assume) better service.  MesaUS.com seems to be the way to go.  Avoid MesaNET.org.  Just my $0.00 (due to nearest nickel rounding, my two cents are now worthless).

As for the project itself, it has been going well but stalled for a bit while I wait for one last essential component to arrive from China - the limit switches.  I have been holding off testing the X, Y, and Z axes because I want to make sure the limit switches are in place and working first.  This will avoid damage due to inadvertent runaway of the servos.  It has been very hard to stick to this self-imposed rule but I'd really beat myself up if I threw caution to the wind and did do some considerable damage.

As for the hardware itself, these boards are AMAZINGLY fast - at least compared to anything I've used, which is limited to the PC's parallel port and the latency-prone USB.  Aside from the very steep initial learning curve, I've been having a much better experience with this hardware than any stepper setup I've muddled with in the past.

As for your suggestion on other hardware, you may already know that LinuxCNC doesn't require very powerful hardware to run well.  I'm presently using an older PC, retired from service as my main computer quite a few years back.  It was a solidly built computer in its day and has no problem running LinuxCNC with very reasonable latency.  I have some thoughts of perhaps a single board computer or embedded whatnot in the future, but until I begin packaging things up the host "brain" is doing its job quite well.

Offline sparky961

  • Hero Member
  • *****
  • Posts: 764
  • Country: ca
Re: Motion Controller Design
« Reply #23 on: May 07, 2016, 11:04:20 PM »
A surprising amount of time has been spent thinking about mounting limit switches and wiring management. There's a lot more to go but now that my sensors finally arrived I spent a bit of time designing and building brackets for the Y axis. Attached photos and simple drawing. Sensor is M8 inductive proxy.

While at it I also drilled and tapped holes both for the sensors and "flags" that will actuate the X axis sensors later on.