Tutorial Present By member julian265
OVERVIEW
I'd like to share two ideas. Firstly, an easy, cheap, and flexible way to get a linear
output proportional to angle from hall effect sensors and magnets. Secondly I found
the basis of a solid joystick, which is commonly available, and has most of the
challenges in making a gimbal already taken care of - a universal joint from a car's
drive line.
The sensing method shown later is not new, however, either there's no explanation
of this arrangement in the joystick-modding community, or I've managed to miss it!
PARTS
This stick is based around part of a car's propeller shaft and a universal joint, which
I obtained at no cost from a friend's junk pile. The cheapest place to find these is
probably your nearest self-serve car wrecking yard (ie breaking yard, pick-a-part,
pick-n-pull, etc). Almost all rear-wheel drive cars have them between the rear axle
and gear box. Most/many joysticks use universal joints too... But they're often
plastic, and often have free play (slack) between joystick movement and sensor
movement. This stick has no sensor slack, and never can have.
I ordered Allegro A1321EUA-T hall effect sensors from Farnell online. The 1321
was desirable due to it's sensitivity - 5 mV/G, compared to the popular honeywell
SS49x series, which are around 3mV/G. The 1321's were also cheaper (around AU $2).
(Take care to get the 1321, not 1322 or 1333... they're less sensitive) The
1321's output is between 0.1 and 5 V, so it's suitable for use without amplification.
I bought 25 8 mm cubic magnets on eBay for AU$16. You need the neodymium
AKA "rare earth" kind. The cubic shape makes for easy mounting, and the 8 by 8
mm surfaces allow easy (forgiving) orientation of the hall effect sensor, when
arranged in the way shown later on.
A cheap joystick can be butchered for it's grip and buttons, or you can make your
own, or even use a real hand grip (thanks Dutneall!!)
Finally you need an interface between the buttons and sensors, and the computer.
You can butcher an existing stick to use it's electronics, replacing it's potentiometers
with hall effect sensors (they're compatible), or use something like Leo Bodnar's
brilliantly simple BU0836. Warning - wiring up a USB device like this gives you
access to the computer's 5V supply. Be VERY careful not to short it out, else
you might kill your computer.
PARTS (continued)
This stick is based around part of a car's propeller shaft and a universal joint, which
I obtained at no cost from a friend's junk pile. The cheapest place to find these is
If you were to rotate the sensor through 360°, you'd see that the output is a sine
wave, however over a restricted angle range, the output is as close to linear as
you could want. (Only a very slight sinusoidal in?uence is visible in the graph... I was
surprised my rough measurements picked it up!)
The following explains the how and why it works.
Hall effect sensors like the 1321 measure the strength of magnetic field at a right angle
to their surface. With no field near by (or if the sensor is parallel to the field lines), they
read 2.5V (or the middle of supply voltage, and reference). As the field starts to flow
through the sensor's face (due to the proximity of a magnet, for example), the output
rises or lowers based on the direction it is flowing through the sensor's face. The following
pictures show and explain what I think is the best way to arrange the sensors and magnets.
The real thing. For this axis, the magnet stays still, and the HE sensor rotates about the dowel's axis. (sensor is in blue for clarity)
The joystick moved to different angle:
I used a different mounting board later, to allow easier adjustment)
So this is what you see in the above picture:
And now looking down the sensor's center pin:
Above: Sensor parallel with magnetic field flow - no flow through it's face, therefore output is centered at 2.5V.
Above: The sensor is inclined so that magnetic field is flowing into the top face and out of the bottom, therefore it's output changes (eg. below 2.5V)
Above: The sensor is inclined in the opposite direction, therefore the field is flowing into the bottom face, and out of the top, so it's output is also in the
opposite direction (eg. above 2.5V)
The output voltage varies proportionally to the angle of the sensor. In the 1321's
case, between 0.1 and 5V. I have found this range to work fine with the BU0836,
without using ampli?cation or the chip's "zoom mode", though you can always
calibrate the stick through the game controller control panel, or DI View.
On the faces between the north and south poles, the field lines will be fairly well aligned
parallel with N-S axis. Therefore the placement of the sensor relative to the magnet's face,
or the axis of rotation is not minutely critical. If you center it by eye (like I did), you'll be fine.
Apart from the ease of construction, this method of angle sensing is also easy to tune to
your needs. The closer the sensor is to the face of the magnet, the more sensitive to angle
it is. To adjust the center position, you can either rotate the magnet or sensor.
MECHANICAL CONSTRUCTION
The shaft and joint shown is the rear-most one from an 80's Volvo 240. Larger and
smaller ones can be found on different cars, or even in different positions along the
driveline. Small ones can also be found in the steering column, which may be more
suited to being used in a joystick than this one. I like the fact that I'll never break
this one. It's even got new bearings... good for few hundred thousand km!
Return springs could be ?tted to each axis, however I ended up setting the new
bearings tight enough so that the stick holds whatever position it's left it in. I prefer
this over a self centering stick - it makes maintaining a chosen attitude quicker and
easier, especially on planes that lack trim.
The movement range of the stick is set by the uni joint. No extra parts were needed
in my case, as I got about +/-24° for each axis, and a square limit of movement - just
like any other stick. Should it be needed, more range could be achieved by
grinding back the areas which touch and stop movement, less range by packing them up.
The aim is to measure the angle between each yoke (or bearing cup) and the
spider (cross). To do this, the magnet is placed on one, and the sensor on the other.
The above magnet/sensor relationship requires that they both be on the axis of
rotation. To achieve this, I needed to bring the spider's movement out into an
accessible area. In other words, I needed to run a shaft from the spider,
out through the bearing cup.
The grinding of holes requires the universal joint to be disassembled, to avoid getting
metal dust into the bearings. Disassembly can be a challenge (lots of
hammering and force), but there's plenty of info on the web about it, or any
mechanic should be able to do it in half an hour or less (make sure none of the
rollers are lost). The spider and bearing cups are hardened, and impossible to drill with
average tools. So I used a dremel tool and grinding stone grinding bit to get
through them. (It didn't take too long)
I found some wooden dowel which fit tightly into the existing holes of the spider,
and glued magnets onto the dowels' ends. Take care to orientate the N-S axis at
a right angle to the dowel... it won't work if either N or S is facing the dowel. To ?nd
out the magnet's N-S axis, hold the magnet near to another identical one. They'll
quickly spin such that one's north is facing the other's south. It doesn't matter which
way you ?t them, in N-S or S-N... if the axis is reversed, you can invert it in either
your BU0836 or equivalent interface, or in the sim. If for some reason you do
require a particular orientation, you can always rotate the dowel through 180° later,
if you get it wrong the ?rst time.
The flange makes mounting the stick convenient. You can't see them well in the above pic,
but there are two bolts holding the stick down. When it was all finalised, I used four
Apart from the smoothness and lack of wear, this arrangement also has an
advantage in its ?exibility. Joystick center position, and sensitivity can be adjusted as in the pic:
Screwing the bolt in and out brings the sensor closer or further to/from the magnet, hence
raising or lowering sensitivity. There's another lock nut hidden under the circuit board, which
the yellow line is pointing at.
In the pic above, you can also see an aluminium guard. These are essential to prevent the
sensor from being knocked, or worse - shorted (which could kill your USB interface, or even
computer). Being aluminium, they won't affect the magnetic field either.
Next page: The same method of angular sensing applied to some DIY rudder pedals. (Is there
nothing you can't do with aluminium C section?!)
I'll put a guard over that sensor eventually...
[/LEFT]