# Sensing millivolts about a 2.5v reference

Hi everyone.

I'm hoping someone can point me in the right direction. I'm trying to read the output from an original playstation 3 controller thumb stick that uses 4 pin hall effect sensors. 2 pins are for 5v and ground, the other 2 pins are the outputs.

The outputs are approx 2.448v (507) when neutral but as you move the thumb stick, one output increases voltage to a max of about 2.517v (523) and the other output decreases to a min of about 2.382v (494). when you move the thumb stick in the other direction the voltages change. To put it another way, each of the outputs show a min of 2.382v and a max of 2.517v opposite to each other depending on if you move the thumb stick left or right.

What i would like to know is how to bring these values in line with something the arduino can effectively measure. With a reference voltage of 5v for analogue read, how can i bring the thumb stick readings to a min of 0v (0) and a max of 5v (1023)?

Before anyone suggests just using one of the many analog pot versions, i don't currently have any project in mind for this, i'm just curious about how to make the 4 pin hall effect version work and using it as a learning exercise.

The thumb stick i'm using.......

http://www.ebay.com/itm/4-Pin-Analog-Stick-Button-Replacement-Toggle-Switch-For-Sony-PS2-PS3-Controllers-/281437715567

Thanks

op amp difference amplifier

Hi,

What DaveEvans is suggesting is there is a special type of analog amplifier that is designed to accurately amplify the difference between two voltages. They are called differential amplifiers. Beware, the "differential amplifiers" found on eBay are not real differential amplifiers (aka DiffAmp).

With such a device you would create a two resistor voltage divider from the same supply as your joystick. The resistors would be chosen so the result is .... say 2.300 volts.

This would go into the (-) input of the DiffAmp.
Your joystick voltage would go into the (+) input of the DiffAmp.

With the DiffAmp gain set at 10, the output would go from:

(2.382-2.300)*10 to (2.517-2.300)*10

JohnRob

Fantastic. Thanks for your help. Ill get on it right away

So i think i’m on the right track. I currently have the circuit set up as per the attached image. Ive tried to set it up as suggested by JohnRob. It’s still not quite right though.

The 16k/15k voltage divider should put a voltage of 2.42V on the - pin and the 2.7k/100k divider should set the gain at 37.

Im reading a neutral voltage on the output of 2.9V and a spread of about 800mV either side giving a min of 2.193V and a max of 3.675V.

I’ve tried multiple resistor values and online calculators and just can’t seem to get it right. What am i missing?

Is it the opamp (OPA2132) i’m using? It’s just one i had in my parts draw. Or i have just completely miscalculated?

Also, the diagrams for differential amplifiers that i’ve been looking at online show another divider on the + input. I currently have it connected directly to the hall effect sensors output as per JohnRob’s suggestion.

Thanks again!

JohnRob:
Hi,

What DaveEvans is suggesting is there is a special type of analog amplifier that is designed to accurately amplify the difference between two voltages. They are called differential amplifiers.

"Instrumentation amp" is what you call it if you know your stuff though, designed for extremely
low input-offset error and very good common-mode rejection, as used for strain guages, thermocouples
and hall-effect elements.

Using any old opamp in the differential amp configuration may not be good enough.

Hmmmmm. Curious. I'll look in to it.

Thanks

BTW there is no 2.5V "reference" here - only the difference in voltage between the sense terminals matters.

Great, thanks for your help. My local Jaycar stocks these.....

https://www.jaycar.co.nz/ic-ina126pa-micropower-instrumentation-amplifier/p/ZL3976

Will pick one up tomorrow and have a play

