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

Should I amplify this analog signal?

Post by colinta »

I've got a light sensor (LDR) that needs to run from the living room window, through the rafters, into the control box in the basement. So it's at least ~30ft of wire.

I'm wondering what I should do to make sure I get a decent reading. Should I use shielded wire? Should I provide a voltage source near the sensor? Should I setup the voltage divider at the sensor, with an amplifier to boost the output? Should I use a 741 for that?

I would love to hear some thoughts on this, or your experience with sending "long distance" sensor readings.

If you're so inclined, I'd also be interested in what to do about a digital signal - though in that case it seems like I could use a buffer at some point as the "amplifier," but maybe that's naïve.

Thanks guys!

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

Re: Should I amplify this analog signal?

Post by colinta »

I've made some progress. Looks like a differential signal would be ideal, and it seems like a relatively straightforward solution... except I can't find *any* examples of this online! So frustrating to just find datasheet PDFs.

So I'm guessing that I need one amplifier to invert the signal, and another at the microcontroller that combines (via subtraction) the two signals to produce one clean analog signal.

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

Re: Should I amplify this analog signal?

Post by Renate »

LDRs are fairly high impedance thingies.
If you wanted to run that a distance you would want to use shielded wire at least.
A better solution would be to come up with some way to have the signal output be low impedance.

What's the purpose of the LDR?
Do you need to only detect sudden changes or have a large dynamic range?

If it's large dynamic range, a photodiode, a log amp and a buffer might be a solution.

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

Re: Should I amplify this analog signal?

Post by colinta »

The bigger story: I'm hooking up LED strips to the basement stairs which are activated by two force-sensitive resistors (and those signals *also* need to be sent to the controller). The LDR acts as a shut-off if it's light outside.

I'm using FSRs instead of an infrared trip-beam because I want to detect weight: adults vs children. Kids will get a fun light show with an audible sound. Adults get the "grown up" version.

So no, not sudden changes, very gradual actually. Essentially I just need to know when the light intensity drops below a threshold. I considered using a real-time-clock for this, but the problem of sending analog signals (from the FSRs) still remains, and the LDR seemed like a simpler low-tech solution (low-tech is the best tech!).

Thanks, Renate!

User avatar
zener
 
Posts: 4567
Joined: Sat Feb 21, 2009 2:38 am

Re: Should I amplify this analog signal?

Post by zener »

I would try the shielded wire at first and see how it goes. That may be good enough. The wire resistance should not be an issue compared to the sensor resistance. I am not sure the FSR's will work reliably, as far as sorting out kids vs adults. It may be possible but may require some fiddling with both the code and the installation.

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

Re: Should I amplify this analog signal?

Post by colinta »

Thanks, Zener, that's good to know. It's not the end of the world if I can't detect those weight differences.

Simple shielded wire sounds good to me!

If anyone knows of an example circuit and components for a differential signal, I'm very curious about it! I won't use it here, it sounds like it would be overkill, but now that I heard about it, I'd like to see how it's done.

User avatar
zener
 
Posts: 4567
Joined: Sat Feb 21, 2009 2:38 am

Re: Should I amplify this analog signal?

Post by zener »

Differential signaling is typically used for digital communications. I think Renate was suggesting converting the resistance into a voltage. Specifically he suggested a log amp which might be a really good fit for the response of the FSR. Maybe you are thinking of a current loop such as 4-20 mA ? That is used for analog signals and is very noise resistant. In any case, you will need to decide how to interface the FSR to the micro.

User avatar
tastewar
 
Posts: 408
Joined: Thu Mar 17, 2011 10:16 am

Re: Should I amplify this analog signal?

Post by tastewar »

Hmm... Can't comment on the 'typically' qualifier, but differential signalling is widely used in the analog world for pro audio e.g., esp. on mic lines so that any interference affects both sides of the signal and can then be subtracted out on the receiving end. Here are some very basic circuits:

http://www.neatcircuits.com/audio/balanced.htm

Not sure how this applies to something that's just a variable resistance, though. (IANAee)

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

