Notifications
Clear all

Pi Pico Options for Emergency Stop & a SAFE Pause

5 Posts
2 Users
0 Likes
1,910 Views
 KevC
(@kevc)
Member
Joined: 3 years ago
Posts: 3
Topic starter  

Hi all,

I hope everyone’s doing well and our US members are having a good celebratory break.

I wonder if anyone can offer some reliable code for a Pico monitored CNC project I’m working on please. The main controls are fine including the stepper systems and reporting but I have a specific need for a reliable “pause” option for tweaking and an “emergency stop (ES)” in case the worst happens.

In my Arduino version I just flipped the state of the Reset to disable for ES and a push-switch operated loop for Pause. However both these options don’t give me much confidence as things have become more powerful and delicate in this more advanced machine.

1) ES reset option great but I can’t find any info on whether this is damaging to a pico or the stepper drivers now locked at the last action.

2) a state based “While” loop doesn’t fill me with confidence based on any possible electrical noise generated by the same event in 1. Especially as mine or someone else’s paws could be in the machine. A total shut down although safer could ruin an hour’s worth of work, so I’m hoping to find a fail-safe piece of Pause code.

Any code solutions greatly appreciated

Cheers

Kev

 


   
Quote
MadMisha
(@madmisha)
Member
Joined: 4 years ago
Posts: 340
 

Sounds like a job for an interrupt. For the ES, if you have an enable pin on the motor controller, you could set the interrupt function to toggle(the function) the enable pin. Most 3D printers(same concept) will not stop immediately, at least not consumer grade. Most will finish the last line of G code. If your controller has an enable pin, use it. That is the fastest way to stop it that I can think of offhand. Although running the enable pin directly through a well built E-stop would be better. I am referring to these(push-pull-twist). They are technically required in most workplaces in the US at least. Physically cutting the power would be the best.

As for pausing, an interrupt could be used as well. If you update a variable with your place in your code, you can then exit a while loop using a flag. I assume that you don't want to hold it in a while loop but if your code that is running the CNC is a while loop then exiting isn't that bad. I would not use the toggle on this because if the ES is pressed then it would restart. I assume there is a start button as well and that could trigger your function to reset it. If you successfully pause it then the ES could be pressed for extra safety. I mean that I never stick my hand in a machine unless the E-stop was pushed or powered off.

It might help to provide a little more info about the hardware and libraries you are using.


   
ReplyQuote
 KevC
(@kevc)
Member
Joined: 3 years ago
Posts: 3
Topic starter  

@madmisha many thanks for your reply. Taking out the delay in shutting down the steppers using the enable pins is definitely the way to go. Thank you for the pointer on that. Sometimes it’s a solution that’s just there in front of you but you need a prompt from someone else who’s been there before. I’ll get that modified tomorrow.

About the setup:

I’m using the Pi Pico to control two A4988 drivers feeding two NEMA 17’s (fed from a separate 9-12V supply), with a series of Hall Effect switches acting as both homing and limit devices. The only other switches are simple latching and non-latching units providing user inputs. The unit is pretty much a derivative of the setup in Bill’s “Homing & Limit Switch” presentation.

The Z unit rotates 360 degrees to move a piston in and out of the (soft) workpiece before enabling a variable step length of the Y unit. The X is currently dormant. The best way to visualise the operation is maybe to think of it as a sewing machine.


   
ReplyQuote
 KevC
(@kevc)
Member
Joined: 3 years ago
Posts: 3
Topic starter  

Forgot to include libraries, I’m currently only using “utime” and “machine” for delays and IO of the pins.


   
ReplyQuote
MadMisha
(@madmisha)
Member
Joined: 4 years ago
Posts: 340
 

@kevc

Ok, so seeing that you are using MicroPython makes a difference. I actually don't know if it has a toggle function but if it does, I wouldn't use it for the E-stop(I think I was wrong before). It could accidently make it live again. Hard coding a low would be better. You still need to consider if an accidental reset might send it high again(maybe make a function that sets it high that you can call only when you start or restart and probably a delay). A physical switch(like the proper one I mentioned above) to kill power on the motors is still much safer, relying on the enable is still a little sketchy. It could also pull double duty. Effectively stop the machine in an emergency and when the machine is paused you could hit it as an extra precaution so if it becomes un-paused it will not crush your hands. You could route the power of it to a pin(You might need to adjust the voltage on the way) and set that as a interrupt as well so your controller knows it stopped(and maybe log where as well).


   
ReplyQuote