PCB-only capacitive keyboard? - Page 1
Forum section: electronics / projects

author: ebastler
author_rank: Super Contributor
timestamp: October 27, 2022, 03:51:32 pm
content: I am toying with the idea of designing a cheap-and-cheerful keyboard made of just a PCB with capacitive sensor areas (hidden under a layer of soldermask and silkscreen) and readout electronics. Full QWERTY keyboard, either regular size or a bit smaller.Due to the lack of tactile feedback, I would not consider this for productive use on a computer. But it might be a nice solution for e.g. single-board functional models of vintage computers, an Enigma model, or a small "travel terminal" when combined with an onboard LCD.Has this been done before? I could not find any open source projects, only a few commercial demos which apparently did not go anywhere.Also, do you think there is any chance to read this via matrix scanning, or would every key need its own input on a suitable amplifier/thresholding chip? I am leaning towards the latter, assuming that the readout electronics would need to sense small changes vs. a baseline they determine after power-up -- that would conflict with a multiplexed/scanned input.Finally, any particular recommendations for readout ICs? Should work well and reasonably fast, and remain affordable when you need about 50 inputs in total...

author: pcprogrammer
author_rank: Super Contributor
timestamp: October 27, 2022, 04:04:18 pm
content: Capacitive touch screens use a scanning matrix, so why not a keyboard like what you have in mind. But don't ask me for schematics because I don't have any, and it is out of my league.

author: MK14
author_rank: Super Contributor
timestamp: October 27, 2022, 04:16:19 pm
content: Here are details of how a 16 channel touch PCB keyboard, is done. Along with the (apparently) low cost IC which does the work. Since the complete module, can be had for £5.99, and maybe less.https://www.tontek.com.tw/uploads/product/106/TTP229-LSF_V1.0_EN.pdfFromhttps://www.instructables.com/Touch-Keypad/

author: ebastler
author_rank: Super Contributor
timestamp: October 27, 2022, 05:54:36 pm
content: Thank you both!The TTP229 looks good. Not for matrixed connections, but they are cheap enough, and three of them should be enough for a basic "vintage" keyboard. (And four for a more complete layout.)I struggle with the datasheet a bit. Could not figure out whether the TTP29 sends make and break codes, or has some other way to indicate how long each key is held? That would be good for proper shift and control keys. Probably worth just buying some and giving this a try.The chip does not seem to be available from the big distributors, but I found a 10-pack on AliExpress for 8.80€. I would feel more comfortable if I had found more than one vendor offering them though... (Yes, it does not help that I am in Germany. I believe AliExpress only shows me vendors who have already found a way to deal with the new European packaging recycling requirements, which Germany apparently enforces as one of the first countries in Europe. Grmpf...)Is anybody aware of a more "mainstream" touch detector IC?Edit: I had searched for the TTP229-LSF. Turns out that there is also a -BSF version which is much more common on AliExpress. It is also listed (but out of stock) at LCSC. I have not figured out the difference between the -LSF and -BSF types yet, but that makes me feel a bit better about availability already.

author: MK14
author_rank: Super Contributor
timestamp: October 27, 2022, 06:02:26 pm
content: Quote from: ebastler on October 27, 2022, 05:54:36 pmFeel free to fill in the parameters that you want, but there seem to be quite a variety.https://www.digikey.com/en/products/filter/interface/sensor-capacitive-touch/560

author: ebastler
author_rank: Super Contributor
timestamp: October 27, 2022, 06:17:40 pm
content: Thank you again! The search gets narrowed down quickly if I filter for active parts and chips meant to read buttons (rather than proximity or sliders), and 16 or more of them per chip. Six hits, three in stock:IS31SE5117 is similar to the TTP229 you found earlier, 16 inputs to be wired to one capacitive pad each:https://www.lumissil.com/assets/pdf/core/IS31SE5117_DS.pdfIQS525 and IQS550 are impressive but also a bit intimidating. Meant for touchscreen or touchpad control with 3584 x 2304 max resolution. They interpolate finger position on a relatively coarse grid of electrodes. Multi-touch, up to 5 fingers. You could potentially map a keyboard layout to it, but would have to do more work in software. But then it's only one chip for a full keyboard, available via large distributors, and affordable at 2.50 to 3.20€. I have more reading to do in that datasheet...https://www.azoteq.com/images/stories/pdf/iqs5xx-b000_trackpad_datasheet.pdf

