NerdKits - electronics education for a digital generation

You are not logged in. [log in]

NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.

Sensors, Actuators, and Robotics » Position Sensor

December 29, 2010
by Jalex
Jalex's Avatar

I would like to make a position sensor that would measure position of a slowly turning wheel in degrees using 3 Hall sensors. Or is there an easier way.

December 29, 2010
by mongo
mongo's Avatar

What kind of resolution are you looking for?

December 30, 2010
by Jalex
Jalex's Avatar

Hi mongo It will be used on a wind direction weather vane. Just 0 - 360 is what I want. I will also want to measure wind speed too but I think I can figure that out. Then I would like to transmit the data to another receiver unit.

December 30, 2010
by hevans
(NerdKits Staff)

hevans's Avatar

Hi Jalex,

There are several ways to do an angular rotation sensor like the one you are talking about. Hall effect sensors would be a perfectly reasonable way to do it. A hall effect sensor basically outputs a voltage proportional to how much magnetic field it sees. In order to measure relative angular displacement all you really need is one hall effect sensor, and magnets placed in a ring on the rotating object. As your magnets move over the hall effect sensors you can detect the voltage spikes either with your ADC or perhaps even with a digital pin. This will essentially tell you how fast something is spinning. If you have two hall effect sensors, offset from each other a bit, you can tell which direction it is spinning.

Note that this scheme does not allow you to sense the absolute position, just the relative position form where you started. You could add a calibration step where you point the thing north and start counting from there, or have some sort of self calibration with a different hall effect sensor and only one magnet in its path so it knows when it is pointed north.

Hope that gets you started! This should be a neat project.

Humberto

December 30, 2010
by Ralphxyz
Ralphxyz's Avatar

As I am also working on a anemometer and thinking about adding a weather vane this is of immediate interest.

Would two magnets/hall effect sensors work at North. It would be nice if there were north pole and south pole hall effect sensors but possible just having one magnet at the rim and the other towards the center would be enough to differentiate the pulse.

You would need some sync code and probable a button to set North.

Has anyone used a Magnetic Sensor Module? I have one from SURE Electronics that uses I2C (TWI) to communicate. Now that would be a cool North indicator. Also one could use a Gyro but you still need a North orientation.

Ralph

December 30, 2010
by mongo
mongo's Avatar

I have used optoelectronic position sensors before. They are 0-359 degree increments. I think they had a binary output that had to be decoded and translated.

My wind vanes have potentiometers that rotate the whole 360°. Full voltage is 0°, half voltage is 180° and zero voltage is 359°. (or was it the other direction?). At any rate, it was a lot easier to interface.

December 30, 2010
by Ralphxyz
Ralphxyz's Avatar

mongo, where did you get a potentiometer that would freely rotate >360˚.

Ralph

December 31, 2010
by Jalex
Jalex's Avatar

Hi Ralphxyz Here is something I did a while back that could maybe spark and idea. I put one rotating metal half circle plate over another and read the capacitance between them then used a IR led to detect the 0 (starting point). Here I switched the Op-amp polarity. This gave me a 0 to 5 volt scale as it rotated. I should be able to get something similar with hall sensors.

December 31, 2010
by Jalex
Jalex's Avatar

Hi mongo That would work work fine for me. I haven't found any pots like that. I have tried to make some but they always had dead spots so I gave up on that.

December 31, 2010
by Jalex
Jalex's Avatar

Hi All Yes, I have also tried using IR leds. I used a cmos gate to check rotation direction from two offset photo-detectors and used it to clock Up/Down counters. This worked fine but used too much current for a battery powered unit.

December 31, 2010
by mongo
mongo's Avatar

"mongo, where did you get a potentiometer that would freely rotate >360˚."

It was actually made to be used for that purpose. Both of my wind vanes use that method.

I have never opened them up for fear of breaking them but they seem to work quite well in a voltage divider type circuit.

December 31, 2010
by mongo
mongo's Avatar

Here is a PDF on a potentiometer type wind vane.

Link

December 31, 2010
by mongo
mongo's Avatar

Here is another for a pot alone. Link

and this is a dual wiper type that the first link refers to. link2

December 31, 2010
by Jalex
Jalex's Avatar

Thanks mongo That would make the process much simpler.

December 31, 2010
by Ralphxyz
Ralphxyz's Avatar

Wow that is one cool potentiometer but did you check the price?