Re: Should I amplify this analog signal?

Post by Renate »

If you only want a simple light/dark measurement you can do the whole slicing at the far end.
That means that only a binary value would have to go over the wire, simple.
On the other hand that means that you would need to set some adjustment at the far end for how light is "light".

Since you only want to know if it's light out you hardly need any bandwidth to the system.
That means that if you do ship analog over the wire you can put a killer low-pass filter on the uP analog input.
That will get rid of any noise on the wires.

The log amp idea is a bit of overkill but would be kind of cool.
It could handle high noon but still differentiate full moon and new moon.
That would be a bit of a circuit challenge, Wikipedia says sun/full moon = ~400,000.
It would require two op amps (one dual package).

Wacko unrelated idea: Use a discarded cell phone with a camera.
Write an app to read the camera hardware AGC level and send updates over WiFi.
(Of course that would require your system to be networked.)

User avatar
adafruit_support_mike
 
Posts: 67485
Joined: Thu Feb 11, 2010 2:51 pm

Re: Should I amplify this analog signal?

Post by adafruit_support_mike »

I'm a bit late to the party, but the general rule for sending signals over long distances is "use current, not voltage."

Voltage is measured between two points in space, and as a side effect, you can pretty much assume that voltage will change any time you move the points where you measure it. The amount of change in voltage is usually proportional to the distance you moved the measuring points, so for small distances (within a few inches) the changes are small enough to ignore. The farther you move the measuring points though, the larger and harder to predict the changes become.

Current remains constant through a loop though. 1mA is 1mA whether it enters or leaves a resistor, LED, or any other component. That makes it a good long-haul signal medium.

If you're willing to use op amps, here's a basic current loop:
current-loop.jpg
current-loop.jpg (29.59 KiB) Viewed 666 times
On the left, the op amp buffers the LDR and uses the transistor to turn the voltage into a current. The amount of current depends on the size of the emitter resistor, and 4-20mA is the common industrial range.

On the right, the high-side resistor turns the current back into a voltage, which is buffered and amplified by the op amp. I drew a non-inverting amplifier but you can use any configuration you want.

You need to provide a return path for the signal current, and it's easiest to do that through the same cable. The VCC rails on the two sides can be independent of each other though.

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

Re: Should I amplify this analog signal?

Post by colinta »

@adafuit_support_mike this sounds like a very nice way of handling both the FSR and LDR signals! And I can use a common 741 opamp I assume?

As far as wiring the circuit, maybe you or someone can double check what I'm thinking here:

- I'll have a 12V power supply near these sensors (to power some LED strips). I'll use that to create voltage dividers for each sensor.
- I'll send each signal into its own opamp. The opamp will be powered by the 12V supply
- The sensor output will be connected to the non-inverting input of the opamp
- The output of the amp will be sent to an NPN transistor (2N2222?)
- "ground" will be a wire connecting the inverting output of the two amps, along with (pull-down?) resistors (what, 10k?)
- On the receiving end, I have an opamp powered by the 5V power supply I've got for the arduino.
- The 5V line is also connected to the non-inverting input with a pull-up resistor
- In the non-inverting configuration, I have a resistor between the output and inverting input.
- The output goes to my arduino, and I get a nice 5V analog signal!

I'd like to build this, if for no other reason than it sounds like a good circuit to have "on file". Can anyone think of any other considerations that I should take into account when choosing parts and values? (e.g. NPN part number, resistor values, Vcc values)

User avatar
adafruit_support_mike
 
Posts: 67485
Joined: Thu Feb 11, 2010 2:51 pm

Re: Should I amplify this analog signal?

Post by adafruit_support_mike »

