Adding smarts to the MPCNC

Related, another thought I had mentioned once before in relation to smart tools, is mounting a load cell and continuously monitoring the forces. This may make it unnecessary to detect missed steps since you could (theoretically) back off the feed rate to keep the forces within limits.

If you have a high speed collision where you can’t prevent missed steps in real time, then you could still know that the forces spiked and you might have missed steps. Maybe you can home again and proceed.

6 Likes

That statement is gold my friend! There’s a crucial difference. Put it another way.

Imagine a front loader driving its bucket back and forth to level some ground. Nowadays they can use lasers and a receiver mounted on the bucket to automatically raise and lower it to keep it steady. That is a feedback loop based on the measurement of a machine position.

However the operator also eyeballs the ground and stops once it looks good enough. This is a feedback loop based off of a measurement of the workpiece.

One common method is back EMF waveform measurement aka stall detection. The same method used for “sensorless” homing. TMC drivers and clones can already do that. It tends to be a bit finicky to tune but Prusa printers ship with somethig called “crash detection” enabled for X/Y by default. To recover the printer stops, raises the head by a fixed amount, re-homes x/y and continues. I think Marlin even has these features built-in nowadays, but I haven’t checked. Not exactly sure how one would recover from a missed step on Z. This may be possible if there’s an end-stop at Z+ and a touch-plate at a fixed location that will never be covered with a workpiece.

3 Likes

Apologies if you have a different machine now, but I recall you built an MPCNC, So one with a single Z motor?

Based off of that, a few idea^H^H^H^Hspeculations that may be usef^H^H^Hamusing.

  1. I disagree with @vicious1 about motor speed. You’re running at 40V so unless something is wrong with the drivers and they don’t actually get that 40V to push to steppers, it’s not very likely that shaft speed is the issue. Torque loss at higher RPMs is mostly driven by increased back EMF voltage and this is fairly well mitigated by the use of higher supply voltages.
  2. If you switched to a lower-pitch lead-screw did you also lower the microstepping factor for Z? E.g. went from 1/32 to 1/16 or even to 1/8? If not, it may be that you are hitting the pulse rate limit of the driver or control board, or the higher frequency signal degrades more in the wires ( I recall you used external stepper drivers, again apologies if your machine has seen revisions since I last read about it).
  3. Have you thought about balancing the weight of the spindle with a spring or something so the stepper doesn’t need to work as hard to lift it? Given the gauges I speculate that the machine loses more steps in “up” direction so balancing the Z may help.
  4. The closed-loop S42[A,B,C] board just on the Z should not be underestimated here. They do offer an advantage that they try to “return” to the desired position even if the motor is temporarily overloaded. That will come at an expense of carving accuracy but at least it will not gauge the workpiece too bad. I have a few collecting dust in a drawer, never thorouhgly tested them though.

Have fun.

2 Likes

I also recall this being discussed. Accurately measuring, predicting and compensating for cutting forces is an active research area in CNC industry.
Here’s a fairly recent (from 2020) meta research paper that summarizes what’s being done and they use all kinds of load-cells, dynamometers, strain gauges etc. The small ones are getting cheap so why not.

1 Like

This is some great discussion that I probably should have broken into several different threads.
Jamie and others, keep posting your Big Picture thoughts about the philosophy and approaches to improving performance and accuracy!

I LOVE the idea of putting load cells or other means for sensing strain here and there, to prevent damage to tools and workpieces. That is how humans do carving, routing, and other tasks with very good closed-loop control using our proprioception. Then we use our eyes and feel with our fingertips how we are doing, for refinement of the workpiece. Using back EMF or more sophisticated fast current sensing should be helpful here, perhaps only requiring new firmware, not hardware.

About solving my skipped Z steps problem, I really appreciate all of your suggestions. Thanks, Anttix! I am indeed using 40V and 4 microsteps on the Z. I think Jeffeb’s comment about some drivers reducing the current when overheated (rather than stopping and/or throwing an error) may be relevant for the TB6600 driver I am using. I have ordered a more powerful fan to keep the steppers in my “cooling tower” cooler. It was an unusually warm day (27C) in Ireland the day I was having the problem with lost Z steps.

I have missed Z steps in both the up and down directions. That suggests that it is the inertia of the spindle, not its weight, that is the problem. I have considered adding a spring to help lift the heavy Z assembly but that would make losing steps in the down direction worse. I have been using an acceleration of 250mm/sec^2 in Z, so one thing I will try next is to go to a lower number, say 100mm/sec^2. Also, I may try going to only 1/1 (no microsteps) or 1/2 microsteps instead of 1/4. That should still give me (with my 2mm/rev leadscrew) a precision of 10um or 5um, respectively, which is plenty for me.

