martinberlin / H-spi-adapters

PCB design for SPI adapters (HATs)

Home Page:https://www.tindie.com/stores/fasani

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Small review

shadowpho opened this issue · comments

I had a day off and I love ESP32 stuff so i reviewed! Feel free to take anything useful to you and ignore the rest 👍
(regarding the 1.54-watch-pcb)

Small review for schematic:

  • Good job on MCP1700, looks pretty decent and low quiescent! One downside is that it does not have an enable pin -- so there isn't a nice way of saying "ok let's go super low power, and turn EVERYTHING off and then wake up on RTC_INT". Using ESP32 in super lower power mode is tricky and painful, and IMHO it's easier to use the active mode and then shut everything down if you only want periodic wake-ups.
  • I dislike using the CP2xxx. They are generally power hungry, expensive and not needed. Newer ESP32 ICs support programming/UART over USB. IO18/19 are USB compatible on c3-mini looks like. I have been using just raw USB on ESP32-S2 from when it was released and it's working out fantastic now (albeit it was buggy when it launched). If you go that route note that you need to configure the usb properly in menuconfig (and you might lose the option to have auto reboot, need a small button/header if that's the case). I'd at least recommend connecting IO18/19 with resistors to USB connector so you can play with that option once you get the boards back.
  • 100 uF (~60 derated) is not going to last very long with 0.25 uA (10 minutes?). That makes C15 kinda useless, as once the battery dies keeping RTC alive for another 10 minutes isn't a long time. I had a similar circuit on my design but just ended up getting RTC from internet on bootup.
  • Why are R/C footprints so large? 0805 is pretty large, you can get almost all of them in 0402. This would greatly help to place them closer to J1 for example (and save A LOT of space). And JLC supports 0402 SMT for very cheap.
  • C16 is not needed. I'd recommend smaller caps in general (and DS recommends 10 uF + 0.1 uF)
  • 2 LEDs + extra button is always nice for debugging, and there's plenty of IO left over!

Brief layout review:

  • No GND flood on L01\L03? Also need more vias, grounding stitching between L3\L4 is not great.
  • Smaller R/C will really help with layout. I'd rotate all R horizontal and move them closer to connector as much as possible. Running routes under discretes is not a great practice and it isn't really needed here.
  • Even if you want to keep the larger parts spend a bit more time with layout, for example I was able to unswizzle and compact parts, see below. It can be further improved. I'd also throw +3v3 on one layer... inner layers not very much used (and they are not great at grounding either). You can also push all the signal vias (EPD_* down to L2 immediately and not route them at all on L1 which gives way more space for discretes right next to connector.
  • See an example below. I did not mess much only on L1 with just a touch on L2. Now parts are closer to connector, there can be a ground flood, and more PCB space. In general you can do the same thing with parts close to ESP32, you can bring vias in closer to the part as well. It can be done better too (R1\Q1 can also move close)
    image

Great review @shadowpho
I will try to correct some of this things. Just to add some context I think we are speaking about the watch PCB.

Some notes from the top of my head:
C16 is there only because max. output power of the MCP1700-33 is 250 mA. Which is enough for most things, but if the epaper update that is about 30 mA is combined with a 250 mA spike from WiFi or BLE then it resets when this additional power puff is not there. That is the only reason of being there, probably a much smaller one could be enough with a different LDO.
Will explore this what you say about the EN pin, but IMHO, it should be always on even when the ESP32 is in deep-sleep mode. Right? Or what is your idea to reduce power more?

For me what is missing is an extra P-Mosfet like Q4 should be added using a free GPIO (2 for example) to enable the 3V3 power line of the epaper. Because they have deepsleep mode but they also consume like 0.2 mA or so which eats your battery slowly. My current demo-watch with DS3231 lasts only about 48 Hrs updating each 2 minutes the epaper on a 100 mA LiOn battery and it is a very small 200x200 monochrome display.