Mouser for the 882-SP22GS-10K wants $56.22 for the 882-SP22G-10K they want $20.05.

I am not sure what the difference is, probable a SP22G (the cheaper one) would do, but still I just bought some Hall Effect Sensors for 60¢.

Now where do I get ball bearings (on the cheap)?

Ralph

December 31, 2010
by Rick_S
Rick_S's Avatar

Maybe check into roller blade or skateboard bearings. They can be fairly inexpensive.

December 31, 2010
by mongo
mongo's Avatar

There is another method using a photocell and a spiral cam. As the cam rotates, more of the cell is uncovered. Illuminated by an LED, it can give a pretty linear result.

January 01, 2011
by Ralphxyz
Ralphxyz's Avatar

Thanks Rick for the ball bearing source, I am heading for a yard sale (well maybe this spring) but great idea.

Mongo I like that spiral cam idea. I suppose you would use a led and a Cad Cell to get a variable voltage depending on exposure.

Ralph

January 01, 2011
by Jalex
Jalex's Avatar

Wow, That expensive for the SP22G pot. I guess I can see why as it has to endure the harsh weather all the time. That's a biggest problem with this stuff. I have made many that worked for a short time. LOL We have tons of rain here on the northwest coast in the USA.

January 12, 2011
by Ralphxyz
Ralphxyz's Avatar

Jalex, what was your final solution to measure position?

I think mongo's post of a photo cell and spiral cam is interesting but I cannot picture how to set something like that up.

Ralph

January 12, 2011
by Jalex
Jalex's Avatar

Hi Ralphxyz Thanks for the reply I think I want to try the capacitor trimmer idea I mentioned earlier. I used two metal plates with an IR zero zero point detector and a duel op-amp and it worked. I think I can do it with 3 pins on the controller. I should be able to trigger 1 on and while reading the zero point and measuring the time from the fire point of one to the second. Then reverse the math when the IR is high. The second pin would go high when the capacitor trimmer is charged through a 1M resistor. I have the kit working now at the first step and I am now studying the coding. My C has mostly been for computer graphics and text handling so I am seeing lots of new commands I don't understand at the moment. I have always had a little trouble figuring out code I didn't write so it's a little hard. I am going to go through the complete tutorial before I try to write code on my own. Right now it seems a lot different than what I am used to writing. It's seems a little like using C as if it were Assembly language with all the bit manipulations. I haven't used Assembly since the old 8 bit Commodore 64 days. I used to write arcade games on it but that was a long time ago. LOL Maybe a list of valid commands and more on pin control would help. Is that in the data sheet? It was so big I didn't want to print it all and I didn't see it.

January 30, 2011
by Jalex
Jalex's Avatar

Hi Ralphxyz Well I am having lot of trouble with that code I posted the other day and have made some changes to it but with no luck. The capasitor idea to get 360 degrees works with Cmos chips but I can't get it to work with the MCU. I have backed all the way to trying to count when certain pins are high or low and I havn't made that work right either yet. I am doing something wrong with the code. I had three counters set up identical printing on 3 sepatate lines of the LCD and only one worked and I never figured out why. The one that did count counted up 1 per second even when the was no increment statment. I thought I knew C good enough but now I am not so sure. LOL I had built this little weather station with cmos chips and used it for a while but I thought it might be better with the MCU.

January 30, 2011
by Ralphxyz
Ralphxyz's Avatar

Hey Jalex, keep plugging away you'll get there (besides I am counting on using your code).

How are you implementing counting? What happens when the wind reverses?

I would like to ask Humberto to expand further on his idea to make a ring of magnets and to count magnet hits, using a Hall Effect Sensor, to get direction, again how would you know you were supposed to subtract when the wind reversed.

I have a Magnetic sensor module I picked up from Sure electronics for $6.00.

I figured what the heck I need to learn I2C (TWI) so I am thinking about using that as my wind direction.

I also grabbed some Hall Effect Sensors so I would be interested using them also.

Break your code down into what works and post what isn't working so we can have a look.

Are you getting a variable voltage from your direction capacitor? I'd like to see more details on that also.

The LCD output gets screwy sometimes.

Ralph

January 31, 2011
by Jalex
Jalex's Avatar

