01 July 2021

Character LCD Clock

I think I was browsing Adafruit when I saw some character LCDs, and also their character LCD backpack. The description mentions 20×4 displays, which is the same size that I use at work for a couple products, but there was the problem that the backpack has the connections in a straight line while the LCDs at work have a row of eight on each side of the board. Because of the incompatibility, I kinda brushed it off for a bit. I think later I went to check the datasheet and compared the pinouts, which proves that it is compatible, but not without some sort of adapter. I decided to grab a spare LCD board from work and an LCD that was literally just collecting dust, and made my own I²C character LCD adapter board with Adafruit's as the basis. (I was fairly hyped about I²C back then because of its use of only two MCU pins to be able to communicate with numerous devices, but also I only had a Trinket M0 as a dev board at the time, so I didn't have a lot of pins to work with. Also, this is probably where I learned about the MCP23008.)

Said adapter board.

Since the LCD board is laid out weird, I decided to place the board directly over the majority of the used pins and then run some wires over to the other portion. Because the top side of the board would be the side that directly faces the LCD board, I put all the parts on the bottom side and just reserved the top side for the header and wires (where the bottom side of the board would be where the wires are soldered to the board). More wires were used for the connection to the Trinket M0, but with the "Dupont" socket connectors on the end of them. I should have crimped the connectors on before soldering the wires to the board, but I think I thought it would be okay, and well, I had to resolder one of the wires because the Trinket M0 was having troubles picking it up or something.

Adapter board before the header. I took this as a reference of what colours was what signal.

It did work fine though, but it seemed a bit slow to display, and seemed like lyrics being displayed for a song. I thought it might be some sort of lag or something with the I²C line since the I²C lines were being held up at 5 volts and not 3.3, but I decided to put it aside since I was pretty much done with the tinkering. I was poking around Mouser for character LCDs (to see what kinds there were), and I found an 8×2 character display that has a 2×7 header, which is more convient for custom boards. I forgot how I decided on making a clock with it where the top line would display the time in ISO format (HH:MM:SS) and the second line would display the date in some way. I think I decided with having a format like "30 Jun" and then having the day of the week displayed, but the problem of only having one character was a problem. At first I wanted to stay with Roman characters and looked around other langauages for their days of the week hoping that there would be at least one that has a different first letter for each day of the week. I did find one, but I only kept it in mind as a sort of alternative. I know I also was deciding on using Japanese (and also Chinese, I think) days of the week, but I was having troubles translating the kanji into "pixel art". I ended up with finding a font called PixelMplus, but it took me entirely too long to figure out how to install it before I realised I didn't download the one from the blog page. (It's the second link, but I think I might've scrolled past it without seeing it.) Anyway, it has two pixel sizes of 10 and 12, and I used the kanji from the 10-pixel size to try to make a 5×8 pixel version, but it was just not working out for some of the kanji. While I think I had TU and TH already done before I was trying the kanji stuff, SU and SA were giving me problems because of the S, and was why I was kinda seeking alternatives, but I did eventually figure something out.

The four doubled-up characters. This page was used for doing this, which Adafruit points to in a guide.

I eventually found an I²C isolation board that was a new product at Adafruit and decided to buy it with some STEMMA QT cables so that I could pass 5 volts and ground to the other side of the isolator. Trying it out, it did work fine, but it still had that slow display problem, which I figured to be the that I²C probably isn't fast enough to draw all four lines of the display "instantly" like I remember from the work products. I think it's when I got the ItsyBitsy M4 when I actually had enough pins to directly drive the 4-bit communication instead of having to go through a GPIO expander, and when I had it all set up, it was like it should. There is a slight lag with the last line, but it's still fast enough. I also want to test 8-bit communication, but I'd probably have to write my own library for that.

Anyway, for the board of this project, I started with using the ATSAMD21E18A-A because I wasn't going to need a lot of pins. I was planning on having the RTC set to local time and having a switch to control DST, but eventually I figured it'd probably be better to have the RTC as UTC time instead because it'd be easier to change the timezone offset in the code than have to set the RTC to the new time (if I moved or something). This presented a problem because there was no easy way to properly adjust the date and time (had this just been the time, then it would've been fine). Because the adafruit_datetime library is thirty-something kilobytes in size, I didn't have enough room on the MCU's flash to have it, the other libraries, and the code.


My options were to either tack an SPI flash chip onto the MCU or to use the ATSAMD51J19A-A, which has double the onboard flash, and for the second revision, I decided to make a board for both routes. As maybe obvious from the notes in the first board, I needed to put the MCU on the bottom of the board and turn it so that I have access to more SERCOM pins, since the first board uses some of the SERCOM pins for the LCD. The reason why I originally had all the parts on top was because they then would be inbetween the board and the LCD and a little better protected from ESD, so while I didn't want to do a board with them and the SPI chip on the bottom, I did anyway.

Tentative second revision.

For the ATSAMD51J route, I had less board space to work with, but I still made it work with everything on top of the board like I wanted. I think it was sometime after I finished this board where I was playing with using the analogue out pin for controlling the contrast, since I'd have a lot more control than a variable resistor as a voltage divider. (The LCD from work says to give the contrast pin about 0.6 volts, and so dividing the voltage from 5 volts makes it a very small window to work with. While I could change the input of the voltage divider to 3.3 volts from the regulator, it wouldn't give me much more to work with.) Making the change removed the variable resistor and its traces and freed up a little bit of space. The second change to make was the fact that the MCU wouldn't have any timekeeping pulses, and because the RTC has the 32kHz output, I was able to just run the trace up to the oscillator in pin (PA00) and connect a pull-up between it and 3.3 volts.


I think it was before removing the voltage divider that I found that the adafruit_datetime library also uses "a bunch of memory" and I might've done some testing to confirm this, but I don't remember. Regardless though, the ATSAMD51 route was the route that I would take because of it.

The SERCOM multiplexing thing started with this project because I wanted to try to have a sort of "direct" connection between the RTC and MCU, but from the Adafruit dev board schematics and how things were set up for those dev boards, my knowledge was limited. PA08 and PA09 are usually the default I²C lines and the alternatives were PA16 and PA17 for one, and PA22 and PA23 for another (assuming those were exposed pins, I don't remember at this point since Adafruit has board names for them that they use instead). After getting the whole SERCOM thing straight, I found that I was able to use PA17 with PA22 because they're both on SERCOM 3. (My explanation on SERCOM multiplexing is in the previous post.)

Whenever I do have this board made and have the MCU for it, it'll be the test for the RTC's 32kHz output as the MCU's crystal, since this board is going to be cheaper than the MCU internet clock one. I'm sure it'll work fine, but I remember not really being able to find any info besides this thread.

No comments:

Post a Comment