Feedback on circuit board for custom Flight Controller

Yeah, that's NOT good at all.

Yes, it can, but the crystal arrangement I find much more worrying because it's overall a much more sensitive circuit.

I don't think the programming error you're getting is due to the PCB layout. It likely relates to a RST pulse not making it through to the uC.
Mind you, I'm assuming that you have programmed the microcontroller with the bootloader and have set the fuses, yes? Can you confirm that ISP programming works?

For the next/improved version of this board. You'll have to order a new version anyway to fix the oscillator circuit because that's just a problem waiting to happen.

You're also missing a ground plane and your power traces are thin, the lack of a copper pour around the linear regulators is a missed opportunity from a thermal management perspective (also no copper pour on the backside or thermal vias), there are no pullups on the I2C lines so you just have to keep fingers crossed that the ones on the BN0008 module are sufficient...but these are 'survivable' mistakes for this board (probably...).

It's not awfully bad for a first try but if you had taken the time to post this here for a quick review, you would have been able to prevent some of the more obvious errors in your first manufactured board.

PS: again, your board looks really really tidy - just not in a functional way.

1 Like

I understand, but it works on the arduino mega somehow? :slight_smile:

Ah, ok, I have tried to manually connect the GND to RST on my pin header for the ISP when starting an upload to the uC, but that doesnt seem to make a difference.

This seems to work I believe, here is the output I get from verbose arduino IDE when I burn the bootloader:

avrdude: Version 6.3-20190619
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "C:\Users\lordmax2\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf"

         Using Port                    : COM4
         Using Programmer              : stk500v1
         Overriding Baud Rate          : 19200
         AVR Part                      : ATmega2560
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PA0
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom        65    10     8    0 no       4096    8      0  9000  9000 0x00 0x00
           flash         65    10   256    0 yes    262144  256   1024  4500  4500 0x00 0x00
           lfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           efuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           lock           0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

         Programmer Type : STK500
         Description     : Atmel STK500 Version 1.x firmware
         Hardware Version: 2
         Firmware Version: 1.18
         Topcard         : Unknown
         Vtarget         : 0.0 V
         Varef           : 0.0 V
         Oscillator      : Off
         SCK period      : 0.1 us

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.03s

avrdude: Device signature = 0x1e9801 (probably m2560)
avrdude: erasing chip
avrdude: reading input file "0x3F"
avrdude: writing lock (1 bytes):

Writing | ################################################## | 100% 0.01s

avrdude: 1 bytes of lock written
avrdude: verifying lock memory against 0x3F:
avrdude: load data lock data from input file 0x3F:
avrdude: input file 0x3F contains 1 bytes
avrdude: reading on-chip lock data:

Reading | ################################################## | 100% 0.01s

avrdude: verifying ...
avrdude: 1 bytes of lock verified
avrdude: reading input file "0xFD"
avrdude: writing efuse (1 bytes):

Writing | ################################################## | 100% 0.01s

avrdude: 1 bytes of efuse written
avrdude: verifying efuse memory against 0xFD:
avrdude: load data efuse data from input file 0xFD:
avrdude: input file 0xFD contains 1 bytes
avrdude: reading on-chip efuse data:

Reading | ################################################## | 100% 0.01s

avrdude: verifying ...
avrdude: 1 bytes of efuse verified
avrdude: reading input file "0xD8"
avrdude: writing hfuse (1 bytes):

Writing | ################################################## | 100% 0.01s

avrdude: 1 bytes of hfuse written
avrdude: verifying hfuse memory against 0xD8:
avrdude: load data hfuse data from input file 0xD8:
avrdude: input file 0xD8 contains 1 bytes
avrdude: reading on-chip hfuse data:

Reading | ################################################## | 100% 0.01s

avrdude: verifying ...
avrdude: 1 bytes of hfuse verified
avrdude: reading input file "0xFF"
avrdude: writing lfuse (1 bytes):

Writing | ################################################## | 100% 0.01s

avrdude: 1 bytes of lfuse written
avrdude: verifying lfuse memory against 0xFF:
avrdude: load data lfuse data from input file 0xFF:
avrdude: input file 0xFF contains 1 bytes
avrdude: reading on-chip lfuse data:

Reading | ################################################## | 100% 0.01s

avrdude: verifying ...
avrdude: 1 bytes of lfuse verified

avrdude done.  Thank you.

"C:\Users\lordmax2\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/bin/avrdude" "-CC:\Users\lordmax2\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf" -v -patmega2560 -cstk500v1 -PCOM4 -b19200 "-Uflash:w:C:\Users\lordmax2\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6/bootloaders/stk500v2/stk500boot_v2_mega2560.hex:i" -Ulock:w:0x0F:m

avrdude: Version 6.3-20190619
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "C:\Users\lordmax2\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf"

         Using Port                    : COM4
         Using Programmer              : stk500v1
         Overriding Baud Rate          : 19200
         AVR Part                      : ATmega2560
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PA0
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom        65    10     8    0 no       4096    8      0  9000  9000 0x00 0x00
           flash         65    10   256    0 yes    262144  256   1024  4500  4500 0x00 0x00
           lfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           efuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           lock           0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

         Programmer Type : STK500
         Description     : Atmel STK500 Version 1.x firmware
         Hardware Version: 2
         Firmware Version: 1.18
         Topcard         : Unknown
         Vtarget         : 0.0 V
         Varef           : 0.0 V
         Oscillator      : Off
         SCK period      : 0.1 us

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.02s

avrdude: Device signature = 0x1e9801 (probably m2560)
avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed
         To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: reading input file "C:\Users\lordmax2\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6/bootloaders/stk500v2/stk500boot_v2_mega2560.hex"
avrdude: writing flash (261406 bytes):

Writing | ################################################## | 100% 0.00s

avrdude: 261406 bytes of flash written
avrdude: verifying flash memory against C:\Users\lordmax2\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6/bootloaders/stk500v2/stk500boot_v2_mega2560.hex:
avrdude: load data flash data from input file C:\Users\lordmax2\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6/bootloaders/stk500v2/stk500boot_v2_mega2560.hex:
avrdude: input file C:\Users\lordmax2\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6/bootloaders/stk500v2/stk500boot_v2_mega2560.hex contains 261406 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 0.00s

avrdude: verifying ...
avrdude: 261406 bytes of flash verified
avrdude: reading input file "0x0F"
avrdude: writing lock (1 bytes):

Writing | ################################################## | 100% 0.02s

avrdude: 1 bytes of lock written
avrdude: verifying lock memory against 0x0F:
avrdude: load data lock data from input file 0x0F:
avrdude: input file 0x0F contains 1 bytes
avrdude: reading on-chip lock data:

Reading | ################################################## | 100% 0.01s

avrdude: verifying ...
avrdude: 1 bytes of lock verified

avrdude done.  Thank you.

It was pretty difficult to get it routed good this small, I will try to have a better layout for the next version!

Thank you so much for your feedback! It is very appreciated!

No.
image
Note the much shorter traces, and in particular how they're surrounded by a GND guard area. You'll likely see a GND pour on the underside as well.

Your ISP programming for the bootloader seems OK. Try to upload a LED blink sketch through the same interface and observe whether it works. I assume you've set the fuses correctly, but I did not verify it. You should do this to ensure e.g. clock configuration is correct.

I removed the R1 and R5 pin (between TX/RX CP and uC) and now it works at least!!

Ah, but there is a larger crystal on it? Maybe that is the one going to the other MCU onboard that I believe is the on board (programmer)?

I can at least recieve Serial prints! My LED doesnt blink in the blink sketch, but I get something at least :smiley:

OK, good!

Yes, the bigger crystal on the Arduino Mega 2560 is associated with the IC just a few mm away from it.

1 Like

I have done some more testing and it seems like if I try to upload a larger sketch, I still get the timeout error.

I tried to upload a small Servo test sketch, but that doesnt seem to work, but I can upload small "Serial.begin" and serial.print sketches. So smoething is definatley not right :upside_down_face:
I guest maybe some of my 1kOhm resistors can cause some trouble. Or is it also maybe a cosequence of PCB placement?

Your topic is marked as solved, so most people will now ignore it.

1 Like

Not sure what kind of problem you're describing here.

But that this board would be giving you problems...yeah, that was to be expected.

1 Like

Great point of reference for you is the board schematics for the Mega2560.

I don't like that reset circuit. Take a look at the official Arduino Mega schematic and see what they did.

1 Like

And their board layout...note the fatal flaws I pointed out earlier esp. regarding the oscillator circuit.

2 Likes

Yes, oscillator must be super close to the chip. Like really super close

1 Like

Thank you!

I guess this is the reset switch part between the programmer and the microcontroller:

I am a little bit unsure of what this part consists of, what type of component is this?
image

Should everything be "as close as possible"?

Like each resistor and capacitor and every component to each other?

Another question, the sizes of each "cable" or connection (I dont know what it is named in circuit boards, but the "line" that connects the components), can you adjust them in EasyEDA?
How do I know if so, how large they should be? :slight_smile:

I tried to make an aesthetically for the eye good looking board, but I realize that that isnt the optimal solution, its great to get tips and help from smart people like you! Sorry if I ask stupid questions :slight_smile:

No; in general, the higher the frequency of the signal and/or the higher the anticipated currents, the shorter the distance. So the oscillator circuit needs to be closely packed (16MHz) just like USB (12MHz and higher) but the UART components are much less critical (dozens to hundreds of kHz).

Yes. Refer to the EasyEDA manual.
Tools like these also help: https://www.advancedpcb.com/en-us/tools/trace-width-calculator/
Finally, keep an eye on the manufacturing tolerances; the PCB manufacturer (e.g. JLCPCB) will have a list of critical dimensions you should not go under.

And you succeeded! So next time, ensure it's functionally sound first, and within the constraints that arise from this, feel free to make it look good.

1 Like

That's a solder jumper.

That's called a trace.

EasyEDA is not as good as KiCAD (I'm sure that will start a debate :grinning:), but I find KiCAD far simpler and more configurable.

The only stupid question is the one that isn't asked.

That's only part of it. Here's the rest:

1 Like

22p is an odd choice for C1. Was that copied from the crystal oscillator and then someone forgot to change the value to a more sensible 100nF - 1uF?

1 Like

No idea.
You'd have to ask the Arduino engineers who designed it.

I would personally have expected to see 100nF

1 Like

Will this reset switch work? Or do I need this part also at the DTR port:
image

To resolve this, do I just "ignore" one of the pairs from the USB port? Like this?

I'd change C8 to 10nF or smaller. Otherwise it may or may not work; it'll be sort of random.

That's a solder jumper. It doesn't do anything as such. To make sense of it, check the PCB layout.

No.
https://www.google.com/search?q=differential+pair+pcb+layout+guidelines

1 Like

Your schematic shows DP1, DP2 and DN1, DN2 connected together by virtue of the net names D11 and D12 even though you don't show a connection via a line on your schematic. Normally you would connect A6 to B6 and A7 to B7 right at the USB-C connector and then proceed with the differential pair traces to their destination.

1 Like