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.

The most beautiful circuit you know/you designed?

Status
Not open for further replies.

misterT

Well-Known Member
Most Helpful Member
It would be fun to share some circuits that you are proud of, impressed of, or just simply enjoyed designing.
Post your circuits (and stories). Anything goes from the simplest circuits to complete systems.


I'll start.
This is one circuit that I enjoyed working out. How to drive a (two leg) bi-color LED using two microcontroller pins.
The challenge was that the two LEDs needed to be "tuned individually" for proper current/brightness.

This was my solution:

**broken link removed**
(sorry for bad symbol for 2-legged bi-color led)

Example assuming 5V operating voltage:

If R2 = 160 ohms and R1 = 3300 ohms then the
current for 2.0V red led is 18.2 mA and the
current for 2.2V green led is 18.3 mA. And the
"wasted" current through R1 while the red led is lit, is 0.6 mA.

Below are schematics for the two states:

**broken link removed**
If you want the LED currents to be exactly the same, then:

R1 = R2*(V+Vr-Vg) / (Vg-Vr)
where V is supply voltage, Vr and Vg are the green and red led voltages and R1, R2 are the resistors.

Original problem is in ETO: https://www.electro-tech-online.com/threads/challenge-of-the-day-dual-color-led.120564/
 
Last edited:
I must say, MisterT, that is elegant.

If I may ask, did you just do the math, or trial and error the different resistors for that puppy?
 
math first... adjust later...

we use the same type of thing for a client that wanted a circuit to switch on a high or a low input... he didn't know how it would be driven, automotive application, output driven to +12V or pulled to ground, and different installations could see different levels... so he wanted it to work either way. Since the switch would be dry contacts (open or closed), to the voltage rail, we used bidirectional input opto isolators, biased one side to 6V, and fed the input to the other side. The bias resistors also limited the LED current.
 
T,
It's a BEAUTIFUL ONE!
Thanks for sharing!

What was behind the challenge? (work / school task?)

Could you share few more?
 
Yes, I did the math first.

Some variables
V //supply voltage
Vg //green led voltage
Vr //red led voltage
Ig //green led current
Ir //red led current

IR1 // R1 current
IR2 // R2 current

When green led is on:
Ig = (V-Vg)/(R1||R2) = ((V-Vg)*(R1+R2)) /(R1*R2)

When red led is on:
IR1 = Vr / R1
IR2 = (V-Vr) / R2
Ir = IR2-IR1 = (Vr/R1) - ((V-Vr) / R2)

Now you have two equations to solve for R1 and R2:
Ir = (Vr/R1) - ((V-Vr) / R2)
Ig = ((V-Vg)*(R1+R2)) / (R1*R2)

or in another form:
(R1*R2)Ir = Vr*R2 - (V-Vr)R1
(R1*R2)Ig = (V-Vg)(R1+R2)

.. and from that it is better to plug in the values you know and solve for R1 and R2.
You can work out a general solution, but.. meh. Maybe later.

I worked it out.. did not check it with real values yet:

[LATEX]R_1 = \frac{V(V-V_g)}{I_g(V-V_r)+I_r(V-V_g)}[/LATEX]
[LATEX]R_2 = \frac{V(V-V_g)}{I_r(V-V_g)-I_gV_r}[/LATEX]
 
Last edited:
Hi,

I've used "ASCII" math for years and years, so it doesnt bother me one bit. In fact, i like it because if the Latex text renderer is broken i can still read the text clearly. It also makes it possible to copy and paste the equations into another application for your own use or for checking to see if they are accurate or what their range of validity is, etc. Many programs can accept ascii text input.

The circuit is interesting. I think what i would have done though is i would have just made one port go to high impedance when it wasnt needed. That would make resistor selection much simpler.

The circuit as is however admits the following solution for the two resistors:
R1=V*(V-vg)/(ir*vg-(ir-ig)*V-ig*vr)
R2=V*(V-vg)/(ir*V+ig*vr-ir*vg)

