A Blue Pill, A SMPS, and LED and my total confusion - Page 1
Forum section: electronics / beginners

author: g0mgx
author_rank: Regular Contributor
timestamp: July 02, 2020, 05:22:41 am
content: Greetings EEVBloggers!I have a conundrum that is doing my head in and I would be very grateful for any assistance you guys can provide.I have a microcontroller based project which runs on a STM32F103 board (aka the blue pill). The project runs well and has been soak tested on the bench for the last few weeks running from my bench PSU without issue.I have ordered a bunch of el cheapo SMPS power packs rated at 5V 3A from our friends in the far east and these duly arrived yesterday.The power light turns on when the SMPS are connected to the blue pill 5V input, but the software doesnt run. If I connect one of the boards GND pins to just about anything like my ST-LINK debugger, a serial port or my bench PSU; then the software runs.It seems I have a scenario where everything works when powered from my bench PSU, but not from the SMPS. ground the SMPS -ve line to something else and it works. I have simplified the circuit to a blue pill on a breadboard with the +5V and GND lines connected to the SMPS; software doesnt run. Connect one of the GND pins to something else and it does. In both scenarios the power light on the board is lit.The SMPS measures roughtly 5.2V with no load, seems to stay about the same under load and the 3V3 line of the blue pill board is at 3V3 as expected.I have some kind of floating ground issue here I guess, but I completely fail to understand the problem and am now looking for large tall buildings to jump off.Any help or pointers very much appreciated.MarkG0MGX

author: garethw
author_rank: Regular Contributor
timestamp: July 02, 2020, 07:33:07 am
content: Initial guess would be a broken GND between the device and the SMPS.Is there a good connection between the Bluepill and the breadboard? (The terminals are not the best in b-boards.)Have you tried another SMPS? (Maybe the wire is broken)

author: g0mgx
author_rank: Regular Contributor
timestamp: July 02, 2020, 08:28:42 am
content: Thanks for the suggestion; I've checked all the solder connections on the blue pill headers, the breadboard connections and tried a different SMPS.The setup is very simple. Blue pill board with a DC power socket connected to the +5V and GND pins. both the bench PSU and SMPS have the same DC plug, both light the on board power LED, one runs the software the other doesnt.It makes no sense at all.

author: eblc1388
author_rank: Frequent Contributor
timestamp: July 03, 2020, 02:26:13 am
content: This would likely happen if there are high frequency pulses riding on the SMPS output.Do you have any means to verify that the output is clean?

author: alsetalokin4017
author_rank: Super Contributor
timestamp: July 03, 2020, 03:31:00 pm
content: Time for a nice clear photograph of the breadboard, maybe?

author: g0mgx
author_rank: Regular Contributor
timestamp: July 03, 2020, 05:49:28 pm
content: This is still causing me total confusionThe red LED is "power" and is on the 3V3 line output from the on-board regulator, the USB DC connection is to the regulator input. The green LED is connected to PC13 and 3V3 so I have to drive PC13 LOW to light the greed LED. That's all the software does.Here is the board powered by USB connection to the PC.Here is the same board powered to the 5V and GND pin from my bench PSU:and here using the SMPS:The SMPS measures 5.36V without load and 5.35V when connected to the Blue Pill, the 3V3 line on the board measures 3.29V when the board is powered by the SMPS.As previous post, if I connect one of the boards GND pins to my ST-LINK debugger (and USB connection to PC) or attach a 'scope probe (and ground through the scope) or connect to anything else I can find that has a GND connection, then the green LED lights indicating the software is running. Without this GND connection, the green LED is not lit suggesting the software isnt running.Most bonkersness.Mark

author: g0mgx
author_rank: Regular Contributor
timestamp: July 03, 2020, 05:52:12 pm
content: Quote from: eblc1388 on July 03, 2020, 02:26:13 amAs soon as I connect a 'scope then it works as expected as I have provided the GND connection that solves the problem. I have tried adding smothing capacitors on the SMPS output but no change; the SMPS output looks very reasonable on the 'scope.Mark

author: garethw
author_rank: Regular Contributor
timestamp: July 03, 2020, 06:13:33 pm
content: What happens if you press the reset button?

author: garethw
author_rank: Regular Contributor
timestamp: July 03, 2020, 06:15:51 pm
content: Not sure why your smps is dropping to <4V when connected to the bluepill. Doesn’t sound quite right to me.

author: g0mgx
author_rank: Regular Contributor
timestamp: July 03, 2020, 06:22:00 pm
content: Quote from: garethw on July 03, 2020, 06:13:33 pmNothing

author: g0mgx
author_rank: Regular Contributor
timestamp: July 03, 2020, 06:23:39 pm
content: Quote from: garethw on July 03, 2020, 06:15:51 pmIts' notTypo!5.36V without load and 5.35V when connected

author: james_s
author_rank: Super Contributor
timestamp: July 03, 2020, 06:37:31 pm
content: I wonder if these are just garbage power supplies with a ton of noise on them? Maybe try a good quality AC adapter from a reputable company?

author: jmelson
author_rank: Super Contributor
timestamp: July 03, 2020, 07:45:36 pm
content: There might be a startup transient on the power supply that upsets the blue pill while it is doing whatever it does at "boot time".You might try connecting a sizeable electrolytinc capacitor on the DC input.Jon

