Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 10 of 10

Thread: Hall effect sensor switch question.

  1. #1
    Junior Member
    Join Date
    Aug 2016
    Posts
    3

    Hall effect sensor switch question.

    Hi all,

    Could anyone advise me on a project?

    I am using 10 x hall effect allegro A1125 sensors as switches, digital ins to trigger midi note on/offs.

    I came across some Unipolar Allegro A1157's, which are (in effect) 2 pin switches, which reduces 3 pin connections to 2 pins.

    My question is; how do I connect the 2 sensor pins, which are ground and 3 volts positive, to a digital pin in, on the Teensy. (I am using a teensy LC).

    Do I connect the 3v sensor pin to 3v, and the ground pin to a Teensy digital pin, or vice versa?

    And, do I need any other components, caps, resistors etc in the circuits?

    Thanks in advance,

    fil.

  2. #2
    Senior Member
    Join Date
    Jun 2013
    Location
    Montréal
    Posts
    467
    You need a pullup resistor but it's already built into the Teensy.
    You would connect the ground pin of the sensor to ground and the other pin to your digital pin. To enable the pullup it would look like this:

    pinMode(n, INPUT_PULLUP);

  3. #3
    Junior Member
    Join Date
    Aug 2016
    Posts
    3

    Thanks nlecaude.

    Thanks nlecaude, that makes complete sense.



    Much appreciated. fil.


    D
    Quote Originally Posted by nlecaude View Post
    You need a pullup resistor but it's already built into the Teensy.
    You would connect the ground pin of the sensor to ground and the other pin to your digital pin. To enable the pullup it would look like this:

    pinMode(n, INPUT_PULLUP);

  4. #4
    Senior Member
    Join Date
    Jan 2013
    Posts
    843
    nlecaude's suggestion definitely won't work. Those 2-wire hall effect sensors operate in current mode and switch between 2 current draw levels. Interfacing with them is much more cumbersome. You need a sense resistor and you need to ensure that the hall sensor gets it's 3V minimum voltage (you need to take into account that the sense resistor will drop a fair amount of voltage). You also need to be prepared for 17mA current draw per sensor. What voltages / power supplies do you have? Which Teensy?

    Is using the 3-wire version that big a deal (ground and Vcc can be shared between the sensors)?

  5. #5
    Senior Member
    Join Date
    Jul 2014
    Posts
    2,570
    Quote Originally Posted by tni View Post
    nlecaude's suggestion definitely won't work. Those 2-wire hall effect sensors operate in current mode and switch between 2 current draw levels. Interfacing with them is much more cumbersome. You need a sense resistor and you need to ensure that the hall sensor gets it's 3V minimum voltage (you need to take into account that the sense resistor will drop a fair amount of voltage). You also need to be prepared for 17mA current draw per sensor. What voltages / power supplies do you have? Which Teensy?

    Is using the 3-wire version that big a deal (ground and Vcc can be shared between the sensors)?
    would it work, if the resister is not internal but external to complete the sensor electronics (fet for impedance transform?) and using an ADC to sense the different states of the sensor?
    (internal resistor may to big for allowing drain of 17 mA )

  6. #6
    Senior Member Ben's Avatar
    Join Date
    Jul 2013
    Location
    Germany
    Posts
    401
    Quote Originally Posted by WMXZ View Post
    would it work, if the resister is not internal but external to complete the sensor electronics (fet for impedance transform?) and using an ADC to sense the different states of the sensor?
    (internal resistor may to big for allowing drain of 17 mA )
    Yes. I'd put the resistor on the low side (as a "pull down") and power from Vusb. The Sensor needs a minimum supply voltage of 3.0 V, so when powered from 5V that allows for 2V drop in the sense resistor. With the worst case values (17mA, 3V) the maximum resistance will be: R = 2V / 17mA = 117 Ohms. Take the next lower standard value of 100 Ohms. Now your worst case "high" signal is V = 100 Ohms * 12 mA = 1.2V, which is well below the 0.7*Vdd = 2.31V the Teensy 3.2 needs to recognize a logic high. So you'd need the ADC. Whether trading the necessity of analog inputs against using the two-wire hall switches is a good trade or not depends on the application...

  7. #7
    Senior Member
    Join Date
    Jul 2014
    Posts
    2,570
    Quote Originally Posted by Ben View Post
    Yes. I'd put the resistor on the low side (as a "pull down") and power from Vusb. The Sensor needs a minimum supply voltage of 3.0 V, so when powered from 5V that allows for 2V drop in the sense resistor. With the worst case values (17mA, 3V) the maximum resistance will be: R = 2V / 17mA = 117 Ohms. Take the next lower standard value of 100 Ohms. Now your worst case "high" signal is V = 100 Ohms * 12 mA = 1.2V, which is well below the 0.7*Vdd = 2.31V the Teensy 3.2 needs to recognize a logic high. So you'd need the ADC. Whether trading the necessity of analog inputs against using the two-wire hall switches is a good trade or not depends on the application...
    Figure 2 in data sheet (download via http://www.allegromicro.com/en/Produ...3-5-6-7-8.aspx) shows the schematic: sense resistor either high or low (as suggested by ben)

  8. #8
    Junior Member
    Join Date
    Aug 2016
    Posts
    3

    Thanks all.

    Thanks everyone for your inputs.

    As I mentioned in my original post the Teensy is an LC type.

    I'm looking at a 3.6 rechargeable battery for power requirements.

    From Ben and MXZ's comments. It looks like the 2 pin sensor has complications.

    They are also difficult to source here in the UK. Shipping in from Digikey, USA is the only option I've found.

    So, although the extra traces for 3 pin operation are problematic, it is doable.

    So, my next question is; Will I need any extra components for using, say a 3 pin Allegro A1125?

    Thanks again for your collective inputs.

    fil.

    Quote Originally Posted by tni View Post
    nlecaude's suggestion definitely won't work. Those 2-wire hall effect sensors operate in current mode and switch between 2 current draw levels. Interfacing with them is much more cumbersome. You need a sense resistor and you need to ensure that the hall sensor gets it's 3V minimum voltage (you need to take into account that the sense resistor will drop a fair amount of voltage). You also need to be prepared for 17mA current draw per sensor. What voltages / power supplies do you have? Which Teensy?

    Is using the 3-wire version that big a deal (ground and Vcc can be shared between the sensors)?

  9. #9
    Senior Member
    Join Date
    Jul 2014
    Posts
    2,570
    Quote Originally Posted by fil View Post
    So, my next question is; Will I need any extra components for using, say a 3 pin Allegro A1125?
    Have a look at the data sheet of Allegro A1125 (figure 1) it indicates a 0.1 uF from Vdd to GND (close to hall sensor) and a resistor to provide current to the FET

  10. #10
    Senior Member
    Join Date
    Jan 2013
    Posts
    843
    Quote Originally Posted by fil View Post
    As I mentioned in my original post the Teensy is an LC type.
    I overlooked that.
    I'm looking at a 3.6 rechargeable battery for power requirements.
    That means it would be close to impossible to reliably supply 3V to a 2-pin sensor. It would also use more power, in the high state quite a lot more.

    If you had a well-regulated 5V supply, you could potentially make a 2-wire version work with a digital input (there are 2.5V sensor versions, TI DRV50XX), but since you don't...
    Last edited by tni; 08-16-2016 at 01:27 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •