Group Projects
Members' Projects
HT1632-AVR : A library to interface HT1632 LED Driver ICs and AVR micro controllers
Adam — Tue, 16/03/2010 - 4:39pm
Introduction
H1632-AVR is my attempt at making an Arduino and generic AVR compatible library to interface with Hoktek's HT1632 LED driver IC; the main component in a number of LED matrix displays available from Sure Electronics. Here is the description of the HT1632 IC from the manufacturer:
The HT1632 is a memory mapping LED display controller/driver, which can select a number of out bits and commons. These are 32 out bits & 8 commons and 24 out bits & 16 commons. The device supports 16-gradation LEDs for each out line usingPWMcontrol with software instructions. A serial interface is conveniently provided for the command mode and data mode. Only three or four lines are required for the interface between the host controller and the HT1632. The display can be extended by cascading the HT1632 for wider applications.
For some of the background on why I wrote this library there's a fairly lengthy post here on Why I Wrote HT1632-AVR. Feel free to skip that though.
How it works
The HT1632 is a bank of memory with constant current drivers attached to some matrix scanning circuits. The memory is read and writen over a serial bus which uses +5v clocked serial communication. It's odd in that it shares a single data line for reading and writing and uses two clock lines to tell the IC when to read and when to write.
The library implements a class which encapsulates the communication method and data transfers to & from the driver IC. The class handles all the bit-banging using a set of C macros which directly manipulate the AVR's IO registers. The class handles things like initialising the device and setting reasonable defaults to get you up and running. It then exposes a few methods of communicating with the HT1632 from as low as setting the mode, address and then reading/writing data or as high as reading/writing to/from a bitmap buffer.
Download
All of the source code is up on GitHub: devdsp/HT1632-AVR. GitHub provides a clonable git repository as well as snapshot downloads. The Master (default) branch should always be stable. If I start breaking things and breaking backwards compatibility it will be in another branch and I'll give people some notice on here when I may be considering merging an experimental branch in.
Communication
The GitHub project page is the most official way to get in contact regarding this project but feel free to drop in to the #MakeHackVoid IRC channel on freenode, I idle there most days under the nick devdsp. Feel free to jump in there or comment here if you don't want to sign up on GitHub.
Contributing
Pull requests on GitHub for code. Contact me via comment here for anything else.
Documentation
There isn't any yet. Sorry :(
There are plenty of example sketches in my repository and more will be added as I work out what I want to do with my displays. The examples give a decent look at the features and usage of the library, sometimes even in an easy to understand way. All of the current examples have been written for my Arduino Duemilanove and my 4 DE-DP104s. To run the examples on an Arduino and a Sure Electronics display; connect the Arduino to the display as shown in the table below and load one of the sketches onto your Arduino.
| Display Label | Arduino DIO | Sure's Connector |
|---|---|---|
| CS1 | 4 | 3 |
| CS2 | 5 | 1 |
| CS3 | 6 | 2 |
| CS4 | 7 | 4 |
| WR | 8 | 5 |
| DATA | 9 | 7 |
| RD | 10 | 6 |
| GND | gnd | 11 |
| +5V | +5V | 12 |
Don't forget that if you are looking at an IDC plug from the bottom, as you will if you are plugging in jumper cables, the rows are reversed. Just remember that CS1, CS2, WR, DATA and GND lines are on the keyed side of the connector and the rest go on the flat side.
Demo
Here's a very short demo of one of the configurations I have been playing with.
HT1632-AVR + Arduino + DE-DP104 from devdsp on Vimeo.
- Login or register to post comments
- Printer-friendly version
Search
Member Tweets
MakeHackVoid
11 hours 10 min ago
—
Space is open until 19:30 (estimate)
|
evildeece
1 day 3 hours ago
—
I learnt about C++ templates today, this will clean up some of the nasty macros in MHVLib :) #mhv
|
MakeHackVoid
1 day 7 hours ago
—
Space is closed (was open five hours)
|
MakeHackVoid
1 day 10 hours ago
—
Space staying open until 19:00 (estimate)
|
brendam
1 day 10 hours ago
—
Interesting post by @mwesch "Maker Bots and the Future of Identity" http://t.co/1TbGHwgE ping #mhv
|
MakeHackVoid
1 day 12 hours ago
—
Space is open until 16:45 (estimate)
|
evildeece
1 day 17 hours ago
—
Relief printing with a laser cutter, from NYC Resistor http://t.co/YQ1aqUvG #mhv
|
evildeece
2 days 19 hours ago
—
Thanks to @projectgus, I have some core memory from 1960, now to write an AVR driver http://t.co/0iI7OKH1 #mhv
|
MakeHackVoid
3 days 4 hours ago
—
Space is closed (was open 4 1/2 hours)
|
MakeHackVoid
3 days 6 hours ago
—
Space staying open until 22:00 (estimate)
|
- 1 of 12
- ››




Library
rvbcrs — Sat, 24/04/2010 - 4:58amHi I like to try this library, but I don't know how to configure the wires from a arduino to the matrix board! Can you please tell me what wires to use!
Thanks,
Ramon
Hi Ramon, The examples in my
Adam — Fri, 30/04/2010 - 12:07pmHi Ramon,
The examples in my repository use the following connections to Sure Electronics displays:
If you only have one display you only need to connect one of the 'Chip
Select' lines, just make sure that you set the dip switches on the back
of the display to match the Chip Select pin you have chosen on the
connector. You also don't need to have the 'Read Clk' pin connected, but you will only be able to write to the display.
Remember that when you look at the IDC cable's connector the rows are swaped over. If you hold the cable's connector with the tab facing towards you, pin 1 (the first chip select pin) is on the top row.
Thanks for pointing out that this isn't documented. I'll go and update the readme file with some ASCII art. :)
Adam.
Request
Rania A. — Tue, 31/01/2012 - 5:54amHi Adam,
First of all, thank you so much for the great effort....
really appreciated...
am very new for interfacing arduino with ht1632 as i've tried your "simple 16*24" code.. and it works some how.but don't know whether it runs probably or not !
here is a video link for what i 've made,
http://www.youtube.com/watch?v=Blq7kyojjSI&context=C3ccbaa1ADOEgsToPDskLSehAJsSaoAohYtGAHXFFr
i'll be grateful if you could contact me.
any reply will do much help.
and thanks in advance
Power
adammhaile — Tue, 07/09/2010 - 9:02amAre you powering all 4 Sure displays off of the arduino 5V output?
I see that each display is rated at 220 mA max, and I thought that that would max out the 800 mA current draw of the Arduino voltage regulator.
Or are you powering the displays off of a separate external power supply? If so, is there anything special required? Would a current regulated 5V "wall wort" work?
When I want to run more than
Adam — Tue, 07/09/2010 - 9:34amWhen I want to run more than 2 displays I power them with a 5v regulated wall wort I picked up from JayCar. One amp is enough to power four displays and the Arduino (by plugging the regulated 5v into the Arduino's +5v header). At a stretch; the Arduino's on board regulator can power two displays, even off USB, but I wouldn't do that for a permanent installation.
What's the difference between
adammhaile — Tue, 07/09/2010 - 9:58amWhat's the difference between plugging the 5V in to the +5v header and connecting power to the regular power jack?
I also thought the +5V header was only for power output...
Powering Arduino's off their +5v header
Adam — Tue, 07/09/2010 - 10:35amThe regulation circuit isn't 100% efficient, and due to the nature of the regulator it needs +7v or higher to provide the 5v needed to run the Arduino. Plugging 5v directly into the 5v header bypasses that circuit and just drives the input of the Arduino directly. The 5v net (traces) is the same regardless of where the power comes in.
Here's the quote from the Duemilanove's Arduino.cc hardware page:
5V. The regulated power supply used to power the
microcontroller and other components on the board. This can come either
from VIN via an on-board regulator, or be supplied by USB or another
regulated 5V supply.
VIN vs 5V
adammhaile — Tue, 07/09/2010 - 12:46pmGuess I'm still confused. That description makes it sound to me like 5V is output only and that you can only input via Vin. Could you still input a regulated 5V on Vin?
RE: VIN vs 5V
Adam — Tue, 07/09/2010 - 1:11pmThe header pins don't have anything that dictate them as inputs or outputs. The are directly connected to the nets which use that voltage level. The putting 5v on the VIN pin is the same as putting 5 volts on the power jack (with the minor exception that the power jack has a diode inline to prevent damage incase you put a center negative plug in). The VIN net is on the 'outside' of the regulator and must be at 7v or above for the regulator to be able to supply 5 volts to the 5volt line. The 5v header is on the ATMega side of the regulator. Connecting to the 5v header is just like connecting 5 volts to the VCC pin on the ATMega. This might be easier to see on the arduino-duemilanove-schematic.
RAM
adammhaile — Thu, 16/09/2010 - 9:36pmThanks your all the connection help, BTW... just got all the components and it worked like a charm.
At the moment, I'm just using 1 display, but will scale up to 4 later.
Any idea how much RAM the library uses when driving 4 displays? I'm hoping to integrate ethernet into my project later and am worried that all the networking code plus these displays will max out the 2K for the ATMega328
RE: RAM
Adam — Thu, 16/09/2010 - 11:36pmTo be honest, I don't actually know how much RAM it takes when using this library. There is overhead when creating the c++ class instances but most other libraries I've seen depend on a framebuffer which takes up a fair amount of RAM. I've got my boards out again tonight to test a few things so I'll see if I can get some numbers for you.
If it turns out that I am starving people of precious RAM it will push me to look into writing a purely procedural interface. I'll keep you posted.
Awesome... greatly
adammhaile — Thu, 16/09/2010 - 11:50pmAwesome... greatly appreciated.
Select Pins set to High
adammhaile — Fri, 17/09/2010 - 6:56amJust getting everything hooked up and trying to understand your sample sketches...
One thing I'm confused by though... why do you set the Chip Select pins to High at the beginning?
digitalWrite(4,HIGH); digitalWrite(5,HIGH); digitalWrite(6,HIGH); digitalWrite(7,HIGH);
The chip select lines are
Adam — Fri, 17/09/2010 - 9:31amThe chip select lines are active low, so if any given chips CS line is low it will think it is being talked to. Without deselecting each chip at start up there is the possibility of contention. After the classes are initiated I use the deselect() class method to handle returning the CS line to its idle state.
Awesome... got it
adammhaile — Fri, 17/09/2010 - 11:46amAwesome... got it working!
Two things though... the CS1 and CS2 lines are reversed from what you show in your diagram above. Maybe they changed it on recent boards? Not a big deal, just switched the wires, but weird.
Second... When I tried the Marquee example the fonts say it's 8 pixels high, but it only uses the top 6 rows of pixels, on the display.
I I'm only using one display, but the only change I made was change max_cols to 31 and comment out the other 3 class instances... so not sure if I'm doing something wrong.
Thanks for letting me know
Adam — Fri, 17/09/2010 - 12:16pmThanks for letting me know about CS1 and CS2 being swapped. I've fixed the doco here and in the repository.
Does your text have any chars that hang below the base line (eg. pqgyj)? The font should be at least 7 pixels tall but I thought it was 8 pixels. I'll take a look again tonight when I try to work out the memory usage.
The mods you made sound reasonable. That should be all you need to do to use the marque demo with less displays.
You would be correct about
adammhaile — Fri, 17/09/2010 - 12:52pmYou would be correct about the fonts hanging down and it does in that case use all 8 pixels. Although I was using capitals and lowercase, it seems my choice neglected any that hung down like that. This brings up another question though... the file font.h says it was created by FontCreator and gives a link, though that website seems to be dead and I am having trouble finding it anywhere. I found what I think is a really old version of the program, though the font.h files it creates seem to be incompatible with what your code uses... might be able to manually fix it, still working on that. Though, do you happen to know where I could get the application that created those particular files?
Other than that, so far so good... thanks for all the help!
Sure 0832 Green display
rvbcrs — Mon, 20/09/2010 - 8:24pmHi!
Are you planning on releasing support for the Green version of the Sure electronics 08x32 board? the pixelmapping is a bit different, therefore the lib won't work for the green ones..
Thanks,
Ramon
Did Sure start putting the
Adam — Mon, 20/09/2010 - 9:06pmDid Sure start putting the reversed cathode green 8x8 matrices on their 0832 displays as well as on their 2416? This doesn't surprise me that much but it is a bit of a pain.
There's nothing in my library which dictates how the LEDs should be laid out. This was done intentionally because of the oddity that was the green 2416 display and apparently now the green 0832 having each of the columns running backwards in groups of 8. All my library does is help you blat out to consecutive memory addresses. This works out great when the LEDs are laid out from top-to-bottom then left-to-right but falls a short when working with stranger displays. The library still works, it's just not as nice to use and you have to do a more work on the user side to get anything cohesive out of it.
I've looked at various different ways of making it easier to use with the Sure displays that have the reversed cathode problem but haven't come up with a universal solution that didn't muddy up my code too much. It doesn't help that I don't have one of the effected display to test on.
What are you hoping to use your displays for? I might be able to give you some examples of mapping columns to address with your displays if I know what your trying to achieve.
Sure Matrix Green
rvbcrs — Tue, 21/09/2010 - 1:42amHi adam!
Thanks for your response! Actualy I do not know for sure if the mapping is different, I assumed it was so because of the Green 2416 ones. But I tried your 0832 demo and all I got was the first display turning on and a whole lot of pixel scrolling from left to right, but no readable text so I thought this had probably something to do with the pixel mappings. What I would love to do with the screens is connect as many as possible (preferably 8 ) and connect a arduino with ethernet shield to it and let people send messages to it and display it on the dot matrices. I hope you can help me with this!
Thank you
Ramon
That's just the simple demo
Adam — Tue, 28/09/2010 - 3:42pmThat's just the simple demo which shows that the code and hardware is working. If you load the marquee8x32 that, by default, scrolls text over 4 displays. You should be able to run 8 displays but you'll defiantly need an external power supply and to make a few changes to the demo code.
Whether my library plays well with the rather fat ethernet library is still up in the air as I haven't been able to sit down and work out the memory usage. Check back again soon because adammhaile is also interested in using the ethernet library
RAM Usage
adammhaile — Tue, 21/09/2010 - 9:47pmAny luck finding how much RAM the library is using?
Not yet sorry. Another
Adam — Tue, 28/09/2010 - 3:45pmNot yet sorry. Another project ate up my free time. I've realised that it should be possible to just do something like Serial.println(sizeof(matrix),DEC); to get the memory usage of one instance. I'll try that out tonight if I get my 328p back into my Arduino board.
Using all 4 displays
adammhaile — Tue, 05/10/2010 - 12:17pmI finally got all 4 displays and hooked them up exactly as you have listed, but I cannot get it to work with more than one display at a time using the marquee example sketch. I can confirm that each display works individually, but when I run the sketch exactly as it came, it will only output to display one. Though there is a large delay until the text gets there as if it thinks it's showing on displays 2-4, but nothing is actually being shown.
Any tips for what I should check?
RE: Using all 4 displays
Adam — Tue, 05/10/2010 - 3:31pmThe first thing to check is if you have set the CS switches on each of the displays correctly. Each display should have a different switch on and all other switches off.
With each of the displays plugged in and their CS switches set so they are each waiting for a different CS line you could try running the simple8x32 demo and just replace the first parameter to constructor. That should show you that you have the CS switches set correctly.
I was able to try that and I
adammhaile — Tue, 05/10/2010 - 9:05pmI was able to try that and I definitely could address each display individually by just changing the CS parameter in the code. The sketch then worked just fine for that specific display.... just never all of them at once.
Arduino Uno
KarlWhitakay — Fri, 15/04/2011 - 9:33amHi,
Is there an efficient way of modifying the code to work with my Arduino Uno?
Thank you,
Karl
Using Library for the first time
rguifa — Tue, 16/08/2011 - 5:00amHi!
I've been reading your work for quite some time, I then got myself a couple of these displays from sure electronics. I bought the green ones.
I've downloaded your files to give it a try, wired everything as described by you, but nothing happens on my display. I'm only using one at this point to keep it simple.
I'm have a Duemilanove, and I am running my display from the arduino's 5 volt port. My display is set to CS1 (Dip swith 1 on, the rest off)
Can you help me out to get this to work? Has anyone succeded working with the green displays?
One more thing, The chip on my display is the Holtek HT1632C, I don't know if that C makes a significant difference at all.
Thanks, and hope you can help me power this things up!
Greetings to you all from Honduras.