Monday, March 28, 2011

Good Hall-effect Sense


My original plan for the accelerator was to 'borrow' a potentiometer from the pedals that came with the wheel and somehow (I hadn't worked out exactly how) rig it up to the pedal I am making. In the mean time, whilst researching electronic stuff I came across talk of 'Hall Effect Sensors' being used in various home-made joysticks and peripherals.

I couldn't find any 'how to' guide on using a Hall-effect Sensor (here on known as 'HES') in a set of driving gaming pedals but I did find a nice explanation from someone who had used them in a home-made flight sim joystick. Kudos to who ever this was.

I noticed when I was ordering stuff from the 'technobots' website that they had Hall-effect sensor called the 'Allegro A1301'. I took a look at the data sheet for these and thought they might work. Unfortunately these were not available from 'technobots' at the time, but I did get some neodynium magnets (these are much much stronger than the normal 'fridge magnets') to use with the HES. The ones I got are 6.4mm diameter x 4mm

I ordered the Allegro A1301EUA-T (SIP-3 package) from 'Rapid' – one of the big electronic component retailers on the web. This stuff was relatively cheap: The sensors cost £0.63 each (I got two) and small neodynium magnets were £0.70 each (I got two). 

Hall-effect sensor and Neodymium Magnet


I rigged up a test circuit now: the problem is that I did not know how much effect the magnets will have on the sensor at what distance. If the magnets cause the voltage to reach maximum from a metre away, or don't show any effect until 1mm away, then there is a bit of a problem.

I rig up the circuit using a tiny bit of strip board, a 3-way PCB terminals (5.08mm pitch), some individual wires from the left-over 9-core cable I brought, a 0.1uF capacitor and the mighty 'Allegro A1301 Continuous-Time Ratiometric Linear Hall Effect Sensor IC'. I solder in the terminal, solder in a capacitor across the power supply and ground (I have no idea the capacitor is necessary, but I'm using the same thing for the loadcell amplifier circuit so decide to do it here. If its not needed, then a capacitor won't do any harm in a DC circuit).

The thing to understand here, is that the A1301 is an integrated circuit and so any amplifier gubbins is already inside the tiny little sensor – which is only about 4mm wide. To fit it onto the strip board I have to carefully prize the pins apart a little to fit them into the 2.54mm pitch holes. I'm so busy thinking about how small it is as I solder it up, I solder wrong, offsetting each pin one row on the strip board. It's only until I've connected it up to power supply and wonder why the output voltage isn't changing that I realise what I've done. I thought I was being so clever as well, for spotting that one of the end pins is the output and not the pin in the middle, as you might expect.

After a brief resolder, I get the circuit connected up to the wheel. To connect the test circuit up I have plugged the USB connector of the DFGT wheel unit into my PC, then plugged in the d-sub of my custom made cable into the wheel unit. At the other end of this cable I connect the black, red and white wires to the correct contacts in the PCB terminal on the circuit. A short length of wire is also fitted into the terminal so I can easily connect up the multimeter. The circuit will still work even if the power supply isn't connected to the wheel unit as this only powers the force feedback motors anyway.

When I switch on the voltage across the power supply and output shows 2.5V (approximately). From reading the A1301 datasheet this is what I expected: no magnetic field applied causes the output to be half the supply voltage.

With trepidation I take one of my neodynium magnets and move it towards the sensor. At about 2.5cm away the voltage starts to drop, as the magnet is almost touching the sensor the voltage has fallen all the way to 0V. Success! The things work! 

Without Magnet

With Magnet. Voltage would be 0V if the magnet were directly underneath the sensor

I do a bit of experimenting with positioning, twisting the magnets, seeing what effect using two magnets has etc. The best way to get the full range of voltage was to have one magnet behind the sensor and another magnet on top. As the first magnet moves closer the second moves away. As, there are two poles on every magnet, flipping the magnet to the other side causes a voltage increase instead of a voltage drop.

So my plan is: when fixing this up to the actual pedal, I will have one magnet causing a voltage increase close to, almost touching, the sensor when the pedal is at rest. When the pedal is pressed this magnet will move away from the sensor and the second magnet (causing a voltage drop) will move closer. I find the distance of motion should be around 4-5cm from moving from the first magnet to the second. Not sure how linear a response this will give in the game, but on the multimeter it looks fairly good.

I should say that I reckon the sensor will work with just a single magnet, due to the way the pedal output is automatically calibrated to a full range of throttle response in the game. Using one magnet in this 'forwards, back' motion way, means that it is only possible to get a maximum voltage change of 2.5V.

I haven't tried it myself, but I reckon it would be relatively simple to replace the pots in the dfgt pedals with these Hall-effect sensor and magnet set-up. All that would be needed would be to find a way to mount a magnet somewhere on the moving pedal so it moves from about 25mm to almost touching the HES as the pedal is pressed. Wiring the HESs would be easy as they can just be swapped directly with the potentiometers. 



Small Set Back:

One thing I came across when doing this was that the d-sub 'hood' which I used for my custom cable (see last post). The size of the d-sub hood covering the plug - as in its length and thickness, means that it is too large to allow the plug to fit the socket when the wheel is clamped down on a flat surface. Looking at the socket for the d-sub connection on the DFGT wheel unit, it is angled slightly downwards, enough to stop the plug fitting. I hadn't noticed this before when testing with the wheel clamped to my workbench.

Looking at the d-sub hoods in the shop - seems like they will all be too large. As a first attempt at a solution, I hacksaw the d-sub hood in half. This is still too large to fit comfortably. I use just the top half of the sawn-in-half d-sub hood and fix the plug in place using black insulation tape. Rather than being a professional looking d-sub plug, I now have what looks like a ball of black insulation tape. Not quite how I wanted it, but at least it works for now. In the mean time I will keep an eye out for a smaller d-sub hood (like the one on the DFGT pedals).

No comments:

Post a Comment