Electronics > Projects, Designs, and Technical Stuff
One MCU port pin state(low, high, Hi-Z), 3 LEDs Design Challenge
(1/3) > >>
eblc1388:
Because of convid-19, I'm bored staying at home. So I set myself a challenge. Do you like a challenge?

Challenge: using common components, lights 3 separate LED according to MCU port Pin state logic high, logic low and Hi-Z(input)

Rules:
1. +5V supply for MCU and LEDs
2. MCU does not have to service the LED states once port pin state changed
3. Only resistor, capacitor, diode(all types), NPN/PNP, N-ch & P-ch MOSFET, JFET allowed
4. All LEDs same type, drive current around 2mA
5. Assume Component cost(units):
   a. resistor : 1
   b. capacitor, diode : 2
   c. LED, npn/pnp transistor, MOSFET : 3    (First 3 LEDs does not count, only for extra LEDs)
   d. JFET : 4
6. the least cost of BOM wins.

The best I can do costs 14 units, if a short glitch between pin state changes is allowed, then its comes out to 12 units only.
The simulation result is attached.

I have attached my design in a zip file. Can you do any better? Do not peek at the solution unless you've given up.  >:D

I used the following circuit(see image) to simulate the MCU port pin, going from logic 0 to logic 1 and then Hi-Z in the space of three seconds. The .asc file of this template is also attached.

Please post the BOM cost, LED current results and your design .asc file if possible.

Good luck.



Someone:
You can drop the diode if there is scope to carefully select the Vf of the LEDs
eblc1388:

--- Quote from: Someone on May 06, 2020, 12:06:58 pm ---You can drop the diode if there is scope to carefully select the Vf of the LEDs

--- End quote ---

Thanks for taken up the challenge.

Current in the third LED is only half that of the other two and there are still 0.2~0.5mA flowing which will light up the LED, with or without the diode.

MK14:
3 LEDs, 2 resistors (current limit) + a bjt (2N3904).

So, an extra BOM of ZERO! (my way of counting, which would be 3 Leds and 3 current limit resistors = 6 components, so my design swaps a transistor for one of the resistors , hence 0 extra components).

But, your way of scoring, would be 0 (Leds) + 2 (resistors) + 3 (points for the NPN transistor) = a BOM of 5.

Assumes you either use the same (White) LEDs you used in your answer (Vf around 3.6V to 4V), or 3.3V supply if lower Vf LEDs used, or extra components.
Current NOT perfectly balanced between which of the 3 Leds are lit, but could optimise if worried/pedantic about it, by suitable adjustment of the resistor values.

No diagram shown (to avoid spoiling it for others who want to try and solve this puzzle, and makes this post easier for me to prepare), but you can see the diagram, if you want, via the attachment, below.
Ian.M:
Off state LED current is a concern.  Add a SPICE directive to your sim and paste this:

--- Code: ---.measure L_ID1 find I(D1) at .5
.measure L_ID2 find I(D2) at .5
.measure L_ID3 find I(D3) at .5
.measure H_ID1 find I(D1) at 1.5
.measure H_ID2 find I(D2) at 1.5
.measure H_ID3 find I(D3) at 1.5
.measure T_ID1 find I(D1) at 2.5
.measure T_ID2 find I(D2) at 2.5
.measure T_ID3 find I(D3) at 2.5
.error ; force SPICE errorlog display

--- End code ---
into it to get your first three diodes' If (in Amps) logged in each state.  The leading letter of the measurement name is the pin state.

My best so far is 1.6uA  through the third LED when its off, with 1.8mA through each LED when on for a 10 unit 'cost'. Edit:  I should be able to tweak that to 2mA on and <1uA off if I put a bit of time into it, without adding any parts.

--- Code: ---l_id1: i(d1)=-1.68827e-008 at 0.5
l_id2: i(d2)=0.0017939 at 0.5
l_id3: i(d3)=1.60261e-006 at 0.5
h_id1: i(d1)=0.00178581 at 1.5
h_id2: i(d2)=-1.6924e-008 at 1.5
h_id3: i(d3)=1.5699e-006 at 1.5
t_id1: i(d1)=7.11125e-010 at 2.5
t_id2: i(d2)=-6.81232e-010 at 2.5
t_id3: i(d3)=0.00182746 at 2.5

--- End code ---

I'm using a somewhat improved MCU I/O pin model (30R on resistance at logic '1' and 20R when logic '0') that's also much easier to program as a single PWL source controls it (1 is High, -1 is Low and 0 is Tristate), and has the .measure directives so you may prefer my test template to eblc1388's one.
Navigation
Message Index
Next page
There was an error while thanking
Thanking...

Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod