Hall Effect Sensor Question

Does anybody have any sample code to check for a voltage change on a hall effect sensor? I saw a posting here: http://www.tinyclr.com/forum/2/554/ that seemed to say you can just use the Button Component, passing in Port.InterruptMode.InterruptEdgeLow as the last parameter to the constructor. Is this correct?

Will an easy component become available for sale on this site soon?

Thanks for your help.

  • Chris

Yeah, this is a digital thing, not analog. The hall effect sensor will either read high or low. An interrupt is probably the best way to handle this.

Thanks. I understand what you mean by it being High/Low; my choice of words ‘voltage change’ probably wasn’t the best.

I’m new to the MF, and am looking for a quick code snippet I can use and override with my own handler for when the Hall Effect Sensor signals that its state has gone to High (or Low - whichever state it is when the magnet affects it).

Thanks again

Check out the ebook on the downloads page. Do a search for interrupts. That should at least get you started.

Also, what is this little baby icon next to my posts?! At least make it a boy baby! :slight_smile:

Once you get more posts in, it’ll change ;D

Check out the ranks page: http://www.tinyclr.com/forum/users/

He has a blue shirt on it has to be a boy.

Hi Gentlemen,
I’ve been trying this for quite some time now, and still can’t get this to work.

I purchased this Magnetic Field Sensor Board: RobotShop | Robot Store | Robots | Robot Parts | Robot Kits | Robot Toys

I have it hooked up to my Fez Domino’s Component Shield - in Di11. I’ve tried it in other Digital Ports too, and I know that this is working, because when I unplug the component from the board, the Interrupt Handler fires.

I have modified the Trackball code, stripping out all the LEDs and the push button stuff, so now it just accepts one FEZ_Pin.Interrupt / Port.InterruptMode, which I call like this:
movement = new Button(FEZ_Pin.Interrupt.Di11, Port.InterruptMode.InterruptEdgeLow);

Then, using Debug.Print() statements, I check the Port’s state, but it is ALWAYS ON. So I created a truth table, setting each of the following properties to achieve every possible combination - both with and without the magnet under the Hall Effect Sensor, but the state still continues to Debug.Print “ON” - button.GlitchFilter, button.Resistor

Can someone please point me in the right direction?

Are you sure that the ordering of the wires matches what the domino is expecting. A example is the distance sensor have to be changed around it maybe the case for this sensor also.

Good idea, but it appears that the plus, signal and ground are wired correctly. Does it make sense that there is a Signal wire? I thought it was only High or Low.

Do you have a link to the sensor’s data sheet?

I’m afraid not. This board is made by InexGlobal, and is just like the ones sold on this site and included in the Domino starter kit for LED Lights. It contains a Hall Effect Sensor, wired to a 3-pin PCB connector which plugs into a port like the Component Shield.

You can get a pretty good idea about the board here - http://www.robotshop.com/inex-magnetic-field-sensor-4.html

It’s really quite frustrating that something meant to make things so simple is so poorly documented, including the Micro Framework.

Also make sure you are pumping 5 volts to it not 3.3

The signal line looks like its analog not digital. I am tired so i could be reading that wrong which would mean you are plugging into the wrong port.

Well the sensor is documented ok. I located on the page you told me under useful links.

No fez driver exists for it since GHI does not sell it and no one else has used it. So you are in your own uncharted territory. Which means you take some risks. Like asking for help when you can’t figure it out. Which is perfectly fine plenty of us have been there.

As for the micro framework it very documented besides the beginners book which shows you the basics located on this site. You can See everything .Net MF does here API Reference for .NET Micro Framework | Microsoft Learn which the link is located in the download section along with the beginners book which covers analog inputs and so on.

If by not documented you mean code samples to look through and work on the beginners book has plenty this forum and the wiki. Also with MF being something that is generic also google has quite a few too. All of which i have used extensively in my time here to figure out why something i chose to do does not work.

Coding for a hall effect sensor is going to be easy as pie. All you are doing is making an interrupt.

Thanks again for your help. I had tried An0 as well, but without success.

Writing code to handle an interrupt isn’t the problem. I’m a fairly decent .Net developer, I’m just new to the embedded world.

I have just one more question - on the Component Shield, I see the 3V and 5V markings.

Is it the case that some of the Analog Ports and Digital Ports supply 3V and some, 5V? I know that in the case of a dc motor or servo you need to use another board with a battery supply hookup to provide enough power to run a couple of them. I can’t find a link that describes the Component Shield.

I do remember seeing something about reading voltage around page 61 of the beginners book. Hey, my avatar has been upgraded to a girl with a lollipop - very humorous. :slight_smile:

Labeled ZX-magnetic on the board.
The Inex Magnetic Field Sensor works with a built-in 3A Hall-effect sensor (UGN3503) which tracks extremely small changes in the magnetic flux density. This sensor provides a voltage output from 0 to +5Vdc that is proportional to the applied magnetic field. If no magnetic field is detected (0 Gauss) the output voltage will be 2.5V. The voltage output can be calculated using the formula: Vout = 2.5 + (0.0013 x Magnetic field density in Gauss units)

ZX-Metal Sold on this site.
Detect presence of any metallic object
Detection Indicator
Digital output.
Operation range varies according to size of the metallic object
Adjustable sensitivity
An easy removable searching coil screw based terminal block
Supply voltage of +5V from the main controller board that interfaced via JST connector.
Available with a small searching coil. Activated via a simple proximity switch.

The First one which you link points to will require code to tell whats there and not there by looking a the voltage on the analog input.

The second one if it is that you can goto the hardware page pull down the driver. The link is right by where the sensor is sold put it into your project and read it to your hearts content.

You can tell for sure which it is by reading the writing on the board.

Also please post your code to go from there so we can see how you maybe utilizing it.

to test reading voltage you can use something like this coppied from page 61 of beginners book.

AnalogIn BatteryVoltage = new AnalogIn((AnalogIn.Pin)FEZ_Pin.AnalogIn.An0);
BatteryVoltage.SetLinearScale(0, 3300);
int voltage = BatteryVoltage.Read();

Analog in will only handle 3v3, so you need a voltage divider to get it back down to readable (and not potentially fatal for Fez) levels. Then the calc above will be different… but similar!

What are you using the hall effect sensor to do btw?

I’ve created a 7 LED Persistence of Vision project on the Domino. Everything else is working great - I need the Hall Effect Sensor to control the timing for when each revolution begins and ends. That’s the last part of the equation.