STM32F103 min system with USB-TTL converter? - Page 1
Forum section: electronics / projects

author: bjdhjy888
author_rank: Regular Contributor
timestamp: January 29, 2019, 07:52:35 am
content: Hi,I recently managed to build my own STM32F103 min. system on a PCB. I was so happy about it. I flashed my LED blinking .hex file onto it, using someone else's USB-TTL module.I wanted to learn more, so I designed and improved my STM32F103 system with my own USB-TTL circuit added onboard. But no .hex file could be flashed onto it. (I used FlyMCU for the flashing).I then used my multimeter to check the voltages of my AMS1117-3.3 chip and noticed its output voltages were too high at 4.5V.I used FT232RL SSOP-28 for the conversion.I also reviewed my schematic and PCB layout and did find an error that one of the pins of my AMS1117-3.3 was not linked to GND of my micro USB.However, even after I fixed it using a flying lead on my PCB, the problem remained, i.e., I could not communicate with my STM32.Could someone on here help me review my schematic? Thank you so much!

author: ataradov
author_rank: Super Contributor
timestamp: January 29, 2019, 08:05:31 am
content: Someone probably can. Why not attach the schematic here?

author: bjdhjy888
author_rank: Regular Contributor
timestamp: January 29, 2019, 11:12:49 am
content: Thank you.Here is my schematic. I apologize if they don't look too professional, as I'm a newbie.Would someone please help me find out where I did wrong? (The system worked perfectly before I adeed my FT232RL and AMS1117.)

author: Psi
author_rank: Super Contributor
timestamp: January 29, 2019, 11:54:53 am
content: Ok, one thing i will say.Ya should wire the ft232rl 3.3v output pin to vccio instead of using 5V from USB.Then TX/RX are 3.3V level and will match the STM32I can't recall which pins on STM32 are 5V tolerant.But if the pin you're using for TX is not 5V tolerant it will backfeed 5V onto the STM32 VCC and this will cause major problemsAlso please correct all the SCH pin names to match the actual IC pins. I assume you just repurposed some other sch component?There's lots of stuff in that SCH that i have no idea what it's doing.

author: bjdhjy888
author_rank: Regular Contributor
timestamp: January 29, 2019, 12:19:30 pm
content: Yes, I am correcting my SCH. Thanks.I hope my SCH will be easy for people to read once it's corrected.

author: bjdhjy888
author_rank: Regular Contributor
timestamp: January 29, 2019, 12:51:45 pm
content: Quote from: Psi on January 29, 2019, 11:54:53 amSo you are saying this is wrong? (I followed this pic I got from the Internet)

author: mvs
author_rank: Frequent Contributor
timestamp: January 29, 2019, 03:50:08 pm
content: Quote from: bjdhjy888 on January 29, 2019, 07:52:35 amGetting to a bootloader in manual way might be a bit tricky. Usually RTS and DTR pins of USB-UART bridge are used to manipulate RESET and BOOT0 pins of STM32, allowing FlyMCU to do it for you automatically.

author: ataradov
author_rank: Super Contributor
timestamp: January 29, 2019, 06:33:14 pm
content: This is a totally unreadable schematic. I know you want to do things quick, but as you can see, it does not work out this way. Clean up the schematic and the issue may become obvious.

author: ajb
author_rank: Super Contributor
timestamp: January 29, 2019, 07:41:33 pm
content: Your schematic and layout both need a LOT of work. But that's okay, you said you're a beginner, and people here can help you learn.Some things in no particular order:* While you have decoupling capacitors, they are way too far away to be doing their jobs. Decoupling caps need to be mounted as close as possible to the IC supply pins to be effective* Also there appear to be no decoupling caps dedicated to the FT232. Read the datasheet for the FT232 and follow all of its guidelines for layout and support components exactly.* Use reasonable schematic symbols for components. You appear to be using battery symbols for headers and for crystals. This is confusing.* That can't be the right symbol for the MCU, either. This is hugely confusing to anyone reading your schematic, includingyouwhen you come back to this schematic in a week. Be nice to future you.* Use power ports instead of wires for gnd and supply nets. This will immediately clear up a lot of clutter in the schematic.* Use schematic symbols with proper names for pins, or at least name the nets attached to those pins. It's impossible to see if your FT232 is even close to correctly connected without referring to the datasheet.*Use a ground plane.Trying to do an MCU and USB on a two layer board with those skinny traces (and no decoupling caps) is asking for all sorts of trouble. It can be done, but just get in the habit of making the bottom side a solid ground pour with as few interruptions as possible.* The routing for your crystal needs to be tightened way up. Currently the loop area encompasses a quarter of the board. That means it's an antenna, and will radiate like crazy.It's possible that your current PCB is still usable, but frankly I wouldn't put good odds on getting the FT232 to work as-is. I would highly recommend you start by redoing the schematic, and post here (not necessarily this thread, but on these forums) for feedback as needed. Then start over with a new board design, and again, post here for feedback. There are lots of threads here of that sort, so it's worth taking a look at them, as well as other resources on layout. With a better schematic and a better PCB, you will have a much easier time troubleshooting. As it is, it's virtually impossible to say whether your FT232 isn't working because it got fried when the regulator was mis-wired, or because the layout is simply not up to it.If you decide to start a new thread, please post a link here so we can follow up and see how it goes. Good luck!

