I2C touch and OLED PCB design - Page 1
Forum section: electronics / beginners

author: metaphase
author_rank: Newbie
timestamp: September 12, 2021, 03:24:05 pm
content: Hi folks - would greatly appreciate any expertise/suggestions on solving this problem! In particular have I done anything glaringly stupid when it comes to my PCB design?I'm trying to get touch control working with an OLED screen, controlled by a Raspberry Pi Zero W. This is via a custom PCB for touch & OLED, connected via a short (~5cm) ribbon cable from the first 8 pins of the Pi. The Pi has built-in 1k8 pull-up resistors on the SDA & SCL lines.The screen is an SSD1306 screen running over I2C (using luma.oled), it's worked well for a few months when used in conjunction with touch control using anAT42QT1070in standalone mode with three keys tied to GPIO pins. However I’m now putting the setup in a plastic enclosure and the sensitivity in standalone mode isn’t sufficient to detect the touch, therefore I need to run the touch controller in comms (I2C) mode (I2C), as that lets you adjust the sensitivity.i2cdetect shows both devices fine (0x3c for the screen, 0x1b for the touch controller). I have a Python script to control the screen and another for touch control. However I'm now finding if I load the screen script it will start the screen and update fine but then after a few seconds it will then crash out with an I/O error. I've tried a different screen but no change and if I put it back on an old board (similar design but with the touch control in standalone mode) it works OK.It seems that if I just run with the screen connected or just with the touch controls it works OK (I can interrogate the registers, pull touch sensor readings, etc.) but when both are connected I'm running into issues, despite both showing up correctly and both working to some extent before they abort.On my breadboard layout (I created one for this VQFN package - unfortunately the larger 14-pin SOIC I had used previously seems to be out of stock thanks to the worldwide chip shortages!) they seem to both work OK at the same time, so I’m worried I’ve done something stupid with my PCB design! As I say I can interrogate the registers on the AT42QT1070 OK, it’s more like something destabilises the I2C bus when I’ve got the screen running too?My KiCAD PCB layout for the main board is attached (the weird board outline is due to other components/fixings in the case I have to work around), I've also attached the breakout I designed for the breadboard. Both are standard 2-layer FR4 boards, manufactured by JLCPCB.I've read through the NXP/Philips I2C design spec as well as the Atmel touch control guidance and have tried to balance things as best I can - e.g, no ground plane around the touch controls, cross touch over other lines at 90 degrees, short ribbon cable from Pi to this PCB. I'm wondering if I need a different routing of the I2C SDA/SCL lines or more ground plane around them? Should I run separate connections for these lines from the IDC pins to the OLED and to the touch controller rather than join them en route as I've done here? I've not quite worked out how to calculate parasitic capacitance, etc. but can't imagine I've gone above the 400pF limit with just two slaves and fairly narrow/short traces? Unfortunately I don't have an oscilloscope which I understand would be helpful to look at the signals better and see if there are any issues there.Please just say if any more info would be useful and thanks in advance for any help!…

author: hermit
author_rank: Frequent Contributor
timestamp: September 15, 2021, 09:08:55 pm
content: No direct answer here but an anecdote of sorts. When I was in school a teacher, who was an engineer at local plant of a large company, said they had a new process control panel installed. It would work for a while and then 'go berserk'. Turns out the company developing it had never tested it inside the case it was installed with because it was much easier to check things when it was outside the case. The fix was a one pico farad capacitor to the chassis.Being a multi million dollar operation it was worth their while (mandatory really) to have a team of engineers trouble shoot the thing and come up with a resolution. You may have to just try a few things like lining the case with aluminum foil and seeing if that helps. Good luck.

author: hermit
author_rank: Frequent Contributor
timestamp: September 21, 2021, 08:25:01 pm
content: No updates?

author: metaphase
author_rank: Newbie
timestamp: September 21, 2021, 08:43:43 pm
content: Quote from: hermit on September 21, 2021, 08:25:01 pmNo other replies so far apart from yourself! Have done some redesign work and awaiting replacement boards to see how it goes. Have also tweaked the Python code to try and recover more gracefully if the I2C bus does run into issues and have shorted the ribbon cable from Pi to PCB from 10cm to 5cm (although suspect it won't make that much of a difference!)

author: perieanuo
author_rank: Frequent Contributor
timestamp: September 22, 2021, 05:32:21 am
content: hi,did you saw page 12 on that pdf you pointed?Quoteyou are using a ground plane on bottom? cause i don't understand the gnd connection for C1they clearly pointed the Vcc for that sensor ic needs to be separate from other. imho, he can be the same, but with impeccable layout. that exclude using raspi and his connectors, but if you wanted like this...i saw the same problems with one project with arduino board, i redesigned that incorporating arduino and sensors, all worked fine (the power/signals routing from ardu board to the sensors they had a mess cause of that 'prototype' approach)also, larger bypass cap is mentioned. i recommend 100n+10n near the chip, maybe 1uF also, and careful layout. and testing that proto thorough by simulating voltage variations, spikes...for me, this power supply pcb design for your touch ic needs to be clarified, then we can move on

author: perieanuo
author_rank: Frequent Contributor
timestamp: September 22, 2021, 05:44:53 am
content: Quote from: metaphase on September 12, 2021, 03:24:05 pmtry to separate i2c comm problems from Vcc problems: script some quick interrogation for those 2 ic's and see if the answer from each ic is comming without issue, thay way you decide if i2c comm is faulty or sensor detection is not working well because of vcc (what i suspect you're dealing with is that second one)

author: perieanuo
author_rank: Frequent Contributor
timestamp: September 22, 2021, 05:48:42 am
content: page 12:Quoteyou have parallel lines for pad1, move that 4-way connector asideanyway, i don't understand why you implanted him in that position, seeing the tracks are going to the right, his place is on top-right side or right side of that pcbtrying to understand your approach, did you tied reset to vdd? and used pins key1/2/3? they recommend resistor for reset line, a resistor costs cents, with this approach in the future you'll get into problems.for me, it's logic to use key 0/1/2, reset must be done hardware or hardware+software via i/o pin. no good.

author: metaphase
author_rank: Newbie
timestamp: September 22, 2021, 12:43:44 pm
content: Many thanks for replying, @perieanuoQuote from: perieanuo on September 22, 2021, 05:32:21 amyes, I've got a decoupling capacitor in placeQuote from: perieanuo on September 22, 2021, 05:32:21 amYes - there's a ground plane around the touch IC/resistors/capacitor - I'd just put KiCAD in outline mode for the ground plane to make it easier to see the other traces, but it's the hatched outlineQuote from: perieanuo on September 22, 2021, 05:32:21 amI'm afraid I don't quite understand? I've only got one power source coming into the Pi (USB) and am using the power from it?Quote from: perieanuo on September 22, 2021, 05:32:21 amthe power supply is just from the Pi - I've got at 0.1uF near the chip as per the datasheet, the Pi has its own on-board capsQuote from: perieanuo on September 22, 2021, 05:44:53 amthe sensor itself seems to be working OK, the issue has more been the screen stopping working due to an i2c comms errorQuote from: perieanuo on September 22, 2021, 05:48:42 amThanks - I'd noticed that too re parallel lines so have moved that and am trying to route it separately nowUnfortunately the layout is quite constrained - the OLED connector has to be placed where it is (which determines where the touch controls) and due to other boards in the box I didn't have enough space on the left of the PCB for the other circuitry, hence why it is over on the right.My new boards are arriving soon so will see how they are. Thanks again for replying.

author: perieanuo
author_rank: Frequent Contributor
timestamp: September 23, 2021, 08:27:54 am
content: it's simple, they say touch IC paragraph 3.4 (Power supply) you should use separate regulator for Vdd pin.how, that's your problem, maybe some other 3v3 regulator powering from 5V raspi rail.it's not my oppinion, it's their yellow marked phraseotherwise they said 'erratic operation'in your place i'll use wider tracks, you have nothing but space on that pcb

author: metaphase
author_rank: Newbie
timestamp: September 23, 2021, 10:59:13 am
content: Quote from: perieanuo on September 23, 2021, 08:27:54 aminteresting, thanks - I had spotted the bypass cap bit in that warning box but hadn't realised about the separate regulator. The IDC pins I pull across from the Pi do have a 5V line as you say so I suppose I could add a regulator to create a separate 3.3V supply for either the touch control or the OLED screen. I've never used regulators before but presume it's quite easy - perhaps this sort of component??https://docs.rs-online.com/b505/0900766b813299bc.pdf- it looks like they need input and output capacitors too?do you mean wider spacing between the tracks or thicker tracks? I've tried to do thicker tracks for the 3.3V but tried to keep thin for other things as I thought that was better. I've definitely tried to space out the tracks on a revised layout - they're hopefully arriving early next week so will see how they are!

author: perieanuo
author_rank: Frequent Contributor
timestamp: September 23, 2021, 02:54:24 pm
content: i'll use something like cheapest ldo possible (that 1117 have 1.2v dropout, it's a little bit at limit), i saw on farnell uk this onehttps://uk.farnell.com/microchip/mic5317-3-3ym5-tr/ldo-fixed-3-3v-0-15a-40-to-125deg/dp/2920683or if you want stability 100% take TI ldo like LP2950-33LPRE3 or whatever you preffer, i avoid microchip for regulators, but it should work. i prefer ti, lt, rohm, ad, diodes.choose some ldo with small drop and no fancy capacitor requirementsbut just for test, use what you got in your lab, even the old 7805 can be set to output 3v3 for testing that supply issue, or some lm317try wider tracks at least for supply and more spacing between them and avoid parallelism, the board is not so small