Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Dark detector

Status
Not open for further replies.
It would be many times easier to connect solar cells to a relay. Then sun comes up relay goes ON. When sun goes down relay goes OFF. Relay has 2 sets of contacts NO and NC. Make it simple, make it work.
I think you may be right . I wonder if I could use a cheap garden solar cell. Don't see why not if I can get one to run the relay current.
The other problem is that I want it to be pretty well dark before it switches on.

Must be a ready made device out there I can just plug in.
 
Last edited:
So I thought to try Mike's and it looks like you all need to include a zip file with all the components in it . I eventually got all of the library files installed correctly I think then yours stick out again.
Error2Capture.JPG


Don't get me wrong . I appreciate the help but there is a lot to do to actually run the thing
 
I'm not a quitter but I have spent hours trying to get LTSpice to work. Could not find an xphotocell anywhere
LTS is telling you that it can't find the file 'photocell.sub' in the directory ...\LTspiceIV\lib\sub. It's also strange that LTS can't find the 2N3904, 2N3906 and 1N4148 models used in Mike's sim. Those models are part of the standard download, IIRC. Perhaps you've over-written some of the original files? Might be worth updating (or re-installing) LTspice. Try 'Tools\Sync release'.

Edit: Mike's sim uses a tlsv5100red LED model, but you can just replace that with any other LED model.
 
Last edited:
  • Like
Reactions: jjw
Thanks both . I got Mikes to run and thats probably the way I'll go if I can't get the solar panel idea to work as I have a solar panel and battery 24V supply right there. Have some suitable relays that I can resistor down to cut power useage. Thanks again alec_t and mike
 
I've had a lot of fun revisiting LTSpice but my knowledge is wanting I find on how to adjust this circuit for my components .
By dropping the pot value to 50K and the hysterisis resistor to to 200K I can get a result with my LDR ,my relay and my transistors which I hope I have understood what is supposed to go where .
The LDR is 2K full light and 10K dark so I assumed the figure needed in there was 10K divided by 24V=416R.
The pot values I have are 1 K ,10K.,100K and 200K, so I don't have a 50K but thats the only one I can get a result from in the sim.
So I've attached it here in case there is something I am missing.
MyphotoCapture.JPG
 

Attachments

  • Myphoto.asc
    2.8 KB · Views: 277
Last edited:
I played with your sim, changing R1 value to R=v(Rt) and changing V2 value to PWL(o 2k 100 10k 200 2k) to reflect your LDR resistance change. A 100k pot set at ~25k-90k works fine for R2.
 
Looks like you are converging to a working configuration. Alec nailed it on simulating your LDR.

Only thing I would add is to use an Ohmmeter to actually measure the resistance of your LDR while holding it in the orientation it will be mounted at the actual illumination level where you would like the relay to switch. After knowing the measured trip resistance, revisit the sim and see if you can find a value for R2 that causes the relay to cycle at the correct LDR resistance.

I thought you said that your relay was 24Vdc? Since you added an external resistor R7 in series with a coil that has an internal resistance of 450, it looks as though you are actually trying to drive a 12Vrelay?

After changing R1 and R2, the correct value for R6 is found by trial and error. Goal is to get a nice snappy turn on/turn off in the relay. Unfortunately, changing the value of R6 affects the R0n/Roff, so you have to go back and forth a few times. It is easier to do it in the simulator than on a breadboard ;)

Plot the power dissipation in Q2 (see LTSpice help file) to see that there is sufficient feedback through R6 to make the turn on sudden and quick. To see the effect of operating this circuit without feedback, temporarily remove R6. Note how hot Q2 would get as the resistance of the LDR slowly changes.
 
Sorry to be a pain but making the changes suggested by alec_t did not get me there unfortunately. Playing with R6 up to 1.2M does not change things . I think I have made an error . I don't understand where the ";op" comes from in the Photocell sim .
So the PWL means start at 2k and increase resistance to 10k in 100 ms and then decrease it again . The v1,v2, etc are calculated from the resistance if given I take it. But then maybe thats where I have gone wrong

However I find it comes up nicely with a 50K pot . To get such a pot I have to row ashore in Salty Crock infested waters amongst box jellyfish and the odd shark , catch a cab to Jaycar electronics store ,have lunch at the Chinese ( well why wouldn't you?) and in a slightly inebriated state row home . I find ordering and paying for a hundred from China the way to go nowadays as we have a mail drop to the boat 3 times a week and good WiFi at anchor.

Yes Mike I found a 12 Volt relay that took less power so I would like to use that . The values for the LDR are as measured with an ohmmeter.With the Power dissipation did you mean the one that does Fourier calculations?

So I am intrigued now . The sim seems not to be varying the trimpot that I can see so why wouldn't I just replace it with a 50K resistor. I tried it out and it seems OK which also means I should be able to trim my 200K on my built circuit to 50 K for the same result . Oh I took the R6 back up to 1 Meg again and it still works OK in the sim
 

Attachments

  • Myphoto.asc
    2.9 KB · Views: 267
Last edited:
Before I dive in, and since you are using a 12V relay, do you want to change the power supply to 12V?

What is the resistance of the 12V relay coil? (either measure it or look it up)

When you say "The values for the LDR are as measured with an ohmmeter.", I assume you mean the 2K and 10K you mentioned earlier?

Can you estimate (or have you measured) what the LDR resistance is just as you want the relay to trip?
 
Its always going to be a 24 Volt system . I found previously that a relay from a 12 Volt system I had before takes very little current at 24 Volts with a 330 ohm resistor in series .It switches well but without the resistor it gets warm .Its resistance is 450 Kohms .Its marked Royal 7A 250 vac 12A 125 vac and 12 A 30 v dc for both,.JQC-3F-C-DC12V

The LDR I measured out of circuit where it showed 2k in full light and 10k in dark . I find in the circuit I have made up to test all this a meter across it in the board shows 16K at dark . I want the device to turn on or off at dusk so 10K is probably OK for a setting

I have made a circuit that I am trying to get going atm but the LED is always on as is the relay (if connected) It has a 100K pot that I set at 50K before I put it in and all the other values are as you had them including the hysteresis R6 at 1 meg. Setting it at 200K gets the sim to work but very widely . So just fiddling now and thinking .
I'll have to do some real work soon
 
Last edited:
Ok, I took your circuit, and tweaked it a bit. I looked up your relay, and its published coil resistance is 400Ω. With 330Ω in-series with it, it should pull-in briskly, without overheating. R7 should be a 1/2Wor 1W resistor.

Since you measured the photocell resistance as varying from 2KΩ to ~15KΩ, I changed V2 to reflect this. Note that the simulated resistance of R1 is =V(Rt), so now it goes from 2KΩ to 15KΩ (in 100sec) and back down in the second 100sec.

To confirm this, I plot the expression V(t)/I(R1), which by Ohms Law R=E/I is the resistance of R1 in Ohms. Look at the red trace and the right hand Y-axis of the upper plot which shows resistance vs time.

You said that you would like the relay to pull in as it gets dark, and you also said that you want the trip point to be ~10KΩ. I diddled R2 and R6 to make the relay pull-in as R1 increases through 10K (getting darker). With R2=80KΩ and R6=470KΩ, I attach cursors in LTSpice's plot to the red trace, and use them to show that the relay picks-up at R1=10KΩ, and the relay drops-out at R1=8KΩ. I am guessing that is sufficient hysteresis; if not, make R6 smaller and try again.

Note the relay coil current I(L1) green trace which shows coil current vs time. It shows that the relay is pulled-in at the right time (i.e. when R1 > 10KΩ...)

Also note R2. It is a 100KΩ pot which has been set to 80KΩ!

My model of a Green LED exhibits a forward voltage drop of ~2.1V, so in the lower plot pane I show V(ref) light blue and V(t) dark blue. You can clearly see the effect of the positive feedback provided by R6 in the steps in the dark blue trace.

Note that D1 does a pretty good job of maintaining 2.1V (light blue trace), even though, because its dynamic impedance is finite, it is not a perfect voltage reference... Again, if the forward voltage of the specific LED you use in the built-up circuit is different than 2.1V, you might have to tweak R2 a bit to compensate. The LED will always be lit if 24V is applied.

MyPhotoM.gif

I attached a modified version of your .asc file for you to play with.
 

Attachments

  • MyphotoM.asc
    2.9 KB · Views: 297
Last edited:
The sim seems not to be varying the trimpot that I can see so why wouldn't I just replace it with a 50K resistor.
The sim varies the LDR resistance only. It is up to you to choose the setting (e.g. half-way, 50k) of the 100k trimpot, to suit the degree of darkness where the circuit trips.
 
Here I show the same circuit as in post #31, but I automatically rerun the simulation at four different values of the pot R2. I am showing at what value of the photo resistor R1 the relay pulls-in/drops-out for four different settings of the pot; namely 70KΩ, 80KΩ, 90KΩ and 100KΩ.
Look at how the pot is stepped in the simulation. This has the photo resistor varying in time, and four different simulation runs with different settings of the pot.

MyPhotoM1.gif
 

Attachments

  • MyphotoM1.asc
    3 KB · Views: 287
Brilliant
Thanks Mike I have been reading up tutes on LTSpice and am starting to get where the bits are as far as extra plots and settings . Thanks also alec-t .
I've built this new circuit on veroboard , in a breadboard and on a protoboard and funny thing is I can blow LED's when I play with the pot and one turns the relay hard on and another it stays hard off ! Phew probably 40 hours on this now . Exasperated indeed. Found the second and third LDR's changed too .One up to 40K . Didn't expect that. Anyway i'll work through the above and try figure it out .
 
Last edited:
..
I've built this new circuit on veroboard , in a breadboard and on a protoboard and funny thing is I can blow LED's when I play with the pot and one turns the relay hard on and another it stays hard off ! .... Don't see why it would blow LED's unless there is some sort of runaway current or A/c RF stuff going through it.

Actually, it is a bad design: mine:mad:.

Think about what happens if you turn the pot to zero resistance? There is nothing to limit the current that flows from the 24V rail to the base of Q1, out its emitter, and to ground through the LED D1. Fix is simple: put a fixed resistance of 10kΩ to 47KΩ is series with the pot R2. Now if you turn the pot to zero resistance, the new resistor will limit the current and protect Q1 and D1. I know not to turn the pot to zero. My mistake was assuming you would know that.

I'm not surprised that you have found great variability between LDRs. If you put in a different one, I would expect you will have to tweak the pot.
 
Below is the filtered Daylight sensor ($3 Digikey/ Pansonic AMS302 which is very precise in LUX level and needs any tiny 3 terminal 5V regulator.

The voltage out depends on the resistance. The current depends on brightness of the shadow and ambient reflections..

Any 5V comparator with desired hysteresis to prevent rapid toggling with say 10~30% hysteresis which depends on your application.

A shadow is highly variable due to unknown ambient reflected light, it also requires a clear sky. A clear sky can be over 100k Lux; a shadow could 1~10 kLux, while an overcast sky can be 10kLux; so there can be ambiguity.
You could tell us why you want to measure a shadow to see if it is practical with any method.

upload_2015-4-2_22-33-47.png

. The peak curve show replicates the Human spectral sensitivity of the eye, unlike all other photo cells.

But if you are just measuring PV sensitivity due to a cloud passing, a small PV will work.
 
Eh? I'm just wondering what relevance or use that might be as a switch for a 24 Volt system . How might I use it . It looks like I would have to build a 5 volt supply from 24 and also attach a transistor based switch of some sort . Do you have any suggestions on its use Thanks.?
 
Last edited:
Mike I had worked that out and indeed put a 10K in and reduced pot to 70K value on sim . just a bit slow . Took me about 6 LED's but I have hundreds of those. Stll can't get the circuit to work though . Looking at your circuits and notes and trying to pull the reference plots up to study them atm
 
Last edited:
... Stll can't get one to work though . ..

What do you mean by that?

Try this: temporarily replace the LDR in the built-up circuit with a 10KΩ resistor. Now turn the pot. There should be one pot position where the relay clicks on. You should have to turn the pot the other way a few degrees to get the relay to turn off. That would prove that the circuit is working at an expected LDR value of 10KΩ. If you put the LDR back in place of the resistor, and cannot get the relay to follow as the LDR is shielded from light, then your LDR is not doing what you expected, i. e. going through 10KΩ at the critical illumination level.
 
My fault error on the breadboard wiring . Working well now......... thank bloody..... .
Now to start duplicating them on some hard veroboard I think. That Protoboard is not my cup of tea . Just get it to where its looking right and a via that really isn't a via falls off and shorts . Trying to get it out you destroy the board so thats one set of components for reuse. Won't buy protoboard again. Iv'e got cataracts on both eyes now so its difficult to keep enjoying electronics . Have to see about eye surgery soon.

That second citcuit on LTSpice is just bloody amazing !

I'll use DIYLayout program and post the completed image here.

Its been a pleasure learning from you thanks Mike -cheers
 

Attachments

  • DarkSensorLarge.pdf
    17.7 KB · Views: 525
  • DarkSensor.zip
    202.6 KB · Views: 394
  • DarkSensorSmall.zip
    11.1 KB · Views: 291
Last edited:
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top