author: bjdhjy888
author_rank: Regular Contributor
timestamp: January 30, 2019, 01:09:13 am
content: I couldn't be happier to read you guys' helpful tips. God bless your hearts. I love this forum!Now, I am re-constructing my schematic from scratch. I will also re-do my PCB layout all over again, following your instructions. Some explanations below:1. I manually downloaded my .hex file onto my STM32 to learn more and have full control, though I know it might be indeed trickier than doing it automatically with something else.2. Yes, I indeed wanted to acomplish my 1st STM32 project quickly. This was good and bad attitude. Now, I want to re-do this project carefully and slowly with a solid fundation.3. Yes, I knew those capacitors were supposed to be placed in close vacinity to my STM32, but I kinda hesitate to do so, as it might still work and I could solder the 0805 capacitors easier with extra spaces.4. Do I really need to follow the datasheet of FT232 exactly? The schematic I found from the Internet had no other capacitors. Does that mean that schematic is inaccurate? I better follow FT232's datasheet stringently?5. I was new to Altium Designer and could not find the proper symbols for my desired components, so I repurposed them. Now, I'm correcting them using the correct ones.6. By "power ports", do you mean these?7. For the MCU pins, would this be better?8. Finally, I did pour copper on both side of the PCB and connected it to GND. The reason you didn't see it was that I deleted it on purpose from my PCB, so you could see the circuits better. In real life, my PCB looks like this:Again, please forgive me for being inexperiened(6-month old self-taught engineer, with learned YouTube lessons, technical books and hands-on kits) and thank you!

author: ataradov
author_rank: Super Contributor
timestamp: January 30, 2019, 02:01:49 am
content: I don't think the problem is with bypass capacitors or the layout of the board. I'm pretty sure, if there is a problem, it is in the schematic or soldering.Another problem with capacitors is their actual placement. While it is OK to leave some space for ease of soldering, they must be located on a shortest path from each VDD pin. They won't do anything if they are neatly placed in a row in the corner of the board.So lets start with a cleaned up schematic. Those are power ports and it looks like a correct symbol. Redraw the schematic using them, and we'll from there.

author: bjdhjy888
author_rank: Regular Contributor
timestamp: January 30, 2019, 02:35:48 am
content: Thank you.I have another question for pouring the copper.https://www.novatel.com/assets/Documents/Papers/OEM7700-Product-Sheet.pdfIn the above link, you will see a pic of NovAtel's board, on which it features its copper at its four corners and on its two upper and lower sides. Note that there are no green pastes covering these specific areas. The copper basically covers all its rims and via's.They look cool and I guess their purpose is to eliminate noise or interferences. Correct? No to mention the dots(via's?) on the copper for the same purpose?My question is,how do you make such feature with Altium Designer?Would I be able to acomplish such work with the software? I did not see such function in the software. Does anyone have any clues?Thanks.

author: ataradov
author_rank: Super Contributor
timestamp: January 30, 2019, 02:41:19 am
content: The opening is to ensure contact with the metal case or mounting chassis. This is done for EMI reasons, but this design is far too low speed to worry about that.I don't know specifics for Altium, but generally all you need to do is modify solder mask polygon to whatever shape you want to keep open.Via stitching in this case looks like it was done manually by simply dropping a lot of vias. But I'm sure Altium has tools to do that automatically, since even KiCad does. This is more useful for your design, but again, not really critical. Just place a few vias here and there along the ground planes and you will be fine.

author: Psi
author_rank: Super Contributor
timestamp: January 30, 2019, 02:54:19 am
content: Quote from: bjdhjy888 on January 29, 2019, 12:51:45 pmThere's multiple ways to connect power to a FT232RL depend on what your connecting the chip to.Put simply...The way you have it the FT232RL core runs at 5V, so all its outputs are 5V.If you have a 3.3V processor they usually don't like 5V on their inputs, so the FT232RL provides an onboard 3.3v regulator.To use it you feed the 3.3v output pin into VCCIO. This makes the FT232RL core run at 3.3V and so all the outputs are all 3.3V to match the STM32 inputs.

author: Doctorandus_P
author_rank: Super Contributor
timestamp: January 30, 2019, 06:51:20 am
content: Why do you not simply buy some ST-Link V2's from Ali / Ebay / China?These cost less than a the FTDI chips and you can not only program the STM32 with it, but you can also use them for debugging.The hardware of these is also just a STM32 in a nice small aluminum USB stick format. You can pull the aluminimum tube off to look what's inside (and for re-programming etc.).Unfortunately there are some different variants of these, and not all have the same quality.Most of these can also be re-flashed with the "black magic probe" firmware to increase their capabilities, but I haven't yet seen a need to dive into this.

author: MFraylich
author_rank: Newbie
timestamp: January 30, 2019, 01:33:48 pm
content: I use "blue pills" STM32F103CB boards for every task an arduino would be used for and am sure that the F103 chips don't need a USB-TTL converter, as the USB on these boards connect directly to the chip. You might need to configure it in the bootloader (I use STM32duino bootloader and this needs to be flashed to the board, instructions on this below if needed).STM32F103C bootloader and USB fix for STM32duino1. Set B0 (right when USB is top) to 1.2. Install Flasher from en.flasher-stm32. Available fromhttps://www.st.com/en/development-tools/flasher-stm32.html3. Connect the STM to a UART interface with RX of the UART to pin A9 and TX to pin A10.4. Use the flasher to add the DFU bootloader in STM32duino-bootloader.5. Remove power and move B0 back to 0.6. Install the Maple drivers using the bat files fromhttps://github.com/rogerclarkmelbourne/Arduino_STM327. Addhttp://dan.drown.org/stm32duino/package_STM32duino_index.jsonto the board manager in preferences.8. In Arduino IDE go to boards manager and install Arduino SAM for the Due board to get the correct g++ files.9. Connect the board using its USB connector to the PC.10. Select STM32F103C and the 128k Flash option and make sure “STM32duino bootloader” is selected as the upload method. At this point the device doesn’t have a port, don’t worry.11. Flash a sketch to the board and it will install the full bootloader, the device will now have a port.12. Use the board!Perhaps this will solve the problem.

author: ajb
author_rank: Super Contributor
timestamp: January 30, 2019, 03:37:07 pm
content: I'm glad you had ground pours, that's good!Quote from: bjdhjy888 on January 30, 2019, 01:09:13 amDefinitely favor the datasheet over random examples found on the internet! The datasheet will tend to be fairly conservative, so while it may cost a little bit more in terms of components and board space, it generally gives you a much better chance of having the part work as expected. Datasheets are NOT infallible, but on the whole, they're FAR more reliable than random schematics on the internet. As you gain experience you'll be better able to tell what's really required to get a part to work reliably, which won't always be what the datasheet says, but it will usually be pretty close.Regarding the picture of that Novatel PCB, the way to do that in Altium is generally to place the copper pour using a polygon, place vias as you like, and then place an object on the solder mask layer to create an opening to expose the copper. (The mask layers are negative layers, in that any object placed on the layer creates an opening in the mask.) Altium does have a tool for automatically placing stitching vias, but it's kind of clunky. For small areas it's just as easy to place the vias manually, perhaps with the aid of the grid or by copying and pasting blocks of them.

author: bjdhjy888
author_rank: Regular Contributor
timestamp: January 31, 2019, 02:04:11 am
content: Quote from: Doctorandus_P on January 30, 2019, 06:51:20 amThank you for your suggestion.The reason that I wanted to add my own USB-TTL circuit onto my STM min. system was I think the best way to master electronics is to DIY modules(systems) from scratch. (I did buy them before, including the USB-TTL converter)I was playing with Arduino and interested in Raspberry Pi, but I realized that despite they are cool platforms with an easy to use IDE and language, I will never fully understand the fundamentals(electronic parts and the C programming language). It's a like good C# programmer may never know what a transistor on an IC is.I believe that buidling an electronic module from scratch with schematics and then get them manufactured at a PCB factory for further soldering and debugging is the best way to understand them with hands-on experience, though it takes quite a lot of efforts. Just my 2 cents though.

author: coromonadalix
author_rank: Super Contributor
timestamp: January 31, 2019, 03:42:02 am
content: Quote from: MFraylich on January 30, 2019, 01:33:48 pmBe sure r10 is around 1.5 k ohms, there was some connection problems on some computersCheck known issues section :https://wiki.stm32duino.com/index.php?title=Blue_Pill#Software_installation

author: bjdhjy888
author_rank: Regular Contributor
timestamp: August 14, 2019, 01:43:36 pm
content: I re-drew my schematic from scratch, correcting all my previous mistakes.Would you please help me review my latest schematic? Thank you so much!The STM32 min. systems is supposed to blink an LED, with the function of USB-TTL.

author: thm_w
author_rank: Super Contributor
timestamp: August 15, 2019, 10:36:26 pm
content: Quote from: bjdhjy888 on August 14, 2019, 01:43:36 pmLooks good and neat.NRST should be 100nF not 100pF, but its optional like you said.What is the purpose of the diode on RxD line?

author: bjdhjy888
author_rank: Regular Contributor
timestamp: August 15, 2019, 11:58:05 pm
content: Quote from: thm_w on August 15, 2019, 10:36:26 pmThanks for your help.As far as the diode is concerned, I previously copied it from another schematic from the Internet, and now it's been removed from my latest schematic.I've also fixed some minor mistakes today.Here's my current schematic and layout. Any suggestions would be highly appreciated.I will get the PCB manucfactured once it's free of mistakes. (The GPIO is left out doing nothing on purpose. I will wire it to STM32 in my next design. And I will pour some copper once the schematic is free of mistakes.)Bless you.

