End-stops vs Encoders

I am a newbie to CNC machines. I’ve read the Farmbot doesn’t ship with end-stops but that they are a common way to calibrate for accuracy on CNC machines. The Farmbot docs give the option of automatically calibrating with rotary encoders or DIY end-stops which some people have written about using on this forum.

I need my Farmbot to be very accurate i.e. to nearest mm and I expect I am going to need to automatically calibrate it often.

I read this post and kinda wanted to know more First Seeding, latest issues.

So I have the following questions which I think would be really helpful to others in the community, feel free to provide links as answers:

  1. Which is the best method for accurate automatic calibration encoders or end-stops and why? (A brief explanation of the pros and cons would be awesome)

  2. What end-stops are recommended and where to buy?

  3. What are the directions to install end-stops onto the Arduino RAMPS?

  4. How do I get the Farmbot software to recognise them i.e. do I need to do anything other than turn on “Enable Endstops” in the Web Apps Hardware Settings?

I have used (and seen used on professional CNC machines) these end-stops:-

They’re magnetic sensors, pretty sure they would be solid state so no moving parts to wear out. They’re sealed so suitable for operation in most environments. The receiver is normally open, so you just connect them to the RAMPS board as indicated somewhere in the documents, organised so that they switch to 5V when activated. Last time I tried them with the farmbot software they were detected reliably for homing, but not so in normal operation. But homing is when they should be used to get the best accuracy. The farmbot homing sequence isn’t as accurate as it could be, but you’ll need to make a feature request to get them to improve their homing sequence (or make the changes yourself).

Others may have alternative/better suggestions…

@Loveny: What is the distance versus triggering graph for those? I am thinking about the reaction time of the board if the motor drives into them very fast… If that is a bit different each time you try it because of the processing time of the board, this could be a problem?!

I looked them up and they’re not solid state, the receiver is a reed relay switch (given the price that makes sense). Distance vs triggering will vary from device to device, orientation of the magnets, and magnet strength. None of that is important for setting an accurate position, the only thing that is important is repeatability. I know from my experience that relays are surprisingly consistent in operation, so while they may have ~1ms operation time, whatever the time is will likely be the same every time, probably to within 5% or less.

I’m using mine for setting the home position, and the algorithm I use has the motor moving slowly at 50 steps/s, so that’s 20ms between steps. I’m sampling the input at 100kHz (every 10 microseconds), so I will detect the input and stop the motor at exactly the right position every time. The only question is the repeatability of the sensor switching. I have a commercial CNC machine here that uses the same sensors, and I’ve never noticed a repeatability problem with it.

There are plenty of ways to detect an accurate position, each with varying characteristics. I’d be interested to know what anyone else thinks would be a better method. It would be better to use a hall effect switch, but that requires power and then sealing. Or an optical slotted switch, but you’d have to keep it clean and clear of debris.

As for driving into them, that’s a control system problem… don’t move the gantry outside the set boundary. My maximum speed is something like 2000 steps/s, which is only 500 microseconds between steps, so my 100kHz sampling still far exceeds the step rate, so I’ll detect the sensor within 1 step. So to avoid hitting the sensor I just need to slow down fast enough. I’m getting >10mm clearance between the magnet and sensor, so I just have to slow down and stop within 10mm.

1 Like

Regarding optical sensors, I`ve got some experience, working in that field:
Laser Sensors: Forget about them in “real” sunlight conditions. None I reviewed would be accepting the outside ambient
sunlight “disturbance”.
Ultrasonic: Forget about it, if you´ve got wind floating across the thing will get mixed up.
Hall: Could work, why not? You would need to power them but that is not a problem. You could even very nicely set your “calibration” curve mm vs. voltage output…

Which A/D are you using? The one from the RAMPS? Why is that then a problem for the guys to sample that high? 100kHz are crazy to sample and way way way enough. Lets say at least 2 times the frequency you would need:
2000 steps / s equals 4 KHz to detect a step correct, right?

Looking forward into an interesting discussion @Loveny :wink:

The sampling rate is for generating the step frequency, not measuring it. The higher the sampling frequency the less jitter you get on the output frequency.

The encoders are read directly in the micro timer, no sampling required (other than that of the micro which is up around 50MHz). But if I were using an AVR then I’d certainly be trying to get the sampling rate up around 40kHz based on the measurements I made at the beginning. That’s certainly do-able but it would require moving the count maintenance out of the ISR (and everything else too), just do the sampling (and frequency generation). Alternatively, I’d consider moving the encoder signals onto external interrupt pins.

The end stops are sampled at 100kHz because that’s a convenient place to read them, and doesn’t involve anything other than to read the state and stop the motor if activated.

We use infra-red proximity sensors on the cricket bowling machines I design, they work fine in direct sunlight. We don’t need any position accuracy so I haven’t assessed their performance in that regard, I’d expect the magnetic ones to be better though. The infra-red sensors aren’t suitable for wet weather outdoor use, although because I’ve got my unit in a greenhouse I’ve fitted an analogue infra-red (10-150mm) sensor to the bottom of the seeder tool to measure how far away the soil is, so I can plant roughly at the correct depth.


I’d love to see your soil depth sensor explained in more detail in another topic :slight_smile:

1 Like

Do you have more information @Loveny?