Home/Limit switches - Hal configuration

597 views
Skip to first unread message

Michel Scory

unread,
Jun 16, 2015, 11:40:47 AM6/16/15
to machi...@googlegroups.com
Hello,

I'd like to install limit/home switches on my 3-axis, gantry-style CNC.

From what Bas told me, I will use switches both for limit switches (low cost) and home switches (Hall effect).  Home switches will be used as limit switches --> 6 switches (at least in a first step).

I found this document explaining how to do.  I suspect that it is not up-to-date.  I understand how to process with the ini file.  I don't understand how to associate the physical pins to machinekit variables (hal file, setup.sh, device tree, ...).

Would it exist another document or an example.  It would help me.

Thanks
Kind regards

Charles Steinkuehler

unread,
Jun 16, 2015, 11:52:27 AM6/16/15
to machi...@googlegroups.com
On 6/16/2015 10:40 AM, Michel Scory wrote:
> Hello,
>
> I'd like to install limit/home switches on my 3-axis, gantry-style CNC.
>
> From what Bas told me, I will use switches both for limit switches (low
> cost) and home switches (Hall effect). Home switches will be used as limit
> switches --> 6 switches (at least in a first step).
>
> I found this document
> <http://blog.machinekit.io/2013/07/adding-homelimit-switches.html> explaining
> how to do. I suspect that it is not up-to-date. I understand how to
> process with the ini file. I don't understand how to associate the
> physical pins to machinekit variables (hal file, setup.sh, device tree,
> ...).
>
> Would it exist another document or an example. It would help me.

The blog post isn't horribly out of date, but you shouldn't have to
mess with any of the device tree stuff or modifying the setup.sh file
to configure I/O pins. Most of the standard capes should have their
switch inputs already setup and appearing in HAL as GPIO inputs. You
basically need to just tie the GPIO input to the appropriate HAL
signal for the home or limit switch.

Depending on your hardware, you may need to invert the polarity of
some of the switches, which is easy to do (there is an invert
parameter available on the GPIO inputs). There is possibly useful
example code in the CRAMPS HAL file:

https://github.com/machinekit/machinekit/blob/master/configs/ARM/BeagleBone/CRAMPS/CRAMPS.hal#L243-L278

...and several other example configurations have home and/or limit
switches as well.

--
Charles Steinkuehler
cha...@steinkuehler.net

Michel Scory

unread,
Jun 16, 2015, 1:33:14 PM6/16/15
to machi...@googlegroups.com
Thank you Charles.

I'm using BeBoPR++.  So,  I suppose that, changing the GPIO address, the example  will work.
I'm going to try.

Kind regards
Michel

Daren Schwenke

unread,
Jun 16, 2015, 2:13:07 PM6/16/15
to machi...@googlegroups.com
If you have separate axis for the gantry, here is a good example I've found recently which does that:
The rest is somewhat off the beaten path and I barely understand it so best not duplicate it.  :)

Michel Scory

unread,
Jun 18, 2015, 6:31:50 AM6/18/15
to machi...@googlegroups.com

Hello,

 

Here is the result of my tests:

 

With the CRAMPS configuration (and others), I'm not able to load "cape-universal":

 

Error loading device tree overlay file: cape-universal

CRAMPS.hal:10: program './setup.sh' failed, returned 1

Shutting down and cleaning up Machinekit...

 

I disabled HDMI, HDMI audio and Audio cape in /boot/uEnv.txt:

 

##Disable HDMI/eMMC

#cape_disable=capemgr.disable_partno=BB-BONELT-HDMI,BB-BONELT-HDMIN,BB-BONE-EMM$

 

##Disable HDMI

cape_disable=capemgr.disable_partno=BB-BONELT-HDMI,BB-BONELT-HDMIN

 

##Disable HDMI Audio

cape_disable=capemgr.disable_partno=BB-BONELT-HDMI

 

##Disable eMMC

#cape_disable=capemgr.disable_partno=BB-BONE-EMMC-2G

 

##Audio Cape (needs HDMI Audio disabled)

cape_disable=capemgr.disable_partno=BB-BONELT-HDMI

#cape_enable=capemgr.enable_partno=BB-BONE-AUDI-02

 

No change.  I suppose that Cramps addresses are different from BeBoPr++ ones.  That coud be the problem.

 

It seems to work with the "Pepper" configuration but, unfortunately, there is no limit switches in the config.