author: Manul
author_rank: Super Contributor
timestamp: July 03, 2020, 11:47:56 pm
content: My guess is that your adapter output has some capacitively coupled AC common mode noise from mains line. Common mode noise means that differential voltage stays at 5V, but relative to ground both lines are jumping. In this case on mains 50Hz and some voltage.When blue pill is powered from such source it is too riding on this AC. Blue pill probably has some high impedance pins / traces on the PCB and because all your setup is sitting on an ESD mat (as far as I see), that makes problem worse because these high impedance traces makes a lot of capacitive coupling to ground and as a consequence are disturbed.It is possible that your setup will start working if you hang your breadboard in the air far from other objects including your hands.Also for interest you may check with multimeter common mode AC voltage between ground of your mains and any of the adapter output lines. I bet there will be some 10's or even 100V.If you will confirm this to be a problem, you may try to find which pin or pins are sensitive and disturb the booting process (maybe JTAG?). Then do some pulldowns or pullups (according to desired default pin state) to make impedance lower and more noise proof (like 10K or even lower).

author: eblc1388
author_rank: Frequent Contributor
timestamp: July 04, 2020, 12:07:23 am
content: Two wire, unearthed smps usually has a small value, high voltage capacitor(about 1000pF) connected between primary and secondary to suppress EMC. Most of the time it is blue in color.Check for the missing or improper value of this capacitor on your cheapo smps to see if it causes the problem.

author: robca
author_rank: Frequent Contributor
timestamp: July 04, 2020, 01:15:52 am
content: It's almost surely a noisy power supply, made it worse by the breadboard acting as a massive antenna for the noise. Try without the breadboardAlso, try looking at the SMPS output with just the oscilloscope connected, and see how clean that power supply is

author: g0mgx
author_rank: Regular Contributor
timestamp: July 04, 2020, 04:56:31 am
content: Quote from: Manul on July 03, 2020, 11:47:56 pmI am measuring 75VAC between ground and the supply - thats made my chin hit the floor. AmazingI think you are on to something here!

author: g0mgx
author_rank: Regular Contributor
timestamp: July 04, 2020, 05:01:22 am
content: Quote from: robca on July 04, 2020, 01:15:52 amHere's the output and it seems reasonable to me - actually suprisingly ok:

author: james_s
author_rank: Super Contributor
timestamp: July 04, 2020, 05:09:13 am
content: Personally I would not even trust those power supplies to be safe to use. Don't forget multiple people have been killed by poorly made cheap mobile phone chargers. I avoid cheap random Chinese power supplies, it's just not worth it when you can find surplus reputable stuff for similar prices and even brand new AC adapters are only $10-$15 from the mainstream distributors.

author: Manul
author_rank: Super Contributor
timestamp: July 04, 2020, 12:02:51 pm
content: Quote from: g0mgx on July 04, 2020, 04:56:31 amAnd that has actually not much to to with cheap adapters, in fact all adapters which do not have grounded mains plug have similar common mode voltage on the output (but of course not much current, in the range of 10-1000uA). You may for example measure a quality laptop adapter if it does not have grounded plug, you will see similar voltage.So this is basically normal for such adapter. How you deal with that and design your circuit is another thing. I wrote some ideas in the previous post.But there are other reasons to not go for cheap stuff, as others mentioned. Yet, even a quality ungrounded adapter will have AC common mode voltage.

author: Doctorandus_P
author_rank: Super Contributor
timestamp: July 04, 2020, 02:48:09 pm
content: Apart from the most obvious such as unreliable breadboard or other loose wires:Add some kind of LC filtering between the power supply and the Blue Pill.It's power supply circuit is completely cheaped out, just as the rest of the board, which means it has very low margins for anything except perfect DC.Treat is as you would normally do with any bare chip.You can start with some inductor in series with a resistor (a few Ohms) to lower it's Q and thus dampen oscillations, in series with the power supply.Then add a buffer capacitor (10uF to 100uF or so) on the breadboard, and preferably also combine it with a few 100nF ceramic capacitors.For more "serious" filtering, use a real common mode filter, and put the STM32 on a decent PCB instead of the < EUR2 Blue Pill board. You get what you pay for!You also may have some success if you use a cable with built-in ferrite rings.There is no need to be "totally confused" about this. It's just a stackup of a few marginal items (just "long (30cm+) cables is one of them), combined with lack of experience. What you see is the normal result of this.

author: alsetalokin4017
author_rank: Super Contributor
timestamp: July 04, 2020, 11:06:24 pm
content: "add a buffer capacitor (10uF to 100uF or so) on the breadboard, and preferably also combine it with a few 100nF ceramic capacitors."That's where I would start. Just put a 100 nF ceramic right across the power bus on the breadboard to start with. I would not be surprised if that cured the issue all on its own, but if it doesn't, add some bulk and some more ceramics.EDIT: I see you aren't using the power bus, so just stick the cap in there between 2 and 3 in parallel with the power connector. If you want to add more capacitance then you can use the breadboard's power bus and parallel the caps along it.

author: GeorgeOfTheJungle
author_rank: Super Contributor
timestamp: July 05, 2020, 01:47:05 am
content: Are you sure the program isn't running, but doing something you don't expect? For example due to a floating input catching noise? To be sure I'd first upload the simplest blinky and see if that fails too.

author: garethw
author_rank: Regular Contributor
timestamp: July 05, 2020, 08:32:28 am
content: I’m sorry but I’m not familiar with the Bluepill so this question might seem dumb.How are you programming your Bluepill? Is it just through the USB via an IDE or are you using a separate debugger like an ST-Link or a J-Link?

author: g0mgx
author_rank: Regular Contributor
timestamp: July 11, 2020, 08:05:13 am
content: In my case I am using an ST-LINK to the 4 pin connector on the Blue Pill.