author: pcprogrammer
author_rank: Super Contributor
timestamp: October 27, 2022, 06:35:49 pm
content: Just an idea, don't know if it can work, but how about using a microcontroller with a multi channel ADC in it.Output for instance 100KHz bursts on the scan row lines with the aid of DMA. (Lets say 8 scan lines) and then use simple low pass filters on the scan columns and read these with the ADC. (For instance 1MSa/s conversion like STM32 devices can do)With 200us bursts you still have a good scan rate and might be able to detect key presses. You are then also free to do with prolonged key presses what you like, because it is all software.

author: MK14
author_rank: Super Contributor
timestamp: October 27, 2022, 06:40:31 pm
content: Quote from: pcprogrammer on October 27, 2022, 06:35:49 pmA number of them (MCUs), have got built in CAPsense inputs. (Names vary, I think, CAPsense was just a similar example).But I didn't mention it, because, it is so hard to get specific MCUs, in stock these days, and the prices are so high (relatively speaking).(From memory), some can have quite a few, such as 47 individual CAPsense pins.EDIT Example/Information:https://www.infineon.com/dgdl/Infineon-AN85951_PSoC_4_and_PSoC_6_MCU_CapSense_Design_Guide-ApplicationNotes-v27_00-EN.pdf?fileId=8ac78c8c7cdc391c017d0723535d4661https://www.electronicdesign.com/technologies/dev-tools/article/21800818/smart-capacitivesensing-design-with-8bit-mcus

author: pcprogrammer
author_rank: Super Contributor
timestamp: October 27, 2022, 06:44:17 pm
content: Yes you are right. I forgot about those. But indeed hard to get MCU's. Hopefully the end of the tunnel is nearby. A friend of mine said that the numbers of available STM32 boards on Aliexpress are rising and the prices are going down again. Have not looked myself.

author: ebastler
author_rank: Super Contributor
timestamp: October 27, 2022, 06:50:34 pm
content: Right -- I had come across capacitive inputs as a peripheral item on MCUs, but forgotten about them too. That's another promising approach, since whatever I want to build around the keyboard would require an MCU anyway. More datasheet reading ahead...

author: MK14
author_rank: Super Contributor
timestamp: October 27, 2022, 06:54:10 pm
content: Quote from: ebastler on October 27, 2022, 06:50:34 pmAlthough I've often come across it (too). I usually skip any such parts of the MCU datasheet, unless I am specifically interested in doing that.Also, significant care, may be needed to get the PCB touch switch shape/design right. Especially after the first spin of the PCB. My understanding (hunch or gut-feeling), is it is quite tricky.

author: MK14
author_rank: Super Contributor
timestamp: October 27, 2022, 07:09:00 pm
content: Quote from: ebastler on October 27, 2022, 06:50:34 pmHaving a quick look at all the information guides, Microchip have about designing them and stuff.https://www.microchip.com/en-us/products/touch-and-gesture/capacitive-touch-solutions-for-buttons-sliders-wheels-and-proximity/microcontrollers-with-integrated-capacitive-touch-module#And their apparent hint(s), about using dedicated chip(s) to do it. Makes me wonder, if it involves a lot of design effort, to get good results. Which might only be worthwhile, for significant production projects, rather than hobby or quick one-off projects.That's another reason why I was mentioning dedicated chips to do it, I think.

author: ebastler
author_rank: Super Contributor
timestamp: October 27, 2022, 07:30:45 pm
content: Yes, I was looking at the same Microchip page. A bit annoying that their parametric search seems quite limited (or I did not find the right one); I could only get a column which shows whether the MCU has a touch controller at all, but not the number of touch-enable inputs.Regarding their ready-made dedicated chips, my understanding is that these would mainly save you from the programming effort, but you would still need to deal with PCB layout. Not sure how complex the programming is; maybe one has to deal with discarding spurious signals or crosstalk? I did not get that far yet.

