HAL component for DC motor runaway protection
- jpa
- Offline
- New Member
Less
More
- Posts: 14
- Thank you received: 10
06 Jun 2022 08:17 #244656
by jpa
HAL component for DC motor runaway protection was created by jpa
With DC motor servo setups, there is a known risk of runaway conditions if the feedback encoder cable gets disconnected or the encoder malfunctions. If the machine is stationary when this happens, the feedback malfunction can show 1-2 encoder ticks of position error to LinuxCNC, which is too small to trigger following error. The PID integrator will try to compensate the error, causing the axis to slowly accelerate towards one end until it crashes.
I had a near-miss with this when messing with the cabling with machine powered on (I know, stupid..). Fortunately quick e-stop press avoided a crash this time. To protect against any future cabling or encoder faults, I made this little HAL component.
Parameters:
Pins:
The basic idea is that once the PID output is high enough, the motor should start moving. If the component doesn't see movement in encoder feedback within given time, it can be used to trigger emergency stop. Small movements that are below feedback_threshold are expected to occur within time_threshold seconds, after which PID output will return below the threshold. Larger movements will reset the timer every time a feedback_threshold worth of movement is detected since the last reset.
There is example of using this component in a full configuration here:
github.com/HacklabJKL/sergei_cnc2/commit...636d14fa01c15c82e95c
I had a near-miss with this when messing with the cabling with machine powered on (I know, stupid..). Fortunately quick e-stop press avoided a crash this time. To protect against any future cabling or encoder faults, I made this little HAL component.
Parameters:
- control_threshold: Movement is expected to occur if absolute value of control exceeds this threshold.
- feedback_threshold: Encoder is considered to work correctly if the changes in feedback exceed this threshold.
- time_threshold: Time delay to account for motor inertia.
Pins:
- input control: The output from PID controller
- input feedback: The feedback input to PID controller
- output out: Goes high if runaway is detected
The basic idea is that once the PID output is high enough, the motor should start moving. If the component doesn't see movement in encoder feedback within given time, it can be used to trigger emergency stop. Small movements that are below feedback_threshold are expected to occur within time_threshold seconds, after which PID output will return below the threshold. Larger movements will reset the timer every time a feedback_threshold worth of movement is detected since the last reset.
There is example of using this component in a full configuration here:
github.com/HacklabJKL/sergei_cnc2/commit...636d14fa01c15c82e95c
The following user(s) said Thank You: tommylight, COFHAL
Please Log in or Create an account to join the conversation.
- tommylight
- Offline
- Moderator
Less
More
- Posts: 19409
- Thank you received: 6507
06 Jun 2022 13:53 #244667
by tommylight
Replied by tommylight on topic HAL component for DC motor runaway protection
Nice, thank you.
Luckily, i had failed encoders but never a run away, still this issue wanders often through my mind.
Installing extreme limit switches is one way of dealing with it, so far i used this, it cuts the power to ser vo drives in case they are triggered.
Luckily, i had failed encoders but never a run away, still this issue wanders often through my mind.
Installing extreme limit switches is one way of dealing with it, so far i used this, it cuts the power to ser vo drives in case they are triggered.
Please Log in or Create an account to join the conversation.
- andypugh
- Offline
- Moderator
Less
More
- Posts: 23560
- Thank you received: 4858
10 Jun 2022 00:12 #244836
by andypugh
Replied by andypugh on topic HAL component for DC motor runaway protection
Do you want to add this to the linuxcnc HAL modules?
Please Log in or Create an account to join the conversation.
- jpa
- Offline
- New Member
Less
More
- Posts: 14
- Thank you received: 10
11 Jun 2022 18:30 #244947
by jpa
Replied by jpa on topic HAL component for DC motor runaway protection
Hi,
Yeah, it could be nice to have this part of the main distribution.
Though it might make sense to let this "bake" bit first, I'm still building my CNC machine so haven't done very much practical testing yet.
Today when testing I did notice a small bug with negative movements , fixed in the attached version.
Yeah, it could be nice to have this part of the main distribution.
Though it might make sense to let this "bake" bit first, I'm still building my CNC machine so haven't done very much practical testing yet.
Today when testing I did notice a small bug with negative movements , fixed in the attached version.
The following user(s) said Thank You: itsme
Please Log in or Create an account to join the conversation.
- andypugh
- Offline
- Moderator
Less
More
- Posts: 23560
- Thank you received: 4858
15 Jun 2022 10:14 #245174
by andypugh
Replied by andypugh on topic HAL component for DC motor runaway protection
Feel free to create a pull request on github when you are more confident in its reliability.
Please Log in or Create an account to join the conversation.
- vre
- Offline
- Platinum Member
Less
More
- Posts: 529
- Thank you received: 16
10 Apr 2024 18:40 #297946
by vre
Replied by vre on topic HAL component for DC motor runaway protection
I have done a test without limit switches
and a failed linear scale resulted in a crash.
Ferror was 3/20mm but this didn't worked.
Ferror protects when encoder does not work
or works unreliable ?
Machine was a mill with analog speed servos
without encoders and position feedback send to linuxcnc by linear scales.
Can use this component to protect from this type runaway ?
and a failed linear scale resulted in a crash.
Ferror was 3/20mm but this didn't worked.
Ferror protects when encoder does not work
or works unreliable ?
Machine was a mill with analog speed servos
without encoders and position feedback send to linuxcnc by linear scales.
Can use this component to protect from this type runaway ?
Please Log in or Create an account to join the conversation.
- PCW
- Away
- Moderator
Less
More
- Posts: 17904
- Thank you received: 4774
10 Apr 2024 19:36 - 10 Apr 2024 19:38 #297949
by PCW
Replied by PCW on topic HAL component for DC motor runaway protection
During motion you would get a following error if the encoder stops counting
since at some point the commanded position would differ enough from the
feedback position to cause a following error.
If stopped, a bad encoder can cause a runaway. One way to address this
failure mode is to
1. Have some integral term so a small error will eventually saturate the system
2. check either pid.N.saturated (a bit) or pid.N.saturated-s (a float) to
check if the PID loop is saturated. A possible refinement here is to set
the PID maxoutput to a function of the commanded velocity.
2A. The previous check does require the error build up to full output before
the error is detected so a faster response would be to check pid.n.errorI
(by comparing it to a limit) Normally you would not expect the integral error to
build up to a large value if encoder feedback is working (note you need to
have "debug=1" on the PID loadrt line ti make the errorI parameters appear)
since at some point the commanded position would differ enough from the
feedback position to cause a following error.
If stopped, a bad encoder can cause a runaway. One way to address this
failure mode is to
1. Have some integral term so a small error will eventually saturate the system
2. check either pid.N.saturated (a bit) or pid.N.saturated-s (a float) to
check if the PID loop is saturated. A possible refinement here is to set
the PID maxoutput to a function of the commanded velocity.
2A. The previous check does require the error build up to full output before
the error is detected so a faster response would be to check pid.n.errorI
(by comparing it to a limit) Normally you would not expect the integral error to
build up to a large value if encoder feedback is working (note you need to
have "debug=1" on the PID loadrt line ti make the errorI parameters appear)
Last edit: 10 Apr 2024 19:38 by PCW.
Please Log in or Create an account to join the conversation.
Time to create page: 0.089 seconds