element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Sci Fi Your Pi
  • Challenges & Projects
  • Design Challenges
  • Sci Fi Your Pi
  • More
  • Cancel
Sci Fi Your Pi
Blog Sci Fi Your Pi: PiDesk - Guide: Endstops with Gertbot
  • Blog
  • Forum
  • Documents
  • Files
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: fvan
  • Date Created: 30 Jul 2015 7:33 PM Date Created
  • Views 699 views
  • Likes 6 likes
  • Comments 0 comments
  • design_challenge
  • touch_motion_controls
  • touch_motion_control
  • sci_fi_your_pi
Related
Recommended

Sci Fi Your Pi: PiDesk - Guide: Endstops with Gertbot

fvan
fvan
30 Jul 2015

  • Introduction
  • Gertbot
    • Pins
    • Modes
    • Code
    • Demo
  • Conclusion

 

Introduction

image

 

In a previous guide, I covered how to control stepper motors using Gertbot. For this post, I'd like to cover the built-in endstop functionality.

 

Endstops (also know as "limit switches") can be very useful to stop motors when an end position has been reached. This is for example the case with 3D printers or CNC milling machines where the motors controlling each axis, back up until the endstops are triggered. This defines a reference point, also called "home position" with coordinates 0,0,0.

 

There are different types of endstops, just to name a few:

  • mechanical: an ordinary switch makes or cuts a connection when triggered
  • magnetic: a hall-effect sensor is used to measure the magnetic field
  • optical: a sensor reacts to sudden changes in light levels

 

For this guide, I'll be using mechanical endstops, such as the one on the right.

 

Gertbot

 

The Gertbot add-on board for the Raspberry Pi offers the possibility to activate endstops, which when triggered, will automatically stop the associated motors without having to code any additional functions.

 

Pins

 

Four pairs of endstops can be defined: one pair per motor channel, covering two extremities. Seen from the top of the Gertbot, the endstop pairs are positioned as such:

image

 

The endstop pins are connected to 3.3V using a 4.7kOhm pull-up resistor.

 

Modes

 

The endstops can be configured in three different modes:

  • OFF (0): don't enable the endstops
  • ENDSTOP_LOW (1): enable endstop, stop motor channel when switch to GND is closed and pin is LOW
  • ENDSTOP_HIGH (2): enable endstop, stop motor channel when switch to GND is open and pin is HIGH

 

When using endstops, the safest option is to use the ENDSTOP_HIGH mode, as a broken endstop wire would result in the motor channel to be disabled, ensuring the safest state.

 

Code

 

Activating endstops for a single motor channel is straightforward:

 

// gb.set_endstop(BOARD, CHANNEL, ENDSTOP_A_MODE, ENDSTOP_B_MODE)
// Configure first board's first motor channel with two endstops, triggered with the pin is HIGH
gb.set_endstop(0, 0, 2, 2) // board 0, channel A, endstops A & B in ENDSTOP_HIGH mode

 

Multiple endstop pins can also be hooked up to the same switch. For example if two servo motors are used, with motor #1 on channels A & B and motor #2 on channels C & D, the setup would be as follows:

 

// gb.set_endstop(BOARD, CHANNEL, ENDSTOP_A_MODE, ENDSTOP_B_MODE)
// Configure first board's first motor channel with two endstops, triggered with the pin is LOW
gb.set_endstop(0, 0, 1, 1) // board 0, channel A, endstops A & B in ENDSTOP_LOW mode
gb.set_endstop(0, 2, 1, 1) // board 0, channel C, endstops A & B in ENDSTOP_LOW mode

 

Demo

 

Here's an animation of an endstop being triggered, resulting in the motors to stop. (You may have to click the image)

image

 

Conclusion

 

This is a very useful feature of the Gertbot, as the endstop functionality only needs to be activated and works independently from that moment on, without requiring specific code to manage them.

  • Sign in to reply
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube