Story

I created this project a couple of years back, just as an exercise as part of learning Op Amp. I was following this playlist about Op Amps by a youtube channel called "All about Electronics". Having just finished video about Op Amp as a differential amplifier, I looked at what analog components I had :

It sparked an idea if Op Amp can be used to drive RGB led based on change in orientation of accelerometer.

ADXL335 output waveform

Referring to datasheet for ADXL335, the sensor measures full-scale range of ±3g, with output voltage level of 0V to 3V. That means -3g of acceleration about given axis will give output voltage of 0V about that axis. similarly, for +3g will give 3V, 0g will give 1.5V.

You can refer the characteristics graphs in datasheet.

Linear Approximation Of Accelerometer Output (for given axis)

Just for the sake of simplicity, I quickly derived following linear equation for output voltage vs load-factor (acceleration in g), based on 0 to 3V output for -3g to +3g load-factor. This is just an approximation and will differ from the actual accelerometer output.

Actual Measurements

Based on above equation, when accelerometer is placed in level plane, with x and y axes located in horizontal plane and z axis in vertical upward direction, then

But the actual values for horizontal plane measured using a Digital Multi Meter (DMM) were (Vx, Vy, Vz) = (+1.74, +1.74, +2.05) V, so there a bias (offset) of approximately +0.25 V about both X and Y axes (with respect to our linear approximation model).

Also, I tilted the accelerometer module along both x and y axes for a moderately large angle on both sides and voltages about both these axes were in range of +1.55V to +1.95V, symmetric around the horizontal position (+1.74 V).

So, we will design our circuit keeping in mind that accelerometer voltage output about x and y axes will be somewhat in the range of +1.75 ± 0.20V (or +1.75 ± 0.30V for larger tilt angles)

Simulation

I decided to design a circuit, with following particulars :

Below are the results of the simulation of a differential amplifier on Falstad Circuit Simulator, I have used ratio R2/R1 = 1000/100 = 10, hence difference between Accelerometer Output and Reference voltages will be amplified by 10 times.

Op-Amp Output Voltage
= (R2/R1) * (Accelerometer Output - Reference voltage)
= (1000 / 100) * ( (1.75 ± 0.2) - 1.2V )
= (10) * ( 0.55 ± 0.2 )
= 5.5 ± 2 V
= 3.5 to 7.5 V

Note that the 100Hz simulated sinewave as accelerometer output in above simulated circuit has nothing to do with the 0.5Hz to 1600Hz range of ADXL335 (as per mentioned in datasheet), but this is just to test the output of op-amp against the expected voltage range from accelerometer.


Try on Breadboard (before building on Prototyping Board)

I tried the above circuit on breadboard (for X-axis only) with few changes :

Although I don't have any photos of actual bread-board circuit, but below is the more or less equivalent simulation and it didn't work as expected. We can see why ...

There are mainly two reasons :

Lesson Learnt (Buffer Signals Before Using Them)

while looking for solutions to aforementioned two reasons, I came across this StackExchange post, the solution was to buffer the voltages (using op-amp as a voltage follower/buffer) before providing it to next differential op-amp. It is not that I was not aware of op-amp as a voltage follower, but never thought about its practical application.

I quickly corrected my breadboard circuit by buffering both the ADXL335 X-axis output and 1.2V reference voltage from voltage divider, and it worked like a charm ! Below is the equivalent simulation of the same circuit, note that I haven't buffered the ADXL335 X-axis output in simulated circuit, because it doesn't make any difference.

Final Circuit

Below is the final circuit diagram, photo and video demo. Please don't mind the quality of soldering work and wires, it is one of my first circuits.


References and Tools Used

Further

I could have further extended this project to actually correct bias of accelerometer using a differential amplifier and further use the corrected output to drive some mechatronics stuff. But this was never the aim, I created this circuit plainly for fun, test my understanding and to realize what it takes to go from Theory > Simulation > Practical Circuit.

Thank You

Thanks for your time, if you have reached here. I am not an analog electronics engineer, but yet I find all the analog magic interesting. Being my very first Op-Amp project, I created this project based on my understanding after referring only a little amount of learning content online. Many of details I have mentioned in this article could be incorrect/misleading. Thanks in advance for any corrections/suggestions/constructive criticism.