Go Down

Topic: Oscillating output from op amp with analogRead (Read 1 time) previous topic - next topic

Wangmaster

Dec 20, 2018, 09:05 am Last Edit: Dec 20, 2018, 09:08 am by Wangmaster
I'm using a phototransistor in a common emitter configuration to capture the brightness of an LED. Since i'm operating on a pretty small range (due to the low brightness of the LED), I hooked up the PT output to an op amp in a non-inverting, negative feedback config, with the PT output connected to V+, a 10k R between Vout and V-, and a 220 R between V- and ground. So my expected gain is in the ballpark of 46x. My power supply is 5V.

I used analogRead(A0) on my UNO to read Vout, but the problem is that my reading oscillates significantly; with everything else stable a particular reading can oscillate between 2.51V - 2.76V with a period of around 1.5s. Strangely, I get stable readings with a multimeter, which means the problem may lie with the UNO board. I've attached a reading from the serial plotter where you can see the oscillation waveform.

Anyone experienced a similar issue before?

Data sheets for the op amp and photo transistor are below:
http://www.farnell.com/datasheets/77774.pdf?_ga=2.99844510.1425671045.1545189460-1042143356.1545094340&_gac=1.224949608.1545094340.Cj0KCQiAr93gBRDSARIsADvHiOrIiN1pT6AThobMblUDfuhl7Do5WS4tSfnYLRPXceyt5LSTOdakywcaAhpqEALw_wcB
http://www.farnell.com/datasheets/2243775.pdf?_ga=2.24282298.1425671045.1545189460-1042143356.1545094340&_gac=1.158162120.1545094340.Cj0KCQiAr93gBRDSARIsADvHiOrIiN1pT6AThobMblUDfuhl7Do5WS4tSfnYLRPXceyt5LSTOdakywcaAhpqEALw_wcB

amdkt7

A schematic drawing would help a lot. Op-amp circuits can be a little tricky. Figure 4-12 on the datasheet gives a circuit that should work for what you are doing.

JohnRob

My first thought is that a 1.5 second period is very very slow for an opamp.

Given not much information I might guess it is 60 HZ pickup (or 50Hz) that is being sampled at nearly 60 Hz or 30 Hz.  The result you see could be the difference frequency between the noise 60 Hz and the sampling frequency.

Your multimeter will filter out such variations.

Remember, the UNO A/D is like taking a flash photo of someone moving.  The photo will show the subject for only that instant.  Likewise the UNO A/D will take a measurement that is near instantaneous as far as your project is concerned.


Please do not PM me with thread based messages.  If your thoughts are worth responding,  the group should benefit from your insight.

outsider

Easiest way to make an oscillator is trying to make an amplifier and vice versa.  :)

Wangmaster

#4
Dec 21, 2018, 05:22 am Last Edit: Dec 21, 2018, 07:56 am by Wangmaster
I've attached my schematic so its clearer what i'm building.

My first thought is that a 1.5 second period is very very slow for an opamp.

Given not much information I might guess it is 60 HZ pickup (or 50Hz) that is being sampled at nearly 60 Hz or 30 Hz.  The result you see could be the difference frequency between the noise 60 Hz and the sampling frequency.

Your multimeter will filter out such variations.

Remember, the UNO A/D is like taking a flash photo of someone moving.  The photo will show the subject for only that instant.  Likewise the UNO A/D will take a measurement that is near instantaneous as far as your project is concerned.

I'm using a DC source, is sampling frequency relevant?

ChrisTenone

What, I need to say something else too?

amdkt7

I would start by removing Q1 and replacing it with a resistor, say about 1k. See if the circuit gives stable readings. It's possible that you are picking up flickering in your light source.

Also, do you have a decoupling cap across the op-amp power pins? Usually a .1uF. You might also need about 10uf along with that to smooth the supply. Both caps should be very close to the chip.

After that, a cap across the 10k resistor in the feedback (220pf might be a decent value), maybe even up to .1uf to slow the response and eliminate oscillations.

Op amp circuit layout can be very critical. Many schematics drawings are perfect, but how the parts are laid out will ruin the design. A picture of your project might help a lot.

MarkT

I'd say its 95% likely this is mains frequency variation in the stray light aliased down to 0.6Hz by sampling not
quite at a multiple of 50/60/100/120 Hz or whatever.  So what is the sampling rate?
[ I DO NOT respond to personal messages, I WILL delete them unread, use the forum please ]

Idahowalker

Strangely, I get stable readings with a multimeter, which means the problem may lie with the UNO board. I've attached a reading from the serial plotter where you can see the oscillation waveform.
Not strange at all. Look at the specs for your MM. You may find that the MM has a high input impendence. With that bit on information you may want to look into matching, more closely, the input impendence of the A:D.

Think of your MM as a resistor that you are putting between the measuring point and ground.
1/18/2018, got my first Arduino Uno.

Paul__B



I'm using a phototransistor in a common emitter configuration to capture the brightness of an LED.
Interesting notation.  I believe you meant "emitter follower", but really with the bases not connected (as there is rarely any reason to do so and newer devices do not offer a base connection,) there is no actual distinction; they are merely a two wire polarised component.

TomGeorge

Hi,
How do you know the period of the oscillation is 1.5s?

You can use the Serial Plotter as the x axis is not a constant time base.

Thanks.. Tom.. :)
Everything runs on smoke, let the smoke out, it stops running....

ChrisTenone

Hi,
How do you know the period of the oscillation is 1.5s?

You can use the Serial Plotter as the x axis is not a constant time base.

Thanks.. Tom.. :)
OP posted the graph below, but the axes have no labels:


The period seems to be 25 of whatever the x axis is.
What, I need to say something else too?

TomGeorge

Hi,
Each point on the X-axis is a Serial.print statement, so it will be loop time.

Not a constant time interval, with Serial speed thrown in.

Tom... :)
Everything runs on smoke, let the smoke out, it stops running....

Southpark

Maybe could try putting a 5 or 10 microfarad capacitor in parallel with your 20 kohm resistor, and see what happens.

Wangmaster

Hi,
How do you know the period of the oscillation is 1.5s?

You can use the Serial Plotter as the x axis is not a constant time base.

Thanks.. Tom.. :)
Yup i know the serial plotter axes arent that reliable, 1.5s period is from my own timing.

Im also quite confused, im using a DC source here, is impedence relevant in this case? Or is my 5V arduino power an oscillating DC source?

Go Up