Renewable Energy Innovation

  • Increase font size
  • Default font size
  • Decrease font size
Email Print

No image

I've been messing around with some 32 x 8 LED displays - as I have been wanting to create graphics. These LED displays are from Sure Electronics are available for around $13 and use the HT1632 LED driver IC, with an SPI-like control.

I have previously used these displays for a couple of projects here and here.

I have designed a new circuit board which plugs directly onto the back of these displays and contains a ATMEGA328 with the Arduino bootloader, a real time clock, a temperature sensor and a couple of input switches.

The notes here show the device in action and how I created some bespoke graphics for the displays.

Photos and video

No Image

Scrolling text on the display.

No Image

Numbers on the display.

No Image

A bicycle scrolling across the display.

Circuit board

The circuit board I had designed had a couple of problems - a couple of components got in the way of components on the LED display and so had to be bent down so the LED display would fit. This works OK, but is not good enough to supply these PCBs in a kit. I'll redesign the PCB and have a few of them in stock.

No Image

No Image

No Image

No Image

Enclosure

I quickly designed a simple enclosure using 3mm laser ply wood, 3mm diffusing acrylic and the new A0 sized laser cutter at Nottingham Hackspace. I added a couple of input button to the top of the unit and a power input and programming port are on the back. I was pretty pleased with the end result:

No Image

No Image

Uploading code

I needed to upload an Arduino sketch to run the LED board. My previous projects with these boards were a couple of years ago on an earlier version of the Arduino IDE. When I tried to upload the code using the latest version of the Arduino IDE (1.0.5) there was a compile error.

I decided to look around for new versions of the HT1632 LED driver library and found this one:

https://github.com/gauravmm/HT1632-for-Arduino

I downloaded this and copied it to my Arduino Libraries folder.

This did not work straight away and took a little bit of head-scratching to get it to work.

It turns out that I needed to set the display as 8 bit high and PMOS (the default was NMOS). I think the manufacturer changed this when they did a new batch of PCBs, hence some displays are NMOS and some are PMOS.

This must be done within the HT1632.h header file, which is within the HT1632 libraries folder. For the LED display version I used I needed to change the #define USR_NMOS 0, as the LEDs are controlled with P-type MOSFETS. This is not obvious and not marked on the display anywhere.

No Image

This is the line to change within HT1632.h file, which I edited using wordpad.

Creating custom graphics

The next thing I wanted to do was create some custom graphics. I found this (Windows only) application to create graphics and output the required binary data, called LEDmatrixstudio

This did not output the data in the format that I would like. The required format are 4bit nibbles for the top and bottom sections of each line of the display.

I decided to mess around with the arduino code to get it to read hex values rather than 4bit nibbles.

I could not find an easy way to do this so I created a slightly convoluted tool chain which I list here mainly to remind myself. I realise that I could also sort out the design tool to be able to automatically do this (and one day, maybe I will), but I needed to quickly get a small graphic displayed.

Here is my work-flow:

Create the graphic (using the grid and clicking on the boxes).

No Image

Rotate it left by 90 degrees.

No Image

Click on File -> Export and it brings up a dialog box. Click the options: Export Format "C Style (1 Dimensional)", "Binary" and "8bit (Swap Nibbles)".

No Image

You will see the data in the output pane on the left hand side.

No Image

Copy the binary data which appears. In this case I am creating an 8x8 graphic, so I select 8 rows.

Open the "images.h" document in some kind of editor.

Create a new graphic and give it a name (I use IMG_**NAME** for these). You also need to create a IMG_**NAME**_WIDTH and IMG_**NAME**_HEIGHT values (in this case 8 by 8).

Paste the data copied from the LEDmatrix program, as shown here:

No Image

We then need to split it into 4 bit nibbles - and add the Arduino prefix 0b to indicate it is binary information.

No Image

Save this file.

Open the example Arduino code and create a new image to display.

No Image

Upload the code to the display and viola - a little stickman moves across the screen...

No Image

Using custom fonts

The problem with the HT1632 arduino library was that the data needs to be in the 4 bit nibble format.

The solution above is OK for small graphics, which can be converted from 8bit data into two lots of 4bit nibbles by hand.

With a whole ASCII font this become a greater challenge. Each number, symbol or letter is a 8x8 graphic (around 120 in total, upper case and lower case) and each would need chopping from 8bit data to 4 bit data, the 0b prefix added. The data within each nibble must also be reversed, which made this task terrible to do by hand. This was due to the format of the 8x8 font I decided to use.

So I tried to do this using software. Thanks to fellow hackspace member Iain Sharp who wrote the code while my head was in a muddle.

Basically we added a short section of code which, during the setup, reads all the font data, mirrors each 4 bit nibble and re-saves it back into the font data array. The code is shown here:

  // This for loop reads the font data and converts it to display correctly
  // Each 4 bit nibble is mirrored. 
  int16_t i,j,k;
  for (i=0; i<sizeof(FONT_8X8);i++) {
    k=0;
    for (j=0;j<4;j++)
    {
      k=k<<1; 
      if (FONT_8X8[i]&(1<<j))
          k |=1;
    }
    FONT_8X8[i]=k;
  }
  

 This only needs to run at startup and runs within a couple of milli seconds. The output text looks great:

No Image

No Image