where
V is the power supply voltage,
vg and ig are the voltage and current for the green LED,
vr and ir are the voltage and current for the red LED,
and the equations should be valid as long as neither resistor goes negative,
[it looks like the constraint on 'ir' is: ir<=ig*(V-vr)/(V-vg)]


and assuming the currents for the two LEDs are as talked about here due to the proposed connections:
ig=(V-vg)/(R1*R2/(R1+R2))
ir=(V-vr)/R2-vr/R1

The design procedure would involve deciding on the two currents for the green and red LED, and because of the connections it looks like the one called "green" should be the one that needs the highest current or else the circuit wont work for some values (see the constraint equation above). If the one called "red" needs significantly higher current then one of the resistors would have to be a negative resistance and i assume we dont want that, so just swap green for red and red for green by just flipping the IC package and then calculate red for green and green for red.

For example, if we want the following currents:
red LED ir=0.010 amps,
green LED ig=0.012 amps

and the voltages are as talked about in this thread (2.2 for green and 2.0 for red) and the power supply V is 5 volts, then the two resistors come out to:
R1=1750
R2=269

and im sure you can pick two standard values that are close to these values.

The equations should be good as long as neither resistor goes negative, so that means some currents for both LEDs wont be possible, but you can always flip the LED package to get the higher level current to the opposite LED if you run into a current level problem. I leave it up to the reader to check for themselves. Once you have a set of resistors you think you want to use, you can also test them in the two equations for the two LED currents.

Interesting that you had an LED circuit that you thought was cool, because i had a circuit too with an LED that i thought was cool used for something different. I'll post it later in the thread sometime. It's also a simple one.

[LATER]
Added the constraint equation above as the current through the red 'ir' is limited by the desired current through the green 'ig'., unless the package is flipped and then 'ig' is limited by 'ir'. Also, max current for the pin has to be observed.
 
Last edited:
Hi,

The circuit is interesting. I think what i would have done though is i would have just made one port go to high impedance when it wasnt needed. That would make resistor selection much simpler.
.

How would your circuit look like in that case? :)
 
Way back when I replaced an incandescent stereo indicator lamp with a LED using the simple resistor LED trick. It didn't work. I had bright and dim as the states.

Your turn to guess.
 
How would your circuit look like in that case? :)

Hi,

I was just thinking simple. Same circuit, but switch R1 pin to high impedance instead of grounding it for say the green LED. Might make it simpler but we can look at this more.

I was also thinking about two resistors biasing one bi directional LED where one resistor goes to +5 and one goes to ground, that requires only one uC port pin, but it does mean higher quiescent current which might be objectionable.

I was also guessing PWM was not going to be an option due to code simplicity.

This simple circuit though is very interesting because we often have to light LED's to act as indicators, and that makes the difference sometimes between a nice circuit and a not as nice circuit. I put LED's on several of my projects just so i know what it is doing during different phases of operation. Hard to beat the simplicity.
 
One of the more important circuits was one that interfaced to a bunch of air valves. All of the valves had to close on a power failure or fire alarm except two. If the valves were closed, they were to stay closed during a fire alarm. If they were open, the system wasn't operating in nasty mode. These were 12 or 10" high vacuum gate valves that needed air to open and air to close.

There was one time when a valve was open and the someone could have a hand or $1000 magnetic screw/pull feed though inserted. So, it's either by by and or expensive feedthrough damage. It was OK if the valve closed until the generator re-started or about 30-45 seconds.

So, two fixes were imployed. These two valves would stay in the same state they were if a power failure or fire alarm occurred.
So, for a fire alarm, or system abnormal shutdown, the valves would stay open.

In a power failure, the valves would shut, but would open again. We did have to manually close off the valve vent when we did those operations.

The valves were 24 VAC.

