Simple Dusk-Dawn switch

Thread Starter

DC_Kid

Joined Feb 25, 2008
794
need some eyes for this simple LM393 ckt.
do 393's bounce when V- = V+ thus need feedback, i cant have the SSR (VO1) flapping, etc. is gnd'ing all the pins on unused comparator in the 393 the right way to terminate it?

393 is a common collector sink. and not shown here, but VO1 is a SSR switch for four 60w PS's. the PS's are 120vac-12vdc for landscape lighting zones. i'll also show later, but the loads on each PS (aka "zones") are actually controlled by a 4ch PWM module driving power FET's. the module has wifi and a app for iphone/android and you can manually control zones and create saved "scenes". i looked for COTS but the systems were like $k+ and the lamps are ~$100ea (i'll have ~28 lamps in my backyard). i think my whole system is on order of $300 and plain 'ol 12vdc anything for lights work (my system is made for LED but is not rgb, thus limiting to 60w per zone, but if you needed more power just replace PS with a bigger one, the FET's can handle lots).

 

Bernard

Joined Aug 7, 2008
5,285
To me it looks reversed- day, PH1 conducts, pulling U1-2 low, output high, turning on lights ??
Day to dark is not always a one shot so normally add some hysteresis so we do not bobble.
On spare IC parts it best to not ground outputs.
 

Thread Starter

DC_Kid

Joined Feb 25, 2008
794
i took common collector BE bias logic in the 393 wrong, i will swap the inputs. a logical lo is transistor on, a logical hi is transistor off.

how about a 50k feedback from out to - ?

how then to terminate a comp in the 393? + to Vcc, - & output to gnd ? this locks the output bjt off and does not leave collector floating.

7 (8 with feedback R) discrete parts. is that simple ?

 
Last edited:

Thread Starter

DC_Kid

Joined Feb 25, 2008
794
You need positive feedback to provide hysteresis.
but the logic is a logical NOT between inputs and output stage Q
when the input logic is false the output stage is sinking (Q itself is "on")

so how then to provide correct feedback to the + input?
 

MrChips

Joined Oct 2, 2009
19,382
When +INPUT > -INPUT, output transistor is OFF, i.e. OUTPUT is high.

Hence for positive feedback, connect feedback resistor between OUTPUT and +INPUT.
 

Thread Starter

DC_Kid

Joined Feb 25, 2008
794
but look close, the output is not Vcc high, its clamped to the Fwd V of the VO1 diode (~3v). how does 3v feedback to + help? to stop the issue with V-=V+ the + input needs to jump just a smidge higher from the feedback. in this case 6v is the threshold.

and this notion of "output" is odd. the 393 doesnt really output anything (current source). the output pin by itself is always gnd or open, it can only be a sink. its a tad different than the logic of a opamp voltage follower.

i made a comparator with 358 for a batt monitor, so maybe i go back to that ckt. i was wanting to try comparator instead of amp for a threshold monitor, etc.
 
Last edited:

Bernard

Joined Aug 7, 2008
5,285
Why not go back to first & connect feed back from pin 1 to 3 ,+, then use U1-B as inverter to drive VO1 ?
Also that would un ground U1-B-1. What happens if IC's normal output is high & we ground it?
 

MrChips

Joined Oct 2, 2009
19,382
but look close, the output is not Vcc high, its clamped to the Fwd V of the VO1 diode (~3v). how does 3v feedback to + help? to stop the issue with V-=V+ the + input needs to jump just a smidge higher from the feedback. in this case 6v is the threshold.

and this notion of "output" is odd. the 393 doesnt really output anything (current source). the output pin by itself is always gnd or open, it can only be a sink. its a tad different than the logic of a opamp voltage follower.

i made a comparator with 358 for a batt monitor, so maybe i go back to that ckt. i was wanting to try comparator instead of amp for a threshold monitor, etc.
The output pin is connected to a load consisting of a 2kΩ pull-up and an LED to GND.
That node is going to switch between 0V and 3V. That is the signal you want to feed back into the +INPUT pin.
That is going to provide the positive feedback in order to give you hysteresis.
 

ian field

Joined Oct 27, 2012
6,540
the feedback has me a tad baffled. is neg feedback correct?
No - your circuit uses a smidge of positive feedback. A high resistance from output to non inverting input slightly influences the switching threshold. It doesn't matter which input you're using for the signal, but you may have to take loading effects into account.

A tiny amount of pfb "encourages" the input trend, and, if you're lucky - slams the output to one rail or the other instead of turning small noise into a burst of "pulse train".

some time ago I posted a hand trace of a commercial unit - the schematic was on the PC that committed suicide, I can't remember if the schematic found its way onto a USB stick before TOD.
 

Thread Starter

DC_Kid

Joined Feb 25, 2008
794
Why not go back to first & connect feed back from pin 1 to 3 ,+, then use U1-B as inverter to drive VO1 ?
Also that would un ground U1-B-1. What happens if IC's normal output is high & we ground it?
if i flip inputs i get Day-ON and Night-OFF. but i could essentially put a pFet (gate) on the output and let fet drive VO1 ?? or i can go back to my 358 "comparator" as it is a current source.

i lost you on your 2nd statement


The output pin is connected to a load consisting of a 2kΩ pull-up and an LED to GND.
That node is going to switch between 0V and 3V. That is the signal you want to feed back into the +INPUT pin.
That is going to provide the positive feedback in order to give you hysteresis.
how does 3v help me move the + input a smidge above 6v ??
 

AnalogKid

Joined Aug 1, 2013
8,138
if i flip inputs i get Day-ON and Night-OFF.
True. But if you reverse the positions of PH1 and R3, your logic is back the way you want.

And about hysteresis - The current that is injected from the output back to the input does not have to be symmetrical. The arithmetic is a bit longer, but there is nothing wrong with an output providing zero feedback current in one state and some effective amount in the other state. The net effect on the input transition levels is the same - they change as a consequence of the output. The locations of the transition levels will not be symmetrical because the two currents are not symmetrical, but they will be different, which is what makes hysteresis work. How different is up to Ohm and Thevenin.

Comparators with open collector outputs have the most asymmetrical output impedances you can get - low and infinite. Swapping an LM358 for an LM393 gets you more symmetrical (but not perfect) output stage, and that does make the hysteresis math somewhat easier.

ak
 

Thread Starter

DC_Kid

Joined Feb 25, 2008
794
True. But if you reverse the positions of PH1 and R3, your logic is back the way you want.

And about hysteresis - The current that is injected from the output back to the input
i could swap it and then use pFet on the output. Day then means no sink current on 393 but that pull up turns fet off. Night means sink current to gnd and fet turns on.

"from the output back to the input"
there is no current vector "from" the 393 at the output, this would indicate a source. it can only sink, thus "to" the 393.

looks like i can go back to 1st schematic, provide feedback to Inp+ and then figure out my output stage for VO1

 
Last edited:

ian field

Joined Oct 27, 2012
6,540
i could swap it and then use pFet on the output. Day then means no sink current on 393 but that pull up turns fet off. Night means sink current to gnd and fet turns on.

"from the output back to the input"
there is no current vector "from" the 393 at the output, this would indicate a source. it can only sink, thus "to" the 393.

looks like i can go back to 1st schematic, provide feedback to Inp+ and then figure out my output stage for VO1

Couldn't see any glaringly obvious thing wrong with that - check for wiring errors and try a pot for R1, the R3 & R4 values are equal, so R1 needs to be close to the LDR between light and dark, not particularly critical, as long as its within that range.

The one I posted ages ago had a photo diode and needed a voltage follower front end for high input resistance. The photo diode looks like a regular IR type - but it seemed to work well enough before the workmen ripped it out.
 

Thread Starter

DC_Kid

Joined Feb 25, 2008
794
so maybe something like this. 393 has dismal 16mA sink ability, so i use pfet driver for VO1.
is termination proper? the 393.2 output will not be sinking as shown.

 
Last edited:

ian field

Joined Oct 27, 2012
6,540
so maybe something like this. 393 has dismal 16mA sink ability, so i use nfet driver for VO1.
is termination proper?

Just had a quick nosey at the 393 data sheet - the output sink current range looks a bit all over the place!

No maximum value stated, typical 16mA - but you have to allow for the worst case scenario of only 6mA.

Not exactly loads to play with, a PNP Darlington should be OK, a P - MOSFET is dead easy. A BJT requires a current limit resistor from open collector to base, but that would be a bad idea to the gate of a P-MOSFET. If you're using an opto for isolation - that can hide many sins. Budget for about 50mA for the opto IRLED. you need a P-MOSFET; so look for complements to TO92 type devices like the 2N7000 or BS170 etc.
 

MrChips

Joined Oct 2, 2009
19,382
You are going overboard here. The LM393 can sink 16mA. You're only driving an LED. There is no need for external buffering.
 

AnalogKid

Joined Aug 1, 2013
8,138
"from the output back to the input"
there is no current vector "from" the 393 at the output, this would indicate a source. it can only sink, thus "to" the 393.
Incorrect for several reasons.

First, I was speaking about hysteresis circuits in general, not the LM393 specifically.

Second, vectors can have negative values.

Third ...
so maybe something like this.
In the post #17 schematic, there is a current path from Vcc to the 393 output pin to the 393 non-inv input pin to GND. When the 393 is "off", the FET Vgs is 0.52 V, not 0 V. That this current does not come through the 393 Vcc pin is not nearly as important as the fact that it is there and that the 393 modulates it. From the point of view of feedback resistor R5, the direction of electron flow changes because the LM393 makes it change. Also, 0.5 V is more than enough to cause some drain or collector current in many transistors.

ak
 
Top