author: AndyBeez
author_rank: Frequent Contributor
timestamp: October 27, 2022, 07:31:44 pm
content: Is your concept restricted to using a printed circuit board, FR4 I assume? You can fabricate capacitive tracks onto a flexible PCB, or even onto a coloured transparent acrylic sheet. A flexible PCB gives you a novel roll up keyboard. However, print onto a cardboard substrate and you'll have a (partially) recyclable keyboard.So how big is the PCB, what surface finishes will it have and, how much per unit will it cost? Any LEDs for caps and num locks? And what is the keyboard layout: British, American, German, Spanish, French, Greek.... Windows, Linux, Mac, agnostic...?

author: magic
author_rank: Super Contributor
timestamp: October 27, 2022, 07:36:52 pm
content: IBM Model F keyboards used matrix layout capacitive sensing on PCB with full N-key rollover using 1980's microcontrollers.

author: MK14
author_rank: Super Contributor
timestamp: October 27, 2022, 07:37:27 pm
content: Quote from: ebastler on October 27, 2022, 07:30:45 pmThis seems to confirm, that some of them are difficult and time-consuming to implement.https://www.microchip.com/forums/m1009566.aspxI think someone who has already created stuff with similar cap sensing keyboards, would know more about it.I think there are libraries/similar (probably free), to help. Which the suppliers can offer. I've come across them, but never really looked into them, as I didn't need that feature.

author: tooki
author_rank: Super Contributor
timestamp: October 27, 2022, 07:45:00 pm
content: Quote from: ebastler on October 27, 2022, 03:51:32 pmI suspect the reason there aren’t any is because it’s not a particularly compelling thing to do. A keyboard size PCB is more expensive than a cheap USB keyboard. So you’d be spending more to produce something significantly inferior.

author: ebastler
author_rank: Super Contributor
timestamp: October 27, 2022, 07:46:02 pm
content: Quote from: AndyBeez on October 27, 2022, 07:31:44 pmI have not settled on specs yet, and not even on an application. Had mentioned a few ideas in the initial post, which would all have relatively basic keyboards -- ASCII or Baudot teletype-style or similar. Maybe some status LEDs, which could be placed on the top or bottom (reverse LEDs) of the PCB.The general idea would be to have the keyboard share the PCB with whatever logic and display the gadget needs. Which would be the excuse for using the capacitive right-on-the-PCB keyboard, because as a keyboard it will probably not be too satisfying to use...I like the idea of an Enigma model as a first application. Only 26 keys, and the original keyboard had an awkward feel, so expectations on the capacitive one would not be high.

author: ebastler
author_rank: Super Contributor
timestamp: October 27, 2022, 07:48:49 pm
content: Quote from: tooki on October 27, 2022, 07:45:00 pmSure, as a stand-alone keyboard this would not make much sense. As mentioned in the first post, the idea would be to use this in single-board gadgets, where I like the idea of a minimalistic "just the one PCB" approach:Quote

author: MK14
author_rank: Super Contributor
timestamp: October 27, 2022, 08:08:52 pm
content: I knew I'd seen it. But couldn't remember which MCU it was. I suspect, you should be able to get hold of this one. (AtMega2560).Up to 64 channels, built in.https://ww1.microchip.com/downloads/en/devicedoc/atmel-2549-8-bit-avr-microcontroller-atmega640-1280-1281-2560-2561_datasheet.pdfQuote

author: tooki
author_rank: Super Contributor
timestamp: October 27, 2022, 11:18:51 pm
content: For those who don’t know, that’s the chip used in the Arduino Mega 2560, which exposes 54 GPIOs. So that’d be an easy and quick way to test that chip.

author: ebastler
author_rank: Super Contributor
timestamp: October 28, 2022, 06:26:38 am
content: Thank you both, MK14 and tooki. This looks like a friendly way to start and explore capacitive touch sensors. Atmel/Microchip provide a "QTouch" library and application notes on designing the electrodes for buttons, sliders etc.https://www.mouser.com/pdfDocs/QTouch_QTAN0079.pdfhttp://ww1.microchip.com/downloads/en/appnotes/atmel-42094-qtouch-schematic-and-layout-checklist_applicationnote_at02259.pdfEdit: Of course, the bare MCUs (ATmega 640/1280/2560) are out of stock everywhere, with 1-year lead times or so... I'll take a look at alternatives, although other MCU series are likely to suffer from the same supply bottlenecks.While everything is out of stock at Mouser and TME, my go-to distributors, Digikey surprisingly has 50000 ATmega2560 on the shelf. Painfully expensive, but still reassuring.

author: Nominal Animal
author_rank: Super Contributor
timestamp: October 28, 2022, 02:24:22 pm
content: One of my forever projects is a full-size projected capacitive keyboard on glass or transparent thermoplastic sandwich with indium tin oxide electrodes.(I.e., a fully transparent keyboard. A trinket, just like some people who love to wear a Rolex watch.)Initially, I was hoping to useNXP MPR121chips, which are essentially 12-channel capacitance-to-digital converters, with input range from 10pF to 2000pF with a 10-bit ADC. Four chips can be connected to the same I²C bus (address 5A,5B,5C, or 5D, depending on where the ADDR selection pin is connected to).I do not believe that a simple capacitance limit works well for touch detection. I was hoping to use the proximity data –– with 1 cm² electrodes, MPR121 can easily detect a finger at about 10mm distance –– and velocity data prior to the touch/limit event to detect a keypress. (I personally tend to have my fingers rest on the keyboard, so I'd want a "keypress" to really be a bounce away and back to the surface, tracked all the time, as opposed to just a "new" finger hitting the surface.)Unfortunately, MPR121 isn't fast enough when it is precise enough, or precise enough when it is fast enough, for this: too much noise. It might be, with good electrode design, but me no EE.So, what I really want now, is something like Apple Magic Trackpad, a projected capacitive proximity sensor, but in keyboard size and aspect ratio, essentially producing a high-resolution grid of capacitance values. At 100+ Hz, the velocity data would suffice for my esoteric purposes.Anyway, if you end up doing a capacitive keyboard, with individual sensors for each key, I recommend you look at the hexagonal electrode patterns: it fits the QWERTY keyboard layouts very well, if you orient the hexagons with peaks at top and bottom, so left and right sides are vertical.

author: wilhe_jo
author_rank: Regular Contributor
timestamp: October 28, 2022, 02:41:25 pm
content: There's the STM8TL series... the STM8TL53C4 supports up to 300 cap-keys.Programming can be done with SDCC. Documentation isn't that great, but you find enough helpful information out there.73

author: ebastler
author_rank: Super Contributor
timestamp: October 29, 2022, 04:39:51 am
content: Quote from: wilhe_jo on October 28, 2022, 02:41:25 pmThank you, these look promising and are much cheaper than the ATMega. Can drive a matrix of touch sensors; the maximum of 300 is via 15*20 transmitters and receivers. Unfortunately the STM8TL53C4 version (in the lareger 48-pin package) is unobtainable at this time, and is apparently uncommon even in normal times -- it is not classified as "normally in stock" at Mouser or Digikey.Quote from: Nominal Animal on October 28, 2022, 02:24:22 pmThat is a cool idea.Thanks for the info on the MPR121. I had come across it too and thought it looked promising -- although you would need quite a few for a full-size keyboard. But if the MPR121 as a dedicated sensor IC still implies speed/precision readeoffs, I might as well focus on the touch-enabled-MCU approach for my first attempt.I would hope that sensitivity (and hence maximizing the electrode surface) is not critical for a PCB-only keyboard. Since I will only have a thin layer of soldermask and siklscreen on top of the electrodes, I would hope for a pretty strong capacitance change upon touch?I think I will go forward with the Enigma model as my first application. No n-key-rollover in the original, and one has to hold each key for a moment to read the indicator lamp -- so this should be a relatively easy one to get right. And then I can try to make it faster, e.g. for a mini terminal.

author: amyk
author_rank: Super Contributor
timestamp: October 29, 2022, 05:30:45 am
content: Note that most if not all of the specialty cap-sense ICs are really just some normal MCU (8051 is common) running some preloaded firmware.

author: Nominal Animal
author_rank: Super Contributor
timestamp: October 29, 2022, 11:04:30 am
content: Quote from: ebastler on October 29, 2022, 04:39:51 amOnly because I need the high sample rate to be able to calculate a reliable velocity/acceleration values. For actual touch, i.e. when the sensor capacitance crosses a set limit, it has additional features that make it extremely suitable for those. I do believe that MPR121 would work perfectly in a touch keyboard, where a finger touching the PCB surface is equivalent to pressing a key there, at least if you use one pin per key (for infinite rollover). It even has touch and release thresholds you can program for each input separately, so you can trivially compensate for different key electrode shapes if you want.The Adafruit break-out board is easily available (including at Mouser and Digikey for under 8€), so you might wish to get one to play with. Copper tape works quite well for electrode experimentation, but you can do with even conductive ink.LCSC does have MPR121Q in QFN-20 in stock, for $2 apiece in lots of ten, so they're not exactly cheap; and it needs two regulated voltages (3.3V and 1.8V).Quote from: ebastler on October 29, 2022, 04:39:51 amFor sure, even a quarter-inch thick glass panel in front won't be a problem. It acts as a dielectric, so all you need to do is to change the electrode shape or spacing to compensate.NXPAN3863(originally from Freescale) contains a lot of useful information on electrode patterns and their effects, and the logic behind.As others have mentioned, one does not need a dedicated chip for this, especially if one uses a matrix approach. Each key is then at the intersection of one row electrode and one column electrode. You measure the capacitance by treating each intersection as a capacitor, and measuring how long it takes for the capacitors to charge or discharge (a set of capacitors at a time, of course). As seen from MPR121, typical capacitances measured are in the 10pF - 10nF range.

author: ebastler
author_rank: Super Contributor
timestamp: November 03, 2022, 07:54:34 am
content: A quick update on Atmel MCU options, after I took a closer look. Atmel has created a bit of a mess...There is a "new QTouch library", the use of which is recommended for new designs. This relies on the dedicated Peripheral Touch Controller (PTC) available in some of their MCUs. Atmel provide an online project builder athttps://start.atmel.com/which, once you select "QTouch" in the middleware menu, shows the available microcontrollers: many ATSAMs with ARM core, only a few of the older AVRs. For my Enigma idea I need an MCU with a larger pin count (> 64), and unfortunately none of these is available much sooner than a year from now.There is also an older QTouch library, which supports non-PTC microcontrollers (not recommended for new designs). A "QTouch Project Builder" is available as an add-on in Microchip Studio. It lets you select the number of buttons and sliders you want, then suggests a list of supported MCUs -- which is pretty short, containing some ATmegas and ATXmegas. Again, these MCUs are currently unavailable.The ATmega2560 mentioned earlier in this thread and its relatives arenotsupported in either approach, even though their datasheet claims QTouch support. That information must be outdated; maybe some earlier QTouch library did support these? I guess I am done with Atmel for this project and will look for other MCUs -- although the supply situation at STM and NXP does not look much better...

author: MK14
author_rank: Super Contributor
timestamp: November 03, 2022, 04:44:17 pm
content: There are some, example follows:https://www.digikey.co.uk/en/products/detail/microchip-technology/ATSAMD51P19A-AU/7390336https://ww1.microchip.com/downloads/en/DeviceDoc/SAM_D5x_E5x_Family_Data_Sheet_DS60001507G.pdfQuoteWith a massive, 2 (claimed) available in stock.Seems to have 32 capacitive touch channels or 256 mutually capacitive ones (whatever those are?).I think there are quite a few MCUs, which can do it. It just seems the component/chip shortages, are making the combined requirements, rather tricky, at the moment.

author: tooki
author_rank: Super Contributor
timestamp: November 03, 2022, 05:41:55 pm
content: Quote from: MK14 on November 03, 2022, 04:44:17 pmWiki:QuoteAnd in the section on projected capacitive touch sensing:Quote

author: ebastler
author_rank: Super Contributor
timestamp: November 03, 2022, 06:55:29 pm
content: Thanks, tooki -- you beat me to it with the explanation on self vs. mutual capacitance sensors. One more addition:From the datasheets and layout guides I have read over the past days, the consensus seems to be that mutual capacitance sensors are more forgiving regarding the PCB layout. You can have longer traces between MCU and touch sensors, and can place traces, active components or ground layers on the back side of the PCB behind the sensors. Makes sense, since mutual capacitance sensors detect a capacitance change between the two electrodes at a row/column crossing, and do not "see" the capacitance of traces and electrodes vs. their environment.

author: MK14
author_rank: Super Contributor
timestamp: November 03, 2022, 07:01:19 pm
content: Quote from: ebastler on November 03, 2022, 06:55:29 pmThanks, that is very interesting.The ESP-S3's, which are often available and reasonably priced (or at least they have been, with some of the ESP32 range). Have 14 capacitance sensing pins.I wonder if you can repurpose them, and use them as a 7 x 7 = 49 matrix (obviously other matrix layouts possible), mutual capacitance sensing keyboard?ESP32's documentation and/or libraries, are not always the best though.ESP32's tend to be relatively low pin count, you mentioned wanted lots of pins. But I think the latest ones,have something like 57 GPIO pins, available, on the best version/variant of the ESP32-S3. I.e. There are a number of slightly/partly different ESP32-S3's.EDIT: No, my mistake, apparently 45 GPIO pins, and maybe the 57 was the total pin count. Datasheet:https://www.espressif.com/sites/default/files/documentation/esp32-s3_technical_reference_manual_en.pdf#iomuxgpio

author: ebastler
author_rank: Super Contributor
timestamp: November 03, 2022, 07:25:58 pm
content: Quote from: MK14 on November 03, 2022, 07:01:19 pmYes, in principle that's how it works. However, at least for the Atmel MCUs (which I reviewed more closely), the matrix needspairsof pins for each of the colums, plus one extra pin for the whole arrangement. So 5*4 = 20 sensors is the most you could address with 5 + (4+4) + 1 = 14 pins.For my "Enigma touch" idea, the pin count adds up quickly: Besides the 26 keyboard keys, one needs four capacitive sliders (to model the rotor wheels), 3-4 further touch buttons for mode settings, a lamp array, and the 26-position plugboard. For the Atmel touch sensor architecture that adds up to approx. 70 I/Os, limiting the choice to larger MCU packages (LQFP-100 or so) if I want to get by with just the one chip.

author: MK14
author_rank: Super Contributor
timestamp: November 03, 2022, 07:50:05 pm
content: Quote from: ebastler on November 03, 2022, 07:25:58 pmDigikey seem to have around 90 of these, 144 pin TQFP's, PIC32MZ's.https://www.digikey.co.uk/en/products/detail/microchip-technology/PIC32MZ0512EFF144-I-PH/5323497The datasheet, confusingly doesn't mention about touch sensing (as far as I can see), at the top, in the features section. But it does have lots of pins/I/O, including 48 analogue input pins (ADC Channels), which it does seem to mention about using them for capacitive touch sensing, lower down, in the very long datasheet.They are rather pricey, at $14.78, one-off price.I stopped looking, but evener high pin count versions of that chip series, I think exist, and MIGHT be available.

author: MK14
author_rank: Super Contributor
timestamp: November 06, 2022, 04:21:31 pm
content: Quote from: ebastler on November 03, 2022, 07:25:58 pmI had a somewhat quick check through on this. It does seem to be 49 (Matrix) Keys, for some of the ESP32 devices, such as the ESP32-S2 and ESP32-S3. A possible reason for this confusion, is that in some schemes, some of the pins, are actually GPIO pins, not ADC input pins as such.Just in case, I was wrong on this. I checked with the ESP32's manafacture's website (Espressif), and this is what they say:QuoteWebpage in question:https://docs.espressif.com/projects/esp-idf/en/latest/esp32s2/api-reference/peripherals/touch_element.htmlIt also seems the ATMEGA2560 with their library (I also checked this), but one of the options (their latest thing, 'the designer/creator') is not available. But that doesn't stop you from using their libraries. If I understand things correctly.Also, alternative, possibly better Atmel (now Microchip), parts seem to be in stock, in Digikey.But I agree, you may have to use an older version of their software/packages/libraries stuff.N.B. I'm definitely NOT sure about the ATMEL stuff. If you want to use it. Please DOUBLE CHECK!!!.I'm not being definitive/exact and could easily be WRONG. Because ATMEL were taken over, by Microchip, so I don't really pay much attention to ATMEL, in general. Also the parts shortage, means some of their stuff is very difficult to obtain.Or to put it into other words, I'd have to spend serious amounts of time reading their datasheets, and building their hardware. But it's NOT my project, so I don't plan/intend to do it. So, I'm only indicating a possibility, as regards this thread and Atmel.Given the apparently wide availability of the ESP32's, both as components (good prices, from what I've seen) and as keenly priced development boards. Also, that they are rather modern parts, with somewhat fast CPUs, for the price. I'd be tempted, to give the ESP32's, consideration.The documentation, is not always, the best. But if you think the alternative(s) are way over priced and/or unavailable for a claimed 12 months waiting time. In my book, that is a good excuse for looking at the ESP32's.In summary, I'm NOT sure you need as many CPU/MCU pins, as you seem to be saying. (I'm assuming here, that 49 keys, is enough to make all your keyswitches and stuff).If it isn't, you could still have a pair of ESP32's.Don't feel pressured, into using ESP32's though. I'm just trying to level the playing field. There are many MCU's which can do this.

author: ebastler
author_rank: Super Contributor
timestamp: November 06, 2022, 06:10:14 pm
content: Many thanks for looking into this, MK14!The ESP32s do look tempting indeed -- seems like they have well-developed touch sensing, are cost-effective, and still reasonably available. My only reason not to use them in my current project is the need for many pins, as mentioned above.I have given up on Atmel as well as Microtech (PICs). With both of them, it seems that capacitivce touch was a thing before 2010 or so, and then they stopped maintaining it. Datasheets mention the hardware capability, but their QTouch or mTouch tools can't be trusted to support it. The ATmega2560 should be supported if you don't use the configuration tool, but then their official library example code required an outdated version of the ASF framework which is nowhere to be found... While I have used the ATtiny and ATMega family a lot, I can't be bothered with documentation and software archeology... Microchip's documentation seems poorer than Atmels in general (even back when it was up to date).Renesas looks like a strong contender -- well-developed touch functionality, decent and up-to-date documentation. But their MCUs seem geared towards professional customers; I could not find many project examples on the 'net, and many processor types are apparently not stocked by Mouser even in normal times. And I did not feel like learning yet another new IDE...For the moment I have settled on an STM32 -- after finding one which is actually available. STM has not the greatest touch support: No proper mutual capacitance sensing; keyboard matrices are possible, but they measure the capacitance of the row and column lines independently (capacitance against the environment). So one probably does not get the robustness improvement, and they can't do multi-touch. But I have used STM32 processors before and know my way around their IDE; and their documentation seems current and quite decent.If and when my "Enigma touch" actually becomes reality, I'll post an update here. I have started to play with component layout and front panel design, but getting the touch hardware and software to work will defnínitely take a while. Maybe a project for the Christmas break?

author: tooki
author_rank: Super Contributor
timestamp: November 06, 2022, 06:16:08 pm
content: You do realize that Atmel doesn't exist anymore, since it merged into Microchip?

author: MK14
author_rank: Super Contributor
timestamp: November 06, 2022, 06:45:08 pm
content: Quote from: ebastler on November 06, 2022, 06:10:14 pmThanks for the nice, detailed, clear and very quick response.That sounds very sensible. The STM32's, are just (in some cases), suffering from the same component shortages, as other MCUs (give or take a bit).We are in strange times (component shortage wise). Despite, having an involvement with electronics, for rather a long time. I've never seen it like this. It reminds me of (reports), about World War 2, where all sorts of items were (understandably), in short supply or unavailable.You hadn't seemed to post in the thread for a while, so I was somewhat confused as to what had happened.I was always somewhat fascinated by touch panels. With the early/original CMOS logic devices (4000 series), you just needed to forget to connect an input, to accidentally create a touch switch effect.The complication (my own issue), that I have with some of the modern MCUs. Is they can have data manuals/guides, which can total 15,000 pages (very, very approximate number indeed). Which (unlike the old days, when the MCU databook, was something you could physically obtain, and potentially read its 250..500+ or so (estimated) pages, over a quiet weekend, and then (feel like you) know almost everything there is about that MCU.Also the 8 bit (original) MCUs, were so much easier to use, in days of old.Things can get rather scary (data sheet/book) wise, these days. My mind still gets blown by the functionality, of the very high end MCUs these days. Even things like Ethernet, graphics, full cryptographic systems, etc, can be built in. Probably more functionality and computing power, than a typical standard PC, from perhaps 30 years ago (very approximately).It seems to boil down to learning new skills, whereby you have to accept, reading the entire range of data books/sheets and app notes, on a particular (high end), MCU, is not especially practicable. So, limiting oneself, to searching or seeking out the relevant sections, is what seems to be best.You seem just right as regards Renesas.Quote from: tooki on November 06, 2022, 06:16:08 pmYes, I know. But some of their chips, such as the Arduino ones, still seem quite popular, and have quite a lot of projects and information available, for them.

author: ebastler
author_rank: Super Contributor
timestamp: November 06, 2022, 06:50:19 pm
content: Quote from: tooki on November 06, 2022, 06:16:08 pmYes, sure. But Microchip continues to make the former Atmel product lines in parallel with their PICs (for the time being). To avoid confusion between the product lines, I tend to still refer to the AVRs as "Atmel microcontrollers".Microchip themselves are a bit inconsistent in their use of the brand: "Atmel Studio" is now "Microchip Studio", but many of the data sheets and software components still go by the Atmel name.

author: tooki
author_rank: Super Contributor
timestamp: November 06, 2022, 06:52:05 pm
content: Quote from: MK14 on November 06, 2022, 06:45:08 pmTheproductsstill exist, it's the company that doesn't. They're now Microchip.

author: ebastler
author_rank: Super Contributor
timestamp: December 11, 2022, 01:28:04 pm
content: A quick follow-up here. A week ago I have received my PCBs for a design using capacitive touch keys and sliders, built around the STM32F373. (A part which is somewhat available, has the required number of I/Os, and is from a manufacturer who's IDE I have used before, with limited grinding of teeth.)Unfortunately STM's implementation -- hardware, documentation, TSL touch sensing library, and HAL code generator -- turns out to be buggy as hell. A few finds from the past week:Three touch inputs which the datasheet declares as "limited sensitivity, recommend you don't use them" are simply not supported at all by the TSL touch library.Two further inputs for which the datasheet does not mentionanyrestrictions are not supported either.Under unclear circumstances the STM32Cube code generator creates a total mess of configuration code, e.g. by duplicating some input channel declarations and dropping others. Deleting all touch sensor assignments in the GUI and starting over seems the only way to resolve this.The raw data generated by the individual capacitive slider electrodes are in the range of 1000 to 6000 counts. But the GUI only lets you select a threshold of 0..255 to detect active sensors. Clearly a scaling error in the slider implementation; the touch buttons' raw data scale properly.There is a dedicated app note explaining how to determine correction factors for the sliders, to balance out asymmetries in the response of their individual electrodes. But you can't enter these factors into the library's configuration data, since the code generator will insist on overwriting them with the default values of 1.0 every time you run it.No matter whether raw data are corrected or not, the touch position calculated for the linear sliders is essentially a random number.Since I have designed the present board around the STM32, I will try to muddle through for this project. But unless some major revelations occur, I don't think STM32 will be my platform of choice if I ever revisit capacitive touch...