Maker Pro
Maker Pro

LED Circuit Question

kris8583

Aug 25, 2010
23
Joined
Aug 25, 2010
Messages
23
Hi all, im new to the forum and have a quick question;

I have 2 LEDs that I want to control using 2 normally open switches. Id like LED A to be on until I press the switch 1, at which point it goes off and LED B comes on. Then when switch 2 is pressed it diverts back to original state of LED A on and LED B off.

I did electronics at school a few years ago and forgot most of what I learnt. I dont want to get into PIC programming, just basic soldering etc. I shall be adding more to the circuit if I can get past this stage.

Thanks in advance for any help.

Regards, Kris
 

kris8583

Aug 25, 2010
23
Joined
Aug 25, 2010
Messages
23
Thaanks for the reply, I have been using some online software and managed to get what I need up and running. For saying I have not done anything this involved, I got it up and running quite quickly (probbably basic to you guys lol)

Heres where I am so far:

INOUTLIGHTSDONE.jpg


For the next part I would like to add a stopwatch, displayed using 7 segment display. This would be counting to 2 decimal places to time the time it takes from switch 1 being pressed to switch 2 being pressed. Is this possible without using a pic? The time displayed should remain unitl switch 1 is reactivated.

Again look forward to any replies,

Kris
 
Last edited:

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,510
Joined
Jan 21, 2010
Messages
25,510
I'm not sure how that circuit corresponds to your problem.

Have you considered contact bounce?

what is the 555 for?

I had assumed the round things were LEDs, but they're not wired correctly, and I've never seen a black LED :)
 

kris8583

Aug 25, 2010
23
Joined
Aug 25, 2010
Messages
23
Thanks for the reply,

Originally I wanted to just operate an LED using a Normally open switch, its has grown to what you see currently, i added extra LEDs and wanted the 3 blue ones to flash when they are actvated by the switch.

They are LEDs but the black ones are turned off, when either of the switches are pressed the lights that are currently on go off, and the others come on then vice versa.

The 555 makes the blue LEDs flash.

As im new to this, I dont even know what contact bounce is, I was going to get a drawing/simulation and take to Maplins to get another opinion to see how far off i am.

Im using this to get it up and running and circuit works fine so far:

http://www.falstad.com/circuit/e-555square.html

I just started from scratch on there and ran the sim, works great lol.

If there are any issues with the sketch please feel free to help and make it better.

Regards, Kris
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,510
Joined
Jan 21, 2010
Messages
25,510
Your blue LEDs will have a very bright, glorious, and very short life without a series resistor.

The red/greed LEDs in parallel will be of very uneven brightness (at best) and will clamp the output voltage from the gate to a value too low for the 555 to charge the capacitor (2 series resistors -- one per LED -- may help).

Both the red and the green LED will be on at the same time (in the best of cases)

Contact bounce means that the state of the output is likely to be random after each button press.

Why 2 switches in parallel? You claimed to want each switch to perform a different function.

What is the point of your question when you tell us a few posts later that you have redefined it into something completely different.

Please start again, and tell us what your current problem is, and then we can put some effort without it being wasted.

edit: do you know what logic family you'll be using? Pretty much all of them have absolute max voltages around 7V. 4000 series CMOS being one exception. Also what particular flip-flop are you looking at. There are many, each with slightly differing behaviour. make sure you know if the one you want is available in 4000 series CMOS (or whatever you plan on using) and tell us what it is so we can figure out if you're using it correctly.
 
Last edited:

kris8583

Aug 25, 2010
23
Joined
Aug 25, 2010
Messages
23
Hi Steve, thanks for the reply,

Heres what it should basically look like:

PLANA.jpg


This is to run pitlane lights on a slot car circuit. It needs to be seperatley powered from everything else. I need to use momentary switches so that a car can activate it easily without interfering with the car or track.

Then blue LEDs need to flash when turned on.

Id like to add a timer to time from switch 1 activation to switch 2 activation. This is to be displayed to 2 decimal places using 7 segment display. This should be counting in seconds and displayed after switch 1 has been activated until switch 2 has been activated, thengiving a final time displayed until another car passes switch 1.

Heres where it get a little more complicated, if car A is using this lane I need to add a switch to the track to prevent car B using the same lane, this diverts the car to a seperate lane.

Hope this makes sense, il try to get some more sketches done if need be.

please any questions please ask, sorry I didnt explain propperly what I would like to achieve.

Regards, Kris
 
Last edited:

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,510
Joined
Jan 21, 2010
Messages
25,510
I suggest you build it in sections on a breadboard, getting each part working before you move to the next part.

The parts are:

1) bistable -- this is the part that changes between 2 states on the press of the appropriate buttons. It can also illuminate LEDs that you want to have steadily on or off in either state. Check out the link I gave earlier, and pick the same one the other person did. Get it working :)

2) once you've done that, we'll talk about making the LEDs flash in one state. We'll probably use another 40106 and a couple of resistors and capacitors.

3) the last step to build a counter and enable/reset based on the bistable state.

If you're not near a store selling electronic components, then maybe we'll design it all first (so you know what you need) and then you can get the stuff and build it part by part.

For various reasons I'd suggest a 5V power supply. An old cell phone charger rated at 5V and at least a couple of hundred mA will be fine. If you don't have one, step 0 will be to design a power supply.

You also need to consider how you're going to construct this. If you build it on a breadboard, there are some circuit boards available that have the same layout so you can just transfer it over. If you have a little more experience you may like to use veroboard, or even make your own printed circuit board.

Does that sound like a plan?
 

kris8583

Aug 25, 2010
23
Joined
Aug 25, 2010
Messages
23
Thanks Steve,

I added some fans to my xbox a while ago and I bought a power supply from Maplins, so im sure I can find something to use to power it up.
Ive got LTSpice on my laptop if thats any help, i just prefer somethng like the java simulator so i can actually see whats happening.

So heres the plan then;

Stage One: Plan schematic of lighting, list parts

Stage Two: Plan schematic of timer with display, list parts

Stage Three: Add S1 and S2 together

Stage Four: Plan basic flipper to divert car 2, list parts

Stage Five: Draw whole schematic for project. Trip to Maplins for parts required

Stage Six: Build

Does this sound ok? Limitations are no PIC and simple for me to understand to wire it all up. I can remember building my own circuit board at school so that should not be too much of a problem, im good with my hands, its the brain that lacks lol
 
Last edited:

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,510
Joined
Jan 21, 2010
Messages
25,510
let's see how it works :) You'll have to explain about the flippers.

Firstly, have you looked at the bistable circuit I mentioned, and do you understand it?
 

kris8583

Aug 25, 2010
23
Joined
Aug 25, 2010
Messages
23
Ok hope this make it easier to understand, I have this working:

http://www.falstad.com/circuit/e-rtlinverter.html

Once on this page right click on blank part of schematic and select circuit, blank page. Then right click again and go file, then import.

Paste this into the box:
$ 1 5.0E-6 5.023272298708815 64 7.0 50
w 240 176 208 176 0
r 208 176 208 240 0 10000.0
w 208 240 240 240 0
w 208 240 208 272 0
w 208 272 240 272 0
c 208 272 208 336 0 3.0E-7 0.22678354071491671
r 208 176 208 112 0 1000.0
w 208 112 304 112 0
165 240 144 256 144 2 0.0
w 304 112 368 112 0
w 368 112 368 176 0
156 48 176 96 176 0 -0.0
g 432 336 432 352 0
w 48 240 16 240 0
w 48 176 16 176 0
w 16 128 16 176 0
w 16 176 16 240 0
w 48 208 48 320 0
w 48 320 16 320 0
s 144 304 144 336 0 1 true
s 112 304 112 336 0 1 true
r 16 240 16 320 0 100.0
R 16 128 16 112 0 0 40.0 5.0 0.0 0.0 0.5
w 144 176 144 112 0
w 144 112 208 112 0
162 368 208 416 208 1 2.1024259 0.0 0.0 1.0
162 368 240 416 240 1 2.1024259 0.0 0.0 1.0
162 368 272 416 272 1 2.1024259 0.0 0.0 1.0
w 368 208 368 240 0
w 368 240 368 272 0
w 416 272 416 240 0
w 416 240 416 208 0
w 144 112 144 64 0
w 144 64 448 64 0
162 448 208 496 208 1 2.1024259 1.0 0.0 0.0
162 448 240 496 240 1 2.1024259 1.0 0.0 0.0
162 448 272 496 272 1 2.1024259 0.0 1.0 0.0
w 448 208 448 240 0
w 496 208 496 240 0
w 496 240 496 272 0
162 544 208 592 208 1 2.1024259 1.0 0.0 0.0
w 592 336 512 336 0
162 544 240 592 240 1 2.1024259 0.0 1.0 0.0
w 448 208 448 144 0
w 448 64 448 144 0
w 592 208 592 240 0
w 592 272 592 240 0
w 528 208 544 208 0
w 448 144 528 144 0
w 528 144 528 208 0
w 544 240 544 48 0
d 448 240 448 272 1 0.805904783
d 448 304 448 272 1 0.805904783
w 448 304 544 304 0
w 544 304 544 240 0
w 16 320 64 320 0
w 496 272 496 336 0
w 432 336 496 336 0
w 496 336 512 336 0
w 416 272 416 336 0
w 432 336 416 336 0
w 416 336 208 336 0
w 592 272 592 336 0
w 144 240 160 240 0
w 160 240 160 48 0
w 160 48 544 48 0
w 208 336 144 336 0
w 144 336 112 336 0
w 112 304 144 304 0
w 64 320 64 304 0
w 64 304 112 304 0
x 94 361 123 367 0 24 S1
x 141 362 170 368 0 24 S2
o 5 32 0 35 5.0 7.8125E-4 0 -1