Remember that most op amp circuits (including an instrumentation amplifier) implicitly assume dual polarity power supplies. Converting them to single supply usually requires a bit of thought. Fortunately this TI datasheet is good. The REF pin (#5) sets the 0 output, so you’ll probably want to drive that at VCC/2 with an op amp buffer. That way, when there’s no difference between the two inputs, the output will be at midscale instead of 0.

You should also look at the AD623 it is much better at single supply operation. The INA126PA can be made to work with some effort, but will be limited on how much useful signal you can get.

As Jiggly-Ninja suggested, the limit is: “Common mode voltage range” you can see it in section 6.6 of the spec sheet.

Basically is says the inputs must remain between +/-11.5v went the power supply is +15 and-15 Volts.

Stated another way, the inputs cannot be closer than (15-11.5) 3.5 volts from either power supply. Not good for your application unless you want to use a +/- supply.

Having said all that, the INA amplifier is really low power. If you want to run with +12 V (arduino RAW) and -9 v (battery) it will likely work for a long time. But wouldn’t as slick.

Also I don’t know your parts limitations in NZ. I know eBay has some AD623AN’s for < \$5

JohnRob

1/ Your gain calculations are wrong, because you haven’t taken into account the impedance of your reference chain - 15k|| 16k ie about 7.74k. Hence your gain is about 11x

Your input signal range is about 130mV, and you want an output swing of say 4v ie a gain of about 25- 30x

Try the enclosed. If you want more gain, increase R1.

A r-c input filter of perhaps 10k/100n may be necessary to reduce noise.

Varying R4 adjusts the midpoint, and alters the gain slightly

Allan

preamp.pdf (15.7 KB)

Actually a bit better like this :

And increase /decrease R1 for more/less gain.

A LM324 would do with a 10k pullup to +5 on the output if you have a high impedance load eg an arduino analog input.

Allan

preamp1.pdf (16.1 KB)

JohnRob:
As Jiggly-Ninja suggested,

No L!

Basically is says the inputs must remain between +/-11.5v went the power supply is +15 and-15 Volts.

Stated another way, the inputs cannot be closer than (15-11.5) 3.5 volts from either power supply. Not good for your application unless you want to use a +/- supply.

That cannot be the correct interpretation, otherwise the amp couldn't work down to its lowest recommended voltage rating of +/- 1.35V (2.7V).

If I'm interpreting Figure 6 correctly, for a single-ended 5V supply the input common mode range is about 1.5-3.5V.

An instrumentation amplifier is way overkill for this though. A differential input ADC with a programmable gain amplifier is enough, and you won't have to worry about the external circuitry.

This is great! I guess im getting my learning exercise!

Ill see what other opamps i can get for cheap locally and perhaps order some more on ebay. They'll take a few weeks to arrive of course.

Ill see if i can tweak my OPA2132, if for no other reason than to observe what happens!

I guess this is why i cant find anyone else who has used these thumb sticks! Analog is so much simpler!

Fun though!

Thanks for eveybodies input!

The OPA2132 is really designed for split rails and a much higher supply voltage than 5…

Pain in the neck waiting weeks for parts.

If you’ve got a handful of transistors/ resistors, try this discrete solution - gain about 32x
centred on 2.5 v in and out.

Allan.

preamp3.pdf (18.9 KB)

Thanks allanhurst.

I should be able to suitably messy up the kitchen table putting that together haha. I have some 2n2222's handy so will have a go at this as well.

;D

Pretty much any silicon small-signal NPN's and PNP's would do.

(edit) ... I presume you noticed Q4 is a PNP. And a small capacitor ( 1n?) between Q2's base and collector would ensure stability.

Allan

So..... Great Success!!

I grabbed a couple of LM324 opamps and using allanhursts schematic i can get some very usable readings.

Neutral is about 2.43V (500), Min is 0.68 (139) and Max is 4.41V (914).

I didn't have any 1k pots so i'm using a 2k. This adjusts where the neutral voltage sits and shifts it up or down essentially adjusting where the thumbsticks dead zone is. Either at the top end or at the bottom end.

The neutral shifts slightly depending on whether you center the stick after having moved left or right but i assume this is just due to a bit of mechanical sticking in the linkages. Nothing a bit of butter in the hinges won't fix.

I'm overseas for a couple of weeks tomorrow evening so won't get a chance to try the transistor method until i get back.

Thanks for your help everyone. Great fun!