author: profdc9
author_rank: Frequent Contributor
timestamp: August 16, 2019, 12:29:54 am
content: If it would help, I have a kicad project with my own version of the bluepill STM32F103C8T6 you could start with if you want to make your own development board.https://github.com/profdc9/STM32altI also made one for the STM32F4 as wellhttps://github.com/profdc9/STM32F4ThruPillI made these so that generic through-hole parts can be used, but you can change the footprints if you choose.

author: thm_w
author_rank: Super Contributor
timestamp: August 16, 2019, 12:47:13 am
content: Quote from: bjdhjy888 on August 15, 2019, 11:58:05 pm- I normally like to see some outlines around the capacitors/resistors in the silkscreen to make it clear where to place it (like C9 has). But that is more for convenience when building, you dont have to have it. I wonder why yours do not show up.- The placement of C6 is not bad, but C7 and C8 can be improved. They can be closer to pins 24, 36, 48, and two do not share the same pin. So you have one at 24 one at 36, etc.- TX1 and TX2 should be closer to the microcontroller. For example, TX1 you have long traces traveling to the left, what you can do is move TX1 into the space to the left of the chip, so the traces will be a lot shorter.- I would put your name and date on the PCB as well on the silkscreen, if you ever want to show someone.

author: mariush
author_rank: Super Contributor
timestamp: August 16, 2019, 12:51:58 am
content: The board's a bit of a mess...Get your oscillators closer to the ICs ... get your capacitors closer to the oscillators/crystals.I'd leave space to lay the 32kHz crystal flat on the board... maybe solder it to a third pad with a bit of solder, or have a loop of wire keep it from vibrating or hitting the board.careful with 1117 regulators.... some are unstable if the output capacitance has too low ESR ... some 1117 linear regulators require ESR on output between 0.1 and 1 ohm ... a ceramic capacitor on output will have too low esr... so either add a tiny resistor in series with the output capacitor , something like 0.22... 0.47 ohm or whatever, or just use a regular electrolytic capacitor (ex a 10..100uF 10v electrolytic )or just use a better linear regulator.add some decoupling capacitors between vin and ground on your micro ... a 100nf ceramic (0.01uF)200 ohm is kinda non standard value... no need for such value for a status led... i'd say just use 330 ohm or even 470 ohm... more common value.I wouldn't use surface mounted electrolytics (c9)... i'd suggest plain boring through hole, or polymer surface mount

author: bjdhjy888
author_rank: Regular Contributor
timestamp: August 16, 2019, 01:47:55 am
content: I have followed your suggestions and managed to re-do the layout.Parts are now much closer to the STM32, resulting in way more vias used. Is this normal? I was concerned when I used extra vias. And, is my overall layout normal? Or, too messy?I did not change my schematic.Will pour copper once there's no issues.Below please find my latest layout. Please let me know if they are okay. Thank you!!!

author: thm_w
author_rank: Super Contributor
timestamp: August 16, 2019, 09:19:22 pm
content: Quote from: bjdhjy888 on August 16, 2019, 01:47:55 amC3 and C4 can be swapped to remove one via.But yes its normal to use vias, there is no cost to you to use an extra via. If you are really lazy, your layout will look autorouted and have a lot of vias, but really, if it works its not too important for hobby use.Your layout is a lot cleaner now.

author: bjdhjy888
author_rank: Regular Contributor
timestamp: August 19, 2019, 03:25:22 am
content: Quote from: mariush on August 16, 2019, 12:51:58 amThank you for your reply.I just ordered some SMD resistors that are of 220 ohm. I guess this voltage divider would be fine?p.s.: my schematic pictures seem gone. What happened?

author: bjdhjy888
author_rank: Regular Contributor
timestamp: August 20, 2019, 06:00:19 am
content: I have decided to add MPU-6050 to my STM32 min. system, before I send it to my PCB fabrication facility.SinceI have never designedanything for MPU-6050, I did a research.What I've learned:- I need to draw a schematic for my MPU-6050, as per Invensense's datasheet onpage 22athttps://www.invensense.com/wp-content/uploads/2015/02/MPU-6000-Datasheet1.pdf- I need to add this MPU-6050 circuit to my exisiting STM32 schematic- I need to use I2C to connect my STM32 with my MPU-6050, whichonly requires 4 wiresto be connected: VCC, GND, SDA, SCL- I need to flash a .hex file to my STM32, whichcontains serial port codes. So, I will be able to read MPU data through STM32, via my microUSB cable, then visually see the data in my Serial Port software on my PC's monitor.Questions:1. Are my above logic correct?2. Is my schematic below for my MPU-6050 correct?I supposed this was correct, so I updated my schematic, by adding this MPU. I also wired 4 pins of my header.Would anyone please help me review my schematic and layout? I need toget it manufactured once it's free of mistakes.Thanks so much!

author: thm_w
author_rank: Super Contributor
timestamp: August 20, 2019, 09:25:45 pm
content: You can use PB8 and PB9 on the STM32 but then you will have to use software control for the I2C pins.If you want the option of hardware/software I2C, then you can use PB10/PB11 (SCL SDA as you can see on your schematic symbol).

author: mariush
author_rank: Super Contributor
timestamp: August 20, 2019, 10:18:32 pm
content: Layout wise i would have some suggestionstry to have traces coming out of pads from the center of the side of a pad and try to get them perpendicularly. For example:* traces coming out of C2 in your picture are fine... in the middle of pads* trace coming out of C1 comes out of the corner directly at 45 degrees ... not nice* traces on R2 and C5 coming out the edge of a pad... not cool* two traces coming out of same side on R1 ... and you have that trace betwen the pads of the resistor when it could come from a side* see two traces coming out of the 1117 ldo .. also consider thicker traces for higher currentconsider flipping c2 to shorten and simplify tracesconsider rearranging c2,c5,r2 to simplify traces there you have pcb area so its not a must to have them all 3 in line ... you can move the silkcreen or remove the actual values or move the values in legend somewhere you don't have partsyou could move the main crystal a few mm lower (shift the regulator lower or to the sides a bit) and make room for the 32.768 kHz oscillator above the main crystal and save a couple of traces on the bottom of the chip.not liking those long diagonal traces on the bottom layer... i'd suggest planning for having a big ground copper fill on the bottom, so aim for using vias just to sort of create jumpers, to jump over top traces by placing small segment on the bottom. break that big ground fill as little as possible.you could move mpu 605 and c12 higher, to shorten those 2 traces going to the headeralso what's with the c13 , those red traces, are those supposed to cross over or is that an error ?same nitpicking about vias coming out of pads weirdly ..see c14 and c15CHK resistor can be placed by the led and this way you don't need that trace that goes around the connector...after all it's supposed to go to ground, so from resistor you'd have a via to the bottom ground fill and you're done.you have a trace from c3 looping all the way around the headers on left and going to c5 .... i guess that's ground or something for both ... use a via to make a shorter trace or get them both to bottom ground fill through viasyou could flip the serial chip horizontally ( rotate 180 degrees) ... this way the 5v and ground would go easier to pads on chip ... maybe you would have to use a via for one of the data wires to step over the other one or you may be able to get them both through the center.The ground pad of the chip can be connected to ground fill on other side through a via.if it makes it easier for you ... draw a thick trace on the bottom layer that goes almost from one side to the other of the board and from that thick trace, route traces out of it which then go through via to top side and connect to pads that are supposed to go to ground.When you'll do a ground fill, that trace and small traces from vias to it will become invisible, lost inside the ground fill.later edit: probably not needed but since you have so much room, maybe leave a small island of copper fill around the tab of the 1117 regulator to act as a heatsink?As i said before 1117 is kinda bad choice due to that low esr on output issue, but another problem is the tab is usually output voltage so you can't use vias to connect that tab pad directly to the bottom ground fill for better cooling.maybe consider replacing it with a regulator that uses the tab for ground or uses the bigger dpak package (to-252 to-263) etc etc.examples :LF33https://www.digikey.com/product-detail/en/stmicroelectronics/LF33CDT-TR/497-1532-1-ND/592050(requires electrolytic on output)NCP5501https://www.digikey.com/short/p5d1tc(stable with ceramic caps only on output)MC3327https://www.digikey.com/short/p5d1c0(stable with ceramic caps only on output)maybe remove the actual values of components and move the values in legend somewhere you don't have parts (could be on bottom side over ground fill)

author: thm_w
author_rank: Super Contributor
timestamp: August 20, 2019, 11:10:48 pm
content: There is no problem with traces coming out of pads at an angle. Try not to overwhelm the guy with information.But good suggestions either way.

author: bjdhjy888
author_rank: Regular Contributor
timestamp: August 30, 2019, 10:52:05 am
content: Unfortunately, my projectfailed again.It really broke my heart!pThe issue is, when I plug my board to my PC, via a microUSB cable, windows 10's Device Manager would show an exclamation mark and read "Unknown USB Device（Device Descriptor Request Failed）"I'm sure my power is ok, cuz the LED by the mircroUSB plug is working. AM1117 is fine, cuz I used my multimeter and confirmed its voltages were all correct.CH340C must be the issue.I checked the voltage between its pin 4 and pin 18, which wasonly 1.8V.It is supposed to be 5V.So what is causing the issue? I tried to solve it but failed.I did check my schematic many times before I sent it to my PCB factory.Any ideas on how to solve this issue?many thanks!

author: Fire Doger
author_rank: Regular Contributor
timestamp: August 30, 2019, 11:33:07 am
content: CH340 work without crystal?Make sure it's the correct model.Also C12 must be 100n not 100p. Datasheet says 0.1uFAlso D+ D- doesn't look like differential routing.

author: bjdhjy888
author_rank: Regular Contributor
timestamp: August 30, 2019, 11:52:59 am
content: Quote from: Fire Doger on August 30, 2019, 11:33:07 amThanks for your reply. But I copied someone else's schematic and I bought his board and his board is designed exactly like mine, aka, his schematic. His board works fine and it works on my PC. But mine does not, on the same PC.So I must be wrong.Could it be my PCBrouting? Thewidthof my wires? (I did use Altium's check funtion and found no errors! strange)Should Idelete my copper pour and get it manufactured again, using the method of elimination?

