Ah, I think I have it. The spherical vectors may have components of X, Y and Z if converted to Cartesian coordinates, and the unit spherical vectors always have a length of one. As X changes (the motor shaft rotates) the magnetic field strength changes based on the sin and cos of X but only as it relates to the alignment of the magnet with the sensor (Rhat and Xhat). And after all that thought, yes, it makes sense that only the max and min matter anyway. The MLX90215 is interesting although the cost is more than what I expected. If you publish your programmer I'll put it up on the site so other people can make use of it. http://www.analog.com/UploadedFiles/Application_Notes/394309286AN263.pdf was an interesting read I'm thinking of trying something much simpler to start.. Just an LC oscillator with a little coil for the L placed next to an arm on the shaft of the motor. Then see if I can count the number of oscillations per unit time and detect changes as the motor is turned. The nice thing about an osc like that is if I drive it hard enough, the signal at the input pin is basically digital. --- James. > -----Original Message----- > From: piclist-bounces@mit.edu > [mailto:piclist-bounces@mit.edu] On Behalf Of Mike Hord > Sent: 2005 Feb 17, Thu 11:40 > To: Microcontroller discussion list - Public. > Subject: Re: [EE] Low cost encoder. Is it a compass? > > > Does "unit radius vector" (Rhat) mean the distance from the > magnet to > > the hall effect sensor? > > > Xhat is then the value we want to solve for? No, it must be > X we are > > interested in. So I don't understand what "unit vector of > deflection > > from the axis of the magnetic field" means. Help? > > First, a note on the names. If you're confused, they aren't > Rhat as in "rat", but as in "are hat". My physics prof > pronounced them as "are hat" or "eks hat", and so I naturally do too. > > Xhat and Rhat are usually written as X or R with a little ^ > over the top. > These are unit vectors; for example, in cartesian > coordinates, Xhat, Yhat, and Zhat would be vectors of length > 1 in the positive direction of the X, Y, and Z axes, respectively. > > It becomes far less intuitive in radial or spherical > coordinates. To visualize spherical coordinates, imagine a > point in space (the origin). > Any other point can be described by its distance from the > origin (R), rotation away from some meridian > (theta)(analogous to longitude on Earth), and by ascension or > declination above or below some equatorial plane > (phi)(analogous to latitude on Earth). Consider the magnetic > field of Earth: ideally (assuming Earth is a perfect sphere > with the magnetic poles at the geographic poles), at all > points on the equator (different values of theta), the > magnetic field strength is the same. Move in phi or R (move > towards one pole or the other, or move closer or farther from > the center of the dipole) and you'll see a difference. > > So when I say unit vector of deflection from the axis of the > magnetic field, I'm saying that it is a vector, of unit > length (1), which takes an otherwise scalar value and assigns > it some meaning. That is, the sinX portion contributes based > on the angle between the position of the sensor and the > central axis of the magnetic field. It's tough to visualize > a unit vector of dimension whose magnitude is stated in terms > of an angle. > > > Once I understand the math a bit better I can start the > hell of trying > > to solve for X and convert it into code. > > May not be necessary. After all, the magnet will change > character over time, and two different magnets in different > devices will not be identical. > > What you're really after is maxima and minima. When the > value is at its maximum, it is 180 degrees rotated from its > minimum. At 50% of the difference, it is halfway between. A > few easy to calculate points in the middle (30 degrees, 45 > degrees, and 60 degrees spring to mind) may allow for your > device to self-calibrate. > > The math I did above was just a demonstration to show that > rotating the magnet will produce a time-varying field, and > that that field is in fact a sinusoid. > > > The need for the slope could be removed by having another sensor at > > 90' to the first? > > Yes. At the possible expense of making things harder, since > now you're dealing with two sensors, and doing math between > the two. I'm not convinced it's necessary. > > > Aside from being slightly less than human with regard to math (RAH > > says "people who don't understand at least calculus are at best > > sub-human") I'm also pretty clueless on analog electronics. > > This probably won't take a lot of heinous analog work. > Probably some filters, some amplification, but nothing that > can't come straight out of AoE or a little Radio Shack > Forrest Mims book. > > > Does anyone have a schematic for connecting a hall effect > sensor to a > > PIC in such a way that the reading is available as an analog value? > > All I can find are go/no-go sort of interfaces where the sensor is > > being used to count pulses. > > There are commercially available analog output Hall effect > sensors. A company called Melexis makes one that is actually > programmable; part number > MLX90215 (IIRC). I looked at using one for the project which > has had me thinking about magnetic fields so much, but even > it turned out to be too insensitive for my application. I > ended up with the GMR sensor, which was VERY sensitive > (rotation in Earth's field produces significant signal > deflection) > but has nasty hysteresis and can easily (very easily) be > damaged by exposure to excessive magnetic fields (even large > ferrous objects coming to close- for example, a screwdriver). > > The MLX90215 is available from Digikey, with several > selectable gains, for about $10. Or, if you prefer, you can > buy a $900 programmer. Or, contact Melexis and they'll (if > you plead enough) send you the programming specs for the chip > and you can knock together your own programmer (I did that; > it wasn't too tough). > > Mike H. > -- > http://www.piclist.com PIC/SX FAQ & list archive View/change > your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist > -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist