Thursday, April 7, 2011

Amplifier Circuit


This is a long post, but it explains as much as can about how I made the load-cell amplifier circuit.

Ok, so I did quite a lot of research on amplifiers in order to make this LC amplifier circuit. I hadn't done anything with electronics for quite a while and what I had done I had mostly forgotten. So I will try and explain this for someone in the who was in the position I was. I still don't fully understand everything but have managed to cobble together enough information to make a circuit.

First off, thing to know is that there are different types of amplifier. The type of amplifier used here is called an 'instrumentation amplifier'. With the more standard type of amplifier (which you will find in audio equipment, maybe on the end of your guitar lead) the amplifier takes a single signal as input, multiplies this signal by some amount (known as the gain) and gives the result as the output. What the instrumentation amplifier 'in-amp' does, is takes two signals as inputs, finds the difference between them, and multiplies this by some amount (“the gain”).

The Loadcell (LC) used is four resistors in a 'Wheatstone bridge' configuration. When the loadcell experiences a force, the resistance changes and so more current flows down one side of the bridge causing an imbalance which can be measured across the device. The way I imagine voltage, current and resistance is with a water analogy. Voltage is the force which makes the current flow - like a slope which the water is falling down. Current is the actual water itself and resistance is something which inhibits the flow of the water, like a partial blockage along a pipe the water is flowing through. The analogy doesn't quite work if you go a little deeper into electrical theory but it kind of gives you the jist.

Anyway, with a voltage across the wheatstone bridge due to a force on the loadcell, we must take this voltage difference between the two sides and feed it to an 'in-amp' where we'd like it to be amplified up to the couple of volts range.

From my testing of the DFGT pedals, I can see that the brake is wired such that when the pedal is in the up position (what I call 'at rest'). The potentiometer output (green wire) is very close to the +5V input (red wire). When the pedal is pressed down, the output moves closer to Ground (i.e goes towards 0V). Ideally, I'd like my LC and amplifier circuit to do the same - have a voltage around 5V with no force on the LC and move towards 0V when the pedal is pressed.(See later on as to why this is crossed out)

Of course the amplifier is not 'magic' in that it can't multiply 0.1V up to 5V without having a power supply of its own. It also can't multiply up to voltages beyond what you supply it with. So we will use the power supply (red and black wires) from the DFGT to power both the amplifier and the LC. Since the power provided by the DFGT is just +5V (known as a single supply, there is no -5V) we will use a amplifier that accepts a single supply.

So at this stage, I am looking for a in-amp which can work on a 5V single supply. Fortunately I come across several links on the web where people mention LC amplifier circuits for exactly this purpose. It seems that the favoured chip is one called 'INA122'. I also come across a guy selling ready made LC amplifier circuits online. If you have brought a LC and need an amplifier circuit it will almost certainly be cheaper, quicker and easier to go with the ready made option. I wanted to make my own, just 'cause, y'know, I could say I'd done everything myself.

OK, so now I know which chip to get, but there are still another couple of components that go in the circuit.

The most important of these is the gain resistor. The gain of the amplifier is set by putting a resistor across the top two pins. Depending on what resistor you put here determines the gain of the in-amp. If you search online for 'INA122 datasheet' you will see that the formula for the INA122 gain is something like (off the top of my head):

5 + 200,000/R

If the maximum output from the LC unamp'ed is around 0.002V (2mV) (2 millivolts) then to get to 5V this would have to multiply by 5/0.002 = 2500. When I work this out the value of R comes out at 80ohms. Which is quite a small value of resistance. I think I will go for 100ohms but will buy a couple of different value resistors so I can have a play around with what gain I use when the circuit is built.

From all the reading up on in-amps I did, there are another couple of components that I will include in the circuit. The first is a 0.1uF (pronounced: nought-point-one-micro-farad) capacitor. The capacitor is connected between the +5V and ground. If you remember from physics and/or electronics classes, the impedance (bit like resistance) of the capacitor is frequency dependent. If the frequency of the current is 0 (which IS DC current which we have here) then the impedance is infinite and so no current passes. So in affect the capacitor does not do anything when using DC current. Why put it in the circuit then? Well, the capacitors job here is to handle any frequency response from the circuit. It will cut out any oscillating feedback as it allows that to pass to ground before it gets going.

I also read that there should be a 'path to ground' for the inputs to help protect the chip from current build up. I will therefore use two 10k resistors, one going from each input to ground.

Sourcing the Components:

OK, so buying an INA122 in an actual physical shop is probably impossible I would say? So the only place is online. I found quite a few online hobby electronics shops that sell amplifiers but could not find one that sells the INA122. I should mention also, that the INA122 (as with a lot of these things) comes in different 'packages' the package I wanted was the DIP (dual-inline-pin) package. These will fit a 8-pin DIP socket which I have encountered before. There are also a number of letters after the INA122 (i.e INA122UA etc), I still don't know what these mean but for the record I got the INA122PA - perhaps I need to read the datasheet more carefully.

Ok, so the only place to get hold of these chips is from one of the big online electronics components retailers. There are a number that I considered; Mouser, RS, Farnell, Rapid. I ended up buying from Farnell. I spent ages putting together an order through Mouser but then got to the check-out and found delivery was a hefty charge. Farnell had a £20 minimum order but postage costs were more reasonable (just). I added an extra INA122 to the order so I'd have one spare incase I messed up or something. The chips cost around £7 each.

If you haven't done any electronic circuit building before (like I hadn't) then deciding exactly what components to get can take an awful lot of time and research. If you go onto the Farnell website with the idea that you're going to buy 'a resistor' you'll be confronted with tens-of-thousands of different 'resistors' that you can buy. I'm going to put a list of all the components I brought, (that I brought and ended up actually using more like) below along with order numbers/codes.

One thing I also got was some 'PCB Terminal Blocks'. These little deelys you solder onto the circuit board and then they allow you to screw in wires (you could solder the wires to the circuit board somehow but this would be much more time consuming and make things difficult to disconnect when you need to). It took me literally hours to find out what these things were called. The ones I got for the in-amp circuit were 2.54mm pitch ones, which is the same pitch as the strip board which I already had. When they arrived, these turned out to be really quite small but still usable for this circuit.

Parts I brought are:

  1. 3 way PCB terminal (2.54mm Pitch) (Farnell: 3041360)
  2. 4-way PCB terminal (2.54 mm Pitch) (Farnell: 3041414)
  3. 100 ohm resistor – any sip (Farnell: 1099867)
  4. 10 kohm resistor (Rapid: 62-0897)
  5. 0.1 uF capacitor (Farnell: 1100383)
  6. 8-pin DIP socket (Farnell: 1101345)
  7. Strip/Matrix Board (2.54 mm pitch) See photo: The stuff I got was from Maplins. It has rows of three connected holes. I adapted the circuit to work with this type of board. If someone tried to make the same circuit using a different type of board you would need to adapt it to fit. I'm told its possible to make your own printed circuit board (PCB) to suit, but I didn't want to bother with this so went with strip board instead. I think it may actually be called 'tri-pad' board.
  8. Wires (individual wires taken from the excess 9-core cable I brought)
  9. INA-122 (DIP package) chip (Farnell: 1459460)
    Strip-board looks like this
Don't expect to be able to buy components like resistors and capacitors in ones and twos. For example: I got a reel of 100 100ohm resistors which was the minimum order. The whole reel cost something like 95p. Having spares of these may come in useful later as it is possible to combine resistors in various ways to get new values of resistance. If you want to get rid of spare resistors why not take a couple, bend one end into a hook, put them into a jewellery case and present them to an earth female as “space earrings”.

Tools needed are: Soldering iron, solder, something to hold the circuit board steady as you solder, wire strippers/sharp knife. The chips come in a special anti-static packaging. As I am not very good at soldering I had a look on youtube for some instruction. Best video I found was this one by 'CuriousInventor'. Although it annoys me immensely that Americans seem to have universally not noticed the 'l' in solder and continually pronounce it as 'sod-er' .

It is important to avoid static electricity when handling these chips, you can have a static charge on you without realising it. The precautions I took were:

Not bothering with an 'anti-static' bracelet
Not wearing any polyester
Touching the cold tap a lot before picking anything up ('tis an earth connection see)
Not rubbing a (inflated) balloon up and down my sleeve

Seemed to work ok so far.

Designing the circuit:

The circuit is pretty simple. It has several features mentioned above: - capacitor across the power supply, path to ground for the inputs. The rest is just a case of connecting up what goes where correctly with regard to the pin layout of the chip. You will find the pin layout in the datasheet. 

My little hand drawn diagram

My little hand drawn diagram shows what goes where. The load-cell itself needs to have a power supply, this is done by connecting it in parallel with the amplifier circuit – which is why you can trace direct connections between +5V and Ground on the supply side to E+ and E- on the load-cell. (I don't think it really matters if you connect the power supply to E+/E- or V+/V- as long as it is across opposite corners of the Wheatstone bridge). I think 'E' stands for excitation voltage.

The gain resistor goes across pins 1 and 8. Simple.

The power supply (+5V) goes into pin 7. The ground connection goes into pin 4. The output is pin 6. In terms of the dfgt pedal wires: power supply is red wire. Ground is black. Output is green.

Pin 5 – the reference voltage is also connected to ground. The capacitor across the power supply goes between +5V and ground. On the load-cell side, the two inputs also are connected to ground although via a large resistor (10k ohms).

The two inputs go to pins 2 and 3. 

What the thing looks like


Making the circuit (1st attempt):

The electronics brains will have already spotted in the photo of the finished circuit that my colour coding is a little messed up on the load-cell side. The white wire from the load-cell is actually ultimately connected to pin 2 of the chip via green wires on the circuit board (and vice versa with pin 3). This happened because of a cock-up on my part when making the circuit. I had got the idea in my head – despite all the electrical testing I had done and written about so far – that the brake pedal had a high voltage/low resistance when the pedal is at rest. In fact it is the other way round – pedal has a low voltage but high resistance when at rest.

I had gone and built a version of the circuit with the load-cell inputs swapped and +5V connected to pin 5 (Ref). When I came to test this with the game, I found that it worked perfectly 'backwards' I.e the brake would be on when the pedal was at rest, but as I pressed the pedal the brake would start to be released. This kind of gave me a big clue towards what I had done wrong and it didn't take me long to fix everything – except of course, I didn't want to go to the trouble of swapping my white and green wires just so the colours would match.

Here is a picture of the 'backwards' circuit to confuse any skim readers: (Incidently if you did want to rig up a load-cell brake with a set of pedals that were wired up in the way I had thought the dfgt's were, then this would work perfectly).

"Backwards"


Making the circuit (2nd attempt):

Ok, so here is the finished circuit. Part of the problem, as mentioned above, was adapting the circuit to work with the strip-board type that I had brought. I don't know how easy/difficult it is to make a PCB – I didn't really look into it. There are different types of strip/matrix-board available but whatever the connections are what is important. 

Adapted to the board


I drew out the three hole row configuration of my strip-board onto a scrap of paper and then overlayed the circuit components. It is important to note how many holes things cover when they are placed on the board – for example the 8 pin DIP socket takes out 16 holes altogether – 4 holes each side for the pins to fit in and then the rest covers 8 holes. Its also good to know how many components can fit into a single hole. I found it easy to fit at least a couple of wires and a resistor/capacitor leg into a single hole – only complication then is keeping them all in place when it comes to soldering.

Before I did start soldering I drilled some holes in the strip-board and fitted some rubber gromets with a 4mm internal diameter: These are used to mount the circuit to the plastic box in which it now lives.

Underside of the circuit


When it came to soldering I scored some lines on the plastic side to mark out the positions of the rows. Components are fitted this side then soldered on the copper side. Once it came to soldering I found things came together surprisingly quickly and having the drawing there in front of me made knowing what to solder where quick and easy. When soldering the resistors and capacitors, I pass the pin quite far through, the snip off the excess with a pair of clippers once it is soldered in place. I did not solder the chip in – instead I soldered in the 8-pin DIP socket and then carefully plugged the chip into the socket. I'm not sure how well the chip survives soldering so took the conservative option. All the wires used are just offcuts from the cable I brought to connect the pedals to the wheel unit.

Testing the load-cell circuit:

The finished circuit (experimenting with 200 ohm gain resistance).
Well you will notice from this later picture of the circuit that the gain resistor is now no longer soldered directly into the board. It is also now no longer a single resistor but actually two resistors in series. What I did here was to desolder the original gain resistor (with use of a desoldering pump), cut in half a spare 8-pin DIP socket and solder that above the chip. There are two small jumper wires (seen in blue) connecting the sides of the DIP socket to pins 1 and 8 of the chip. I did this so it would be easy to swap the gain resistor by just plugging/unplugging into the DIP socket.

During testing of the brake pedal, I began to realise a few things about how the amplifier circuit can be used to configure the 'feel' of the brake pedal. Basically... the larger the value of gain resistor used, the smaller the gain; if you increase the gain resistor by a factor of 2, you need to press the pedal twice as hard to get the same braking force in the game. But, at some point, the output of the amplifier circuit will saturate at 5V; at this point pressing any harder on the pedal has no effect as the braking force is already maximum. With a small gain resistor, this happens quite quickly so a relatively soft pedal press gives full braking force. With a really large gain resistor this might not happen. There is a balance to be found. Due to the way GT5's automatic in game configuration works, I found it is actually desirable to get the amplifier output to saturate at 5V: without this happening the game would continually recalibrate the brake pedal to whatever the hardest brake press had been during that gaming session. By setting a gain resistance so the output does saturate at 5V, this acts as a buffer meaning once a brake press causing 5V output is detected, the game knows 'this is the maximum' and so any harder presses of the brake later on won't trigger a recalibration.

With respect to the braking force maxing out, this is also more like a real car in some respects: if you are pressing the brake so hard that all four wheels are locked (or ABS is kicking in), then pressing the brake pedal any harder won't affect the deceleration of the car.

Anyway, after a little bit of testing I have settled on a value of 250 ohms for the gain resistance. Those of you who remember anything from electronics will know that it is possible to make a 250 ohm resistor by combining four 100 ohm resistors (those spares did come in useful). I have two resistors in parrallel and two more in series with those. I think the maximum output from the load-cell may have been a few more millivolts than I originally thought, which is why the 100ohm resistor was too sensitive. Knowing how changing the gain of the amplifier affects the feel of the pedal is useful because I can relatively easily change the force needed on the pedal to get maximum braking effect. 


2 comments:

  1. What kind of loadcell have you used? And kg?

    ReplyDelete
  2. hello friends, how many watts of resistor are you using?

    ReplyDelete