Hi Ralphxyz One of my favorite things to experiment with has been sensors. I have tried many different ways to measure positions of rotating object. One way is similar to the way a mouse works where you use two offset detectors and then detect wich one turns on first. I have used $1 hall sensors, and IR. They both work but in the case of a weather vane it's hard to keep it 0'ed at North. If it misses a pulse or two the up/down counters 0's in a different place. The capasitor idea counts up 0 -180 and back down when the direction reverses and then when the rotating plate covers the IR I need to add the difference to 180(360 - the reading). My original was anologe and used two op-amps one set + 0/180(0 to 2.5volts) and the other 360-180 (inverting 5 to 2.5 volts) Then it switched acording to the Ir On/off state. I have a schmatic some where if I can find it that would help explain how it worked. I use charge pumps to measure lots of things so I will have to learn how to measure pulse widths very accuratly with the MCU. I also measure water this way and the sensor is nothing more than a piece of copper tube with an insulated wire inside making a capasitor. I have found that quite accurate in anologe too. It's basicly the same charge pump system used in the cheap capasitor testers. Jameco.com has lots of sensors at pretty cheap prices if you need some. One I want to play with is a flex strip that varries resitance when it bends for robotics. So far I only get to work with my nerdkit once a week and I just seem to get on to what I am doing wrong and then I have to quit. LOL As you can see I am an anologe tech and learned most of my digital experience programming and I don't fully understand the workings of MCU's yet. One of the simple things I designed and built was a digital clock with nothing more that a few Johnson counters (4017's) It has 72 leds and reads like an anologe clock. That's nothing to what I see the 168 can do. LOL

February 01, 2011
by Jalex
Jalex's Avatar

Hi Ralphxyz That's a really cool sensor you have there. I had looked at the ones Honeywell makes like this but they were way too expensive for me to use. If you get this working I would like to see your code.

February 23, 2011
by Ralphxyz
Ralphxyz's Avatar

Whowee, I just received some continuous turn potentiometers that I spotted on ebay. They are good for a million spins.

At 360˚ they get a little confused but they recover at 1˚ and 359˚.

I have been planing on using the Magnetic sensor Module for my weather vane maybe I'll do both just for experimentation I am going to have duplicate windspeed detectors, a photo transistor and hall effect sensor just for experimentation so another experiment will not hurt.

These appear to be high quality potentiometers

I see on searching the web I could have saved a couple of dollars, but you can all ways do that after the fact, NEVER LOOK BACK!!

Ralph

February 24, 2011
by 59zoocat
59zoocat's Avatar

Hey Ralphxyz and Jalex, Check out the Cherry AN8 series position sensors. AN8

I bought the 360 degree one a while back but it is still sitting on my bench (way too many projects). I had intentions of making a more affordable wind sensor for sailing. After more research I found Davis has a replacement for their wired weather stations that's ready to install at the top of the mast. This is still a pricey way to go but I'm sure it is built to take the elements. Davis Sensor

Good Luck! I'll be watching this thread close. Keith/59zoocat

February 24, 2011
by Ralphxyz
Ralphxyz's Avatar

Hi 59zoocat, darn I would like to know how it is working using hall effect sensors.

I got ahold of a bunch of hall effect sensors to play around with but I cannot grasp how to use them for direction sensing.

Those AN8 seem a bit pricey to me. But probable very nice, they certainly have high life cycle counts.

I just got the March Circuit Cellar mag. There is a Hall Sensor for 360˚ Navigation in HMIs Easy Point.

This would be fun to play around with. Oh, HMI is Human Machine Interface (who thinks these things up probable the same ad guy who came up with "free gift"). Technically it is a mini joy-stick. At 2.92 for a thousand even at $5.00 to $8.00 it might be a good buy.

They also have a very attractive young women at the end of their video, I love the accents.

Ralph

March 04, 2011
by Jalex
Jalex's Avatar

Hi Ralphxyz I think Honywell makes a chip that can be used for an electronic compas. I have only played with the cheap ones myself as well. You place two of them at 90 degrees and then N/S poles rotate around them. All I have seen is the mechanical lay out and couldn't figure the math out for reading them.

April 04, 2011
by Hexorg
Hexorg's Avatar

You can use a ring of magnets + 2 hall effect sensors to read speed and direction, but also, if you put one magnet at some different location, facing north, and a 3rd hall effect sensor, you can sense north with that. However for such an on/off action, wouldn't magnetic switches work better?

April 04, 2011
by Jalex
Jalex's Avatar

Hi Hexorg

I use 2 flat metal plates with a half circle rotating above them then measure the capacitance as they rotate. It switches between the two metal plates with an IR to give a voltage 0-5 volts. The second plate has double the capacitance to give a smooth switch at 2.5 volts. This works with only one CD4069 inverter chip and it does the switching and the capacitance to voltage conversion. I use this on a weather vane and it seems pretty accurate. We had 10" of rain last month and all the moisture in the air doesn't seem to mess it up. I tried some cheap pots but they only worked for a while and them got messed up. I also use this converter system to measure liquid in a container and it works pretty well here too. I like playing with all kinds of sensors.

April 04, 2011
by Ralphxyz
Ralphxyz's Avatar

Jalex, would you post some pictures of you weather vane and maybe a drawing of your directional capacitor. I "think" I understand your description but it is still kinda fuzzy.

It really seems like a fascinating method of capturing rotational direction.

Of course Stans's hall effect sensor method seems like a good method, one thing I do not understand though is how "North" is determined. Would you use a compass to find North than position the weather vane to point that way and then push a button to capture the North reading this would work as long as power was maintained but seems like it would have to be repeated every time you re-powered the circuit.

Of course your directional capacitor might also have that problem.

So how do both of you determine North? and how do you maintain North between power ups? and what happens if you change locations?

As soon as I get the I2C EEPROM working the next step will be getting the I2C Magnetic Compass sensor working.

But I sure like having alternative methods (in other words I am not sure of my programming abilities to get the Magnetic Compass sensor actually working so I need alternative methods).

Ralph

April 05, 2011
by Jalex
Jalex's Avatar

Hi Ralphxyz I will post some soon. I have to take some pictures and my wife has the camera at work. I have to find it too as I moved and it's still packed somewhere here. All I have is a hand drawn schematic at the moment. When I set it up I have to set it for 0 Volts then orient it to North with a compass. If I remember right it's used a trimmer cap on one side to set the switching point. The Pcb was just a circle cut down the center. It probably would work be better to etch the foil so that one side was actually double the capacitance of the other side. They were diode switched by the 4069. I got the idea while making a rain gage. Just a piece of insulated wire stuffed inside a copper tube will make a pretty accurate measurement of water in a pipe using the same circuit. I have been playing with RF stuff lately so I haven't done anymore on that one. The hall effect one is supposed to work with just two hall sensors at 90 degrees and a north and opposing south rotating around them but I didn't have much luck with it. I think that would be a cool project for the 168 if I could figure out the math.

April 05, 2011
by Ralphxyz
Ralphxyz's Avatar

Jalex, that's great.

For your rain gage and a piece of wire are you measuring capacitance to get the volume (inch's of rain)?

Determining North with a compass makes sense I figured you might do that.

I picked up some hal effect sensors but I could not reconcile the specsheet with using them for rotational direction. I can understand revolution counting but not directions, especially when the direction reverses. But I'll play around with them one of these days.

The capacitance wind direction really makes sense, functionally thought I am having a hard time conceptualizing it so some pictures or sketches would be appreciated.

Speaking of sketches have you seen Google SketchUp. Man I sure would like to be able to knockout 3D sketches of my projects. I just have not taken the time to learn how to use it. Speaking of the free version of course.

Ralph

April 06, 2011
by Jalex
Jalex's Avatar

Hi Ralphxyz Yes The inverter circuit is one I designed and seems to work better than the ones using a 555 timer you may have seen on the net. It works all the way down to a few Pico-farads. That system is suppose to work for measuring all liquids but I tried it in gasoline and it didn't work very good as the capacitance variation is a lot less. The one I took it from had two tubes one inside the other that was insulated. I think the wire in the tube just isn't good enough for lighter chemicals other than water.

I got my hall sensors from allelectronics.com and they gave me a plus voltage(2.5 to 4) for north and a minus voltage (2.5 to 1) for south poles. They should work for a rotation sensor, I think. Compass is the wrong word for that device and I should refine that because something like that would not measure the Earths magnetic pull.

I will have to check that out. I don't go to Google very often. I got some spyware there a long time ago an never went back even though it's not a problem any more. Graphics is another one of my favorites I wrote a paint program that does a lot of things you don't see in major graphic programs. Not in 3d though.

April 06, 2011
by Ralphxyz
Ralphxyz's Avatar

You probable got the spyware from following a link from Google not literally from Google.

The Page you opened from Google was infected.

Ralph

Post a Reply

Please log in to post a reply.

Did you know that the microcontroller's crystal oscillator can be used to keep accurate time? Learn more...