Unfortunately, I did develop a more comprehensive interlock , but it was never installed. Eventually funding dried up. The idea, anyway was to prevent accidential release of gases that kill in ppm concentrations. There was the ability to release the entire manifold into the atmosphere. When the pressure interlock was bypassed, certain operations were to be disabled such as the ability to put the nasty gases in the chamber.

Aside:

Management had an interesting view about safety. They bought a hydrogen detector and had ii in a box for a year or more. Then there was a Hydrogen explosion. Then the Hydrogen detectors were installed. Reaction rather than proactive.

I wasn't allowed to fix an alarm, like $70 for a water flow switch, for a 20 Killo-gaus magnet. The alarm was simple. If the magnet lost cooling water the loud bell went off. Shutting the magnet off would have been much harder. INHO, the safety needed to be there even if it was barely used. My micomanaging boss couldn't spare the $70 or the time to do it. The instrument got bursts of usage or none at all for long times. The best time for a mistake to happen. The load bell was a reminder that you didn't turn the water on.

Another cute story. The builders totally botched the cooling water system and the know it all managers totally botched the electrical specs of a lot of equipment. many years later, i would find out that a large percentage of the 470 normal electrical outlets were defective. I could identify the bad ones, but did we, no! My recomendation was to replace them all after we had significant damage.

Management said to replace all of the ones located in labs and to check any outlets that had computers plugged into them. This was early PC era.

The cooling loop issue was really cool. They basically put all of the equipment on city water and luckily there were drains installed in the labs. You cant use 6 psi 90 degree water from the heat pumps to cool a piece of eqipment thatrequires a few GPM of 60 degree F water at 80 PSI through a 3/8" pipe. "They" actually tried a booster pump.

Later there was a push for water conservation and "we" were using a lot of water by basically dumping it. 3 pieces of equipment had a 3/4 pipe and the tap was full open. No filters were initially installed either, Maybe $2000 each to repair six pieces of certain equipment without a filter.

Well, anyway they eventually did a site survey of water consumption and it actually turned out favorable. We do pay for equipment damage and installation of the water stuff, but we DON'T pay for the water, it was a no-brainer not to do it. Ironically, we were developing renewable energy and probably the most energy inefficient building on the campus.
 
Probably the neatest thing I invented was a "Plane separator" for dynamic balancing machines. It eliminated "Cross effect" which made it hard to balance things such as train wheels, where one side would interact with the other.
 
It's not a circuit but a project with many circuits of digital and analog control.
One project that's used daily at work is a rebuild assembly tester. The machines are fairly old and use a system of relays and resistors (it's in a very high EMI and RF/X-RAY area) to control speed and direction of ion beam steering electrodes. We have a contractor that cleans and rebuilds used modules but we needed a way for him to test them before installing so we could be sure they worked as required to reduce downtime. So, I designed a uC controller box simulator with a special set of interface cables that automatically configures the test gig box for each type of module when the cable is inserted in the adapter connector. We also use this test box to manually control modules in the machines when they are powered off for alignment testing.

MANDM project.

Here is a link to a old version of the project software and early design: https://github.com/nsaspook/mandm
and some media of the prototype controllers. https://www.flickr.com/photos/nsaspook/sets/72157630632759744/

One of problems was the high resolution QEI encoders on some of the digital position feedback systems as some were up to 360,000 counts per revolution. For testing this precision was not needed and at high speed the PIC couldn't handle the interrupt load easily so a simple divide by 16 counter circuit for the A input and latching for the B input was used (both 74193 chips from the shops misc parts bin). At every 16 counts the divided A would latch the full count B signal and send an external interrupt to the controller to increase or decrease the internal position counter from the current latched B bit on the input pin for 1/16X positioning.

clip_image006_thumb.gif

