Adding smarts to the MPCNC

Coolstep in particular. It should dynamically change the stepper current depending on load. I can not figure out how to tune it at all. In FluidNC we have toff_coolstep = 3 I can’t find anything about tuning it in the wiki, firmware, library(…or even the spec sheet (pg 60). All the setting are different in each one. I think I might do a guess and check on this tomorrow. Try a 2 and a 15 to see what happens. Similar stuff in Marlin.

I love the fact that this design includes an IMU. They say it is to sense vibrations or resonance, but I think it could be used on a CNC machine for much more. Like, optimizing acceleration and jerk dynamically. This is a great example of what I was hoping to see when I created this thread.

2 Likes

Vibrations and jerk issues are going to show up far larger from the interaction of the bit and the material more than the machine right? You can tune it in free air but that will only help with rapids.

1 Like

I think this could be one of the problems, with a lower pitch leadscrew, to achieve the same feed, the stepper have to turn faster, and this can reduce the torque and increase the risk of skipped steps

Would using thrust bearing plates, and/or top mounted the z-axis steppers help reduce friction/energy-loss due to weight pressing down on Stepper’s internal relatively small assembly?

Asking after seeing some printers use steppers with shafts long enough to be captured and resist lateral force from tensioned belts.

That’s a different axis/situation, but got me wondering whether some cheap mechanical weight/force support external to the Stepper could help the Stepper achieve more rotational force with the same power.

The internal bearings are rated for a pretty large thrust load.

1 Like

Hay all, it’s been a while. Happened to see this post and thought I would put my 2 cents worth.

Like others have said, your leadscrew seems like the biggest issue. Go back to the 4 start, and add a break(I have diy ideas for that if you want them) to keep from dropping the tool head when power is off.

If you insist on keeping your leadscrew, then upsize the z motor, or get a real servo (not a closed loop stepper, there is a difference) witch will maintain its torque even at high rpm.

As for smarts, using a camera for real time AI monitoring would require some pretty fancy hardware and some serious software. That said usi g a camera vision system to verify other things before milling is well within the range of possibility.
Where I work we use vision systems to ensure proper fuel/media mixture, temp, and all sorts of other things.
For the mpcnc I could see a camera checking for perpendicularity of the bit, as well as detecting any wobble. It could detect a derty or dull bit, and a bit that is not seated in far enough.

Other smarts ideas would be adding feedback checks on tool speed. In your story, you said you could hear the difference after it skipped… If you could hear the difference, then feedback from your router would be able to tell the difference as well.

On the topic of closed vs open systems, a lot depends on what loop your closing. If your closing a positional loop then it’s possible but, again, requires some impressive hardware. In industrial machines, every move is confirmed before exicuting the next. And every movement is monitored, if either is out of tolerance or it has taken longer then expected it puts the unit into a hold state. That’s the most useful thing about a closed loop system, but it’s not as useful when you don’t have industrial servos with internal accuracy down to 0.000064". Making it possible for It to know internally that it is off long before it’s off far enough to affect your final product. But any encoder on your mpcnc would at least be able to tell you when you have lost steps and stop(though I wouldn’t expect a very high rate of recovery).
Finding a way to close your tourque loop would be far more helpful on a router. It would keep you where you want to be rather then trying to get you back to where you should be. In order to do that on steppers I belive you would need to be able to control the live current to the drive, adjusting it on a predictive algorithm so you could over juice your drivers and motors to 110% of their rated maximum for the .5s that your jerking to give you the torque you need in that moment without melting down your steppers like Chernobyl. I think that the features Ryan mentioned earlier (such as cool step). Fallow this line of thought but unfortunately no one has seem to gotten them to work well.

Also for expanded functionality, how about adding a wire fed welder to the mpcnc and seeing if you can do metal printing?

Also I have noticed that linear bearings are becoming more affordable, I wounder if replacing the 608 bearings with something like this would make a difference.

uxcell SCS16UU Linear Ball Bearing Slide Block Units, 16mm Bore Dia(Pack of 4) https://a.co/d/gwG9GT6

Well that’s it for me, hope you found my mad raveings entertaining.
~Atom

2 Likes

How fancy, Pi5 good enough, or something more powerful needed? Been thinking about integrating Pi smarts, but not got very far…

1 Like

Was gearing up the Z drive with pulleys suggested? It’s not adding smarts per the original post, but something that I’ve considered. The you could have the Z-lead screw with non-back-driveable (is that even a word?) pitch without losing speed.

Of course it’s a bit silly to have 2mm pitch and then gear up 4:1 to be back at 8mm/rev. But Z dropping under it’s own weight can also be a pain.

all depends on what your trying to achieve exactly. real time analyzation of flame composition takes a PLC to interpret the images fast enough. as well as a high speed camera to capture images at a high enough sample rate. but i doubt you would need that level of precision. i feel like a Pi 5 would have the power to do at least some basic real time analytics, such as watching for wood damage (burning, chipping, ext.) i’m sure it would be able to monitor things like bit/tool slippage in real time. and probably many other things i haven’t thought about. the real hurdle to implementation I think would be coding, all the machine learning and vision software i know of is very expensive. but if your interested in it you should dive in and see what’s possible. this forum has shown me that with enough effort you can do almost anything you put your mind to.

1 Like

Back again with some additional thoughts,

i have been installing Klipper on my 3d printer and its calibration methodologies have given me some new ideas for closed loop steppers.
if you could feed skipped step status from the closed loop stepper, it would be possible to use that info to do some advanced calibration to find things like max speed, acel & jerk setting. and with some fancy programing could even be used in machine learning to help you build profiles for specific material types. so you could use them to be able to get the most out of the setup and hardware you have.

1 Like

Moving this here from another less appropriate thread.

I pointed to a couple of really inexpensive options, including the Broadcom aedr chipset family for optical reading and an off the shelf optical strip:

and I wound up ordering the first one, set into a small board, for $2.50 off AliExpress, and a similar strip for around $10/piece (actually bought a 3 pack of 1200mm for $28.50, but they go up 7000mm).

Steve noted:

I really wanted absolute positioning as well, but couldn’t find a good solution. Broadcom has an absolute positioning chipset (link below) but the signalling seemed more difficult and more importantly the absolute encoding tops out at only 52mm at 318lpi. Broadcom sells a tape strip double that length (a bit longer for 180lpi) but I didn’t see any option or availability of one long enough to be useful to us.

They also support what they call pseudo-absolute positioning in the AEDR line - I need to reread the docs to understand its limits, but it does let you use a second row in the grating at various binary multiples to create an absolute position window. Unfortunately I didn’t find any off-the-shelf tape that seemed to already be in that format, and there are places that will custom print the grating inexpensively in volume but small quantities are very steep.

Regarding the lines-per-inch, I ordered my samples at 180dpi, mostly because the Broadcom chips that support that resolution work at 5v while anything higher resolution was at 2.8 or 3.3v and I didn’t feel like adding another transformer for now. 318lpi is the highest I found for reflective sensors, though there may be other vendors. For transmissive sensors (where the light shines through the strip to the receiver) you can go up to 2000lpi but that seemed mechanically more difficult and delicate. I’ve been thinking about Y for now and assuming the strip would mount directly to the rail of a lowrider (out of the way of the rollers) or if it doesn’t like the curve on a piece of square steel tubing running parallel to the rail. The encoder wants to be about 1mm from the strip, so a small roller to keep it off the strip and a spring to keep it on the strip should be enough.

No idea how it likes the presence of wood dust. :slight_smile:

Will update when parts arrive and if I get a chance to play with them. I have a feeling it will take a while just to show something on a signal analyzer but maybe I’ll get lucky.

I am eager to hear how you get on with these linear encoders!
The FAGOR website you linked shows some exploded views in their videos emphasizing how well sealed their encoders are, against dust and cutting fluids. I imagine any optical sensor will be very sensitive to dust and must be covered pretty well.

The hard part, for me at least, would be programming the feedback loop. The closed-loop stepper controller I am using for my Z axis has that embedded in a DSP in the controller box. Who knows what all may be in that proprietary code. Is that something you can do/have done?

Agreed, I have no idea how well this will work. I saw the same thing, but on the other hand the main use for these is apparently in ink-jet and large format printers (which is why these strips are available), and from looking at some repair manuals there doesn’t seem to be anywhere near the same level of care.

Here’s a random video that came up first on youtube that shows how the encoder strip is mounted in a printer. I think it must be using a transmissive reader instead of reflective, but I’m also pretty sure the guy shouldn’t be putting fingerprints all over it the way he is and it seems to work out ok.

There’s also magnetic encoders but their resolution isn’t as good and they seem much more expensive. The other alternative is something called a draw-wire displacement pot, which is basically a sealed optical encoder and a wire wound around a spring. I’m shocked they work at all but apparently they are extremely accurate and would be super easy to integrate since they really only need to mount to the fixed side of our hardware.

I’ll order one of these for $25 from aliexpress to try out. Search for “CALT 1000mm Range Draw Wire Displacement Sensor Linear Rope Encoder” if that doesn’t come up. They have a model with absolute encoding as well if I’m reading the spec sheet correctly, just need to figure out how to get the right one.

I have done the PID loop thing before, in a few different ways. Open-coded in Simulink (though if I remember right we didn’t use the PID block and just manually built the layers), in C code (I didn’t write the original code but did become quite familiar with it), and eventually using an external hardware controller that did a pretty good job driving our motors based on an external positioning device. The basic loop is pretty easy, modeling and tuning is the fun part but also runs the risk of becoming highly specific to a given system.

I guess we probably need two loops, one for constant speed (travelling as fast as possible is probably not the best idea when actually cutting!) and one for position (limited by the speed of G0/G1 say). Or nested. Or possibly they’re the same loop, need to think about that for a bit.

I haven’t yet looked at how you integrated your z-axis control into the overall system, because that’s obviously a big change but you’ve got it solved somehow. :slight_smile:

Great info! I have sketches of an encoder like the draw wire in my ideas book – Glad to know they already exist and are pretty cheap! Be sure to post a follow up when you have tried yours.

My closed-loop Z stepper was just plug and play: it takes step pulses as input, like any stepper controller, and from that figures out where you want to be and makes sure you get there. If it can’t, it throws a position error alarm and unpowers the stepper motor. I have the alarm trigger a Door Open alarm in grbl, pulling up the spindle and braking its rotation.

In my reel encoder brainstorming, I imagined three of them with their ends mounted to the spindle, since what we care about is where the cutter is, not where the trucks or other components are. Those may be at some distance from the cutter, with lots of potential for flexing in between. Doable?

The $25 version was analog output, which confuses me greatly. The absolute encoder version was going to require me to talk to someone, so I wound up ordering the $80 CESI-S1000E variant which has incremental encoding and TTL, and was in-stock at Amazon by the same people that were going to ship it from China on AliExpress at the same price. I’m on vacation in any case (currently in Lyon, which has been lovely, what a great city) but this way it will probably beat me home…

That’s a good point. For the X axis (and again I’m thinking of this in the context of the lowrider which is what I know) it would seem easy to mount one to the fixed XY panel and straight to the spindle. For the Y axis I was imagining tracking the position on the rail but I hadn’t really thought about flex.

One option would be to put a pulley on the rail and then route the wire along X to the spindle, though I’d need to think through the geometry because I’m not at all convinced that helps identify the actual flex.

The crazy option would be to just draw a wire straight from a fixed point to the spindle, and use trigonometry and the known X position to solve for Y. This actually has a huge advantage that you can pretty much stop caring about flex in the lowrider and just solve it in software. It has a huge disadvantage that it seems insane.

Dumping a few thoughts about somewhat expensive but out-of-the-box solutions just so they’re written down somewhere.

Apparently LinuxCNC can handle exactly this setup - motor with rotary encoder plus auxiliary linear encoder. Typically with an add-on board like this one :slight_smile:

https://store.mesanet.com/index.php?route=product/product&path=69_62&product_id=383

When I mentioned I had worked with an external controller in the past, it was from a-m-c.com. Something like the board below supports both an on-motor rotary encoder as well as an auxiliary external encoder, and their software is great for tuning the loops to get exactly the curves you want. Guessing around $250-$450 / board though.

I clicked around a bit without thinking too hard about parameters, but here’s an example (this one is serial comms, I had worked with their canbus boards in the past):

Your comment made me think a bit more about the difference between direct brushless motors, servos, and steppers. I’d worked with the first two but hadn’t really appreciated the strength of steppers for things like CNC where easy constant speed control is more important than fastest or smoothest motion, and the precision is locked in to the mechanism of motor motion.

That said, there’s clearly still room to push either speed (at least in non-cutting motions) or accuracy, as you’ve already demonstrated on your z-axis. Bart Dring also mentioned an interesting use-case in a github thread - being able to manually position the cutting head to a given location and have it pick up seamlessly from there because it tracked position.

As mentioned I’ve gone ahead and ordered a variety of motors (including a couple of closed-loop steppers like you used) and encoders to play with, including the draw string one. LinuxCNC was the only open-source platform I found that directly supports external encoders, but only does so with an external card from Mesa and I wasn’t ready to open that door yet to a full platform switch. I did however get one of these as an experiment:

The interesting thing about this guy is that if I’m reading it right it takes the encoder feedback in from a separate wire. Normally you would wire that to its own built-in encoder or I guess an add-on rotary encoder of some sort. But I figured it was worth the experiment of trying to connect it to a linear encoder with the same resolution and see what happens. I think it would have to connect to the truck and not my crazy trigonometry idea (for that we’d need something in the middle that aggressively lied about measurement) but it might still wind up being a good experiment. Equally possible I’m misunderstanding what it does. Worst case I’ve got a cool dev motor.

Will take a bit for various parts to come in and finding time to play with them, will update if any of the experiments pay off…

3 Likes

Hi @Hillsdale Joel, Got your DM and saw your vid testing the string encoder. YES please get a proper workbench! I would hate to see your keyboard get ruined by a blob of solder falling between the keys :slight_smile:

Looks like you are making great progress, and using the ESP32 and its encoder pulse counter is the right approach.

I am eager to see what you devise to get truer motion!

1 Like