Should I amplify this analog signal?

General project help for Adafruit customers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
User avatar
colinta
 
Posts: 12
Joined: Tue Apr 01, 2014 10:13 am

Re: Should I amplify this analog signal?

Post by colinta »

Thanks guys! I had the transistor in correctly in the circuit, I just copied it wrong in my drawing - thanks for checking on it!

Glad you liked the graph! I'm a programmer by trade, and I know that when bug reporting there's no such thing as "too much data". I was tempted to include measurements on multiple points, with different colored ink :-)

Sounds like my problem could be with the op-amp, tonight I'll see what my ranges are.

I tried to find more examples of this circuit online, I had a heck of a time, this is the best I could find: http://www.allaboutcircuits.com/vol_3/chpt_8/7.html - it's not much info, though, and doesn't use a transistor, but I thought it looked similar in concept at least.

User avatar
Renate
 
Posts: 291
Joined: Tue Nov 13, 2012 3:21 pm

Re: Should I amplify this analog signal?

Post by Renate »

Actually, the circuit is working fine (within the limits of its parameters).
The overall behavior of the circuit is inversion since you have a two non-inverting opamp layouts and a common emitter transistor.
The left "flank" of the "ditch" is the correct operation.

Consider if you just connected the two free ends of the 1k resistors together.
You'd get 6V at the junction.
So there is no way that the voltage going over the signal line can ever go above 6V.
When the output of the opamp on the left starts going above 6 V it starts pushing current through the base of the transistor out the collector.
This is the action responsible for the right "flank" of the "ditch".

The fact that the main output signal tanks out at 10V is related to the output opamp range.
You need to have the resistor that goes to ground on the right to go to a higher reference voltage to put the signal in range.

If this circuit is really supposed to be working as a constant current driver, you'll have to leave it some compliance voltage.
Constant current means the current is constant irrespective of the voltage.
Let's say you operate this circuit on a 1 mA peak signal current.
That means that each of those 1 k resistors would drop 1 volt, throw in 0.3 or so for the transistor, subtract from 12 V and you have 9.7 V compliance.
That means, you could stick a bunch of resistance in that signal line and still have the circuit happy.
You could even throw in a LED or two and the circuit would work fine.
Well, how about 10 mA peak signal current?
12 V / (1 k + 1k) = 6 mA, that's not going to work.
Ok, how about 5 mA?
5 mA across a 1 k is 5V, time 2, add 0.3, subtract from 12 = 1.7V
That 1.7 V could be lost at 5 mA with 340 ohms cable resistance.
Going back to the 1 mA scenario, we could laugh at up to 9700 cable resistance.

Let's rethink things a bit.
4-20 mA is an industrial spec, but we don't need to be that industrial.
Let's use 10 mA peak current.
We want to leave a nice chunk of that 12 V for compliance.
So let's lose 2V off each side (we could easily make the sides different).
A 200 ohm resistor for both sides would give us 2V drop at 10 mA.
We've got 12V - 2 x 2V - 0.3V = 7.7V compliance left.
That gives us a tolerance of 770 ohms on the cable.
You can test this circuit by throwing an LED in series with the signal cable and the circuit should behave identically.
(Still want 20 mA? Make it a 100 ohm resistor.)

Ok, so we changed the parameters of the current driver/receiver
What else do we need to change?
If we are only allowing the left current resistor to go to 2V, that means that the input to the opamp can only go to 2V.
We have to set the signal using resistors to not exceed this range of 0V to 2V.

On the receiver end, we need to bias the opamp (and add gain) such that the 12V-10V signal on the input gets converted to a useful range.

P.S. throwing an LED in series with the signal line is also a good check.
You should be able to see the brightness vary nicely as the current goes from 0 to 10 mA.
That way you can check the circuit even if you haven't got the range on the output opamp yet.

User avatar
colinta
 
Posts: 12
Joined: Tue Apr 01, 2014 10:13 am

Re: Should I amplify this analog signal?

Post by colinta »

Wow, Renate, thank you very much for such a detailed explanation! You could have easily said "use 100 or 200 ohm resistors", but I really appreciate that you explained WHY those values work, and how you came to that conclusion.

I played more last night, and the LED did "warm up", though I think I need to add offsets because I still have that "ditch" effect. More experimenting, and I think I'll nail it. :-)

User avatar
Renate
 
Posts: 291
Joined: Tue Nov 13, 2012 3:21 pm

Re: Should I amplify this analog signal?

Post by Renate »

Going from 1k to 200 ohm, just increases the current for the same input range.
The important thing is to limit the range of the input signal to a maximum of 2V.
Then you will see just a downward slope.
To get the output range where you want you'll have to change the setup of the output opamp.

User avatar
colinta
 
Posts: 12
Joined: Tue Apr 01, 2014 10:13 am

Re: Should I amplify this analog signal?

Post by colinta »

Ahhh gotcha! I'm gonna have to reread all this stuff when I'm done, to make sure it sticks! But now, rereading what you said, it's very obvious.

I can work with a 0-2V range - thanks again! If you ever need to write an iOS app and have questions I'll be able to return the favor! ;-)

User avatar
Renate
 
Posts: 291
Joined: Tue Nov 13, 2012 3:21 pm

Re: Should I amplify this analog signal?

Post by Renate »

Here's a variant on the output stage.
It will get you in the ballpark with a 0-5V output for a 0-2V input in the driver circuit.
It uses an inverting layout so the entire system is non-inverting.
photo.png
photo.png (4.11 KiB) Viewed 298 times
Another possibility is just to use an INA219 high-side current monitor and a single resistor.
That will give you a 12 bit readout over I²C interface.

Um, we might be going down the rabbit hole on this one.
Your problem is determining if it's light or dark outside.
I think that you'll find that your photo sensor is not going to give you useful information if you handle it in a linear fashion.
That is, you'll have to put an adjustment at the far end (the light sensing end) to set an offset.
I think that you'll find the resulting signal goes quickly from one end to the other.
That is, it will hardly ever be in the middle of the range.
You might as well just have the circuit deciding light/dark at the far end.
Throw in a bit of low pass, a bit of hysteresis and you're done.

On the hackish end of things, you might as well buy a inexpensive LED nightlight, put an optoisolator and a resistor across the LED and run the output in a pair of wires to your remote microcontroller.

User avatar
AlanCM
 
Posts: 20
Joined: Mon Dec 15, 2014 1:13 am

Re: Should I amplify this analog signal?

Post by AlanCM »

Many thanks to all for the fine discussion.

Alan

User avatar
AlanCM
 
Posts: 20
Joined: Mon Dec 15, 2014 1:13 am

Re: Should I amplify this analog signal?

Post by AlanCM »

Many thanks to all for the fine discussion.

Alan

Locked
Please be positive and constructive with your questions and comments.

Return to “General Project help”