Code:
        if (INTCON3bits.INT3IF) { // motor QEI input
                INTCON3bits.INT3IF = LOW;
                if (TMR4 > V.qei_counts) V.qei_counts = TMR4; // if timer4 is not 0 then update
                TMR4 = 0; // reset the timer to zero
                T4CONbits.TMR4ON = 1; // start the timer if stopped
                V.b3++;
                // not a very good position counter, relies on a 1/16 A channel hardware divider and a B channel logic level latch
                LATJ = LATJ | 0b00001111; // clear diag 0..3 leds on PORTJ
                DLED_3 = ON;
                qei1.ticks = 0;
                if (QEI1_B) {
                        --qei1.c;
                        qei1.cw = TRUE;
                        DLED_1=ON;
                } else {
                        ++qei1.c;
                        qei1.cw = FALSE;
                        DLED_0=ON;
                }
                if (QHOME) qei1.home = TRUE;
                if (QBACK) qei1.back_stop = TRUE;
                if (QFORWARD) qei1.forward_stop = TRUE;
        }

Hand drawing of the circuit from the project notes.
 

Attachments

  • qei_divider.jpg
    qei_divider.jpg
    84.4 KB · Views: 211
Last edited:
X2 Mains Cap LED project...

My little X2 project is going really well. My friend that has the first one purchased is using it everywhere. I told him...you hear thunder or lightning....make sure you turn everything else off in your house and make sure you plug this little bugger in. I want to see that it is able to survive. So far so good. Heck, I know mine handled 400VAC for three runs @ 5 Mins a run. Not bad for a 220 VAC rated product.

Still waiting for a failure of any kind. Not enough testers though. I cannot give things away simply for testing purposes. So it is a case of wait and see.

Family want to know. I said it's early days. The principle of using a Cap for AC Current limiting is well known......but not well practiced.

Casing must be strong (ABS). User must have no chance of coming into any electrical contact with any part of the internal circuitry...no output stuff in other words...leads, connectors etc.

Relatively easy to do in this case. No output stuff :cool:

Regards,
tvtech
 
Last edited:
Well, it has been a full day, and no one else has posted any circuits. Maybe MisterT has set the bar too high, and others are too embarrassed to present something less. Let me break the ice with some considerably more trivial circuits.

I cannot claim to have invented any circuit. I am just a hobbyist. I cut, paste, snip, assimilate, and modify. I don't believe either circuit presented here is particularly useful, but each served a purpose at the time.

The datasheet for a GLCD I was using had very specific recommendations for timing and sequencing the negative bias voltage, namely never allow Vee to be present without Vdd. So, I looked for a negative-voltage switch. There weren't a lot of options, but based on what I found, I came up with this circuit:
upload_2013-11-2_13-34-20.png

The asc file is attached below. Here is an image of it:
Capture.PNG
The green trace is taken at the base of Q1 in the simulation schematic; the red is at the load. NB, the component numbers are different in the simulation from the schematic posted above.

After discussion on ETO, others convinced me that such timing was not critical. I ended up using just a negative-voltage generator with an enable pin. A simple delay was used to allow the voltage to decay before turning off the positive supply. The value if R1 in the schematic above is not critical. All you need is enough Vgs differential to turn on the mosfet. The circuit will simulate without the transistor(Q2) and a voltage divider, but then, the divider resistances become very touchy.

The second circuit came about as sort of a tacit challenge. It is often stated that the LM555/NE555 lacks frequency stabiltiy. I don't think that is a fair criticism. It is like any other RC oscillator. Bill Marsden (aka QuietMan on ETO) is fond of representing the 555 as a Schmitt innverter. One of my favorite application notes is from Fairchild on CMOS inverter oscilators (https://www.fairchildsemi.com/an/AN/AN-118.pdf). So, putting 1 and 1 together, I came up with a crystal-stabilized, 555 oscillator:
555 CRYSTAL TESTED_2.png

I don't believe this has any real use, unless one has a box of 555's and no simple Schmitt inverters.

John
 

Attachments

  • Draft1.asc
    1.8 KB · Views: 177
Hello again,