I'm a bit desperate, thinking to move from BeBoPr++ to another cape or even to leave Machinekit.


If I could start from a working configuration with BeBoPR++, limit switches, possibly emergency stop, it would greatly help me.


Thanks for your help.

Kind regards


Michel

Message has been deleted

Charles Steinkuehler

unread,
Jun 18, 2015, 12:13:45 PM6/18/15
to machi...@googlegroups.com
On 6/18/2015 5:31 AM, Michel Scory wrote:
>
> Hello,
>
> Here is the result of my tests:
>
> With the CRAMPS configuration (and others), I'm not able to load
> "cape-universal":
>
> *Error loading device tree overlay file: cape-universal*
>
> *CRAMPS.hal:10: program './setup.sh' failed, returned 1*
>
> *Shutting down and cleaning up Machinekit...*

What's in your slots file?

cat /sys/devices/bone_capemgr.*/slots

What happens if you try running setup.sh manually from the command line?

> I disabled HDMI, HDMI audio and Audio cape in /boot/uEnv.txt:

You should only uncomment one cape_disable entry at a time, only the
last one will be used. But it looks like what you have should work
(HDMI audio is disabled, but HDMI is still enabled, which works fine
with CRAMPS and the default universal cape).


> It seems to work with the "Pepper" configuration but, unfortunately, there
> is no limit switches in the config.
>
> I'm a bit desperate, thinking to move from BeBoPr++ to another cape or even
> to leave Machinekit.

Do you actually have a BeBoPr installed? If so, that's why you can't
load the universal cape, the BeBoPr cape has been loaded and has
claimed most of the I/O pins.

> If I could start from a working configuration with BeBoPR++, limit
> switches, possibly emergency stop, it would greatly help me.

There are numerous sample configurations available for the BeBoPr, but
it doesn't look like any include limit switches. The chunk from the
CRAMPS configuration:

https://github.com/machinekit/machinekit/blob/master/configs/ARM/BeagleBone/CRAMPS/CRAMPS.hal#L243-L278

Can be used, you'll just need to adjust the I/O pins used to match the
BeBoPr where they're assigned to nets (and optionally inverted, if
necessary):

https://github.com/machinekit/machinekit/blob/master/configs/ARM/BeagleBone/CRAMPS/CRAMPS.hal#L243-L278

--
Charles Steinkuehler
cha...@steinkuehler.net

Daren Schwenke

unread,
Jun 18, 2015, 12:14:49 PM6/18/15
to machi...@googlegroups.com
Go back to starting with BeBoPr++Pepper.ini.
In the .ini file, first uncomment HOME_SEARCH_VEL and HOME_LATCH_VEL for the axis you have home switches on.
Then for adding in the pins, in BeBoPr++Pepper.ini, the lines you are missing would be:

net home-x bb_gpio.p8.in-09 => axis.0.home-sw-in
setp bb_gpio
.p8.in-09.invert 1

net home
-y bb_gpio.p8.in-14 => axis.1.home-sw-in
setp bb_gpio
.p8.in-14.invert 1

net home
-z bb_gpio.p8.in-18 => axis.2.home-sw-in
setp bb_gpio
.p8.in-18.invert 1

They are commonly placed after each AXIS definition.  Not sure if that makes a difference.  Probably not.

Bas Laarhoven

unread,
Jun 18, 2015, 12:19:13 PM6/18/15
to machi...@googlegroups.com

Hi Michel,

If you want to experiment with another overlay, you also have to disable the bone-bebopr-brdg
overlay that get's loaded by the kernel during boot. That might be the problem you're seeing.
Have a look in the slots file or kernel log to see what's happening.

But what about limit switches not being there? I'm pretty sure the limit switches in the
Pepper/lineardelta configuration are working. You probably can use that for testing
motors and switches, as long as you don't switch to 'delta-mode'. I'm not near a
MK system right now, but I'll try to verify this later tonight.

-- Bas
--
website: http://www.machinekit.io blog: http://blog.machinekit.io github: https://github.com/machinekit
---
You received this message because you are subscribed to the Google Groups "Machinekit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to machinekit+...@googlegroups.com.
Visit this group at http://groups.google.com/group/machinekit.
For more options, visit https://groups.google.com/d/optout.

Charles Steinkuehler

