8x8 Matrix Thermometer

It takes the temperature from the DS18B20 chip (using the built-in READTEMP command) and scrolls that over the face of the 8x8 LED matrix (see the Scrolly Text project).

What you need

PICAXE 28X1*
8x8 LED Matrix (I use these from http://earthshinedesign.co.uk)
2x 74HC595 shift chips
DS18B20 thermometer IC
4k7 ohm resistor

* The code takes up only 346 bytes of available program space and the character data only 65 bytes of EEPROM space but it does use the "scratchpad" which is only available on 20X2, 28X1, 28X2, 40X1 and 40X2 chips. It also requires a running speed of at least 8MHz, 4MHz is too slow.

What it does

The character data is stored in the scratchpad as a series of bytes, each one represents a column of our display;

Each row can be represented by a single byte, each "on" pixel represented by a single bit.

The top row in this C would be;

(0*128) + (1*64) + (1*32) + (1*16) + (0*8) + (0*4) + (0*2) + (0*1) = 112

Second row;

(1*128) + (0*64) + (0*32) + (0*16) + (1*8) + (0*4) + (0*2) + (0*1) = 136

etc.

The matrix code for this project is optimised in such a way that the character data needs to be stored so that the character is rotated 90 degrees clockwise and then inversed (sounds complicated but it saves doing it in code and is therefore faster and easier!!!).

Each row of this character represents a column of our display.

The top row in this C would be;

(1*128) + (0*64) + (0*32) + (0*16) + (0*8) + (0*4) + (0*2) + (1*1) = 129

The second row in this C would be;

(0*128) + (1*64) + (1*32) + (1*16) + (1*8) + (1*4) + (1*2) + (0*1) = 126

The scratchpad is filled from the highest bytes backwards. Why is this...?

The routine that builds up the list of column data doesn't know in advance how much data there will be and the temperature digits will be added in reverse order, a temperature of 20'C will be added in the order; C, ', 0 then 2.

We could start at the beginning of the scratchpad (byte 0) and then shift the data up so we can insert the next character at byte 0, but that would a) add more code and b) complicate things more than they need to be and c) slow things down a little.

We store, in the EEPROM, character data for the numbers 0-9, the degree character and the letter C. I've designed a simple 5x8 font, so in order to conserve EEPROM space I've only stored the data for the 5 columns as we don't need the empty space on each side. The EEPROM to scratchpad copy routine automatically adds a space between each character.

This uses up an additional 8 bytes of code memory but saves us 1 byte for each character, 13 bytes. Which doesn't sound much, but when you only have 256 bytes of EEPROM space available (on the 28X1) that's a decent saving.

It's then up to the scroll routine to do the pretty/clever stuff.

For 25'C we would end up with 23 bytes of character data in the scratch pad, representing each of the 23 columns of data required;

The scroll routine starts at column 1 and outputs columns 1,2,3,4,5,6,7,8 to the matrix then moves one to the right (a scroll to the left) to display 2,3,4,5,6,7,8,9 and so on.

When it reaches the end, so it's showing columns 16,17,18,19,20,21,22,23, it would revese the direction to then display 15,16,17,18,19,20,21,22 etc.

The 8x8 matrix is acting like a window that only shows part of the data at any one point in time.

Because the number of columns will change depending on temperature the code that builds the character data keeps track of the number of columns it adds.

Notes

The 8x8 matrix I've used here, like many others, doesn't allow all of the columns to be accessed at the same time. If you look at the code you'll see that we're actually only ever lighting up one column at a time. However, the columns are being lit up so fast that the eye percieves them all to be on at the same time!

The first of the shift registers sets the column to activate, the second shift register sets the data.

Future improvements

The 8x8 LED matrix I'm using is bicolour (red and yellowy-green) so I'd like to make use of that in the future.

The READTEMP command can take up to 750ms (3/4 of a second) to process which results in the matrix going blank. I'd like to improve this somehow, maybe by having the text scroll off the screen, get the temperature and then scroll the text back on...