author: thm_w
author_rank: Super Contributor
timestamp: August 30, 2019, 09:44:41 pm
content: Can you post their schematic? Or compare yours and theirs and see what the difference is in terms of USB/CH340.

author: bjdhjy888
author_rank: Regular Contributor
timestamp: August 30, 2019, 10:48:22 pm
content: OMG!!!!!!!!!!!!my project is working!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!2 issues degbugged!1. CH340C's pin 4 and pin 16 are now powered at 3.3V, instead of 5V, thanks to another schematic found on the internet.2. Reset button must be pressed before flashing, while boot 0 is onman, i'm thrilled!thanks for you guys' help!debegging is painful, but it's worth it!thanks again, bros!!!

author: bjdhjy888
author_rank: Regular Contributor
timestamp: August 31, 2019, 01:23:50 am
content: My next step is to connect an external MPU-6050 module with my board.In order for the module to communicate with my board, I need to use two wires for an I2C connection between MPU-6050 and my STM32.The thing is, there is no room around PB6 and PB7 of my STM32.I will need to put two viasinsidemy STM32. Is this unprofessional? I tried to avoid putting vias inside any IC's.Please let me know. Thanks!

author: mariush
author_rank: Super Contributor
timestamp: August 31, 2019, 12:01:46 pm
content: Well, i wrote two long posts with suggestions and you seem to have ignored everything i said, or even acknowledge what I wrote.... so why would i bother giving you more advice or tips?just the first thing that comes to mind is.... for example at least two people told you that those oscillators/crystals/whatever should be close to the chip and those small ceramic capacitors should also be close, yet your parts are still centimeters away from your chip.

author: bjdhjy888
author_rank: Regular Contributor
timestamp: August 31, 2019, 09:57:34 pm
content: Quote from: mariush on August 31, 2019, 12:01:46 pmThough I did appreciate your reply, I had the right to not follow yours.I followedmostpeople's replies.If you feel uncomfortable,please do reply my posts again.I don't like being overwhelmed or reading huge paragraphs with no capitalizations or logic.I had trouble reading yourEnglishas well.Sorry.

author: eliocor
author_rank: Unknown
timestamp: August 31, 2019, 11:08:13 pm
content: mariush's suggestions are perfectly clear, valid and sound: it would be better if you follow them!Your current layout can be defined in a few words: what a mess!

author: bjdhjy888
author_rank: Regular Contributor
timestamp: September 01, 2019, 04:18:14 am
content: Quote from: eliocor on August 31, 2019, 11:08:13 pmNot if someone like you who cannot read the forum's user code of conduct.Just stay out of my thread if you can't be nice to beginners. Thanks, bro, or... ahem... PCB layout PhD.Oh! Your English suffers from capitalization deficiency as well.

author: Simon
author_rank: Unknown
timestamp: September 01, 2019, 08:33:44 am
content: Perhaps you should calm down a bit. No one learnt to lay boards out overnight. I did not read all of the suggestions but when I looked at the picture I too thought: but I thought you were told not to do that.Do you know why we use bypass capacitors? because there is no room to put those capacitors in the chip itself! That is how important placement is. You are not building a nice housing estate, you are using everything you can to your advantage. Every trace no matter how wide is an inductor and a resistor. When I put bypass capacitors next to a chip the positive pad points to the chip and gets as close as possibe to the pin it connects to, yes I will put the positive pad on a ceramic capacitor 1mm away from the pad of the chip. The negative of the chip goes to a ground plane as does the negative of the IC.Nothing in this world is ideal, you can only but approach ideal as much as possible. The other thing is that you can use this forum to host images, that way they won't keep dissapearing or have watermarks all over them.I hope I capitalized everythig correctly for you so that you can read it OK.

author: Kilrah
author_rank: Unknown
timestamp: September 01, 2019, 08:58:07 am
content: Quote from: bjdhjy888 on September 01, 2019, 04:18:14 amBeing a beginner is perfectly fine. Being a beginner who doesn't listen to the good advice they received after asking for it, and going after those who take time to try and help them usually doesn't end well for them. That has nothing to do with being a beginner in the first place.

