Position switch for servo controller - Can someone explain the principle? - Page 1
Forum section: electronics / beginners

author: KS
author_rank: Newbie
timestamp: January 15, 2024, 06:55:03 pm
content: Evening All,Completely new to electronics I am looking to set up an Arduino to control a servo motor based on a linear position of a physical switch. Programming is all well, but I can't seem to work out how this sensor I am trying to replicate is supposed to work.There is a magnet (red cube on photo) glued to a physical switch on a machine, which moves back and forth relative to the sensor (as arrows show), and the sensor somehow detects when the magnet is at either side of the sensor. The three wires seem to feed into a chip on the circuit board.Can someone explain the principle behind this sensor and how to make one myself, or suggest alternatives? In simple terms I need the Arduino to detect when the switch on the machine changes position and to operate the servo.Please let me know if I sounded confusing and need to clear up.ThanksKiryl

author: pcprogrammer
author_rank: Super Contributor
timestamp: January 15, 2024, 07:15:13 pm
content: Take a look at this wikipedia page:https://en.wikipedia.org/wiki/Hall_effect_sensorYou can find sensors that give an analog value telling how close the magnet is or sensors that have a digital output. On when the magnet is close of when it is further away.Hope this helps.

author: KS
author_rank: Newbie
timestamp: January 16, 2024, 07:01:16 pm
content: Thank you! Do you reckon I can get away without using an amplifier? I could find these sensors online, and the principle seems pretty simple, but I'm now struggling to grasp whether its output will be enough to trigger the arduino response. Some say that for more precise position an amplifier is necessary to equate output voltages LOW and HIGH values to 0 and 5V. Also, what would you go by when matching a sensor to an amplifier?Thank you!Kiryl

author: pcprogrammer
author_rank: Super Contributor
timestamp: January 16, 2024, 07:55:44 pm
content: You are welcome.It depends on the sensor you choose. It is a very long time ago that I used some, but if I recall correctly they had a high enough output voltage to not need an amplifier.Post a part number of what you found, so that I can take a look at the specs. If an amplifier is needed a simple opamp circuit would probably do. Bare in mind that for your use case it is only needed to detect if it is on the left or the right, and maybe the middle of the sensor, and the Arduino has analog inputs with which you can easily detect this.For matching a sensor to an amplifier it is needed to know the output range of the sensor and the needed input range on the detector side plus the resolution that is needed. Based on this one can design an amplifier. Noise has to be taken into consideration for high resolution, so supply voltage is then also important to filter properly to reduce noise as much as possible. This would also mean that the conversion to digital needs more attention. And the list goes on.

author: Andy Chee
author_rank: Super Contributor
timestamp: January 16, 2024, 07:56:55 pm
content: There are LOTS of different versions of hall effect sensors.For a positioning servo, you'll probably want one with a variable analog output (similar to potentiometer). This output minimum-maximum range (e.g. 0-1V) may not match the full range of the Arduino ADC (e.g. 0-5V), so would need to be amplified.I would first try and find a hall effect with the same or close output range as your Arduino.If you can't find one, then you will need to use an opamp circuit with a gain of 5x to amplify the example sensor I mentioned above.I should also add that the magnet you use is also important. Depending on the mechanical geometry of the motion you're sensing, the magnet may need to be diametrically polarised, which although readily available, is not as ubiquitous as axially polarised magnets:https://magneticsmag.com/diametrically-magnetized-magnetstech-briefing-diametrically-magnetized-magnets-perfect-for-magnetic-angle-rotation-sensing-by-daniel-a-baker-nve-corporation/

author: pcprogrammer
author_rank: Super Contributor
timestamp: January 16, 2024, 08:38:44 pm
content: I looked in my parts collection and found the ones I have used before. UGN3503U. They are still manufactured and work of 4.5 to 6V supply. Linear output with a 2.5V null line when no magnet is near. Swings from ~0 to 5V when magnetic field is applied. So no need for additional components.https://www.bristolwatch.com/hall_effect/ugn3503.pdf