colinta wrote:And I can use a common 741 opamp I assume?
Sure. You'll need to keep the 741's working range in mind when you design things (officially it can only go within 2v of either rail), but if you're already comfortable using them that shouldn't be any trouble.
colinta wrote:- I'll send each signal into its own opamp. The opamp will be powered by the 12V supply
Good. That will give you about 8v of working range, which should be plenty.
colinta wrote:- The sensor output will be connected to the non-inverting input of the opamp
Yep.. basic buffer.
colinta wrote:- The output of the amp will be sent to an NPN transistor (2N2222?)
Any small-signal transistor will work, and the 2N2222 is well-known.
colinta wrote:- "ground" will be a wire connecting the inverting output of the two amps, along with (pull-down?) resistors (what, 10k?)
The GND rails on both sides need to be connected to the negative supply rail, or at least to some low-impedance voltage rail referenced to the negative supply. The op amps won't do what they're supposed to if the negative rails are floating.
colinta wrote:- On the receiving end, I have an opamp powered by the 5V power supply I've got for the arduino.
The 741 may not be the best choice for that.. after you take away the headroom, it only has 1v of output range. My jellybean op amps are the MCP6001/2/4 family. Their performance is nothing special (though the specs are pretty amazing by 741 standards), but they're inexpensive, modern chips designed for 5v single-supply operation.
colinta wrote:- The 5V line is also connected to the non-inverting input with a pull-up resistor
Technically that's the current-sense resistor, or the collector resistor for the 2N2222 at the other end of the wire.

You'll need to play with your resistor values to get the levels and sensitivity you want, and there are several points of possible adjustment: you can vary the resistor in series with the LDR to make the raw input more or less sensitive to small changes in light. You can control the amount of current that flows through the loop by changing the value of the emitter resistor on the input side. You can control the sensitivity of the current sensor by changing the value of the collector resistor on the output side. And you can control the sensitivity of the output voltage by playing with the voltage divider that runs from the output to the negative input and then to GND.

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

Re: Should I amplify this analog signal?

Post by colinta »

I gave this a shot last night. Going into it I thought I really understood how this circuit worked, but when it came time to measure the output voltage I was stumped. I expected the output voltage to increase linearly with the input voltage, but instead I got this strange "upside down bell curve". :-|

This is not entirely surprising – seems like whenever I try a new circuit, it takes a few tries before it works. And after that it's hard to imagine how I ever did it wrong!

Vs = 12V regulated power supply. For the op amp I used an LM358. I thought I had a bunch of 2N2222's lying around, but I had 2N3904's handy instead. Resistor values are as marked in the schematic.

This should be equivalent to the schematic that adafruit_support_mike posted, but in case it isn't I wrote this one based on how I had things wired up on the breadboard. Looking at it now, it occurs to me that I don't have a negative rail on the op-amp, it just goes to 0V/ground.

The graph is a plot of "Vi" versus "Vo", as you can see from the table.

Does anything jump out as wrong here? Are there obvious places I could measure current or voltage that would help me figure out what components are wrong?
Attachments
OpAmp Current Loop.png
OpAmp Current Loop.png (673.15 KiB) Viewed 612 times

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

Re: Should I amplify this analog signal?

Post by Renate »

The transistor is in upside down.
Look at the original drawing.

User avatar
adafruit_support_mike
 
Posts: 67485
Joined: Thu Feb 11, 2010 2:51 pm

Re: Should I amplify this analog signal?

Post by adafruit_support_mike »

The upside-down NPN could be the source of trouble, or the second op amp may be running past its limits.

First, check the transistor to make sure the emitter is connected to the first op amp's negative input and the collector is connected to the second op amp's positive input. If you have it reversed don't worry, it would be *far* from the first time anyone has been caught by that.

For your next test run, take a measurement of the voltage at the second op amp's positive input. That will give you a better picture of what the actual current loop is doing, and where that signal sits relative to the output. Since the second op amp is configured as a non-inverting amp with a gain of 2, the input voltage needs to stay between 3v and 9v, and ideally between 4v and 8v so the '741 doesn't have to try to take its output all the way to the rails.

Brilliant data collection and graphing though.. if you do that habitually, give yourself a cookie right now. If you don't, start (and give yourself the cookie anyway. that graph is awesome). Electronics is an applied science, and a big part of science involves collecting data and arranging it in ways that make the patterns easier to see.

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

Return to “General Project help”