unread,
Jun 18, 2015, 12:29:29 PM6/18/15
to machi...@googlegroups.com
On 6/18/2015 11:19 AM, Bas Laarhoven wrote:
>
> But what about limit switches not being there? I'm pretty sure the
> limit switches in the Pepper/lineardelta configuration are working.
> You probably can use that for testing motors and switches, as long
> as you don't switch to 'delta-mode'. I'm not near a MK system right
> now, but I'll try to verify this later tonight.

It looks like the limit switch inputs are defined at the HAL driver level:

https://github.com/machinekit/machinekit/blob/master/configs/ARM/BeagleBone/BeBoPr%2B%2B/Pololu/BeBoPr%2B%2B.hal#L27

...so the signals are available in HAL, there just isn't anything
tying the physical input pin signals to the home/limit switches for
the motion controller.

--
Charles Steinkuehler
cha...@steinkuehler.net

Bas Laarhoven

unread,
Jun 18, 2015, 12:35:04 PM6/18/15
to machi...@googlegroups.com
For certain that my delta was homing on the switches. I'll look into it
after dinner.

-- Bas

Daren Schwenke

unread,
Jun 18, 2015, 12:41:10 PM6/18/15
to machi...@googlegroups.com


On Thursday, June 18, 2015 at 12:14:49 PM UTC-4, Daren Schwenke wrote:
Go back to starting with BeBoPr++Pepper.ini.
In the .ini file, first uncomment HOME_SEARCH_VEL and HOME_LATCH_VEL for the axis you have home switches on.
Then for adding in the pins, in BeBoPr++Pepper.ini, the lines you are missing would be:
Correction... in  BeBoPr++Pepper.hal.

Michel Scory

unread,
Jun 18, 2015, 1:52:27 PM6/18/15
to machi...@googlegroups.com


Thanks so much.  Many suggestions.  I am going to try.

Just for info:

I built my CNC during the winter (BBB with BeBoPr++).  It was working in a basic way since March.  
A few days ago, I tried to implement home/limit switches, emergency stop, router control.  First of all I upgraded Machinekit.  After that operation my previous configuration didn't work anymore.  I made a backup of the system so I could go back but it is not the goal.

Machinekit isn't probably not yet ready for people with my level of expertise (close to 0 with Linux).

Daren suggestion is the easiest thing to do.  I'll start with it.

Kind regards
Michel



Bas Laarhoven

unread,
Jun 18, 2015, 3:17:28 PM6/18/15
to machi...@googlegroups.com
Here's what I found:

The lineardelta configuration indeed does use limit switch inputs for homing.
Look around line 111 for the X axis in the BeBoPr++/Pepper/lineardelta.hl file.

You probably can copy these lines without change to your own configuration.

IIRC we talked about separate home and limit switches, I'm not sure what
came out as final configuration. Either use two limit switches and connect
them to the MIN and MAX inputs, or keep the HOME position connected
to the MAX input, as it's done now and connect the two limit switches for
each axis to the MIN inputs. Parallel for NO, in series for NC switches.

Then you probably have to connect the inputs in a similar way as the home
switches (in the HAL file). Something like

net limit-x bb_gpio.p8.in-08 => axis.0.limit-sw-in (??? what's that input name)
setp bb_gpio.p8.in-08.invert 1 (if needed, depends on switches, determine
by trial and error)

The table below can help finding the right pin numbers and names.

Success,
-- Bas


BBB signal 4 axis function 5 axis function BBB pin GPIO pin old MK pin






EHRPWM1A PWM2 P9-14 GPIO-50 214
EHRPWM2A PWM1 P8-19 GPIO-22 119
EHRPWM2B PWM0 P8-13 GPIO-23 113
GPIO0_2 E_STP A_STP P9-22 GPIO-2 222
GPIO0_3 E_DIR A_DIR P9-21 GPIO-3 221
GPIO0_4 Y_ENA B_STP P9-18 GPIO-4 218
GPIO0_5 Z_ENA B_DIR P9-17 GPIO-5 217
GPIO0_14 X_ENA AXES_ENA P9-26 GPIO-14 226
GPIO0_15 E_ENA SPINDLE P9-24 GPIO-15 224
GPIO0_26 Y_MAX P8-14 GPIO-26 114
GPIO0_27 Z_MIN P8-17 GPIO-27 117
GPIO1_12 X_STP P8-12 GPIO-44 112
GPIO1_13 X_DIR P8-11 GPIO-45 111
GPIO1_14 Y_STP P8-16 GPIO-46 116
GPIO1_15 Y_DIR P8-15 GPIO-47 115
GPIO1_16 Z_STP P9-15 GPIO-48 215
GPIO1_17 Z_DIR P9-23 GPIO-49 223
GPIO1_28
PEPPER_MISO P9-12 GPIO-60 212
GPIO1_29 STATUS LED P8-26 GPIO-61 126
GPIO2_1 Z_MAX P8-18 GPIO-65 118
GPIO2_2 #IO_PWR_ON P8-7 GPIO-66 107
GPIO2_3 X_MIN P8-8 GPIO-67 108
GPIO2_4 Y_MIN P8-10 GPIO-68 110
GPIO2_5 X_MAX P8-9 GPIO-69 109


Michel Scory

unread,
Jun 19, 2015, 11:50:06 AM6/19/15
to machi...@googlegroups.com
It works !!!!  :-)))