I don’t think I am near the frequency limits with my current setting of 4 microsteps. The TB6600 driver can work up to about 130kHz according to This Youtuber . The Teensy should be able to output hundreds of kHz. Phil Barrett has a good analysis of the Teensy speed for CNC here. I am set to the recommended (for TB6600) pulse width of 5us, so that limits me to 100kHz pulse frequency, I think, assuming 50% duty cycle.

I have a closed-loop stepper on order for my Z axis that is a bit more powerful than the one that came with the Primo kit (0.65 N-m) and comes with a driver that says it can do 200Khz steps. I was discouraged from trying the cheaper S42B on reading experiences of others here.

The issue of what to do in response to missed steps (or a phase advance alarm in the case of a closed loop stepper controller) is very complicated. The goals for carving are to not break bits or destroy the workpiece, and to not burn the workpiece and start a fire by just stopping feed and not the spindle. Bonus for being able to gracefully continue carving autonomously with minimal imperfections. Throwing a DOOR OPEN alarm (0x84) would seem a good thing to do, followed by a manual resume of the job. I have grbl set to raise the spindle and brake it in 1sec upon DOOR OPEN. It is what I use for my Emergency Stop button. I am glad to hear that this missed steps problem has been “solved” in Marlin for the 3D printing world. I will look into that.

I would not worry about frequencies at 1/4 microstepping. For any kind of an overload condition (too much weight, too much acceleration etc), I’d expect step loss of an unbalanced Z to be vastly biased towards Z+ e.g. the weight of the spindle will make it more likely for overload to happen when working against gravity. So if you are indeed losing steps in both directions then an electronics problem such as overheating drivers or maybe a loose wire become more likely.

EDIT: Here we go, TB6600HG datasheet confirms that this driver chip is similar to DRV8825 in a sense that it features a “Thermal Shutdown Circuit”. What that means is that the chip just shuts down for a while when overheated.
EDIT2: It should raise the “alert” pin while it is in thermal shutdown so it may be wise to attempt to monitor the states of these pins/LEDs

1 Like

Thanks, Anttix.

It turns out that these “TB6600” stepper drivers actually have the next best chip installed:
Toshiba TB67S109. Here is the datasheet.

But your same comments apply to this chip.
The stepper controller has an alarm LED so I can tap into that line without much difficulty.
But I see the overtemp threshold is very high (160C) and I work from 40-55C (measured by a DS18B20 temp sensor glued to the other side of the PCB under the chip) so I don’t think overtemp will ever be used unless there is a serious problem.
Loose wires is a possibility I will check out. I am using aircraft (screw on) connectors so I think it is unlikely but a solder connection may have broken.

I am leaning towards acceleration and the inertia of the spindle as the problem, because all of the skips happened on the steepest terrain (fastest Z commands), and there were more skips moving up than down. I will do more tests and report back here!

2 Likes

That is usually as measured directly on the die (junction). Case temp can be a lot lower than that and PCB temp even lower. In short I would not be surprised of die temps rising to over 160C in 50C ambient, but again this is speculation, if it is easy then wiring up the alerts is a good way to be sure.

I know the max step rate is usually pretty easy to calculate on most boards, has anyone seen a really good info on max possible RPM of these steppers? All the torque curves I have seen move slightly to the right with Higher voltages but they are not usually super drastic. There has to be a very clear limit at some point.

This could very easily be getting close to both limits.

(the Ramps board’s step rate maxed out at 400steps/mm @32nd stepping 15mm/s running Marlin)

1 Like

Clough42 has some good comparisons and testing of various steppers (closed-loop) at speeds up to 3000 RPM, with curves of torque. He is using them to drive the leadscrew of a lathe, but his analysis is sound.

3 Likes

Manufacturer provided torque/speed curves are often slightly misleading because many are given for “rated” voltage. That is the voltage that can be directly applied to windings w/o any current limiting. With drivers, steppers usually run at much higher voltages so rated voltage graphs are not super relevant. E.g. 17HS19-2004S1 has winding resistance of 1.4 ohm and rated current of 2A which would give us a rated voltage of a whopping 2.8V.

RepRap Firmware’s EMF calculator is the easiest way to compute the effect of supply voltage, I can’t recommend it enough. It will tell you what voltage is needed for what speed. It even has a preset for 17HS19-2004S :slight_smile:

So given this stepper, max current (2A) and the standard lead screws we use on MPCNC, RepRap calculator claims the torque “starts to drop” at

  • 28mm/s @ 12V
  • 59mm/sec @ 24V
  • 100mm/sec @ 40V

Pretty steep differences I’d say.

Probably the best article I’ve seen so far that takes a shot at explaining the theory of elevated voltage is this one from servotecnica. The key takeway from a graph in that article is that even a fairly modest increase from 24V to 35V can significantly “flatten” the curve.

Ok, this is theory, what about actual measurements?

This guy reports torque increase of almost 40% at 500rpm by increasing voltage from 24V to 50V. This of-course applies to his specific steppers.

I also took another look at manuf. information and I’m glad that some vendors are starting to publish torque curves at higher voltages. Specifically our beloved Stepper Online’s 17HS19-2004S1 has published a torque curve at 24V assuming a current limiting (chopping) driver of-course.

This is great because it tells us that given a 24V supply, the motor will not lose much torque all the way to 450 rpm. Given I calculated this correctly, it should be about 60 mm/sec for Z given the “standard” lead screws we use on MPCNCs - exactly as the RRF calculator predicts.

Being able to refer to this graph may be considered an excuse to upgrade to 24V :smiley:

I also recall the original author of “smart stepper” boards (the design that S42 family is based on) mr. MisfitTech claiming speeds of around 700rpm.

So where are the limits? Well, mechanical limits aside, windings will be ruined if driven over their dielectric strength which is usually around 500V. However stepper drivers and control boards that can do voltages higher than 42V are not that common and truth to be told, I’d be very uncomfortable with driving my steppers at more than 50V anyway, the wires are just not insulated well enough.

EDIT: Re-ran RRF calculator at 2A to make results comparable to manuf. published curve at 2A

2 Likes

Love it! Never seen that before.

I finally have some sample coming…I might have found some for the same price as the 12v, hopefully they are as stable.

Hard limit 500V! 48v starts to make me pay attention. For now The Rambo is keeping us at 24v max.

Thanks, Anttix, for those excellent resources!
And for your useful analysis! Yes, higher voltage (40V) gave me a big practical improvement.
Take home for me:
Because I am using a non-standard 1-start (2mm/rev) leadscrew, I am pushing to 4x higher RPM and suffering the torque losses that come with that. But it takes less torque to move this finer pitch leadscrew, so it is complicated. I wonder if there is an easy way to convert motor current to torque for a Smarter stepper analysis and control.

I will be delighted when I can move a heavy spindle in Z as fast as I can carve hardwood in X and Y which is around 80mm/sec, limited by machine flex.

I have a new stepper motor to test and another on the way, so I will start a stepper motor thread soon with some results from practical tests of those vs. my V1 Engineering kit’s KL17H248-15-4A.

1 Like

It takes less torque to get the same push force. But friction loss is the same or more. It is complicated.

The 1 start needs 4x as many RPM, but lifts the router with 4x the force per torque.

The leadscrew friction is still proportional to the weight of the Z axis. And I would guess a 4 start has less friction, because the weight of the Z axis is more in the same direction as the angle of the leadscrew ramps. That is why the 1 start leadscrews don’t drop the low rider gantry when the motors are disabled.

So if you swapped for a 1-start and then added a 4x heavier router, you would need more torque, at higher RPMs. With a 2x router, you would have at least twice the friction (compared to stock) but the raw lifting force would be half. IDK what the crossover point would be.

Can’t wait!

Realtime plasma torch height control seems like a good example.

Admittedly I’ve only skimmed the thread, but at the risk of being “that linuxcnc guy”, I cant help but think that linuxcnc might be worth considering for your smart projects. You’d have the full power of a PC and ease of use of python and it’s libraries at your finger tips to control your machine…

(Edit) forgot that python modules for linuxcnc don’t run on the realtime thread, you’d have to compile c code for the timing critical stuff.

1 Like

Was tempted to post in the Neat! topic, but maybe more discussion/action will happen about https://creapunk.com/ here and/or on creapunk’s discord server

2 Likes

Liking and following in the hope that I’ll learn what all that actually means in the ensuing discussion!

Shoot I think TMC’s stallguard and coolstep are nearly everything we need to turn up the power under load and turn it down when there is not. That lets you probably get twice as much out of a stepper when it really matters without adding a ton of heat all the time. They just don’t seem to deliver what they promise. Closed loop seems like you have bigger problems if you get to that point.

1 Like

Clarification on your statement:

Could you be more specific? It doesn’t work? It isn’t open source? It is too complicated?