Endstops
There are only a few machines that don't need endstops. Endstops are
normally used for homing. They should be placed at the end of each
motor joint.
Endstops are used to determine zero the 'machine offset' of the machine.
All offsets (like work offsets) are normally calculated from the machine
offset. If you encounter a crash or power loss, to get back to the same
position, you should re-home and use the new machine offset.
Homing
Homing is the process of moving the machine to a known location. You
usually want to home the machine once, and then use soft limits to
prevent crashes.
Always test homing by homing one axis at a time, at a reasonable speed.
You need to keep in mind that homing requires a deceleration when it
hits the endstop, so you should not home at a speed that is too high
(or risk destroying the endstop). You can do some basic calculations
on the distance that will be travelled after the endstop is hit:
x = v_0 * t + 1/2 * a * t ^2
v_t = v_0 + a * t
v_t = 0
t = (v_t - v_0) / a = -v_0 / a
x = v_0 * (-v_0 / a) + (1/2) * a * (-v_0 / a) ^2
x = - (v_0 ^2) / (2 * a)
where is the homing velocity and is the max acceleration and
is the travel distance after hitting the endstop.
Wiring
Wire endstops to the input terminals of the board. The input terminals
are isolated and opto-coupled, and can handle 5v endstops.
Do not wire any 5v terminal to the isolated 5v terminal of the inputs,
and do not wire the GND of the inputs to any other GND. This will
void the isolated output and can cause damage.
|
x |
y |
z |
a |
b |
c |
stop |
probe |
input |
gpio.41 |
gpio.40 |
gpio.39 |
gpio.38 |
gpio.18 |
gpio.48 |
gpio.16 |
gpio.17 |
Configuration
The configuration of endstops is per motor. Depending on NPN or PNP, you
need to invert the input using :low
. Most setups use only a single endstop.
x:
steps_per_mm: 800
max_rate_mm_per_min: 1500
acceleration_mm_per_sec2: 100
homing:
cycle: 1
mpos_mm: 0
positive_direction: false
seek_mm_per_min: 1500
feed_mm_per_min: 700
motor0:
limit_neg_pin: gpio.41:low
limit_pos_pin: NO_PIN
limit_all_pin: NO_PIN
hard_limits: true
pulloff_mm: 2
Using endstops for safety
Endstops can be used for safety under certain conditions.
The first condition is that your maximum speed is lower than the above
travel distance. If not, you risk destroying the endstop (which is probably
better than destroying the machine).
The second condition is that no metal swarf or coolant can get into the
endstop. While this is always a good idea, it will probably trigger an
alarm or yield undefined behavior when you least expect it.
When you are running closed loop steppers, soft limits should keep the
machine boundaries in check. If you are running open loop steppers,
using endstops for safety is generally a good idea, to have an extra
safety net for the case when a step is lost.
If you want to protect both positive and negative sides of the axis,
you can wire NPN endstops in series, and PNP endstops in parallel.
Make sure to use 5v endstops, and always wire them on the input terminals.
Calibrating velocity and acceleration
Endstops can also be used to determine the maximum velocity and acceleration
of the machine. This is done by moving the machine at a given velocity and
acceleration, and checking if it re-homes to the same location. If it
doesn't, steps have probably been lost.
Testing maximum velocity and acceleration is done by running a test
program. Basically the test program just does a series of moves, like:
G92 X0 Y0 Z0
G0 X100 # Move to the end of your axis (100mm) at max speed
G1 X0 F500 # Move back to 0mm at a slow pace
G0 X100 # Move to the end of your axis (100mm) at max speed
G1 X0 F500 # Move back to 0mm at a slow pace
G0 X100 # Move to the end of your axis (100mm) at max speed
G1 X0 F500 # Move back to 0mm at a slow pace
G0 X100 # Move to the end of your axis (100mm) at max speed
G1 X0 F500 # Move back to 0mm at a slow pace
# You are now back at X=0. Re-home your x-axis.
If the machine doesn't re-home to the same location, you should lower the
velocity and/or acceleration. Once you found the maximum values, use a
safe margin, like 75% of the found values.