I looked at making the R2 port pin go to high impedance and what i found was that the only thing it accomplishes is it makes the calculation a 'little' simpler. This, in itself, is not a good reason for using this idea, and there is another big drawback.

First, the equations are:
R2=((V-vg)*(V-vr))/(ir*V+ig*vr-ir*vg)
R1=(V-vg)/ig
R2=(R1*V-vr*R1)/(ir*R1+vr)

where if you use the third equation for R2 instead of the first you just have to calculate R1 first, so it makes it a tiny bit simpler.

But the big drawback appears when we calculate the required pin current for the microcontroller when turning on the red LED which is:
ip=(V-vr)/R2 {same for both circuits}

and amazingly this current can come out significantly higher for turning the red LED on when making the R2 port pin go to high impedance than when making it just go to ground for the green LED.
The reason for this is that when the port goes to high impedance, resistor R1 has to supply all the current to the green LED and this means that it must be a lower value, and that means that when the red LED is on more current is bypassing the red LED.

So i look at this as a severe drawback simply because it is just too much higher (could be 1.6 times more pin current or maybe more). So this means that misterT's circuit is the best circuit to use for this in most cases.

Just how much difference are we talking here?
Well, with the port switching to ground the port pin current for the red LED came out to around 12ma, but with the port going to high impedance, it took about 18ma to light the red LED properly (12ma green, 10ma red). I consider that too objectionable to be useful. Again the reason for the difference is because R2 must be lower for the high impedance implementation.

Good circuit misterT :)
 
Last edited:
Well I don't know about a beautiful circuit, but one of the most interesting I had to sort out was a pretty simple spec, with one slightly awkward twist to it!
4 buildings on an industrial site, each about 400 yds apart (perimeter buildings). There was a requirement to relay the presence of whether there was an officer in situ or not ( a simple LED on or off) at each building. Each building to know what the status of all the others was at all times. Only a single telephone cable pair, 'daisy chained' between each building was available. There was power in each building, but there was a requirement for galvanic isolation at each node (no 'commons')
Simple enough task.......except that the client refused point blank to allow the use of ANY software control at all.
No Microcontrollers, no PICs, no PCs.... nothing. It all had to be done in hardware, and it had to be cheap!....
Not actually that difficult of course, but it was an interesting use of DTMF tones!
 
At a place I worked about 30 years ago, I built a test box for the electrical department (I was part of the computer department).

The box provided a "stiff" supply to test voltage and frequency trips for generators*.
It used an 8038 oscillator, driving a 100watt amplifier module, driving a transformer to step up the voltage to 250v (ish).
The frequency was variable from abput 40 to 60hz.
There was a built in frequency/period counter.

I built this neatly into a case and had a front panel overlay printed on plastic sheet.

All in all it looked quite good when it left the computer workshop.

I next saw it a few months later on a shelf in the stores, I nearly cried.
It had an ugly stores stock label just stuck haphazardly on the side and the top of the case was scribbled on with a big black magic marker (Sharpie Pen ?)

Sacrilage!

JimB

* The electricians had previously used a transformer driven by a 2N3055 multivibrator.
When the device under test tripped, both the voltage and frequency changed.
I got involved when I was asked if there was anything we could do to improve it.
Yes, replace it with a proper one!
 
Old thread, but here is Dave answering my question.. not too exiting answer, but I understand. It is a tough one to answer in short amount of time.
Click the link to jump to the question:
https://www.youtube.com/watch?feature=player_detailpage&v=YpJ9ueJ9bEA#t=5697

And if somebody has a pretty/interesting/fun circuit to post to this thread.. please, post it :) I have enjoyed the stories and circuits so far.. very interesting.
 
Hi there misterT,

I clicked on the link but it just took me to a 3 hour video, no question unless it is part of the video but i cant watch a 3 hour vid just to find that one question. If you tell us the time it appears though i would be happy to check it out. Is it the water control question maybe? Thanks.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top