If you operate either switch the LEDs change, hopefully getting somewhere near.
 
Last edited:

kris8583

Aug 25, 2010
23
Joined
Aug 25, 2010
Messages
23
I had a look Steve and tried the 3rd picture in the java program to try and understand how it works, when i operated either switch nothing happened, am i doing something wrong?

The pit lane is accessed via a digital lane changer, selected by the users controller. I need to add a moving flipper before this piece of track to divert cars automatically so they cant enter the pit at the same time as another car. This flipper will be activated when a car passes switch 1 in the pit, effectively closing the pit lane until the second switch is used to re open the lane
 
Last edited:

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,510
Joined
Jan 21, 2010
Messages
25,510
It's a perfect example of why simulations are traps for young players.

It shows the Q output driving 6 LEDs and a 555. Admittedly, this won't kill the LEDs as the flip-flop won't be able to supply sufficient power, but it's also likely to sag badly under that load and the 555 will either not oscillate, or will do so rather oddly.

Also the simulator doesn't simulate contact bounce. This is like clicking the button a random number of times (say 15 to 20 times) each time you want to simulate a button press.

Draw my circuit using that tool and let me have a look at it. It's possible the simulator just isn't very good.

No, it works fine.

$ 1 5.0E-6 10.20027730826997 50 5.0 50
I 144 208 240 208 0 0.5
I 240 208 320 208 0 0.5
r 320 208 416 208 0 100.0
r 320 208 320 112 0 100.0
162 416 208 416 288 1 2.1024259 1.0 0.0 0.0
g 416 288 416 304 0
w 320 112 144 112 0
w 144 112 144 208 0
w 144 208 96 208 0
s 96 208 96 64 0 1 true
s 96 208 96 336 0 1 true
g 96 336 96 352 0
R 32 48 32 64 0 0 40.0 5.0 0.0 0.0 0.5
w 32 48 96 48 0
w 96 48 96 64 0
 
Last edited:

kris8583

Aug 25, 2010
23
Joined
Aug 25, 2010
Messages
23
Thanks steve, I got it up and running.

So when top switch is closed the led is on. When bottom switch is closed, because it has an easier path to earth it cuts out the rest of the circuit, am i right? There seems to still be power trapped between the diodes as it is still lit up green.

If you could explain how it does what it does and what the types of diode(?) are used.

Experimenting on the circuit, i added an led between the 2 diodes and connected it to the earth by the bottom switch, this gives me what im looking for, for the static lights. is this acceptable?


$ 1 5.0E-6 2.922428378123494 63 5.0 50
I 320 336 416 336 0 0.5
I 416 336 496 336 0 0.5
r 496 336 592 336 0 100.0
r 496 336 496 240 0 100.0
162 592 336 592 416 1 2.1024259 1.0 0.0 0.0
g 592 416 592 432 0
w 496 240 320 240 0
w 320 240 320 336 0
w 320 336 272 336 0
s 272 336 272 192 0 1 true
s 272 368 272 496 0 1 true
R 208 192 208 208 0 0 40.0 5.0 0.0 0.0 0.5
w 208 192 272 192 0
162 416 448 416 496 1 2.1024259 1.0 0.0 0.0
g 272 496 272 512 0
w 272 336 272 368 0
w 272 496 416 496 0
w 416 448 416 336 0
o 1 64 0 35 5.0 0.1 0 -1

