Connect with us

Dark activated light

Discussion in 'LEDs and Optoelectronics' started by Anon_LG, Jun 24, 2014.

Scroll to continue with content
  1. Anon_LG

    Anon_LG

    453
    117
    Jun 24, 2014
    I have recently designed a dark sensing light on a piece of simulation software called Yenka, I have not yet fully constructed the circuit in reality, however I am very close to completion ( I just hope I have not fried the logic gate when I soldered it) The main components+bits I am using are: Cd4001be Nor gate manufactured by Texas instruments (being used as an inverter), a kia 358p op amp, 2* bc548b transistors, a SFH300-2 Phototransistor and 6* 1.2V rechargable batteries (being used in 2 sets of 3). The phototransistor in the simulation can not be edited but this part of the circuit should work as the real phototransistor has an even lower dark current of only 5 na.

    upload_2014-6-24_19-33-34.png
    upload_2014-6-24_19-34-31.png
    *NOTE: The led in the picture is actually taking 388 miliamps, the circuit will be control whether or not current flows to a bunch of recycled Christmas lights, however my simulation program does not contain this so I had to set the max rating on the led really high

    I was hoping someone might have some useful observations on my circuit?
     

    Attached Files:

  2. KrisBlueNZ

    KrisBlueNZ Sadly passed away in 2015

    8,393
    1,271
    Nov 28, 2011
    Yes, I have lots of useful observations. First, it's far more complicated than you need, and second, it doesn't have any hysteresis, which means it will not switch cleanly.

    But it's very hard to follow that circuit. It's just a jumble of wires. Start by redrawing it with the negative rail along the bottom, and the positive rail along the top. Try to connect things vertically between the rails, with the signal progress going from left to right. Then add component type numbers for every component, and circuit references (e.g. Q1, Q2, R1, R2 etc). This will make it MUCH easier for us to understand, and give you feedback.
     
    Last edited: Jun 25, 2014
    (*steve*) likes this.
  3. Arouse1973

    Arouse1973 Adam

    5,165
    1,087
    Dec 18, 2013
    I agree Kris. I wonder if anyone would like to do a resource on good practices regarding drawing circuit diagrams.
    Adam
     
  4. KrisBlueNZ

    KrisBlueNZ Sadly passed away in 2015

    8,393
    1,271
    Nov 28, 2011
  5. Arouse1973

    Arouse1973 Adam

    5,165
    1,087
    Dec 18, 2013
    Looks good Kris
     
  6. Anon_LG

    Anon_LG

    453
    117
    Jun 24, 2014
    Yes I see what you mean, I am currently fixing this now.
     
  7. Anon_LG

    Anon_LG

    453
    117
    Jun 24, 2014
    OK, I have cleared up the schematics and labelled the components. First could you tell me what I could make less complicated. (however if it is about the batteries I have several reasons for picking these. Firstly I have limited space for this project as it is all being held in a Ferrero Roche box, secondly I wanted the batteries to be rechargeable, thirdly I needed BT 1 to be 3 rechargables as this is what the Christmas lights run off and fourthly I thought that BT 2 should be 3 rechargables as this is just above the minimum supply for the logic gate and is the right size for the box.) I am only a beginner to basic/intermediate electronics . Could you suggest how I could add hysteresis, (I thought I had already done this as I gave feedback from the output to the non inverting input of the amplifier). dark activated light cleared up- no hysteresis.jpg
     
    Last edited: Jun 25, 2014
  8. KrisBlueNZ

    KrisBlueNZ Sadly passed away in 2015

    8,393
    1,271
    Nov 28, 2011
    Well, you're doing OK for a 13-year-old! If you put your date of birth in your profile, we will see your age, and will be able to respond accordingly.

    It can also help if we know your location, so we know what component suppliers to recommend.

    OK, that circuit has a number of problems and can be simplified a great deal.

    First, let's get the schematic issues out of the way.

    1. The power rails.

    You have shown the 0V rail across the bottom, which is good. It's also customary to put the supply voltage (the batteries, in this case) at one end or the other.

    Each IC should have its own decoupling capacitor connected between its power and 0V terminals as close as possible to the device. Typically a 0.1 µF ceramic capacitor is used.

    2. Component identification

    "D1" should be "Q1" because it's a phototransistor, not a photodiode.

    "OP1" should really be "IC1" or "U1" because it's an IC. Sure, it's an op-amp, but an op-amp is just a type of IC, and you don't call the CD4001 "NOR1".

    The 4001 should have its VDD and VSS connections (pins 14 and 7) shown.

    The op-amp and the 4001 should have all of their pin numbers marked, and you should show the unused sections. The inputs of the other half of the LM358 can be tied to VDD, and unused CMOS inputs should be tied either high or low otherwise they pick up noise and increase power consumption.

    It's better to show all part numbers on the schematic, next to the components. Having a separate list wastes time and leads to errors ("OP1" vs. "OP", and the CD4001 "U1" is also marked IC2a on the schematic).

    We know what a "358P" is, but you should show the full name, which is normally LM358P or LM358N.

    Now to the design issues.

    I'm going to address them all, even though I'm going to suggest changes that will make most of them irrelevant. This is supposed to help you learn. Let me know if you don't want detailed explanations.

    3. Two +3.6V rails.

    You seem to have two +3.6V rails. One from BT1 supplies "D1" and Q2, and the other supplies OP1 and Q1. I don't see any need for two separate batteries.

    4. D1 needs a load resistor.

    "D1" (which is not a diode) passes an amount of current that depends on the light level falling on it. An op-amp or comparator compares voltages. You need to convert the current into a voltage. This is what resistors do.

    If you add a resistor between the emitter of "D1" and 0V, the current that flows through R1 and "D1" will cause a proportional voltage drop across the resistor. That voltage can then be fed into an input of an op-amp, comparator, or other circuit.

    Say you want the resistor voltage to be around half supply (1.8V) when the light falling on "D1" causes a current flow of, say, 500 µA. Rearrange Ohm's Law to give R = V / I and plug in the numbers:
    R = V / I
    = 1.8 / 500 x 10-6
    = 3600 ohms
    = 3k6.

    There is no need for R1 because the maximum current that can flow through "D1" will be limited by the load resistance and the power supply voltage.

    There is also no need for Q1 because op-amps, comparators and most voltage-input circuits have a fairly high input resistance, so buffering isn't needed.

    If you want the dark/light threshold to be adjustable, you can use a trimpot - 10k for example. In this case you might want to protect "D1" from excess current if the trimpot happens to be turned to minimum resistance and "D1" is exposed to lots of light. You could put R1 back in the collector path, or in series with the trimpot (better). R1 doesn't need to be so high though; to limit the current to 10 mA from a 3.6V source, R = 360 ohms.

    5. OP1 has one input tied to its output and the other input tied to VDD.

    You can't tie the output of an op-amp back to the input where the input signal is being applied. Q1 and the op-amp output will fight and the voltage will not be properly defined.

    The only time you connect an op-amp's output back to its input like that is when you're making a buffer or voltage follower. In that case, the output connects back to the inverting ('-') input, not the non-inverting ('+') input, and the input signal is applied to the non-inverting ('+') input. The op-amp then acts as a buffer.

    Most op-amps and comparators won't do anything useful if one of the inputs is tied to the device's VCC pin. Op-amps and comparators only work over a limited range of input voltages. Many will work with their inputs tied to their negative supply rails (these are called "single supply" devices), and one or two will work with their inputs tied to their positive supply rails (but not the LM358).

    The change you need to make here depends on what you're intending to do with the op-amp. If you want to use it as a comparator, you need to set one of the inputs to a threshold voltage. Often this voltage is created using a voltage divider (two resistors in series) across the supply rails.

    If you intend to use the op-amp as a voltage follower (buffer), connect the output to the inverting input. But there's no need for a buffer; the inputs of a CMOS gate have much higher impedance than the inputs of an LM358 have!

    6. Threshold voltage, CD4001 gate, hysteresis

    The voltage you get from the phototransistor reflects a real-world quantity, and these aren't usually clean and tidy. A phototransistor responds quicker than the human eye, and it will see the flicker of fluorescent and incandescent lights, and can detect very small variations.

    If you want a clean ON/OFF control from this signal, you need to clean it up. This is why I mentioned hysteresis.

    You seem to understand what hysteresis is, and why it's needed. If not, say so and I will explain.

    The CD4001 inputs don't have hysteresis. Worse than that, around the decision voltage the gate goes into "linear mode" where it draws extra current from the supply. This is not recommended. You can get CMOS devices that have hysteresis built in - the CD4093 quad NAND gate and the CD40106 (aka CD4584 and 74C14) hex inverters.

    Does Yenka know about any of those devices? If so, they are a reasonable choice for this circuit. If not, it's not hard to make a Schmitt trigger with two transistors and three resistors - see http://www.physics.ucdavis.edu/Classes/Physics116/Schmitt_fig.GIF

    7. LED drive from emitter follower

    You have Q2 connected as an emitter follower. This is a good buffer circuit, but it wastes voltage - about 0.7V base-emitter voltage. This means less voltage for LED D2. A better option is a PNP common emitter circuit. That is a PNP transistor, with its emitter connected to the positive rail, its base connected to the Schmitt trigger output through a resistor (e.g. 1k), and its collector feeding the LED.

    If D2 actually represents a real LED, you'll also need a current limiting resistor in series with it. If it represents the Christmas lights string, that's designed to be powered straight from a battery, then you don't use a current limiting resistor.

    Have a think about all that, and let me know how you want to proceed.
     
    Last edited: Jun 25, 2014
    Anon_LG likes this.
  9. Anon_LG

    Anon_LG

    453
    117
    Jun 24, 2014
    I will fix these on the simulator there is however one of those things I can not do on the simulator, I can not label the pin numbers as the simulator shows only a single logic gate and the supply has to be shown weird, thanks for all that advice. The LED is representing the Christmas lights but there is still a current limiting resistor in the original circuit so if the current gets too low I can just lower the resistor. I am going to Maplin over the weekend and can obtain the parts then, however Maplin does not sell 358 op amp but this is the only op amp available in Yenka will it make much difference if I use a KIA358P op amp instead?
     
    Last edited: Jun 27, 2014
  10. KrisBlueNZ

    KrisBlueNZ Sadly passed away in 2015

    8,393
    1,271
    Nov 28, 2011
    Yes, a KIA358P is a second-source of an LM358 and will be just as useless in that circuit.
     
  11. Anon_LG

    Anon_LG

    453
    117
    Jun 24, 2014
    Shortly after adding my above post I decided I would not use an op-amp for buffering, so I will not be using an op-amp anyway now. I am now using no op-amp, a 4093 schmitt NAND gate and a LDR is working better than a phototransistor, using these seems to make the circuit work, your suggestions worked really well!! All have to do now is edit the resistances so that it works with a different specification for my phototransistor and then I think it will work, also I may attempt to design the circuit so that it only uses one set of 3* 1.2 Volt batteries due to the reduced power consumption.
     
    Last edited: Jun 28, 2014
  12. KrisBlueNZ

    KrisBlueNZ Sadly passed away in 2015

    8,393
    1,271
    Nov 28, 2011
    Good :)
     
  13. Anon_LG

    Anon_LG

    453
    117
    Jun 24, 2014
    Because of KrisBlueNZ's suggestions the circuit is now a lot simpler. I have chosen the LDR over the phototransisor as the current is easier to control with the LDR. I have removed the op amp and replaced the NOR gate with a NAND schmitt gate. I have put a 2K resistor in parallel with the LDR so that the LED does not come on when still light. If there is not enough current flowing through the lights I can put a resistor in parallel with the base-emitter of the transistor and then edit the resistor in parallel with the LDR to re-adjust the trigger light level. I will add a picture of the real complete circuit when it has been soldered. The out put from the transistor is shorted to ground because otherwise for some reason the circuit does not work (have no idea why)


    dark activated light cleared up with hysteresis.jpg
     
    Last edited: Jun 28, 2014
  14. KrisBlueNZ

    KrisBlueNZ Sadly passed away in 2015

    8,393
    1,271
    Nov 28, 2011
    That circuit won't work either. There are a number of errors.

    These errors would become clearer if you arranged the diagram the way I described. That is, with the negative rail along the bottom and the positive rail along the top.

    1. You still have two batteries. There is no reason for this. They are already connected together at their negative sides.

    2. You need a resistor (or a trimpot) from the bottom side of the LDR to 0V, to make a voltage divider so you get a variable voltage at the junction. Without the second resistor, there is nothing to pull the bottom end of the LDR down towards 0V. Also, there is no need for the 2k resistor you have in parallel with the LDR.

    3. There is no need for the emitter follower transistor. If you really want an emitter follower, it needs a load resistor (a resistor between the emitter and 0V).

    4. You have shorted the output of the emitter follower to 0V.

    5. You are still using an emitter follower to drive the LED. I explained in point 7 in post #8 why this is not a good idea.
     
  15. Anon_LG

    Anon_LG

    453
    117
    Jun 24, 2014
    What about this one? It has only one set of batteries, there is no short circuit and there is a potentiometer from the LDR to ground.
    dark activated light cleared up with hysteresis working.jpg

    Should I add a capacitor between VDD and ground? And do I need any current limiting resistors anywhere ( inputs/supply to logic gate?)
     
    Last edited: Jun 29, 2014
  16. Anon_LG

    Anon_LG

    453
    117
    Jun 24, 2014
    IT WORKS!!!!
    I have built it on to a solderless breadboard and it actually works! I am not complete failure! :)

    Thanks to KrisBlueNZ for the great suggestions!
     
    Last edited: Jun 29, 2014
  17. Anon_LG

    Anon_LG

    453
    117
    Jun 24, 2014
    Last edited: Jun 29, 2014
  18. KrisBlueNZ

    KrisBlueNZ Sadly passed away in 2015

    8,393
    1,271
    Nov 28, 2011
    Yes, you should have a decoupling capacitor. All logic ICs should have one across their power supply pins. No, you don't need current limiting anywhere, but you might want to put a 1k resistor in series with the LDR to prevent possible damage in unusual circumstances.

    I'm glad to hear that it works. There are still improvements you can make to the drawing and to the design.

    From my post #8:

    Point 1. You should who the battery on either the west or the east side, and run the positive rail along the top of the diagram only. This will reduce clutter.

    Point 7. You will not get the full supply voltage across the LED because you are using an emitter follower to drive it. An emitter follower drops around 0.7V. If you want the full battery voltage across the LED, you should use a PNP connected in common emitter configuration.

    From my post #14:

    Point 3. There is no need for the emitter follower between the LDR and the 4093 gate.

    Also, you could delete R1 and R2 and use a higher value for VR1 - for example, 50k. But this will reduce the amount of hysteresis in terms of the amount of light falling on the LDR.
     
  19. davenn

    davenn Moderator

    13,833
    1,950
    Sep 5, 2009
    Much better :)

    But you still haven't done the one thing Kris has said to you several times ....

    Get you + V rail across the top of the diagram, you still have it going through the middle .... moving it will make it all look so much tidier and easier to follow

    cheers
    Dave
     
  20. Anon_LG

    Anon_LG

    453
    117
    Jun 24, 2014
    I have changed the circuit to make it turn on/off when it is a bit darker. dark activated light cleared up with hysteresis working.jpg
     
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-