Hall Effect Sensors as Limit Switches

RobCee
Posts: 587
Joined: Wed Jan 08, 2014 11:33 am
Location: Birmingham, UK

Hall Effect Sensors as Limit Switches

Post by RobCee » Sun Jan 26, 2014 3:32 pm

Hall Effect Sensors as Limit Switches – ShapeOko2

I have been working on setting up limit sensors for my ShapeOko 2 over the last week or so. My investigations have prompted me to commit my findings here for others to benefit from.
It seems that the use of magnetic Hall Effect Sensors is not quite as simple as it initially sounds, but I should be able to explain how I have setup mine and somebody out there can critique or improve my findings.

There are quite a lot of varieties of Hall Effect Sensors available, my main criteria was to find one that was small and cheap. I ended up using the Honeywell SS443A, which is described as a “SS400 Series medium-Gauss unipolar Hall-effect digital position sensor IC, flat TO-92-style package, straight leads”. This is a very small sensor, about the size of the head or a match.
In order to try to work out how it worked, I used my Arduino to create a test circuit based on the manufacturer’s wiring diagram and some of the circuits I had used before while playing with the Arduino.

There are a couple of things that need to be considered when making this small circuit.
  • 1. If you power an LED with the output, which is handy if only to check that it is working, the LED needs a small resistor in series with it to protect it from burning out (R2 in my circuit). These seem to be typically around 220-330 ohms. My LED supplier sells the appropriate resistors and LEDs in packs together, so I used 220ohm ones.
    2. You probably want to use a ‘pull up’ resistor on the output, usually about 10k ohms (R1 in my circuit). There is a lot of information on this, but it can be hard to understand – or at least it was for me. I will explain this below.
    3. You will need a small magnet for testing, along with the sensor itself, which looks like a transistor.
    4. The sensor I am using is unipolar, which means that it switches on when the correct pole of a magnet is within it’s sensing range and it switches off when the magnet is moved out of range. I thought this was the correct sort of sensor for limit switches on my ShapeOko.
Here is the basic circuit for wiring up the Hall Effect Sensor:
HallEffectSensor1.png
Here is the basic circuit for wiring up the Hall Effect Sensor:
HallEffectSensor1.png (13.75 KiB) Viewed 5721 times
So, what on earth is a ‘pull up’ resistor and what is it doing?

The output from the Hall Effect Sensor that I chose works as follows:
  • • When there is no magnet near the sensor, the output is typically between 1v and 3v
    • When the magnet comes near, the output switches down to about 0.1v
This is ok, but there is a risk that the voltage on the output could get very low when there is no magnet around, given that the motors in the ShapeOko are moving around all over the place. The Arduino is expecting the digital signal to be High (5v) or Low (0v), if it gets something in between these values, it may interpret it in a way you do not expect.
To counter this, you use a ‘pull up’ resistor which pulls the output voltage up to a consistent High (5v) when the sensor is not active. I found many explanations for calculating the value of this resistor, but it seems that using 10k ohms is suitable in most cases. The opposite of this (not useful in our case) is the 'pull down' resistor, which drops a voltage down to Low (0v) as a default value.

This ‘pull up’ resistor has the following effect on the Hall Effect Sensor:
  • • When there is no magnet near the sensor, the output is pulled up to 5v
    • When the magnet comes near, the output switches down to about 0.1v
What this means is that by adding the ‘pull up’ resistor, you are minimising the risk of the unconnected output giving you a false reading. You don’t actually need it, as apparently the Arduino can be configured to do this internally, but it makes sense to use your own if you can do it.

Here is my Arduino circuit showing the LED off when the magnet is not close to the sensor:
HallEffectSensor4.png
Arduino Hall Effect Sensor magnet out of range
HallEffectSensor4.png (421.75 KiB) Viewed 5721 times
Here is my Arduino circuit showing the LED coming on when the magnet is close to the sensor:
HallEffectSensor3.png
Arduino Hall Effect Sensor magnet in range
HallEffectSensor3.png (453.71 KiB) Viewed 5721 times
If you are interested, I am using the SparkFun Inventor’s Kit to play with this, rather than the Arduino in my ShapeOko.


To Be Continued
Last edited by RobCee on Sun Jan 26, 2014 3:45 pm, edited 1 time in total.
ShapeOko2 #3400 - Chinese 800W AC Spindle - Stiffened X-Axis - TR10 Z-Axis - Inverted Z Motor - Hall Effect Limits - Drag Chains & Custom Brackets

RobCee
Posts: 587
Joined: Wed Jan 08, 2014 11:33 am
Location: Birmingham, UK

Re: Hall Effect Sensors as Limit Switches

Post by RobCee » Sun Jan 26, 2014 3:37 pm