EDIT: since posting i went through all components until i found the inverter, going to do a bit of reading about it now to understand a bit better
 
Last edited:

kris8583

Aug 25, 2010
23
Joined
Aug 25, 2010
Messages
23
Ok so did a bit of reading and I sort of get the idea behind the inverter, it basically makes yes into no and no into yes (0/1 and 1/0). What i dont understand is where the power comes from between the two inverters when the second switch is activated.
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,510
Joined
Jan 21, 2010
Messages
25,510
With an inverter, the output is either high or low -- they do not operate in between (actually that's not entirely true, but accept that for the moment).

The inputs are also very high impedance, and require very little current to operate.

The basic circuit is the ring of 2 inverters. Pretend for a moment that there is no resistor there, and that it is just 2 inverters connected back to back.

Assume that on power up, one of the inverters is turned ON -- the output is high. It will turn the other one off, which will reinforce the state of the first one. They get latched into one of two states. Always one is on and the other off.

Now include the resistor. It makes no difference to the operation. Remember that I said the input impedance is very high, the series resistance is too low to affect the logic level seen by the input it is connected to. In real life, I might put a 100K resistor here,

There are switches connecting the input of the inverter to either high or low logic levels (the supply rails) The point of having the resistor is clear, it limits the maximum current that can be drawn from the output of the second inverter if we decide to force the input state of the first inverter.

Lets assume the first inverter is off (output low). Therefore the second one is on (output high) and the input to the first inverter is high.

If we press the button connected to the +ve supply rail, nothing happens. The input to the first inverter is already high and we change nothing.

If we press the second button connected to ground, the input of the first inverter is pulled low (overriding the output of the second inverter. The output of the first inverter goes high, causing the output of the second inverter to go low, and then reinforcing the low on the input of the first inverter. When the button releases, the state is maintained.

Pressing the lower switch again will do nothing, but via a similar (but opposite) series of effects, the upper button will change the state again.

Inverters are very fast. The switching action will happen in nanoseconds, so the briefest of button presses is all that is required.

This is not a practical circuit though. What happens if the operator presses both buttons? To guard against the power supply being shorted out, we would put resistors in series with the buttons (about 1/20 of the value of the resistor connected to the output of the second inverter.

However there is still a problem. What happens if both buttons are pressed? An indeterminate signal is forced in the input of the first inverter, and passed to the second. The output of the second inverter could be high, low, or somewhere in-between. The solution is to use schmitt trigger inverters -- alas these do not exist in the simulation software. Schmitt trigger inverters ALWAYS have a high or low output, even if the input varies from supply rail to supply rail. Using them will ensure that even if both buttons are pressed, the output will be a predictable state.

Where does the power come from? The power supply connections for the inverters are not shown. Typically you might have a 14 pin device containing 6 inverters and also having 2 power supply pins. These are typically not shown on a circuit diagram (just to fully confuse the young player)
 

kris8583

Aug 25, 2010
23
Joined
Aug 25, 2010
Messages
23
Ok waaaaay too much info my brains hurting lol.

I sort of understand what's happening, and it will get easier I think.

So where do we do from here, now we have both switches in place there should be minimal chance of both being activated at the same time.
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,510
Joined
Jan 21, 2010
Messages
25,510
no, unless the switches cannot be pressed at the same time (for example they're a SPDT toggle switch) it's a bit like driving your car with a knife sticking out of the steering wheel. Sure, you're safe unless you have to brake hard, but will that never happen?
 

kris8583

Aug 25, 2010
23
Joined
Aug 25, 2010
Messages
23
Thanks for your help so far steve,

I think im more confused than what I have understood so far lol.

So how do we get over the possibility of both switches being activated at the same time?

The flipper I want to add would certainly reduced the risk to a bare minimum as 2 cars would not be in the same lane at the same time. However if the racing is close there is the possibility of it happening still.

Heres a image of the track. A is where the cars select to enter the pitlane (its a digital system). B is where I propose to add the flipper to divert the cars to the other lane. C and C2 are the 2 switches to operate the lights.

untitledbnb.jpg
 
Top