author: mariush
author_rank: Super Contributor
timestamp: September 01, 2019, 10:11:08 am
content: Here, I'll try to summarize what I wrote in the posts above in a more concise and clearer way.Note that some of the below may not be rules, but they're good practice.1. Try to make the whole bottom of your circuit board a copper fill, which is connected to ground. This way, you don't need to have long traces connecting the ground pins/pads of various components on the top of your circuit board. You can simply use a via to connect the top pad to the ground copper fill on the bottom.This bottom ground fill will also act as a sort of shielding, insulator, and also as a heatsink if you so choose to use it. In order to improve the effectiveness of this bottom ground fill, make a sustained effort to have as short traces as possible on the bottom ... think of those traces as "jumper links" or 0 ohm resistors.2. It seems you adjusted the layout of some components and some traces in a negative way in order to not cover the silkscreen, the printed text. One of the problems I see is that you added the value of components to the text, which makes the printout much longer.This is not regularly done, as you often have revisions or tweaks (for example changing a 10pF ceramic capacitor for the time crystal to 18pF) and then there's a mismatch between what's soldered and what's printed. As you have a very big circuit board, my advice is to make a small "legend" box in a corner of your circuit board, where you can print the values of each component, in a nice table.Alternatively, you could sign up for Github (owned by Microsoft now) or Gitlab (the "open source" Github replacement) or other free repository websites, create a project URL for your circuit board and then simply print the short URL on your circuit board. Maybe use a nice QR code that links to your project, where people can download the schematic or at least read the component values for various revisions of your circuit board.If this printing of component values is a must, just make an effort to ignore it and route traces under the text. You can also check the options of your board layout software to move the position of that text on another side of the component.3. It's very important for components to have decoupling capacitors, as close as possible to the Vin and GND pins/pads of those components. When we're saying as close as possible, we mean it... at most a few millimeters. If it's not possible to have traces directly from Vin and GND, you should have at least a very tiny trace from Vin and then the other pad connected directly to the bottom GND copper fill using a via.Traditional values for decoupling capacitors are 0.01uF (100nF) but this value is not critical, you can use other values as long as it's +/- 30% or something like that around that value. For higher frequency chips, sometimes they use multiple decoupling capacitors in parallel to cover different frequencies... so for example, they'd have a 0.01uF, a 0.047uF and a 0.1uF capacitor.Traces have inductance and resistance, and decoupling capacitors help smoothing out and stabilizing the energy going into chips. Without them, the circuit may work fine but you could randomly have resets or glitches and you would have a hard time figuring out the problem.4. The crystals / oscillators should be closer to the chips that need them. I would say no more than 1cm away from the chip. In your design, the crystals are too far away. Also, the trace lengths should be as matched as possible, and the traces going to the two ceramic capacitors should be of relatively equal length. Keep in mind that 1 cm of trace can add 1-2 pF of capacitance, so your timing may be off if the ceramic capacitors are too far away from the actual crystal.Also, it's not a good idea to have the 32 kHz crystal sitting vertically on your circuit board. It's much better and common practice to lay these crystals horizontally and have them locked to the circuit board using glue, selastic material, a blob of solder or even a wire. I've recommended adding a small pad (to solder the can to the pad) or two through holes (so you could have a wire loop over the body of the crystal) on the circuit board near crystal footprint the holes. If you don't know how to make a custom footprint or you're too lazy, then just leave room on your circuit board for the footprint of the crystal and use a drop of glue to keep it locked down.If it sits vertically, it can be subjected to vibrations which can affect the timing. Also, it's a good idea to have a few mm of leads as a sort of natural spring, don't put strain on the rubber or whatever material is at the bottom of the crystal, and prevent solder from going up the leads into the package.You can check out this link :https://www.google.com/search?q=32.768+kHz+circuit+board&oq=32.768+kHz+circuit+boardLook at how many pictures have the crystal horizontally and locked through some mechanism and how may don't. If you don't believe me, maybe believe everyone else. Also see :https://electronics.stackexchange.com/questions/158383/why-are-32-786khz-crystal-cans-soldered-to-pcbBring your oscillator / crystals closer to the chip.5. While it's not really bad, it's a good practice to always make traces curve at 45 degree angles and to come out of pads and through holes at 90 degrees (perpendicular to pad walls). Don't go directly 45 degrees out of pads, go out a few mm out of the pad and then make the angle to curve your trace.Smaller angles can cause solder to be caught between the traces, or can etching material to be caught there and corrode traces and make them thinner... and there's lots of reasons why narrow angles are not a good idea.Traces coming out of corners of pads are not a good idea for other reasons. It's better practice to have the traces coming out of pads as wide or slightly thinner than the actual pads.I used the * lines to give you some examples of good and not so good.... again, it's not really bad, it works, but it's not a good practice. If you learn now to them right, it will be automatic to you and you'll do it right in the future.Do what I said in point 1. and take advantage of bottom ground fill (use vias to the bottom ground) to simplify your design.6. I've suggested to rotate some components 90 degrees or even 180 degrees, in order to shorten the traces going to them or to reduce the number of vias going to them, or to reduce the number of bottom traces. As examples, I gave you C2 and the serial IC. Even in the last design, you use vias to route the traces on the bottom and making those traces pointlessly long, and not equal in length : in your particular case, considering the small bitrate, the mismatch in length is not going to cause an issue, but it's good practice to make USB traces as equal in length as possible.7. Your input voltage regulator may cause you problems.7a. Output capacitor:I've mentioned that 1117 is a very cheap linear regulator but care must be used when working with it. By design, the majority of 1117 regulators (I say majority because 1117 is so generic and it's made by so many manufacturers in so many versions...) require an output capacitor and in order to be stable and output a clean voltage, the ESR of this output capacitor MUST be between 0.1 ohm and 1 ohm (again, for most circuits).Some datasheets don't mention this at all. In some datasheets you will see example circuits and text mentioning only tantalum or electrolytic capacitors. This is on purpose : ceramic capacitors have the ESR way below 0.1 ohm, tantalum capacitors traditionally have a high ESR, somewhere around 0.2-0.5 ohm. Electrolytic capacitors will typically have an ESR value above 0.1 ohm at low capacitance (100uF or lower) and low voltage rating (let's say 25v or less) but you have to pay attention to the series of capacitors you use. Some ultra low series of capacitors like Panasonic FM or FR series, or Nichicon HW series can have very low ESR even at such low capacitance+voltage combinations.For linear regulators, you don't need very low ESR capacitor series, you can do just fine with more "middle of the road" choices. For example, Panasonic FC, FK, or Nichicon HD etc etc..If you don't want to use an electrolytic capacitor on the output for various reasons (maybe it's a height issue for example) you can add a ceramic resistor in series with the ceramic capacitor in order to increase the total resistance. For example, add a 0.47 ohm resistor or wire two 1 ohm resistors in parallel (to get 0.5 ohm) and then place the ceramic capacitor in series with these resistors. You could have footprints for 1 or two resistors on the circuit board and then simply populate only one footprint, or even use a 0 ohm resistor (or a blob of solder) to eliminate the two resistors completely.7b. Input capacitor:As for input, a lot of datasheets will say that an input capacitor is not required... however, most assume the energy comes from a small distance away, a few centimeters at most, produced on the same board (for example, a switching power supply outputs 5v and then two 1117 linear regulators are used to produce 3.3v and 2.5v or 1.8v for some components).When the input power comes from an outside source, through a cable that may be 1-2 meters long, there can be problems, as those long cables have their own inductance and resistance. Therefore, it's important to have some amount of capacitance on the input.You're using a 0.1uF capacitor, which can work as a decoupling capacitor and a relatively small "bulk storage" capacitor.7c. Thermal considerations:The 1117 series is also a somewhat bad choice because the TAB which dissipates heat is connected to Vout. In most configurations of linear regulators, the tab or big pad that typically connects to a heatsink, is connected to GROUND.In your particular case it probably doesn't matter as your circuit doesn't use a lot of power, but it's good to know for the future: it may be worth to use a linear regulator that has the tab connected to ground, because this could allow you to connect the big top pad to which you solder the tab to the big ground copper fill on the bottom, using a few vias. This way, a big part of the bottom copper fill will also act as a heatsink for your component.Again, your circuit uses very little power so overheating is unlikely to be a problem. For the future, it's important to know that the difference between input and output voltage is dissipated as heat on the chip, and the chip can only dissipate so much heat through its body and through the pads and traces.Datasheets will have some numbers about how much heat the chips can handle, but those numbers are usually valid only if the tab of the chip is connected to approximately 1 square cm of copper. Your pad is barely as big as the actual tab, so it won't help with heat dissipation.I've suggested those DPAK or TO-253 linear regulators because majority of those regulators have the tab connected to ground and they're bigger packages that don't heat as fast as the smaller regulators. Some of the models I suggested are also guaranteed to be stable with ceramic capacitors on the output, reducing the need for a big electrolytic capacitor which may break off the board if subjected to mechanical stress.-Review my previous posts with the information in this post. I hope it's written nice enough for you to understand - I've even installed the grammerly extension (but it's useless on this forum)

