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

Thread Starter

johnaustinkaty

Joined Jul 16, 2021
284
Hi

I've modified my schematic in line with the comments below.

1. I've added filter/bypass capacitors (as Eric suggested). These basically ensure voltages remain stable.

2. You've determined that the 1K pullup prevents the power-on flash you were seeing earlier.
It didn't make sense (to me) for the mosfet to control power to the LDD-300 anymore.
So I connected the LDD-300L supply pins directly to the supply rails, and configured a mosfet (2N7000) to
provide a signal to an Atiny GPIO pin as an "enable" control signal for the LDD-300. You can configure the
Atiny to set the DIM pin low/high, or "in-between", to control the LDD-300 OFF/ON/DIM, repectively.

3. I replaced the NPN LED drive transistor with a 2N7000 NMOS.
This reduces the number of different transistors and current requirements.

4. I recommend keeping the PMOS reverse voltage circuit. Its more efficient than diodes.
I've included suggested part numbers for the mosfet and Zener.

5. Lastly, I still think the LM393 comparator function can moved to the ATiny.

These are just some observations and suggestions.

View attachment 361820
Great! I have a lot to study, absorb and understand. I'll probably follow up with a few questions tomorrow. Thx for all your effort. Much appreciated.
 

Thread Starter

johnaustinkaty

Joined Jul 16, 2021
284
Hi

I've modified my schematic in line with the comments below.

1. I've added filter/bypass capacitors (as Eric suggested). These basically ensure voltages remain stable.

2. You've determined that the 1K pullup prevents the power-on flash you were seeing earlier.
It didn't make sense (to me) for the mosfet to control power to the LDD-300 anymore.
So I connected the LDD-300L supply pins directly to the supply rails, and configured a mosfet (2N7000) to
provide a signal to an Atiny GPIO pin as an "enable" control signal for the LDD-300. You can configure the
Atiny to set the DIM pin low/high, or "in-between", to control the LDD-300 OFF/ON/DIM, repectively.

3. I replaced the NPN LED drive transistor with a 2N7000 NMOS.
This reduces the number of different transistors and current requirements.

4. I recommend keeping the PMOS reverse voltage circuit. Its more efficient than diodes.
I've included suggested part numbers for the mosfet and Zener.

5. Lastly, I still think the LM393 comparator function can moved to the ATiny.

These are just some observations and suggestions.

View attachment 361820
So, the 5v circuit is energized at dusk by the 2N7000 that will replace the IRFZ MOSFET? The other 2N7000 will replace the 2N2222 and be the switch for the RA LEDs. Don't I have 12v to the LDD-700L 24/7? Or, does that 1k pull down on pin 5 keep it switched off until the PWM signal from the attiny turns it on? I will keep the reverse voltage circuit as suggested. Does that zener come in a larger SMD pkg? I'll almost need a microscope for that thing.
 

Thread Starter

johnaustinkaty

Joined Jul 16, 2021
284
With a lot of input from ericgibbs and eetech00, this circuit is coming together very efficiently and correctly. I am very thankful for all of this help.
 

ericgibbs

Joined Jan 29, 2010
21,464
hi,
Your circuit section is overcomplicated, for simple detection of Light/Dark switching.
Simpler version option.
Use the power of the Tiny85
E
1767989051278.png

EG 1959.png
 

Thread Starter

johnaustinkaty

Joined Jul 16, 2021
284
hi,
Your circuit section is overcomplicated, for simple detection of Light/Dark switching.
Simpler version option.
Use the power of the Tiny85
E
View attachment 361851

View attachment 361854
WOW!! This will simplify my board while reducing many parts and my assembly time. I assume this is what eetech00 was talking about. Much cleaner. Is this a matter of doing an analog read on PIN 2 in my code, then executing?
And, shouldn't I keep the reverse polarity circuit as eetech00 recommended as opposed to just one zener diode?
Also guys, I am happy to compensate you for your efforts. Just send me a PM to discuss. Thx again.
John
 

eetech00

Joined Jun 8, 2013
4,709
So, the 5v circuit is energized at dusk by the 2N7000 that will replace the IRFZ MOSFET?
Referring to my schematic post 180:
1. when battery is connected, M1 energizes 12v-SW rail.
2. 12v-SW rail energizes LM393 and Mini-360
3. Mini-360 energizes LDD-700L, but LDD-700L output is disabled because DIM pin is pulled below 0.4v.

What happens next depends on whether the output of the LM393 is INITIALLY high or low.

If the output is low, M2 stays off and applies 0v to Atiny GPIO.
If the output is high, M2 turns on and applies 5v to Atiny GPIO.

The Atiny logic reads the signal at the GPIO pin then either enables the
LDD700L (via PWM), or does nothing, keeping it disabled.

[QUOTE}
The other 2N7000 will replace the 2N2222 and be the switch for the RA LEDs.
[/QUOTE]

Yes. It only requires a voltage on its gate to turn on (extremely low current).

[QUOTE}
Don't I have 12v to the LDD-700L 24/7? Or, does that 1k pull down on pin 5 keep it switched off until the PWM signal from the attiny turns it on?
[/QUOTE]

The LDD-700L will be energized, but its output will be OFF because the DIM pin is pulled below 0.4v by the pull-down resistor.
When PWM is applied to DIM pin, it pulls the voltage to the DIM pin above 0.4v turning the output on.

I will keep the reverse voltage circuit as suggested. Does that zener come in a larger SMD pkg? I'll almost need a microscope for that thing.
That's a good thing.
Use any 6.8v zener that requires low current (5ma is good).
 
Last edited:

eetech00

Joined Jun 8, 2013
4,709
WOW!! This will simplify my board while reducing many parts and my assembly time. I assume this is what eetech00 was talking about. Much cleaner. Is this a matter of doing an analog read on PIN 2 in my code, then executing?
Yes. this is basically what I was writing about.

And, shouldn't I keep the reverse polarity circuit as eetech00 recommended as opposed to just one zener diode?
Yes, you should.
 

Thread Starter

johnaustinkaty

Joined Jul 16, 2021
284
Awesome! I will revise my schematic based on eric's latest and include your input of course. I will post for review when done. I feel confident as long as you guys are in agreement for the most part. That's very reassuring. Thx guys.
 

ericgibbs

Joined Jan 29, 2010
21,464
hi john,
Please post a copy of your Tiny Code, I assume you used the Arduino IDE to create the coding??
If that is the case, I could write and post the switching point and hysteresis limits code for the Nano, which you could then convert to suit the Tiny,

I am now using a Nano for testing the GL5528 LDR's.
You stated earlier that the LDR resistance was centred around 35k at the Dark/Light switching point.?
Determine the resistance switching for On Dark and Off Light, and I will use those values in the Coding.

E

EG 1960.png
 

Thread Starter

johnaustinkaty

Joined Jul 16, 2021
284
How did you write the code for ATtiny?
I initially wrote the code back in 2020 and it only reads a signal from the PIR (WHILE) and executes a basic PWM sequence.... analog 0-255 fade up, fade down, blink, delay, etc....
The examples of code I saw yesterday related to hysteresis appeared more complex, but maybe it is simpler than what I ran across. I only looked at a few examples briefly. I have tweaked the code several times since 2020 (basic research and development).
 
Top