2024-01-15 - the button story

a couple of days ago i finally received by new PCBs for Lemur's bobik project. that's an old one, that started as a COVID-time project – started in 2020, when COVID hit, but final touches were done only in 2022. the new (2023/2024) incarnation did not have old restrictions, so i (finally) went for all-SMD, even though i kept the original PCB size, so that i do not need to re-print the entire enclosure, just to mount the thing. ;)

PCB v2.1

over the weekend i've assembled the whole thing. since buttons are located on the separate board, and there's nothing more there, i've kept the original (home made) PCB for that. whole thing is now powered with 6S LiPo batter pack, so that steppers (finally) have the voltage they like. ;)

whole electronics assembled

however the new PCB change 1 important thing, related to buttons. PCB is in shutdown mode, unless a button is pressed. if so, µC keeps PCB awake for 2mins. if there's no button press, it will power itself off again.

PCB schematics - buttons part

on the schematics, power is provided from 6S LiPo cell to U5 voltage stabilizer, through Q1 P-MOSFET transistor. the gimmick is that stabilizer is powering on µC only, if one of the buttons is pressed or when Q3 N-MOSFET is opened. so the SW path goes like this – each button press auto-powers-on U5 and thus µC (+LED ;)), and when µC is up, it immediately opens Q3, so that power is preserved, even if button is released. on top of that D7 zener diode is used to ensure that Q1's source-gate voltage is never breached, even if >1 button is pressed. additional D2-D6 diodes are there to protect µC's I/O pins from ~22V voltage, when buttons are release (i.e. circuit is opened).

so far, so good. the problem is that after this change, my original code for reading button presses became super noise and started to report a lot of false readings (or – mostly no read at all). took me a moment to realize, i need a better de-noising algo for reading it, as new setup is now R+C circuit.

PCB with keys -- one key and de-noising cap

C is there to short-circuit mechanical switches, on PCB. but C5 + R15 makes rising edge a bit slower than before, where C5 + key was directly connected to I/O pin!

fast forward 2h+. with ~3 iterations of in-SW noise-removal algo, it works much better… yet far from perfect. today i was desperate enough to connect oscilloscope to see what's going on… and guess what – turned out that “forward” and “start” buttons were completely trashed and did not react to ~1/2 of presses! when pressed, it also tend to generate noisy output. well… in a hindsight this toy has been heavily abused by my sons for ~3 years now – failing mechanical button shall not be a surprise…

after replacing all 5 buttons (just to be on a safe side), it all now works like a charm! lessons learned – while guessing is fun, when in doubt – just measure…

blog/2024/01/15/2024-01-15_-_the_button_story.txt · Last modified: 2024/01/15 20:22 by basz
Back to top
Valid CSS Driven by DokuWiki Recent changes RSS feed Valid XHTML 1.0