 So, after a lovely holiday in Greece, I have got back home and I've been working on my keyboard for a while. It's been a little bit since my last update, so I shall talk about where I've got so far because it's quite interesting. Now, I have been working on the firmware and I deciphered some of the keyboard matrix and I've also managed to get the LCD intermittently working and displaying text, but it's only like 15 characters. So, if for debugging purposes I have set up a USB serial connection from the microcontroller to a PC and it is dumping debug information and I'll show you what we've got. So, what's here is a representation of the keyboard matrix. It's got 17 connections horizontally and 17 vertically and when I press a key it tells you that if it energizes line B it sees that line F is also energised and of course vice versa. So, depending which key I press you get different combinations of letters. All good so far. There's a few little surprises. For example, shift energizes a whole row. This is actually expected. It means that the shift key is not part of the keyboard matrix. Instead, when you press shift it just provides power to line H and H does not use anywhere else on the keyboard. This means that you can use shift with any other combination of keys and not upset the matrix. The other little surprise is the caps lock key which, as I discovered last time, is handled by logic on the board, but it doesn't have its own caps lock line. Instead it generates a shift signal. So, it's exactly the same from the microcontroller's point of view as pressing the shift key, which is not really what I want for a PC keyboard. So, I'm actually going to have to rewire the caps lock and shift keys to farm them out to separate signals on the microcontroller board, which is absolutely fine. I mean, I have lots of spare pins. It's easy enough. Now, the other surprising thing is, if you notice, whenever line P is energized, it gets a signal on line O, and that's odd. That shouldn't be happening. And if you combine that with some other keys such as six here, this is doing very odd things. Now, I see that when I press the six key, when row I is energized, O is energized and vice versa, but we also get spurious signals on other combinations. And this strange thing here disappears. Now, I think the other keys do similar odd things. In fact, six and eight both generate the same. No, they don't. Sorry, I'm getting my I and my J mixed up. Anyway, what I believe is happening here is that there's a short or other electrical misconnection for row P and row O. And this may be my fault or it may be some weird feature of the board. So I'm actually going to disassemble it and do a bit of tracing and see if I can find out what's going on. So first thing is to like unplug it and take the lid off. So pull that and let's stick the tablet somewhere out of the way. So it's not actually a tablet. It's a foldable Chromebook, which I love dearly and I've used for years. And let's take the bottom off this thing. So Phillips screws screwdriver. Yeah. And just remembering I actually have this is even got a bit in it. This time I actually remembered before I had worked on half the screws. Also, some of the keys are a bit dodgy. And I suspect it could do with a bit of a clean. As I discovered last time, this is the circuitry for handling the shift, the shift lock. I don't know why it's so complicated. At some point I'm going to remove all of that. There are a lot of screws. Okay, so this off. Let's try and lift this up. How about I unplug the LCD module first. Unplugged and replugged this thing so often. Actually, a little aside on the LCD module, I have modified it a bit. The way these LCDs work is you have either four or eight data lines running to the microcontroller. That's these eight tracks here, plus some signal lines. And one of the signal lines is pulsed as a clock every time you send the byte to or from the microcontroller. But for some reason on this thing, there was a resistor capacitor circuit in line with it, which made sending pulses rather odd. So I've chopped all that out. So now the signal is just sent directly from the microcontroller, this microcontroller, to this microcontroller, and it works much better. But it's still not always starting up properly when I provide power, which is kind of weird. Still working on that one. Have I done all the screws? Yep. Okay, just a bit sticky. Right. So let's put the lovely and clicky keyboard module aside. Plug in. Okay, it's now working. So here we have the bare keyboard with no actual keys. And here we have a nice conductive metal drill bit. And if I short a couple of these things out, it really worked very well. But you can see that we get a key press. Now we see that the O line is still there. The mysterious O signal. And yes, if I press the six key, we still get the weird thing. So what we need is actually I was going to get my volt meter out. But what we need right now is my new toy, which I need to find. So my new toy, which was a little fiddly to set up due to need to find something to power it, is this logic probe. And what this will do is I touch this to something touches my finger, although it's not supposed to work. And it will tell me whether it sees a high voltage, a low voltage, or pulses. So if we touch it one of these, we see pulses, which we expect because the microcontroller is probing the keyboard matrix. If we touch it to here, we see a low voltage. If we touch it to here, we see a high voltage. And we expect this because these are the power fees to the LCD. So let us work along here and see if we can see so anything odd going on. So expect this to be logic one. That's the power line. We see data, data, data, data. Yeah, just a poor signal. Oh, logic zero. That's one of the LCD lines. So logic one. Yep, we don't really expect to see activity on those. Let's try the top. This is ground, data, data. And this is getting yeah, just shorting two pins, which is why I got activity here, data, and the LCD lines. So I don't see any obviously stuck pins, which actually matches what we see on the keyboard matrix. We only get this spurious line when P shows up. I mean, there's something wrong with the letter six. That's one, two, three, four, five, six, this one. We see data of both sides here, to be shortened together, stuff happening. So what we're getting is that when P is energized, O is energized, and I don't know why. Now I need to figure out which is line P because of course all my mappings arbitrary. It's probably one of these two. Yeah, this is going to be more complicated than I thought because the, yeah, I actually do not believe the logic probe is going to help here. What I actually need to do is to disconnect the power, statically determine which line P is, which I've got all the tables written down to do so, and then do manual continuity tests. Okay, I'm going to have to go and do that. Damn, I was really hoping to find a really useful use for this. I haven't had a chance to use it yet. Okay, time for the paperwork. So here is my pin mapping, and I have written down here the microcontroller pin, the letter code used by my firmware, and I should add these have nothing to do with the letters on the keys. They're just arbitrary labels, which I could have numbered but didn't because I had 17 and I wanted a single character each. And this column, which I've just grouped out with the multimeter, is the pins here. So that we know that when line O is energized, we get a signal on P, or possibly the other way around, I have kind of forgotten, but let's try it both ways. So we know that's pin 15 and 17. So they are both odd. So one, three, five, seven, nine, 11, 13, 15 and 17. Is this interesting there next to each other? Not getting a thing, which is interesting. Oh, I've had a thought. 15 and 17, 15, four and 15, three. See, these are on the side of the board down here where there are capacitors. I'm pretty sure that the capacitors are not actually hooked up to anything. I mean, I'm pretty sure that the capacitors are not hooked up to those pins. We deliberately skipped some pins. But if those capacitors are actually present, then when the microcontroller probes the board, when the microcontroller probes one line, that could charge the capacitor. And then when it looks at the next line, it sees it energized because the capacitor is still producing power. Yes, how do I test that? I think I use another of my toys. This one I have actually used and I know it works. It's USB-PROD, so I need to find a cable. Right, this is a component tester. What it does is it pings the component you connect up to it and it can then identify what the component is. I need a longer USB cable. So if I connect it up to a, for example, a capacitor, I don't have one at hand, then I push the button and it looks at the component and it will tell me it's a capacitor and what's more it will tell me the capacitance. So yeah, that's trying to test something. It has spotted a capacitor of peculiar value, probably because it's not hooked up to anything. So I do that. It says zero ohm resistor. So 15 and 17, eh? 1, 3, 5, 7, 9, 11, 13, 15, 17. The question is can these hooks actually hold? Ah, curse has lost count. 1, 3, 5, 7, 9, 11, 13, 15. Because I need another hand to press the button. Now it's too smooth. You can't see if I can just use multiple hands. It says 800 picofarad capacitor and it doesn't know what that is. I think this is just spurious noise. Yeah, it's just producing random stuff. It doesn't know what it is. That's a shame. I was hoping it would be able to positively identify a capacitor on those lines. I might try connecting it to the board. It is suspicious that the two suspect lines are next to each other. 0, 1, 2, 3, 4. Yeah, it's just producing noise. Okay, well another of my choices fails me. So I'm afraid there is nothing for it but to get serious and hook it up to the oscilloscope. The trouble is that I have not found a way to fill the oscilloscope yet. So I'm actually just going to do this offline and get back with the results. The oscilloscope will let me see the actual pulse shape. So I'll see a nice square pulse on one pin and hopefully a different pulse on another. Okay, all right. I have a success or at least an answer. I'm going to do this by compositing in still photos. So if I look at this pin here you can see nice clean pulses. There's a little bit of capacitance on the drop-off but that's fine. If I look at which pin is it? This pin you see a much longer drop-off. That means there's a capacitor somewhere on that pin. Now I don't actually know whether this is the fault of the microcontroller which I know has some capacitors or the keyboard itself. I don't very much it's the keyboard because why would you put capacitors on a keyboard and cause this exact problem? So what I need to do now, oh yes this pin is 1, 3, 5, 7, 9, 11, 13, 15 which is line P in my matrix. Yes, so what's happening is that P is being energized. Why is it seeing a signal at O? I would expect it to be the other way round. You see I would expect P to be energized then it becomes de-energized and then when we scan the next row which will be Q I would then expect to see a spurious signal there. Let me do that again. 1, 3, 5, 7, 9, 11, 13, 15, 15 is O. Right, yep not line P. Yep that's exactly what I would expect. O is energized then O is de-energized then we scan P and we still see the remnants of the voltage on line O so we get our spurious signal. Yeah and I bet all the other spurious signals when we press keys were caused by the keyboard matrix causing O to be energized via another row which then causes spurious signals thereafter. Okay so line O is 15.4 so we need to figure out what 15.4 is connected to. Now I was pretty sure that was nothing. I did go and look all this up. The board says C-M-O-D which sounds like it's got something to do with the capacitive touch thing that all the onboard capacitors are for. You know what it's probably not worth it. I think I'm just going to move that pin. I've got lots of spares particularly as I actually cocked up and I attempted to skip the pins that the debugger and programmer was using and actually I missed one. So if I have the debugger plugged in to the keyboard I get spurious hits everywhere because it's energizing rows. So I think I'll just move that wire and while I'm at it I may as well move the one the debugger is using so let me use the debugger again and I'll just stick them up here. Yeah so I've still got a long row of unused pins here which will eventually be the shift keys and the cap slot key. I want both shift keys to be independent. That will involve probably cutting tracks not scary at all. Okay so short break while I go and figure out what the relevant pins are which involves reading the data sheet for the microcontroller board. Okay data sheet read yes pin 15.4 does in fact have a 2.2 microfiber capacitor attached to it and the debugger UART is attached to pins 12.7 and 12.6. In addition the three pins I skipped here because I thought they had the programmer interface on it in fact don't. The programmer interface is on some pins over here. So well done me really for all that. So I'm going to move all three wires hopefully to these three pins there. So this is going to be fiddly 15.4 is this one here. So a bit of tension on the wire a nice new soldering iron bit which is not transferring heat. Oh it sort of turns on. I'm an idiot. Yeah I pressed the switch on the soldering iron power supply but I didn't actually turn the bus on. So let's wait for that to warm up. Yeah just because the thermocouple says it's hot doesn't mean the end of the tip is hot yet. There we go come on melt melt down you there you go 15.4 and we want 12.7 and 12.6 next bit is this one. Yeah these are the built-in USB UART on the programmer board so they were being held high or low well I hope that's what the problem was but yeah there's definitely the wrong in the wrong pins. These Cypress boards are great but the documentation does kind of assume that you're working on an industrial design and not on the development board with all the built-in hardware. So actually finding what the built-in hardware is is sometimes not as obvious as it could be. Right I don't want to put those in in those holes those are the holes they came out of. I want to put them in down here. So what I'm actually solder 15.4 before it falls out. This is going to be another of one of my amazingly competent soldering joints. If you've actually been watching any of this you can probably tell why this didn't work first time. That's one of my less awful joints actually. I just hope it was in the right wire. Everything is awkward. Yeah I this entire project has so far been a catalog of errors. It's not even particularly complicated but soldering the wires onto the board on the wrong side has made things so much more complicated. There were four and three. Ah they're springy. I can't take my finger off them so I'm going to have to use back them down. Okay they are going to spring out as soon as I melt those joints again. I'm going to do this poorly. Try this as it's still on the camera so it looks like a joint. Not a very good one but it's a joint. It does not look like a joint. Yeah that's fine. Okay so we've moved 15.4 and we've moved 12.7 and 12.6. So the next thing I want to do is to beat them out and figure out where they've moved to. I know it's like 101 and 101 and one. I know it's these three pins but I want to get them in the right order. It was... I don't know where I put them in now. I just look for the wires that don't fit these three. 02 or 03 or 04. So 02 is now get 1, 3, 5, 7, 9, 11, 13, 15. Good. So what was on pin 15 which is this one is now on 0.2. 12.7 and 12.6. These are pins. These were on 14 and 16. So that will be on... Let's try what's on 03, 4, 6, 8, 10, 12, 14. 14 is now on 03. This one and that means that 16 which was on 12.6 must be on 04. But let's check it because of some old parable about donkeys. 8, 10, 12, 14, 16. Yes. Good. Right. So that is the board rewired. The next thing is to go and update the firmware and reprogram it which is also going to happen offline. And the computer says complete cock up. Yes well you can tell I do this late at night when I'm tired and not tracking terribly well because it turns out that those three pins I soldered the three wires to were not the pins that I thought the debugger was on and aren't. They were in fact the pins that I was completely correct about avoiding because these were the pins that had the capacitors on them. And the result I've just hooked it up to three capacitors loaded wires producing three tracks like this. And I'm going to have to do it again because that was just wrong. So that was awesome and a highly useful waste of time. So let's turn the soldering iron back on again. Yeah it is now 5 to 11. I want to get this done tonight. So what I'm going to do is I'm going to move the three wires and I can tell which ones they are because I have them written down on a piece of paper somewhere. Be right back. Written down on a piece of paper. 0304 and 02. And I'm going to move them to 03332 and 031 which are hopefully actually unoccupied. Fantastic. Right well at least the wires are obvious and the soldering iron is actually hot so let's just take them off. See if I keep doing this eventually the end of the wire will fatigue and snap and then I will have to strip it again and you know how much I like wire stripping. Still the main reason for recording all this apart from demonstrating to the global public just how poor just how bad I am at doing this is as a video diary of what I've actually done hardware wise. The software is easy. The software has got a version control system. I can look back and find out exactly what I did but the hardware I need a record of what's happened to my other wire should be a stray wire somewhere. What's all that happened is this is sprung back to roughly where it was so I can't see the end anymore. They actually turn out to be right next to each other on a ribbon cable. Go figure. That's actually moderately convenient. So it's these three. I hope that was those three. 0304. Yeah matches my paper. All right. So let's push them through to the other side. Now you're going to use 333231 in order. This one goes in do goodbye solder blob on the end of that wire. I hope it will go through the hole. No it won't go through the hole and this one. Okay. Solder joint time. Again not bad. Beeper time. Where are they now? So it's these three here. These three, three, two, three, one. Three, three is either 14, is 14, 16 or 15. One, three, five, seven, nine, 11, 13, 15 are these. That's actually put a decent amount of flux on the joints. So they're not necessarily making good contact. Interesting. Okay. This is two, four, six, eight, 10, 12, 14, 16. That's three, one, two, one next to it. That's the one on the other side. So that must be 15. One, three, five, seven, nine, 11, 13, 15. Yep. Which means that the remaining one is been 14, which must be one through three. Two, four, six, eight, 10, 12, 14. Yep. Okay. Right. So now once again, I have finished the board. So once again, I have written down what the new, written down what the new pin assignments are. So once again, I need to go back and reprogram the firmware. Be right back. Good news, everyone. Pin 3.2 has a capacitor on it. I cannot believe this has gone on so long. The, the data sheet for the microcontroller is desperately hard to read. There is no single list of what all the pins do. So what I'm doing is I'm actually reading the circuit diagram schematic. But again, there is no single line from the pin on the microcontroller output to where the circuitry is. It's all neatly divided up into little boxes with no linkage between them. So the only way to figure out whether a component's attached to anything is to go look at every single one of the boxes and see whether it's associated with a pin. So that's not good. It's a really lousy piece of design. So I'm going to have to move that wire. Well, there's one pin next to it, which is 3.2, that's 3.0. So I'm going to put it on there. Good grief. This is ridiculous. At least I didn't bother to turn the soldering iron off that time. Okay, it's undone. I inserted into the hole. No, I don't because there's a solder blob on the end. The wire has not seen better days. Let's try the actual hole. Yeah, there we go. There's enough tension to make it stick, solder, where you put the smoke to dissipate. That lovely smell of flux. All the carcinogens that you know are really good for you. Looks like a sensible joint. Once again, the board is finished again. You know the drill, be right back. And finally, it works. We have a nice blank keyboard matrix. And when I short out pins, we get a nice, clean pair of tracers. So, well, that was a bit of a disaster. So I'm now going to reassemble the damn thing. This is actually literally all the electronics I need to do. I now have enough to actually turn it into a functioning keyboard. And I even have the code somewhere. So all I really need to do is to map the keyboard matrix and I'm done. It would be nice to be able to identify the row lines from the column lines because it makes a slightly more efficient sampling, but it's, I really don't think it's going to be worth it. I might as well just scan the whole lot. Okay. And I'm also, I'm going to have to take this apart again to give it a proper clean. Some of the keys are dodgy, as I mentioned. The return key is a bit dodgy. Backspace a bit more. Yeah, there's actually fluff on the pads. Not going to help. I do that now, actually. Probably that's a cotton bud and just very lightly. Yeah, I think I'm going to need more than this. I don't want to have to. Yeah, and I suspect I'm actually adding more fluff. There's a few hairs. All right, well, it's actually late. So I'm not going to bother. I'm just going to put it all back together and plug it in again. Finally turn the soldering on off because I'm going to have to take it apart again anyway to deal with the shift keys. I'm actually slightly running out of pins on the board. The good news is that the shift keys being modifiers are just simple switches. So you press the key and it makes a connection from live to the pin. There is no keyboard matrix. It seems there's no scanning required. So I could actually use one of the pins with a capacitor on it, and that would not be a problem. I think I've got enough pins. I don't need to worry about this. The keyboard is used up 17. The LCD has used up eight plus three is 11. And we've had the blacklist at four for the capacitors and another two for the debug you are. So that 17 plus 11 is 28 plus the five blacklisted ones is 33. So I think the thing's got about 40 GPIO pins. So it should be okay. But this is why some keyboards use discrete counters, not counters, multiplexers so that you can send, you can wire the multiplexer up to four pins and send the binary code from zero to 16. And then the extra logic will actually take care of energizing one of the sense wires. It means you need far fewer GPIO pins on the microcontroller itself. Of course, once I'm done with the wiring and the electronic side of things, I then need to try and find a box to put it in. That'll be completely bodged together. Okay, let's put that away. And I will set it up with the computer again. Okay, so it's all hooked up. And I can press keys and you can see nice coherent pairs, all the keys. So I just need to write them down, come up with a mapping table, make sure there are no horrible, no more horrible surprises. I'm sure there will be horrible surprises. Yeah, the backspaces are feeling much better now. Shift is still on each code is another one. And my eventual, let me just make sure you can see code code is down here. Eventually, I want to use code as a modifier key. Because this has no like cursor keys or anything. I'm not going to bother with these. And the way I've done this in the past is use code as a modifier and then use WASD. But this is not a rolloverable keyboard really. So yeah. So D, the D key is B and M on the keyboard matrix. Code is B and Q. When I press them both at once, these actually connects Q and M via B. So it gets spurious key presses. So that ain't going to work. So I'm going to have to unwire code from the keyboard matrix and wire it directly up to the microcontroller as a modifier key. Yeah, repeat works, space works and relock works. I'd also kind of like at least repeat to be a modifier. Relock I will probably end up using as a compose key so that I can type international characters. But yeah, that is actually now working, which is very, very nice. So the next or it occurs to me, one thing you can do to prevent rollover issues is to wire up diodes to the keys. I suspect I'm not going to be able to do that simply because the way the key switches are not soldered to the board, they're just like printed on the PCB and then these rubber pads make contact. So modifying the board is going to be hard. So there's no real place to put diodes. Plus I don't understand how they work. The layout is weird. But yeah, the next video is probably going to be me mangling the board and hopefully not breaking it beyond all recognition because I need to deal with caps lock, shift, other shift code and repeat. That's one, two, three, four, five modifiers. I could use a sixth wire for the caps lock light. I'm not really sure what I'll do with it, but I might as well like wire it up. So oh yeah, there's also one wire already used for a modifier, which is H here. So I need to find an extra five GPIO pins on the microcontroller. I think I can manage that though I'll need to check carefully. Anyway, wow, this was a performance. Thank you for watching. If anyone still is, please let me know what you think in the comments. And now I think I'm going to go to bed.