About built-in USB: I had a very different start than you. Started with first S2 models and I found it difficult to use, at that time you had to press RST + BOOT buttons. It was hard to debug using Serial output... I really want to have proper UART. Do not have to press any buttons at all and I want that enters serial mode automatically using: idf.py flash monitor
But if you confirm me that everything works exactly as with an UART chip then I will have a try. Maybe in last 2 years things changed a lot and I am being too old school :P

But overall I agree there is still a lot of room to improve this PCB. About the smaller resistances I agree of course everything could be smaller using 0402. But only until till discovering that you need to change a pull-up or whatever, and I dont have 0402 at hand and it is also awful to solder. I stick to 0604 in first revisions because is very often you need to correct something and at least this I can solder manually. Also many parts are bigger than they should because they are Standard basic parts. Otherwise you end up using external parts that sum up to make your PCB much more expensive. If it was for a client that is paying and needs quality plus a very small PCB it will make sense, but when you are doing a hobby project and financing it from your own pocket you need to have some constraints.

Great review @shadowpho I will try to correct some of this things. Just to add some context I think we are speaking about the watch PCB.

Yep! Watch PCB.

Some notes from the top of my head: C16 is there only because max. output power of the MCP1700-33 is 250 mA. Which is enough for most things, but if the epaper update that is about 30 mA is combined with a 250 mA spike from WiFi or BLE then it resets when this additional power puff is not there. That is the only reason of being there, probably a much smaller one could be enough with a different LDO. Will explore this what you say about the EN pin, but IMHO, it should be always on even when the ESP32 is in deep-sleep mode. Right? Or what is your idea to reduce power more?

That's scary! ESP32-C3-mini mentions max power at 350 mA. The fact that 100 uF fixes it is very worriesome for sure! (100 uF is not very much power, meaning it's going to be very marginal... a slightly longer current spike or different silicon will break for sure, especially across temp/humidity). There are better parts but I used TPRT9013-33 (500 mA LDO, 8 cents on jlcpb, has enable pin. Slightly higher quiescent, but not noticeably unless you are doing deep sleep).

For me what is missing is an extra P-Mosfet like Q4 should be added using a free GPIO (2 for example) to enable the 3V3 power line of the epaper. Because they have deepsleep mode but they also consume like 0.2 mA or so which eats your battery slowly. My current demo-watch with DS3231 lasts only about 48 Hrs updating each 2 minutes the epaper on a 100 mA LiOn battery and it is a very small 200x200 monochrome display.

I had issues with deepsleep on ESP32-S2. It was very tricky to achieve and very difficult to debug. (I turned off i2c clock, shut down wifi... oh it doesn't wake up. Looks like I have to leave some wifi clocks on... but then it instantly wakes up? grrrrr). It seems that everyone just uses light sleep and calls it good enough.

Instead I found it easier to turn off ESP32 + circuitry altogether and use an external chip to turn power back on (like with your RTC -- interrupt pin used as wakeup). You program the RTC to wake ESP32 up in ~2 minutes, and then turn off enable (you can use a flip-flop for example or even just RC with diode). This way you don't need a second P-FET either, as all of 3v3 goes off. The epaper\esp32\any leakages.... all power is gone :).

The downside is that you have more limited ways to wake up, but in this example is not needed -- The ESP32 can set a certain wake-up time and wake up then (plus maybe add a button to wakeup if desired?)

About built-in USB: I had a very different start than you. Started with first S2 models and I found it difficult to use, at that time you had to press RST + BOOT buttons. It was hard to debug using Serial output... I really want to have proper UART. Do not have to press any buttons at all and I want that enters serial mode automatically using: idf.py flash monitor But if you confirm me that everything works exactly as with an UART chip then I will have a try. Maybe in last 2 years things changed a lot and I am being too old school :P

No, that sounds about right, I had similar issues with S2, especially earlier software which was pretty crappy. However it seems newer versions are better, for example here is what espressif says about debugging:
"The quickest and most convenient way to start with JTAG debugging is through a USB cable connected to the D+/D- USB pins of ESP32-C3. No need for an external JTAG adapter and extra wiring / cable to connect JTAG to ESP32-C3."

Now I didn't use this chip so I would not recommend switching just based on my word, but if you add an option to test it out you will know how good/not good it is (plus will be able to switch to it for production, as that will save the IC cost if you want to make >100).

But overall I agree there is still a lot of room to improve this PCB. About the smaller resistances I agree of course everything could be smaller using 0402. But only until till discovering that you need to change a pull-up or whatever, and I dont have 0402 at hand and it is also awful to solder. I stick to 0604 in first revisions because is very often you need to correct something and at least this I can solder manually. Also many parts are bigger than they should because they are Standard basic parts. Otherwise you end up using external parts that sum up to make your PCB much more expensive. If it was for a client that is paying and needs quality plus a very small PCB it will make sense, but when you are doing a hobby project and financing it from your own pocket you need to have some constraints.

0402 is not that bad to solder. My hands are pretty shaky, but 0402 is decent (albeit not fast). With that said I perfectly understand not wanting to use the smaller parts if one prefers faster\easier soldering :-).

