Control three transistor switches from two pins?

Posted on
  • Hi :)

    I'm trying to learn electronics, especially the basics (as I know I could use shift regs or other MUX chips for this) so I tried to challenge myself to design something that would allow me to control three sets of LED banks using two pins.
    I ended up missing one pin so I thought I'd try to gain a pin by using two to control three.

    Here it is:

    I'm not sure if it will work though? I've probably missed something.

    Currently downloading LT Spice to try and simulate this

  • That seems plausible - what worries me is the possibility that even with the diodes, there could still be a small current flow (due to the 0.7v drop across the diode) - you'd definitely want to use a schottky diode if you do this... I can't say I like this design though... I'd rather do it with a little discrete logic chip instead...

    Are you using a Pico? There are a few pins that aren't broken out that can be accessed with careful soldering... this is a better solution if it's viable for you.

  • I guess this is more of a fun experiment than something I could actually use, so I'll revert back to some shift reg. As I'm driving LEDs I might go for something a bit more tailored for that need.

  • I2C or SPI and an expander ? Endless pins... with i2c even read.

  • Soo yeah. I've decided to not use some sort of transistor logic gate setup and go for a more tried and true approach.

    Something like this:

    Serial-in/parallel-out shift register 74HC164 into a buffer 74HC07 that will drive a N-channel PFET IRF511 which in turn switches my load on and off.

    The load will look a lot like this:

    And for my 12v supply I'll chain a max of three LEDs (Vf = 3v, Iled = 60mA) per 'loop' and calculate resistor for n LEDs with R = (12 - (3 * n)) / (n * 60mA).

    You think I'm on the right track @DrAzzy? :) Here's the FET I've chosen for now: http://www.mouser.com/ds/2/308/EN8999-D-­256482.pdf
    Vgs = 1.8V
    Continous Current = 2A (will only ever see max 400mA)
    Vds = 20V (need at least 12v)

    EDIT:
    I changed to using a constant current driver; http://www.mouser.com/ds/2/408/Toshiba_T­C62D723FNG_datasheet-340777.pdf
    Much cheaper both BOM and construction time.

  • Yeah - I'd say you're doing it right (now) - a dedicated LED controller with constant current drive is the way to go here imo. The current is within the limits of those small drivers, so you should be fine.

    Usually when I think of driving LEDs, I'm driving either "pixel" style LEDs (WS2812, or WS2811 LED drivers with 1206 LEDs on them, so 20mA each), or I want bright light, so I'm using a 1W+ leds, at 350 or 700mA (or more)

  • After laying out various alternatives I ended up using 60 APA102C. I actually just pressed the 'order' button! $240 for five boards :d

    I wrote about the process on my blog
    and here is what I just ordered:

    They are 25mA nominal I think I read somewhere, so 70*0.025mA = 1.75A but for good measure I rated everything for 3A.

    I grouped the µCU and RTC in one block with the silkscreen, and the power regulation in another block.

    I'm about to pull the trigger on the parts from Mouser as well :)

  • Wow, $240? How big are those boards then? And where did you get the manufactured?

    Surprised you didn't use WS2812B actually - there's a bit less wiring involved with them :)

  • Hehe, I did go all in on this one. It's for a present for my mom actually. I'm getting a laser cut aluminium front plate to go with it.

    It's 28 by 28 cm and I'm using Seeed for this one. I'm also waiting for another board from Elecrow to try them out.

    I could go by with smaller PCB and probably also use the WS2812B but it just turned out this way. Excited to see how it turns out :)

  • Are Seeed assembling it too? Doing 70 of those chips will be 'fun'.

    By the way, I was recently doing something with WS2812 chips (the APA102 may be similar) and I found they have quite a lot melting point. Enough that it was basically impossible to solder them with the '8' tip I had in my Weller soldering iron, and had to go back to a '7'. I'm not 100% what temperatures those equate to, but it's worth keeping in mind if you have problems.

  • Sadly I'm doing the assembly, but I will use paste and hot air gun for those LEDs (I think). Thanks for warning me about temperature! I'll keep in in mind. (I got 1000 of the APA's from AliExpress so at least I don't have to worry about ruining a couple ^^)

    I'll make a separate projects thread for it down the line. I kind of want to make something like firmata that end up being able to control the Wiring/Arduino board using JS in the form of var wiring = require("Wiring").connect(Serial1); and then be able to issue commands on the form wiring.digitalWrite(13,HIGH); and I also have plans to implement a simple RPC so one could do wiring.call("myFunction", 13); where myFunction is programmed to the chip as an Espruino function.

    EspruinoCanCall(myFunction, char *czPin, { 
        /*convert czPin to int pin*/ 
        digitalWrite(pin, HIGH); 
    });
    

    I have some thoughts about this already sketched out :)

  • Not sure I quite understand - so you'd be using an Arduino (not Espruino), but allowing JS functions to be loaded onto it? Or controlling an Arduino from an Espruino?

    Of course maybe the most flexible (and awesome) thing would be to get a build of Espruino working for Arduino. I did have something compiling, but not working (I think since ints are 16 bit for most Arduinos) - and the lack of debug really scuppered my attempts to get it working. If someone attacked it with a proper debugger (is there a software simulator of Atmel chips?) it shouldn't be too hard to get going.

  • The idea is to implement a simple register based bytecode interpreter on the ATMEGA chip, and then make an Espruino wrapper for calling into that interpreter over Serial or I2C. I'll also make a client driver for 'Arduino' / Wiring and one for C++ (using the CLI so I can use from C# as well).

    The main goal is to enable the Espruino to have the ability to interact with the Arduino using a simple and known API like arduino.digitalWrite(13, HIGH). Because it's backed by a register based bytecode interpreter I could potentially make a plugin for Espruino where it parses JS and makes it bytecode before passing over. Natyurally the common stuff like digitalWrite will be prewriten to emit the correct bytecode, but with the translator one could imagine things like

    arduino.exec({
        digitalWrite(8, LOW);
        shiftOut(11, 12, LSBFIRST, 16); //make 74hc595 go 0b00010000   
        digitalWrite(8, HIGH);
    });
    

    It's just an idea. Probably yet another pointless academic endeavor but I don't know... What do you think? Worth spending time on?
    In certain situations it's nice to have an off-board device that can deal with high time-sensitive things and as such offload the Espruino and let it sleep more.

  • Personally, I reckon a lot of that is handled by firmata already on the Arduino side... It is kind of a bytecode interpreter already - just without loops :)

    Now a module for Espruino that emits firmata? That'd be very cool - and yes, I guess you could parse rudimentary JS into bytecode.

    However something like this might work for functions?

    var wiring = require("Wiring").connect(Serial1);
    wiring.digitalWrite(13,HIGH);
    var commandList = wiring.record(function(wiring) {
        wiring.digitalWrite(8, LOW);
        wiring.shiftOut(11, 12, LSBFIRST, 16); //make 74hc595 go 0b00010000   
        wiring.digitalWrite(8, HIGH);
    });
    wiring.send(commandList);
    

    so when you do wiring.record it actually executes the JS on Espruino, but instead of sending the bytes for those commands to Espruino, it stores them in an array. Then, if you want to do something fast you can just blurt the command list out.

    I guess if you wanted to go faster, you could extend firmata on the Arduino with 'store command list' and 'play command list' commands? I don't know if that exists already - it seems like it'd be great if not?

  • it was basically impossible to solder them with the '8' tip I had in my Weller soldering iron, and had to go back to a '7'. I'm not 100% what temperatures those equate to, but it's worth keeping in mind if you have problems.

    7 weller tip is 700F, 8 is 800F. They also made a 6.

    IMO the 8 is too hot for everything except scavenging parts.

  • Ahh, thanks! That makes a lot of sense. I've really liked the 8 - it works well on most stuff, but you've got to be quick with it :)

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Control three transistor switches from two pins?

Posted by Avatar for alexanderbrevig @alexanderbrevig

Actions