Basically keep the common ground joint closer to the power supply than the usb.
Easy enough.
That’s fine until you forget, and turn off the external power supply before unplugging the USB.
Hi Jeff.
That’s easy
Fit larger wire into ALL of the ground circuits if that is causing a problem.
cheers Bob
The likely problem part is the PCB trace between the module tab and the USB port, as mentioned above. Also probably the USB port itself as the MCU module is not designed for a high current supply.
If you manage to protect the USB supply side from the full load of LEDs then there is no need for the external supply during development, and the point becomes moot.
What about an alternative less risky approach.
How about I use an optocoupler between my Xiaos PWM data output and the data in of my strip while I’m in a testing phase.
That way I don’t even need to consider a common ground because my xiao and my LEDs have interdependent circuits.
My only worry is that the diode inside the optocoupler may not be able to switch at the speeds required for the WS2812 protocol. Is it worth a shot?
I think you have wandered away from what you are trying to achieve.
If you have a single power supply then you can power both the MCU (through the 5V pin) and the LEDs from that single supply, with a common earth. That’s the simplest setup.
The problem only arises when you also want to connect the USB supply to the MCU. Then you must either disconnect the external supply to the 5V of the MCU, or use a diode to prevent the USB from attempting to drive the LEDs.
You can certainly have separate supplies (ie, no common 5V) for the USB and the LEDs, with the LED control separated by the opto-isolator, and no common ground. Or you can have separate supplies for the USB and the LEDs with no opto-isolator, no common 5v (they are separate supplies) and a common ground. But in both cases when the USB is not connected the MCU will have no power! When you unplug the USB you will have to connect the external supply to the MCU 5V pin, and disconnect it before you plug the USB back in. Which is the adjustment you are trying to avoid.
Maybe that’s the miss-communication.
My fault, ive switched modes half way through a thread.
The original question about diodes was me blindly following the setup guides. I was thinking in the future, when my code was complete and I only need one supply.
Now that I know that it will be possible to do that, I’m thinking about how I can rapid develop whilst keeping my setup safe.
- I’ll start with my mcu plugged into my computer and the strip plugged into the wall.
- when I’ve got my code how I want it, I’ll ditch the USB power and permanently solder to a breadboard with the 3a supply as the sole 5v source.
Because of that risk, where I turn off the power supply before unplugging the USB, I’ll use my optocoupler idea which seems easy and robust.
I can ditch the optocoupler when I am ready to solder the MCU to the final circuit (where I will include a diode in-case I need to make future adjustments)
Hi Pix and all,
Another way to develop and keep everything powered easily would be to update the software via OTA.
What language are you looking to use? I’ve seen Arduino OTA used to great success on the ESP32s, and have seen the WebREPL many times in Thonny
The optocoupler will not protect the MCU from damage if the LEDS try to draw current through the 5V pin of the MCU. The problem is not connected with the LED control signal.
I can’t think of any reason not to go with the simple solution of the diode. Then you have no concern about what gets plugged in when. There is ample headroom available for the MCU regulator.
Ok. It’s time for some quick diagrams. I’m sorry my drawing is a bit wonky I was on my couch trying to write on a soft cover book.
This is what I was suggesting… I actually tried it and it doesn’t work anyway. Reading the timing diagram on the datasheet the optocoupler might not be able to handle the speeds required for the WS2812 protocol.
And, @Jeff105671 I think this you’re saying that something I haven’t yet internalized, namely, that the schottkey diode doesn’t just protect me from plugging in a usb by mistake, but It actually allows me to deliberately plug in a USB from my computer and upload code.
The diode lets me upload code to my MCU, form my PC, with a standard usb c cable, even while it’s 5v pin is connected to a live 5v 3a power supply?
Yes. With the diode in place then you can have none, either one, or both supplies switched on and the MCU is protected.
During development you will have both USB and external power connected, because you need the USB communication and USB power is automatically included. When development is complete you will only have external power connected and the MCU will be powered through the diode. If you need to update the software following deployment simply re-connect the USB, upload, test (the LEDs will work because you still have the external power connected), and disconnect the USB. If you have a test case that doesn’t need the LEDs to be powered up then you can disconnect the external power.
Note that this is not entirely ideal - your test and development system should be as close as possible to the deployment arrangement or you risk getting a problem at deployment that you didn’t detect during testing. In this case there is a risk that the WS2182 control will function differently when it comes from a MCU being driven at the full 5V of the USB and when it is being driven at 5V less one diode drop for the external power. This shouldn’t happen because of a difference in power, but might occur due to the change in the ground path - a problem that can be difficult to debug. The usual recommendation of a resistor in the data line (up to about 1k) usually fixes any problem. If there is any distance between the MCU and the LEDs then a level shifter will be required to condition the data line. It can also resolve problems with the ground path, and has the added advantage of some protection for the GPIO.
The option of OTA as suggested by Liam120347 means that your test and development systems are identical - a big advantage when deployment is some distance from the PC.
Ah man this sounds great!
This is just a basic mood lighting stip behind my desk. I might as well leave the usb plugged in during development too incase i ever want to quickly change the colour.
With the diode is this a concern. I dont need to worry about dosconnecting the power while the usb is plugged in?
Like in the case of a common ground, discussed above, what is stopping 3a from travelling through my mcu.
Like I believe you that its safe, im just trying to understand why its safe.
Hi Pix
Should be no problem turning the external power off first. With the diode in place as in that bottom schematic all that will happen is the LEDs will go out. The diode will prevent the USB powering the LEDS. This does not affect the data line at all.
Cheers Bob
Correct. The concern was about the USB trying to power the LEDs via the MCU, not the plugging and unplugging as such.
Nothing is stopping the power from the external supply from driving the voltage regulator U2 to power the MCU. Diode D1 in the MCU is stopping the external supply from trying to drive the USB power supply to the MCU if that happens to be at a lower voltage.
/Edit. I just re-read that. By ‘through’ do you mean through the MCU dev board components? There is no risk of 3A ever running ‘through’ the MCU, because the resistance that the MCU provides to the external supply would never be low enough to require a 3A current. The MCU will only ever draw enough current to power itself and its accessories, and that will be in the order of a few hundred mA at most.
Edit/
Concerning the diode ive used a diode specked up to 1amp
I figured thats all i need because the mcu will only draw an amp.
Do I need to spec it up to 3amps for any reason? I cant think of any?
Hi Pix
The only reason would be to give you a bit of head room if you think you need it.
But as has been stated the physical track on the MCU board might not like much more than that.
The 1N5822 would give you a bit of fudge factor and would prevent stressing a 1N5819 if you continuously demanded close to 1A. If you are going to be close to 1A the 1N5822 would be a better choice.
Cheers Bob
Hi everyone.
Thanks all for all your answers, and for patients while I slowly internalised whay we were saying.
Im writing to report that this worked no problem, as seems obvious now that I understand.
Whilst this conversation has been going on my idea has grown a bit more complex, but ill start a new thread for that.
This thread can tied off.
Thanks everyone.
Hi @Pixmusix
Nearly everything I’ve learned about designing PCBs has come from our series The Factory | Design A Product With Us as well as a fair bit of trial and substantially more error. I would say give it a crack and the worst thing that can happen is you’re not happy with the design and you start again.
I’ll check it out.
PCB design is something I know I’ll tackle one day.