So now, I have the circuit working, I need to think about multiplying it by six, for the extremes of each axis. I also need to think about where I am going to put the LEDs and resistors in relation to the sensors.
Here is my circuit for the six sensor outputs, it may not be the best design, but it seems to work:
HallEffectSensor2.png
Multiple axis Hall Effect Sensor circuit
HallEffectSensor2.png (40.76 KiB) Viewed 5716 times
Having finished the circuit design, I had to decide how to build this so that it can be mounted somewhere on the ShapeOko. It makes sense to keep limit switches off moving elements as much as possible, so I decided to mount them on the makerslide and have the magnets moving with each carriage. I created a small mount from Perspex and cut out six of them with the ShapeOko itself – I do love getting it to make it’s own upgrades.
HallEffectSensorMounts.png
Sensor mounts
HallEffectSensorMounts.png (336.64 KiB) Viewed 5716 times
These have a 5mm hole for mounting onto the makerslide and the sensors can be glued to the other end for positioning. I thought about having all the electronics on these mounts, but it was looking rather complicated to do it that way.
Given the choice of having the main electronics distributed around the machine, or self-contained with the other circuitry, I chose the latter. This makes the sensor mounting easier and keeps the circuit board away from everything else. This should also make it simpler to change a faulty sensor at a later stage too.
The next step was to turn my schematic into a real circuit and that too, proved slightly more in depth than imagined.
I eventually found a ‘Veroboard’ template for Inkscape, which is much loved by the maker community, so thought I would give it a whirl. Following a bit of trial and error, I came up with a suitable design. With hindsight, not the best, but it seems to work.
HallEffectSensorVeroBoard.png
Veroboard design in Inkscape
HallEffectSensorVeroBoard.png (53.51 KiB) Viewed 5716 times
To Be Continued
ShapeOko2 #3400 - Chinese 800W AC Spindle - Stiffened X-Axis - TR10 Z-Axis - Inverted Z Motor - Hall Effect Limits - Drag Chains & Custom Brackets

RobCee
Posts: 587
Joined: Wed Jan 08, 2014 11:33 am
Location: Birmingham, UK

Re: Hall Effect Sensors as Limit Switches

Post by RobCee » Sun Jan 26, 2014 3:41 pm

Here is the completed circuit board – Front
HallEffectSensorCircuitFront.png
Board Front
HallEffectSensorCircuitFront.png (457.53 KiB) Viewed 5715 times

Here is the completed circuit board – Rear
HallEffectSensorCircuitRear.png
Board Rear
HallEffectSensorCircuitRear.png (487.1 KiB) Viewed 5715 times
Yes, my soldering is rubbish! Took me right back to my childhood, when I was also rubbish at soldering. I could also have used solder links instead of wire ones.
I have spaced the LEDs off the board so that I can eventually put them into an enclosure. They are also spaced so that they form a logical XYZ shape like the following image:
HallEffectSensorLEDPositions.png
XYZ Image
HallEffectSensorLEDPositions.png (11.03 KiB) Viewed 5715 times
I have tested the outputs and they all work when connected, so it is now a matter of working out how to position the limit switches onto the machine and getting them all wired up.
I will update things once I have that stage completed.

I hope this helps some of you to shortcut the investigation process!

/RC
ShapeOko2 #3400 - Chinese 800W AC Spindle - Stiffened X-Axis - TR10 Z-Axis - Inverted Z Motor - Hall Effect Limits - Drag Chains & Custom Brackets

MeanderBolt
Posts: 560
Joined: Mon Nov 04, 2013 6:45 pm
Location: Georgia
Contact:

Re: Hall Effect Sensors as Limit Switches

Post by MeanderBolt » Sun Jan 26, 2014 8:08 pm

Dude!
I am still reading through this, but I wanted to say... Heck of a Job so far!!!
I have some surface mount Hall Effects I was going to use on a wind vane. I am thinking about re-purposing for this exact thing. Good work. I am going to go back and reread this.
Shapeoko 2 # 3569 - DW660
Current tool chain > Draftsight > CamBam > ChiliPeppr
Build log

RobCee
Posts: 587
Joined: Wed Jan 08, 2014 11:33 am
Location: Birmingham, UK

Re: Hall Effect Sensors as Limit Switches

Post by RobCee » Mon Jan 27, 2014 9:15 am

Currently, this design is working for testing each sensor individually, but cannot be implemented onto the machine due to the following problem:

There is currently no way to combine the max/min signals without triggering both together. It's only an indication problem, but currently I am unsure how to make it work another way. I am sure it has something to do with diodes in the circuit, but I am not sure how to position them.

This means that the multiple sensor schematic, the veroboard design and the physical circuit board are all currently incorrect.

If anyone with a bit more circuit design knowledge cares to jump in and advise, I would appreciate it!
ShapeOko2 #3400 - Chinese 800W AC Spindle - Stiffened X-Axis - TR10 Z-Axis - Inverted Z Motor - Hall Effect Limits - Drag Chains & Custom Brackets

RobCee
Posts: 587
Joined: Wed Jan 08, 2014 11:33 am
Location: Birmingham, UK

Re: Hall Effect Sensors as Limit Switches

Post by RobCee » Mon Jan 27, 2014 11:15 am

OK, I worked it out!

I need an AND Logic Gate across the outputs for each axis pair. This is pretty simple, but naturally requires components I do not currently have in the right quantity.
Once again, the Arduino and breadboard environment is perfect for trying to sort out and prove these circuit designs.

It is achieved by connecting diodes across the outputs, joining them together. On the positive side, it means that I can lose half the 'pull up' resistors, as they are used on each joined output rather than each individual one. I will sort out the circuit diagram a bit later and add it in here.

I have worked out the circuit for the pair of sensors coming together for a single input to the Arduino board, using diodes. (Please don't complain if I get the LED / Diode symbols the wrong way around - just tell me and I will update it).
Here it is:
HallEffectSensorPair.png
Hall Effect Sensors - Pair to single output
HallEffectSensorPair.png (17.65 KiB) Viewed 5659 times
Here is the schematic for the 3 Axes together:
HallEffectSensorMultiplePair.png
Hall Effect Sensors - Multiple pairs
HallEffectSensorMultiplePair.png (39.8 KiB) Viewed 5658 times
ShapeOko2 #3400 - Chinese 800W AC Spindle - Stiffened X-Axis - TR10 Z-Axis - Inverted Z Motor - Hall Effect Limits - Drag Chains & Custom Brackets

MeanderBolt
Posts: 560
Joined: Mon Nov 04, 2013 6:45 pm
Location: Georgia
Contact:

Re: Hall Effect Sensors as Limit Switches

Post by MeanderBolt » Mon Jan 27, 2014 2:28 pm

Wouldn't you need a OR.
If x1 OR x2 register as low, then register the change. If you use AND, you would need to trigger both sensors at the same time. This and that = change.
Edited :for content.
Last edited by MeanderBolt on Mon Jan 27, 2014 2:51 pm, edited 1 time in total.
Shapeoko 2 # 3569 - DW660
Current tool chain > Draftsight > CamBam > ChiliPeppr
Build log

MeanderBolt
Posts: 560
Joined: Mon Nov 04, 2013 6:45 pm
Location: Georgia
Contact:

Re: Hall Effect Sensors as Limit Switches

Post by MeanderBolt » Mon Jan 27, 2014 2:42 pm

More... Where I am headed is using an additional Arduino (Adafruit Boarduino) as I need it for a couple other functions. Since you already have one, you could solve this programmatically. Take both hall effect outputs into 2 pins. If either trigger as low , then you send a 3rd pin (EDIT) LOW which will go to the Shapeoko Arduino / GRBL Shield limit input.
EDIT: I spaced on the fact that grbl shield limits are held high. So yeah, keep the output pins high (on the second Arduino) and send low it low when triggered. Make sure that you have both board's grounds connected.
Shapeoko 2 # 3569 - DW660
Current tool chain > Draftsight > CamBam > ChiliPeppr
Build log

RobCee
Posts: 587
Joined: Wed Jan 08, 2014 11:33 am
Location: Birmingham, UK

Re: Hall Effect Sensors as Limit Switches

Post by RobCee » Mon Jan 27, 2014 3:13 pm

MeanderBolt - You are correct, you would need OR logic, if both pins were being held LOW and then pulled up to a HIGH output.
With the way things are configured with the Arduino / GRBLShield, the outputs are pulled HIGH and then one of them drops to LOW and pulls the combined output down to LOW.
I got a bit lost on the way through with the logic, diodes, and all. The important part is that the circuit now works, as I proved it on the breadboard with two Hall Sensors, two LEDs and a single output to the Arduino. From looking at the associated Truth Tables for AND and OR logic gates, I thought I would need AND.

Suffice to say, it needs a logic gate, with the two diodes in the correct direction! :D

I have mapped out another (messy) Veroboard in Inkscape and have ordered the appropriate parts. They should be delivered in a few days and I will update when I have it assembled.

Here is the Veroboard design:
HallEffectSensorVeroBoardMk2.png
Hall Sensors with AND/OR logic circuit for pairs
HallEffectSensorVeroBoardMk2.png (90.18 KiB) Viewed 5650 times
ShapeOko2 #3400 - Chinese 800W AC Spindle - Stiffened X-Axis - TR10 Z-Axis - Inverted Z Motor - Hall Effect Limits - Drag Chains & Custom Brackets

CrazyBillybob
Posts: 199
Joined: Mon Dec 16, 2013 2:09 pm
Location: Ohio
Contact:

Re: Hall Effect Sensors as Limit Switches

Post by CrazyBillybob » Mon Jan 27, 2014 4:31 pm

RobCee,

Is your + voltage the 5VDC from the Arduino or the 24VDC input voltage from the Shield supply?
With the resister values and configuration I'd guess 5VDC but wanted to clarify for others that are looking at this for their Shapeoko's.


Nice work on the Schematics and drawings. It helps show that these sensors can be easily added.


CBB

Post Reply