Charles, Daren, Bas: thanks so much !

I am currently cleaning the config files and the GUI.  Everything related to temperatures were removed from the config file and the GUI.

Now I'd like to display the EMC original left pannel with spindle information.  How did you change it ?  I didn't find any XML file.

Thanks
Kind regard

Michel

Daren Schwenke

unread,
Jun 19, 2015, 2:39:41 PM6/19/15
to machi...@googlegroups.com
The parts you just removed related to the temperatures, well kinda...  :)
In your.ini, the following controls that.

[DISPLAY]
PYVCP
= your.gui.xml
[HAL]
POSTGUI_HALFILE
= your.postgui.hal



The PYVCP creates it, and the POSTGUI_HALFILE wires it into the hal after it starts up.
If you have both files still, you are all set, probably.

Michel Scory

unread,
Jun 19, 2015, 5:23:00 PM6/19/15
to machi...@googlegroups.com
These lines were already removed, plus temperature variables (definition and processing).

I was probably not clear enough:
In the original EMC interface, in the left panel, there was information related to the spindle.  Starting Machinekit, the original panel appears for one second but disappeared at the end of the starting sequence.  For my router, I'd like to use the EMC original left panel.

So my question: how did you change that panel ?

Thanks
Kind regards

Michel
Message has been deleted

Daren Schwenke

unread,
Jun 19, 2015, 6:32:06 PM6/19/15
to machi...@googlegroups.com
I don't recall the 'left' panel, sorry.  Perhaps someone else does.  I imagine the same instructions apply.
Take a look at the example configs, pull out the contents of those two lines, and put the corresponding files in your ini foldier. 
It would probably work.
I just rebuilt my BBB and don't have a machine with axis configured handy to try it out.

Michel Scory

unread,
Jun 21, 2015, 5:42:56 PM6/21/15
to machi...@googlegroups.com
Daren: for the left panel, I can imagine that Axis doesn't display the spindle info if there is no spindle connected or configured.

Another strange behaviour: using the original Pepper.LinearDelta, after LinuxCNC is started, the Z-coordinate (machine coordinates) = -121.711.  I zeroed every offset, check the variable file (everything is zero) no change.  I'm not able to make machine coordinates = relative coordinate (surprisingly called joint coordinates in the GUI).

Same behaviour with my configuration but the value is -237.

Is there an explanation or did I misunderstood something ?

Thanks
Kind regards

Michel

Michel Scory

unread,
Jun 21, 2015, 5:49:30 PM6/21/15
to machi...@googlegroups.com
Sorry, I think I have just understood: I probably should change my kinematic to Trivkin.

Michel Scory

unread,
Jul 20, 2015, 11:21:04 AM7/20/15
to machi...@googlegroups.com
Hello,

Thank to your advices, my limit and home switches work now properly: NC circuits, min and max connected together (series).

Still a minor problem: after having hit one of the limit switches, I cannot move back on one side.  Let me explain:
  1. the limit switches are connected to [x,y or z]-MAX
  2. I hit the limit switch on the "min side"
  3. everything stop: ok
  4. after having checked "override limits", I'm not able to go to the right "can't jog joint [xyz] further past max hard. limit"
The opposite connecting the limit switches to the MIN.

Is there a way to bypass that control ?

Thanks
Kind regards

Michel

Kyle Wade

unread,
Aug 23, 2016, 12:50:56 PM8/23/16
to Machinekit
I may be a bit late to the party, but can you share what you did or upload files? I'm currently using the same hardware and trying to do the same thing except with optical sensors rather than limit switches (which I'm assuming will act in the same way). Thank you.

Kyle
Reply all
Reply to author
Forward
0 new messages