author: bjdhjy888
author_rank: Regular Contributor
timestamp: September 01, 2019, 12:32:47 pm
content: Thanks, guys. My bad.If you saw my initial layout, you would be surprised how much worse it was. It was very very bad. I cannot even look at now. That's why I did appreciate your replies.I'm gonna re-do the layout from scratch and improve my schematic, again!Thanks again. Bless you, mariush!p.s.: Though I've been following Dave on YouTube, it wasn't until today that I noticed that his vlog has some videos on PCB layout. I just started to watch them. Hope I can improve my PCB layout skills.

author: Simon
author_rank: Unknown
timestamp: September 01, 2019, 05:59:44 pm
content: No coponent is in physics what it is labeled as and we are basically playing with physics at a higher abstracted layer. The higher you go in frequency the more heed you pay to actual physics.No passive component is purely a resistor, capacitor or inductor. Every one is a tuned circuit with a dominant characteristic. All other components have R, C, & L in them too. Every pin of a chip has capacitance, gates of MOSFET's are capacitors, sure you can pick a bigger MOSFET with lower Rds_on that will make less heat when conducting, but now it will have more input capacitance and take longer to turn on and off which means making more heat....

author: thm_w
author_rank: Super Contributor
timestamp: September 03, 2019, 10:58:17 pm
content: Quote from: Kilrah on September 01, 2019, 08:58:07 amSure, and he should be appreciative. But advice given should match, to some extent, the skill of the OP. If its the guys first board and you whip out a laundry list of mostly non-critical criticisms, its going to overwhelm or discourage them.eg "acid traps" and such are really not a thing any more, a lot of PCB design advice is from times past when PCB manufacturing was not as well refined as it is these days. Some recommendations that used to be "good practice" have become obsolete, although some still have value in terms of clean layout/etc.Quote from: bjdhjy888 on August 31, 2019, 01:23:50 amYes you can put via's under the IC, there is nothing wrong with this. Just keep it far from the pads (to avoid solder shorting where you cant see it), and not if the part in question has a metal pad in the middle (this STM32 does not).