By the way, lcsc has dirt-cheap caps\resistors. I ordered 3 books of 0402\0603 parts for total of $50. It's a lot of common and tuning values (100 types of 10-100 parts). I do some wireless tuning with VNA so I needed a lot of values, but I found a lot of use out of them otherwise as well. Plus I got to indulge and bought random large caps\supercaps\antennas as well 😏

LDO
I‘m going to switch LDO to the one you recommended. The MCP1700 is leaking from 3V3 VOUT to VIN when you power the PCB directly via the 3.3V pin. This draws 4mA in deepsleep since starts feeding the UART chip which was not in anyway intended. Thanks for recommending me TPRT9013-33. The others I will slowly update in next revision.
By the way: Could not find the TPRT9013-33GB footprint anywhere so far.

Note that all* LDOs are going to leak VOUT to VIN! They all* control a FET internally which means there's a backwards diode due to structure of the FET.

I am a bit confused on design above -- because if VBUS is not plugged in then there will be no 3v3, so this will not operate on battery at all.

As for UART chip -- it's likely the MCU was backdriving the chip into TX pin (as UART by default is active low, meaning in IDLE the line has 3.3v on it). If you turn off UART and set TX to low you would see it go away?

image

I am a bit confused on design above -- because if VBUS is not plugged in then there will be no 3v3, so this will not operate on battery at all.

Yes. That’s how it was intended since it’s a wall switch. So it’s either powered by VUSB and has UARt just for programming/Serial output. Or by 3V3 directly.
would like to send you a kit just for fun so you try it out. At least you can play with the PCB you’ve helped me to improve so much.
Thanks a lot for the recommendations.

updated schematics: https://github.com/martinberlin/bistable-smart-switch/tree/master/Hardware/C3-27-epaper-touch/schematics

About:

As for UART chip -- it's likely the MCU was backdriving the chip into TX pin (as UART by default is active low, meaning in IDLE the line has 3.3v on it). If you turn off UART and set TX to low you would see it go away?

I'm not sure if I can turn off UART in ESP32. I will check it out, you mean setting directly that GPIO to low... interesting idea. Thanks a lot!

Yes. That’s how it was intended since it’s a wall switch. So it’s either powered by VUSB and has UARt just for programming/Serial output. Or by 3V3 directly. would like to send you a kit just for fun so you try it out. At least you can play with the PCB you’ve helped me to improve so much. Thanks a lot for the recommendations.

Ahhh I see interesting.. so the battery is only there for RTC then. No problem! Happy to see more hobbyists hardware! I'll ping you on twitter 👍

I'm not sure if I can turn off UART in ESP32. I will check it out, you mean setting directly that GPIO to low... interesting idea. Thanks a lot!

image

Looks like it can -- change UART0 to GPIO20/21. However I don't think there's enough information to tell if it's plugged in (ESP32-C3-Mini does not have VBUS. If desired you can add a resistor divider from VBUS (divide by 2) to a GPIO and that can tell to reconfigure. )