Wiring for resistive sensor

Go To Last Post
9 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm using a photocell for one of my hobby projects. The photocell is a simple resistive sensor, i.e. it generates a resistance that depends on light intensity.

The sensor is connected directly to 5V, and through a 10k resistor to ground. The signal fed to the uC is the voltage across the 10k resistor.

When mounting my circuit for actual use, I will need to place the sensor 10-20 ft away from the circuit.

Is the direct connection I am currently using good enough, or should I look into Kelvin sensing or some other multi-wire hookup ?

What kind of wire should I use ?

Should I add any circuit protection, in addition to the 100nF decoupling cap on the uC input ?

I'm interested in what's best/good enough in this particular case, as well as the more general case of any resistive sensor at various cable lengths.

Sid

Life... is a state of mind

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi Sid,

If it was my project I would be examining the range of change of sensor resistance with respect to the other variables in the design ... for example, the stability of your 5 volt rail, the operational temperature range and its effect upon your 10K resistor and all wire looms. And don't forget the sensor's specification. There is little or no point in trying to achieve sub 1 percent error sources if your sensor is plus minus 5 percent.

Cheers,

Ross

Ross McKenzie, Melbourne Australia

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for answering, Ross

I think the main problem I am facing is that I don't know much about electronics. I have studied enough recently that I can design simple circuits. I understand the basic rules that apply to the components I'm using. But this is mostly theoretical, based on ideal components and ideal circuits.

I was hoping that there were some specific rules or at least rules of thumb for hooking up a sensor like this, based on cable length or other easily determined factors.

Finding the stability of the 5V rail must be a trivial task for those who know how to do it - but I wouldn't know where to start.

The resistor is supposed to be 1% but the datasheet for the sensor says nothing about accuracy.

For the case at hand I don't think I need high accuracy but repeatability would be nice. I'm using the sensor to detect the transitions between night and day.

I have a surplus of CAT5e cable, I guess I could just hook it up using a single pair and see how it performs. But CAT5e is not cheap, it must (?) be overkill and there must be some general guidelines somewhere ?

Sid

Life... is a state of mind

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ok Sid,

Thanks for the elaboration. In the 70s I worked on a tethered buoy that measured the temperature of the sea surface at sunrise and sunset and radioed the result to a shore receiver. I used an LDR as the sensor in a monostable oscillator with a Schmitt trigger input. The sensor was around 5Kohms in daylight and 100Kohms at sunrise and sunset. If you can measure these values for your sensor in its final enclosure (because the value will be different outside an enclosure, I am sure we can make some recommendations for you.

Cheers,

Ross

Ross McKenzie, Melbourne Australia

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

A couple of thoughts:

As Ross already eluded to, one good option is to put a micro, (say a Tiny), at the sensor and convert the analog signal to digital at the site of the sensor.

Then transmit the digital signal. This eliminates noise on the lines from giving one an error signal. There are many ways to transmit digital data, RS-232 being a good choice for your application, RS-4xx being another option( s ), and low power RF being yet another choice.

If you really don't want that added complexity, and just want to run the wire, then do so. But...

Using a twisted pair of wires will be better, noise wise, that untwisted wires. And running your wires within a "shield", (wire weave, foil, etc), will be better, noise wise, than without a shield.

Any good length of wire without a shield will pick up lots of noise, as it acts like an antenna. It will pick up RF, Power Line, and energy for lightning strikes in the area, to name a few sources.

It may not matter in your application, but be aware that the actual switching voltage on the digital input pins is (rarely) tightly spec'd, meaning that it will change from chip-to-chip, based upon the exact operating voltage, and upon the chip's temperature.

If you wanted a more defined switching point, then using a voltage reference and an analog comparator would be an option.

One might want to put a diode from the signal line to the V+ and another one to Ground to help clamp any transient noise spikes.

JC

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thank you both for answering.

I don't know what kind of enclosure I will use for the sensor - probably just something simple that keeps it dry.

I am using ADC to read the sensor. That allows me to move the "twilight zone" by using a pot on another ADC channel. I realize that I could have done the same thing using only a digital input, but I have more pins than I need and knowing more about software than hardware I find it easier to wrap my head around this in terms of software. At least for now.

I think I’ll just hook it up with the Cat5e cable I have and see how it works. If that doesn’t work you’ll be the first to know. ;o)

Sid

Life... is a state of mind

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Sid,

Another thought. You could tie one end of your sensor to an output pin (normally low) and the other end to a grounded capacitor and either an ADC input or a simple input pin. When you want to check the light level, you raise the normally low output to a high and then time how long it takes the capacitor to charge to either a specific ADC value or a high on the input (say a pin change interrupt one). Then return the output high to a low (allowing the capacitor to discharge) before repeating the process.

Cheers,

Ross

Ross McKenzie, Melbourne Australia

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ross,

That’s an interesting way to solve it without ADC. I know how to do the math and I could easily program for that configuration, too.

For the case at hand, would you put the cap next to the sensor or on the PCB ? Also, would a solution like that somehow be better than using a series resistor and ADC or did you suggest this only as a way to get it done without ADC ?

In the general case – as stated above I understand how this works but one thing that complicates it is the signal range between VIL and VIH. Is the idea that the rise/fall through that region will be fast enough to not cause problems ?

Sid

Life... is a state of mind

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Sid,

There are always many ways to skin a cat (sorry Cliff).

Another, depending upon your particular microcontroller, would be to use the analogue comparator. Compare your charging cap voltage against a preset value and generate an interrupt or timer action.

As for cap placement, I would place it at the controller, it then serves to smooth any noise on your connection cables.

I wouldn't worry about the VIL/VIH issue (if there is one). The charging would be slow enough to be the dominant time element. Besides you are only looking for a consistent switch point on the charging cycle. If your supply is "stableish", the VIH should be also.

Cheers,

Ross

Ross McKenzie, Melbourne Australia