Dark sensor circuit using LM393 question.... unstable OFF/ON... flickering

Thread Starter

johnaustinkaty

Joined Jul 16, 2021
284
This is what I am getting for LDR resistance:

3.6 Mohm in 100% darkness (completely wrapped in electrical tape)
270 ohm outside on a cloudy day at noon
103 ohms in direct sunlight

BTW, I did a bench test using the 470k resistor and it seemed to be pretty close to what I need. I have the light outside now and will see what happens at dusk this evening. Thx for all of your help !!
I got 80k ohms reading from the LDR at dusk. This is the darkness level I want my board to power up. Thx again!
BTW, the light with the 1M resistor connected to PIN 1 & 3 came on a few minutes after I measured the 80k on my Fluke.
The light with the 470k came on several minutes later, which could work too.
 
Last edited:

ericgibbs

Joined Jan 29, 2010
21,462
hi john,
With the LDR =80k at dusk, this is the circuit I would use.
To allow for some adjustment, I would make R3 a 20kpot and a 33K resistor in series.
Note R7 used for Hysteresis.
E
I guess you know the comparator output is High when it is Light???

EG 1916.png
 

ericgibbs

Joined Jan 29, 2010
21,462
hi john.
Ref your PM.
Ref the sense of the LM393 output.
LTSpice is showing the resistance change of the LDR in the incorrect sense, that resistance plot should be inverted, so the LM393 output will be High when it is Dark
E
I will check why the plot is inverted.?????
 

ericgibbs

Joined Jan 29, 2010
21,462
hi john,
I have modified the simulation to show the LDR resistance in the correct sense.
The LM393 output is going LOW when the LDR is Dark.

I would suggest you redesign the circuit, consider swapping the LM393 NonInv and Inv inputs over.
E

EG 1920.png
 

ericgibbs

Joined Jan 29, 2010
21,462
hi john,
You asked me to check your PCB tracking, this is a part check, there are no pin numbers on the Tiny drawing also I don't see R12.
I suggest you post a new circuit with the changes on the LM393 inputs.
E

I thought the output from pin 1 went high at dusk, triggering the gate of my IRFZ mossfet. Is that not correct?
Added: Please explain how you see the PMOS being controlled by the LM393?
You said you expected a High output on the LM393 when the LDR was Dark.???
Did you design the circuit.?

PC board as of 12-23-25.png
 
Last edited:

Thread Starter

johnaustinkaty

Joined Jul 16, 2021
284
hi john,
You asked me to check your PCB tracking, this is a part check, there are no pin numbers on the Tiny drawing also I don't see R12.
I suggest you post a new circuit with the changes on the LM393 inputs.
E



Added: Please explain how you see the PMOS being controlled by the LM393?
You said you expected a High output on the LM393 when the LDR was Dark.???
Did you design the circuit.?

View attachment 361132
Thx for all of this effort!! I did design this circuit originally with help from another on this forum a few years ago. I have made changes since then based on the way I want this product to function. Everything is working exactly as it should now. The only missing key was the 470k resistor for hysteresis. I soldered a 470k between pins 1 and 3 as suggested. My light has come on at the ideal time at dusk/twilight two nights in a row with no chatter, which was my only remaining issue prior. Should I not have the high output from pin 1 on the LM393 triggering the gate on my PMOS? I understand that my circuit and PCB are not designed like a knowledgeable electrical engineer/designer would have done it. My background is structural engineering. I plan to post an image of my updated PCB today before I order more boards. I will be eliminating R12 going to my 5mm red alert led (RA) as it has a resistor provided on the lead wire already. I will study your latest suggested schematic to make sure I am understanding. Thx again!!

P.S. It is possible that my schematic is not matching my PCB at this point. I have typically been making changes directly to my PCB as opposed to editing my schematic and importing changes to the board. I know.... probably not the right way to approach it.
I plan to update and verify that my schematic ends up matching the actual board. Sorry for any confusion.
 
Last edited:

ericgibbs

Joined Jan 29, 2010
21,462
Hi john,
When switching that PMOS you do not need to modify the LM393 inputs, a LM393 LOW output is required to switch on that PMOS transistor, when the LDR is Dark.
OK?
E
 

Thread Starter

johnaustinkaty

Joined Jul 16, 2021
284
Hi john,
When switching that PMOS you do not need to modify the LM393 inputs, a LM393 LOW output is required to switch on that PMOS transistor, when the LDR is Dark.
OK?
E
Ok. I'll leave it as is. Here is my updated PCB and schematic utilizing the recommended resistors (attached .pdf's): I circled the modified items and added a few design notes for reference. I will solder on a 1k between PIN 1 and VCC as you advised and retest my lights this evening. I'll have to leave the R7 at 51k for now because I need to order some 47k SMTs.
 

Attachments

Thread Starter

johnaustinkaty

Joined Jul 16, 2021
284
Ok. I'll leave it as is. Here is my updated PCB and schematic utilizing the recommended resistors (attached .pdf's): I circled the modified items and added a few design notes for reference. I will solder on a 1k between PIN 1 and VCC as you advised and retest my lights this evening. I'll have to leave the R7 at 51k for now because I need to order some 47k SMTs.
One more issue I would like to address if possible is delaying the current flow to the LDD-700L led driver by .5 or maybe a whole second. My super bright LED is flashing at full brightness momentarily (like a camera flash) until the pwm from the attiny has a chance to kick in. This all happens in a split second of course. Can I put a capacitor at the +in of the LDD-700L to solve this issue? What would you suggest?
 

sghioto

Joined Dec 31, 2017
8,634
Can I put a capacitor at the +in of the LDD-700L to solve this issue? What would you suggest?
Using the other half of the LM393 to provide a 1 second delay.
Pulling the DIM pin below 0.5 volts will shut off the LED driver.
Showing pin6 connected to pin2, the 4 volt reference.
1766795363739.png
 
Last edited:

Thread Starter

johnaustinkaty

Joined Jul 16, 2021
284
Wouldn't this only delay the PWM signal from the ATTINY for 1 second, but allow the 12v to power the driver and LED to full brightness during that 1 second, extending the time of the bright flash when power is connected?

1766798917011.png
 

Thread Starter

johnaustinkaty

Joined Jul 16, 2021
284
hi john,
This plot shows the LDR resistance at the LM393 output switching points,
E
View attachment 361178
That looks great. I added a 1k from output pin 1 to vcc on one of my lights last evening and it came on 30 min later than the light that did not use that resistor. Both lights used the 470k from pin 1 to pin 3 of course. I will replace the 1k with a 10k as indicated and see if the lights come on closer to the same time. Thx again!!
 

ericgibbs

Joined Jan 29, 2010
21,462
hi john,
By adding 1K and LED to pin1 of LM393 you will change the LM393 Vswing which will affect the circuit hysteresis and On/Off point.

I would suggest a 100k 10 turn Trim pot, so that you can control the On/Off point.
E
This shows the PMOS switching.
EG 1931.png
 
Top