Wednesday 29 July 2020

LED Matrix


I wanted to give my robot that retro look, so I decided to add a matrix Display.
I wanted it to be independent of the main controller, I did not want the main controller to control it all the time.
So I added another small processor to control it and the main controller just sends a task for it to do via the I2C bus.

The Matrix Display is made up of four 8x8 LED matrix, each controlled by a MAX7219 (Serially Interfaced, 8-Digit LED Display Drivers)

I got cheep one with a single PCB with four 8x8 LED displays attached from eBay.


If you look closely at the image above you will see gaps between the 8x8 Displays.
This is because the PCB is designed for Metric Displays which are 32mm x 32mm.
The ones fitted to this PCB are Imperial, which are 1 1/4" (inch and a quarter = 31.75mm).

As I was going to mount them in a 3D printed frame, I fixed this buy cutting the PCB into four separate pieces, the saw thickness was enough to remove the amount needed to bring the 8x8 displays together.


All I had to do was bridge the five lines at each joint.





The processor I chose to control the Matrix Display is an ATTiny85.
I found an SMD version on a breakout board with a USB connection on the board (GY Board, Digispark clone), on eBay.

This worked well, but if you look at the video, you will notice Scanning when the display changes.
This is because the Arduino library updates the screen every time it draws a column. I assume this is to keep the library footprint as small as possible, and not use a buffer to write to first, which makes it more versatile to how many devices are connected together. (It is possible to connect eight MAX7319 end to end)

As I am not going to change the number of 8x8 displays, I am going to write my own commands to write to the Matrix Display, using a buffer to send the whole display to the matrix at once.
This way the Matrix Display will change instantly without any scanning seen.

I have currently re-wrote my code for the Matrix Display.
I wanted to be able to send text to it from my phone application, so that any messages can be displayed.
This requires a font. Adding a font to the program made the code too large for the ATTiny85, even when I reduced the font to just capital characters and numbers.
I am over by 66 bytes. I trying to remove some more code to fit it on.
If I removed the numbers from the font as well, it would reduce it by another 50 bytes. (not quite enough)

Then I thought what about using an ATMega168?
Looking on eBay the price of an ATMega168 and ATTiny85 are pretty much the same.
The reason I originally chose an ATTiny85 is because I thought it was the cheapest option, and I thought I wouldn't need a lot of memory. But as soon as you start to use buffers and fonts, memory becomes an issue.
As space and size is not an issue, I may as well use an ATMega168, it gives me twice the memory and a lot more pins, I could have the ATMega168 control something else later.


What I may do for a prof of concept, is continue with the ATMega168.
Then when I have it as I want it. Because I am using the I2C bus to communicate with everything, is put the font on an AT24C256 Module. Then see if the code fits on a ATTiny85.

I managed to put the font onto the AT24C256 for the ATMega168 to use.
But because I wanted to add more functionality to the program, the code it still to large for the ATTiny85.
I have modified my Application from my phone so that I now can send any message I want to the display.
It also holds 5 pre-sets so that I can send commonly used messages quickly.


I love is when people comment, some times it give me an idea.
One did, I'm not ready to do text to speech yet, I'll try that when I come to build the head.
But I thought: Android/Google API has the ability to do voice recognition, so use it hehe.
I decided to add this feature to mi application.

I haven't made it send the word spoken straight away, I put send it on another button, so that the word it thinks you say can be checked first.
It save all that typing haha.


Have managed to get the program to fit on the ATTiny85, didn't realise I was using a float for command selection, soon as I changed it to an Integer, I had a lot more memory to play with.

The setup now looks like this:

The Android device sends a command to the Bluetooth Module, which is connected to the Arduino NANO RX and TX pins. (via a voltage changer)
If the command is for the LED Matrix, the Arduino NANO sends the command to the ATTiny85, via the I2C Bus.
If the command is a function command, the ATTiny85 carries out the function.
Functions are:
On/Off.
Scroll.
Chevron Display.
Retro Display.

If the command is to display a message, the ATTiny85 will read the message and get the required Fonts from the AT24C256 Memory Module, via the I2C Bus.
Then display them on the LED Matrix as it retrieves them for the memory module.

It's a display, what more could I display with it?
Oh just realised I could add a RTC (real time clock) to the I2C bus.
So I did.
The processor I am using to drive the LED Display can now get the time from the RTL and display it.


While doing this I have learnt how to give voice commands to my robot.
So later I intend to do another menu on my controller application to control more functions by voice commands.


The RTC I was using did not come with a backup battery, so while looking for a battery for it, I found another RTC with a memory chip on the board as well as the clock chip.
This was cheaper than buying a battery for the current board, and it came with a backup battery.
The memory chip is only a 24C32 which is enough to fit the font.
This board replaces the previous RTC and 24C256 modules.






If you like what I have done, or want to know more.
Please leave a comment below.








No comments:

Post a Comment