Sensing stepper motor current as a sanity check?
-
I recall a thread where someone made the suggestion of using stepper motor current sensing to determine if the nozzle has bumped into something. For example, if the motor is being asked to move slowly, but current draw is high, it must have hit the bed.
I think the idea was largely abandoned because it was mentioned that such sensing could only be done on full steps and so the resolution wouldn't be sufficient. But, I'm wondering if there is some utility to this, even if it's not super-accurate (or if changes in the firmware or hardware could enable such sensing while microstepping), because none of these printers seem to have much in the way of safety features or sanity checks, and I thought perhaps this technique could help.
For example, I just broke my Prusa because one z motor was hooked up and, accidentally, one was not. So, one lead screw turned, the other did not, and the result was that the Z carriage did not move and the one turning leadscrew just ripped right through its plastic bracket.
Granted, in this example, I screwed up. But, it would be nice if the firmware knew to say "Wait a minute, you're missing a motor," or "Wait a minute, why is that motor drawing so much current when it was just asked to move down slowly?"
There are many use cases here: Missing motors, miswired motors, the tip hitting the bed, the tip hitting anything (e.g., the part being built when it gets dislodged from the bed), a wire or something getting caught in the works, any mechanical part on the printer breaking… Is there a reasonable way of addressing such issues, or will the solution have to be "Be careful"?
-
Almost impossible I'd say. In your example, even if you sensed motor current, what would happen if a pulley came loose just enough that the shaft didn't turn? The motor current might well be close to "normal" but you'd end up with the same problem. As you rightly point out, there are many things that can fail, electrically as well as mechanically (and of course, human error). If you tried to catch every eventuality, you'd have to plaster the machine with sensors, use some form of closed loop control and build in so much redundancy that it would cost a small fortune.
-
Let me phrase the question a bit differently: Is there some really low-hanging fruit where it might be possible to account for some (certainly not all) problems that aren't currently being accounted for, without adding much complexity or cost (maybe just code if the hardware can already take these readings)?
I agree that some kind of closed-loop system is needed to thoroughly address such issues, and I assume that's just not worth it (although laser diodes are pretty cheap – I wonder how much it would cost to add, e.g., interferometry-based metrology).
-
David chimed in on the Stallguard feature of the TMC driver to say it can sense the end of travel of an axis but only to 1 full step, so not really accurate enough.
Closed loop is again probably a case of - sounds good but does it really solve a problem? You can use cheap DC motors? But steppers are cheap now. You can correct for being out of position? But a well tuned printer doesn't skip steps. As Digital Dentist on reprap put it, having closed loop control of a printer might be useful if someone was going to grab a carriage and pull on it, but when is this really going to happen? It might be the way forward if you wanted to make a 3d printer super cheap, make it like an inkjet with linear encoders and cheapo motors.
As for sensing the bed I am quite convinced that the piezo sensor has it covered, its cheap, its accurate/repeatable and it works. Build the current signal conditioning board into the controller, with some sort of auto-setup to calibrate the piezo and you're about as close to perfect z-probing as you're going to get.
-
James
You are right to look for low hanging fruit as you say, it's what drives the improvements we have seen over the last few years. The various features of the TMC, such as stall guard may be used in the future to. llow for dynamically variable current. Only have the current high enough to achieve the torque required for the particular move. This would allow the stepper driver to run cool for some of the time and probably allow us to increase the maximum current, knowing it would only be at max part of the time.
-
David chimed in on the Stallguard feature of the TMC driver to say it can sense the end of travel of an axis but only to 1 full step, so not really accurate enough.
Closed loop is again probably a case of - sounds good but does it really solve a problem? You can use cheap DC motors? But steppers are cheap now. You can correct for being out of position? But a well tuned printer doesn't skip steps. As Digital Dentist on reprap put it, having closed loop control of a printer might be useful if someone was going to grab a carriage and pull on it, but when is this really going to happen? It might be the way forward if you wanted to make a 3d printer super cheap, make it like an inkjet with linear encoders and cheapo motors.
As for sensing the bed I am quite convinced that the piezo sensor has it covered, its cheap, its accurate/repeatable and it works. Build the current signal conditioning board into the controller, with some sort of auto-setup to calibrate the piezo and you're about as close to perfect z-probing as you're going to get.
I kind of have to disagree with the Digital Dentists assessment of closed loop control, although I do agree that it might be overkill and lead to excessive cost and complexity. As an ex automotive engineer, I'm thinking along the lines of how modern engine management systems work. With regard to fuelling the engine, the cpu calculates the fuel requirement based on engine speed, load, air temperature, coolant temperature and few other parameters but this might not be the optimum air/fuel ratio for the catalytic converter to work at it's most efficient. So there is a Lambda sensor in the exhaust that feeds back a signal to trim the fuelling to give the optimum air/fuel ratio for the catalytic converter- that's the closed loop bit. An analogy to 3d printers might be some sort of sensor that measures the actual amount of filament coming out of the nozzle which closes the loop by feeding back to the electronics, which would trim the extruder motor pulses. It'd be a kind of automatic compensation for variations in filament diameter and anything else that might affect the extrusion amount. I have no idea how this would be implemented in practice and as I have said, probably overkill in terms of cost and complexity. Another automotive example is ignition advance. The cpu calculates the optimum ignition advance setting similar to how it calculates the fuelling but there is a knock sensor on the engine block that detects detonation and retards the ignition should that occur. (Those of us who are old enough will remember the term "pinking" which was audible detonation or knock). This is another example of closed loop control used to compensate for variations in fuel Octane rating. It's probably possible to fit some sort of acceleration sensor to the hot end that would sense ringing or resonance and feed this back to the electronics to modify the acceleration or speed settings in a similar fashion. This is all theoretical conjecture of course and just my twopence worth….....
Ian -
Hi Ian. Not an automotive engineer but tinkered with a good few cars, lpg systems, ecu tuning so not against closed loop control as an idea. If you're talking closed loop control of actual extruded filament I'm all signed up, I just don't know how to do it.
But there is the issue of how fast you can trim it. If you underextrude for 0.5mm on an external perimeter you'll get a bit of a nasty line, do it for 20mm and it's a bust.
-
Hi Ian. Not an automotive engineer but tinkered with a good few cars, lpg systems, ecu tuning so not against closed loop control as an idea. If you're talking closed loop control of actual extruded filament I'm all signed up, I just don't know how to do it.
But there is the issue of how fast you can trim it. If you underextrude for 0.5mm on an external perimeter you'll get a bit of a nasty line, do it for 20mm and it's a bust.
Agreed. The biggest challenge would be how do you measure what is coming out in order to be able to compare it with what the "demand" was?
I do have another idea but this is way off topic and I apologise to James for hijacking his thread so I'll start another.
-
…...........
There are many use cases here: Missing motors, miswired motors, the tip hitting the bed, the tip hitting anything (e.g., the part being built when it gets dislodged from the bed), a wire or something getting caught in the works, any mechanical part on the printer breaking... Is there a reasonable way of addressing such issues, or will the solution have to be "Be careful"?In another place, nebbian came up with an idea to use a piezo disc connected to a stepper motor mounting to detect the load from nozzle contact http://forums.reprap.org/read.php?1,635075,756496#msg-756496 While I can think of several reasons why that may not work, it may answer precisely the question you have put .
Mike
-
Coincidentally, I just had another mishap that motor current sensing would have been useful for. I thought I had z_probe working, so I hit the button for delta auto-calibration. Apparently the z_probe sensor was not actually working and the nozzle proceeded to plunge into the bed – hard -- and keep right on going, scraping sideways until it fell off the edge of the bed.
These motors are pretty strong. Strong enough to damage the nozzle, the bed, the effector arms on a delta, maybe chew up the GT2 belts a little, etc. Given this, not having any kind of check for when the motor is obviously using too much current, over a pretty long distance or period of time, seems like a bad idea.
Can someone explain why full-step sensing isn't useful? For a Cartesian (forget about the fact that I'm using a delta, since I think the step to nozzle movement ratio differs depending on where the nozzle is), I believe that a full step, assuming a 16 tooth gear with 2mm pitch and a 1.8 degree motor, is 160 microns (0.16mm). Presumably with 0.9 degree motors, a full step would be 80 microns. Would it be useful to me to know if the nozzle hit something (hard!), even if I don't know it for up to 80-160 microns later? Yes!! Stopping less than a millimeter after impact is far less likely to break things than if the motors just keep on going.
Am I not understanding something about the TMC stall guard? Because if it can take a reading each full step and then cut power if the data doesn't make sense, I really, really think that feature should be taken advantage of, and my reading of the docs on StallGuard seem to indicate this is possible (see FAQ at https://www.motioncontrolshop.com/products/tmc-239-sa)).
-
StallGuard doesn't work at low speeds because then the back emf isn't big enough to measure reliably. You would have to probe at high speed for it to work.
Some time ago i added the M913 command so that you can temporarily reduce the motor current easily during homing or bed probing, and restore it again afterwards.
-
I don't know about stall guard and sensing motor current so I'll leave that to the experts. I'm guessing it's a case of sensing when is too much? It probably doesn't take much more current to do damage, than it takes does to move a (in my case) 7kg bed or 1.9kg Y axis assembly.
There are however a couple of things you can do though, to minimise damage (as well as the obvious "if in doubt have a hand hovering over the power switch when testing thing").
Firstly, you can reduce the motor current when homing. Find the lowest current where the motors start to skip under normal, slow speed, homing moves then set it a bit higher. For example, my motors are normally set to 1800mA but in the first line of my homing files I have M906 X400 Y400 Z1200 which sets X and Y to 400mA and Z to 1200 (it's a big heavy bed so Z needs to be at least this). So if an end stop fails, the motors will likely skip steps rather than mangle the frame. Of course, the last line of my homing files has M906 X1800 Y1800 Z1800 which puts them back to where they need to be for normal operation.
The other thing you may be able to do depending on your printer configuration, is have a back up end stop. Something like a micro switch set to trigger 1mm or so after the probe would normally have triggered. You can then wire this to a spare estop and the use M581 to trigger an emergency stop. It will limit damage to the first 1mm or so of excess travel.
I have normally closed micro switches on all of my axes maxima as well as "Z min-1mm" and all wired in series then connected to E0. So if any one of them is triggered, it'll initiate an emergency stop. That prevents damage if I do something stupid like try to send an axis beyond it's maximum travel before the machine has been homed (once it's homed, the maximum travel will be limited to whatever you set the maxima to in your config.g ).
HTH
Ian
Edit. Was typing te same time as DC. Just read his post - forgot that you can now use M913 to temporarily reduce the current.
-
Thanks for the suggestions. I did reduce the motor current through config.g, but obviously not enough.
If I was using a Cartesian, I'd definitely use backup endstops. This doesn't seem possible with a delta since there isn't actually one Z axis. I'm beginning to feel like deltas are more trouble than they are worth.
-
Deltas are more trouble, whether its more than they're worth is a matter of opinion, I think not but others may disagree. Certainly when people starting in 3d printing ask if they should start with a delta, I reply with "are you a patient person?".
-
Thanks for the suggestions. I did reduce the motor current through config.g, but obviously not enough.
…..................Leave the motor current in config.g - best to set it to about 80% of the motor rating. Just set it to a low value at the start of your homing files (and remember to set it back up at the end of the homing file).