Author Topic: Detect wire break on LDR - long cable  (Read 591 times)

0 Members and 1 Guest are viewing this topic.

Offline mrburnzieTopic starter

  • Regular Contributor
  • *
  • Posts: 139
  • Country: cs
Detect wire break on LDR - long cable
« on: January 29, 2020, 03:16:14 pm »
Hello everyone!

I have a part of a project where I have an LDR,  which I read through an ADC with a voltage divider configuration.
LDR is connected to +5V and ADC, 4k7 to ADC and GND. Simple stuff.
I have to detect the full range of the LDR, meaning from total dark to full light.

Everything works, but I need a feature where I have to detect if the LDR is disconnected.
By disconnected I mean disconnected from the +5V rail and the ADC rail, independently.
The extra problem is that the LDR is connected with 2m, 3mm thick copper cable (4m because it is on both legs of the LDR, so back and forth it's 2x 2m).
I have a 100nF cap on the ADC which is helping with the distortions.

I had no luck, because when I'm detecting full darkness (Rd is 20M) I detect it as an open circuit.

I have seen a lot of examples on the internet, but I need assurance on what should I try?

Extra:
http://www.farnell.com/datasheets/77395.pdf the datasheet of the LDR used
Would a photodiode make the job easier? Something like a SFH203FA?
Using an ATmega32u4
« Last Edit: January 29, 2020, 03:18:05 pm by mrburnzie »
"Talk is cheap, show me the code"

Anyone need of freelance software/hardware developer, hit me up!
 

Offline macboy

  • Super Contributor
  • ***
  • Posts: 2309
  • Country: ca
Re: Detect wire break on LDR - long cable
« Reply #1 on: January 29, 2020, 03:58:28 pm »
Place a low leakage diode (1N4148?) across the LDR, reverse biased (so it normally does not conduct). Connect the LDR to a GPIO pin instead of to +5V, and place a high value (100 K to 1 MOhm) resistor to ground.

To detect a break in the connection, set the ADC pin to digital and output high/one (5 V). Set the LDR output pin to digital input and read the value. If the connection is good, the diode and/or LDR will conduct, so the voltage will be at about 4.4 V which will measure as a high/one. If it is disconnected, the pin is pulled low by the resistor to ground, and it will read as a low/zero. It is not possible to detect the exact location of the break.
 
The following users thanked this post: mrburnzie

Offline mrburnzieTopic starter

  • Regular Contributor
  • *
  • Posts: 139
  • Country: cs
Re: Detect wire break on LDR - long cable
« Reply #2 on: January 29, 2020, 04:20:09 pm »
I just ran a simulation on the configuration, and it should work!

Thanks! Will get back to you with real life testing ;) kudos! :clap:
"Talk is cheap, show me the code"

Anyone need of freelance software/hardware developer, hit me up!
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf