Help with I2C Control of 4-Digit 7-Segment Display w/I2C Backpack

EL Wire/Tape/Panels, LEDs, pixels and strips, LCDs and TFTs, etc products from Adafruit

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
User avatar
sealyon
 
Posts: 283
Joined: Mon Jun 18, 2012 12:14 pm

Help with I2C Control of 4-Digit 7-Segment Display w/I2C Backpack

Post by sealyon »

I need information on the I2C command set used for interfacing with the 4-Digit 7-Segment Display w/I2C Backpack (ID#: 879). I will not be using this with an Arduino controller and need the I2C command sequences. Somewhat surprised that the documents provided for this product do not provide the direct I2C commands. I understand you are catering to Arduino users and supply the driver code for that processor, but I am using a different controller. Appreciate any help.

User avatar
pburgess
 
Posts: 4161
Joined: Sun Oct 26, 2008 2:29 am

Re: Help with I2C Control of 4-Digit 7-Segment Display w/I2C Backpack

Post by pburgess »

Howdy,

Here's a link to the PDF datasheet for the HT16K33 driver chip. It's amazingly detailed and exhaustive, so you might have better luck just picking apart the Arduino library to get up and running more quickly.

User avatar
sealyon
 
Posts: 283
Joined: Mon Jun 18, 2012 12:14 pm

Re: Help with I2C Control of 4-Digit 7-Segment Display w/I2C Backpack

Post by sealyon »

Agree, probably easier to pull the I2C details from the library vs. unwinding the datasheet. Others using this backpack with other controllers have obviously had to go through all this before. Wish someone had documented what they did to make it easier for others. I'll try to post back an I2C overview for the backpack to make it a bit easier for others using the backpack with other controllers. Thanks.

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm

Re: Help with I2C Control of 4-Digit 7-Segment Display w/I2C Backpack

Post by adafruit »

the I2C interface is fairly trivial, porting the library is your best bet

User avatar
sealyon
 
Posts: 283
Joined: Mon Jun 18, 2012 12:14 pm

Re: Help with I2C Control of 4-Digit 7-Segment Display w/I2C Backpack

Post by sealyon »

A few quick questions. When power is first applied to the 7-segment backpack, should the 4-digit be totally OFF? That's what I'm seeing, so I'm guessing this is correct.

I've tried to walk-thru the arduino code and pull out the associated I2C messages. I'm currently using a BusPirate to do this initial testing (I'm using the default I2C address (0xE0)).

What I2C message(s) need to be sent to the backpack to initialize it? I'm guessing the oscillator needs to be turned on. Here's my guess:

[0xE0 0x21] -- Turn Oscillator ON

What is the initial value of the brightness level? Do I need to set brightness level before displaying anything? There appears to be 16 levels of brightness supported and I'm think the brightness command is 0x0E. So, to set the display at MAX brightness, here's what I've sent:

[0xE0 0x0E 0x0F]

Sending display values to each digit position appears to be done by sending the digit # (i.e. 0,1,2,3) and then the segment value to turn on the LEDs for the digit. First looking at just #'s, here's the values to send:

0x3F -- 0
0x06 -- 1
0x5B -- 2
0x4F -- 3
0x66 -- 4
0x6D -- 5
0x7D -- 6
0x07 -- 7
0x7F -- 8
0x6F -- 9

So, to set the digits to '1234', here's the needed I2C message;

[0xE0 0x00 0x06 0x01 0x5B 0x02 0x4F 0x03 0x66]

I'm guessing something is missing, since this doesn't appear to work.

Anyone have any ideas?

Thanks,

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm

Re: Help with I2C Control of 4-Digit 7-Segment Display w/I2C Backpack

Post by adafruit »

We suggest wiring up an Arduino, getting it to display what you want, then printing out the I2C commands sent to get that display. that's by far the easiest way.

User avatar
sealyon
 
Posts: 283
Joined: Mon Jun 18, 2012 12:14 pm

Re: Help with I2C Control of 4-Digit 7-Segment Display w/I2C Backpack

Post by sealyon »

Well, sure, I can use the BusPirate I2C sniffer to reverse-engineer the I2C message set. But, I don't have an Arduino and should I really have to do that? Your docs should outline the I2C interface used by your board (this applies to all your I2C-related boards). Not looking for anything fancy, just a brief description of how to initialize the board and a description of how to use the I2C message set to get the board to display LED segment info (and how to adjust brightness & flashing options). Take a quick peek at the http://www.byvac.co.uk/downloads/datash ... aSheet.pdf for a simple explanation of another vendors 7-Segment I2C board - this provides the basic info needed to properly use the I2C commands (starting on page 7). Yeah, your board is a $10 board and I understand the support cost issues, but somebody had to do all the I2C message design work when the board was designed and it certainly should already be documented somewhere. Can't you just provide the info? How about you hook it up to the BusPirate and document the I2C message set for everyone who needs it (and add that to the docs page for this board).

Your description for this product states that it can be controlled "via a simple I2C interface." Well, that may be true, but since you don't describe the interface it's hard to say how simple it actually is. If this is only meant to connect to an Arduino then you should just say that and not advertise it as an open I2C board controlled via a simple I2C interface.

Again, I wish I could get a little help here.

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm

Re: Help with I2C Control of 4-Digit 7-Segment Display w/I2C Backpack

Post by adafruit »

We didn't design the HT16K33 chip, its just a breakout for it. We do provide tested, fully working code in the form of an Arduino library. Any other code or information you need is available at the Holtek website or by googling for the HT16K33 chip datasheet which will pull up the datasheets - that's what we based the library off of. The BV4513 requires a full documentation because it is a programmed microcontroller written by that company. The HT16K33 is manufactured by Holtek (not us) so they provide all documentation on how to use it. See burgess's handy links above for the datasheets

mtbf0
 
Posts: 1645
Joined: Sat Nov 10, 2007 12:59 am

Re: Help with I2C Control of 4-Digit 7-Segment Display w/I2C Backpack

Post by mtbf0 »

SeaLyon wrote:So, to set the digits to '1234', here's the needed I2C message;

[0xE0 0x00 0x06 0x01 0x5B 0x02 0x4F 0x03 0x66]
took a brief look at the code and i think column two is the colon. you say your i2c message doesn't work, but you don't say what it does, so i may be way off base. i would try

[0xE0 0x00 0x06 0x01 0x5B 0x03 0x4F 0x04 0x66]

User avatar
sealyon
 
Posts: 283
Joined: Mon Jun 18, 2012 12:14 pm

Re: Help with I2C Control of 4-Digit 7-Segment Display w/I2C Backpack

Post by sealyon »

Appreciate the help. Do you have the board and do you have it working? Currently I can't seem to get mine to show anything. It powers-up blank and remains blank no matter what I2C messages I send to it (my guess is I've missed something in the I2C initialization stream). At this point, all I'm doing to initialize is turning the oscillator ON [0xE0 0x21] and setting the display to MAX BRIGHTNESS [0xE0 0x0E 0x0F]. Once I do that everything is still blank. Then I try to set digit segments, but the display remains blank no matter what I send.

Can't seem to get Adafruit to provide any reasonable guidance, so I'm not sure if it's supposed to be doing this or if there may be a problem with the board. Unfortunately, I don't have an Arduino to test it with at this point, but should in the next few days, then I can at least verify if the board is working or not. Once I have this I can use the BusPirate to sniff out the I2C message stream and properly determine what needs to be sent for initialization & segment display. This is turning into a lot more work then I bargained for, which I really didn't plan on, but what should I expect for a $10 board? If they at least properly documented their library code to show the details of the I2C message stream that would have made this a ton easier. In my opinion, Adafruit should provide a simple I2C message description page with each of their I2C products that fully describes how to successfully communicate with it (regardless of whether it is a breakout board or a custom uController). This isn't difficult (they are writing the Arduino libraries already anyway and obviously have to test it, so they have to know the I2C message stream) and having direct access to this information would be extremely helpful for their customers.

To help others, I'll post back what I find.

User avatar
sealyon
 
Posts: 283
Joined: Mon Jun 18, 2012 12:14 pm

Re: Help with I2C Control of 4-Digit 7-Segment Display w/I2C Backpack

Post by sealyon »

Ok, I've unwound the I2C interface for the backpack. I have the I2C Interface Specification for the board put together which provides the details of interfacing to this board. The format isn't great at this point, but I believe this provides the bulk of the information necessary to successfully communicate with the board using a general I2C interface. Although this is meant for non-Arduino users, this will provide the missing code documentation to help you better understand how the Adafruit Arduino Library actually works. I think something like this should be provided by Adafruit for all of their I2C products.

Unfortunately, the board is not allowing me to attach the spec (it's a pdf). Why is that? I'll provide a link to a file sharing site in a bit.

User avatar
sealyon
 
Posts: 283
Joined: Mon Jun 18, 2012 12:14 pm

Re: Help with I2C Control of 4-Digit 7-Segment Display w/I2C Backpack

Post by sealyon »

Here's a link to the LED Backpack I2C Specification: https://secure.kitedrive.com/courier/we ... 1.1%29.pdf. Please let me know if you have any questions.

User avatar
high-fidelity
 
Posts: 4
Joined: Mon Jun 18, 2012 9:04 am

Re: Help with I2C Control of 4-Digit 7-Segment Display w/I2C Backpack

Post by high-fidelity »

I had trouble accessing the file linked, so thought I would add my bits here, for those that don't want to or aren't able to BANNED the arduino library or datasheet.

I'm interfacing with a bunch of these on an STM32F407.

I've got a total of 8, 4 red and 4 green. Have set them up as unique addresses (0x70-77 - 8 is the max per i2c bus).

The interface is pretty simple when you realise how Adafruit have laid it out. I did this without looking at the schematic, just by reading the HT16K33 datasheet and the Arduino library.

To initialise:
send 0x21 - start the oscillator
send 0xEF - set brightness to max (not really required, but a bit of a sanity check).
send 0x81 - turn blink off and display on

To BANNED this
0x21 = 0x20 + 0x01 // 0x20 = System setup command. 0x01 = S bit (1 = oscillator on, 0 = oscillator off)
0xEF = 0xE0 + 0x0F // 0xE0 = brightness command. 0x0F = 16/16 duty cycle. (valid values are 0x00 - 0x0F for 1/16 to 16/16 duty cycle)
0x81 = 0x80 + 0x01 // 0x80 = blink command. 0x01 = display on (add 0x06 for .5hz blink, 0x04 for 1hz blink, 0x02 for 1hz blink)

The adafruit backpack has each individual digit (and the colon) configured as a column output.
Left most digit = column 0
second digit = column 1
colon = column 2
third digit = column 3
right most digit = column 4

For each column, up to 16 rows are connected. A 16 bit value is written to configure the output of each column. If a 1 is set in the corresponding row position, then that will light up that segment.

For each digit the rows are:
BANNED

x = don't care
P = decimal point
A-G are the individual segments.

Code: Select all

        A
      -----
   F |     | B
      --G--
   E |     | C
      -----
        D
As per previous reply... Some standard codes:
0 = 0x3F
1 = 0x06
2 = 0x5B
3 = 0x4F
4 = 0x66
5 = 0x6D
6 = 0x7D
7 = 0x07
8 = 0x7F
9 = 0x6F
A = 0x77
b = 0x7C
C = 0x39
d = 0x5E
E = 0x79
F = 0x71
to turn on the decimal point, add 0x80 to any digit code above.

The colon = 0xFF to turn on all segments, not sure which rows the colon segments are actually connected to.


The driver chip has 16 rows x 8 columns. This is represented as a 16x8bit RAM. Effectively, this means that you have 16 transfers on the i2c bus to fill the RAM that represents the displays.

To actually update the display, do the following:

send 0x00 // Starting RAM address, this auto increments after each successive write and wraps after 16 writes.
send 0xXX // column 0 row 0-7 drivers - this is digit 1.
send 0xXX // column 0 row 8-15 drivers - not connected
send 0xXX // column 1 row 0-7 drivers - this is digit 2.
send 0xXX // column 1 row 8-15 drivers - not connected
send 0xXX // column 2 row 0-7 drivers - this is the colon.
send 0xXX // column 2 row 8-15 drivers - not connected
send 0xXX // column 3 row 0-7 drivers - this is digit 3.
send 0xXX // column 3 row 8-15 drivers - not connected
send 0xXX // column 4 row 0-7 drivers - this is digit 4.
send 0xXX // column 4 row 8-15 drivers - not connected

My application is in a track day special car, so I'm interested in automotive related things. My examples will be geared around that.

I've got a warning for low oil pressure, so I display OIL blinking on the display to indicate that.

send 0x83 // display on, blink = 2hz
send 0x00 // starting RAM address for driver outputs
send 0x3F // = O
send 0x30 // = I
send 0x00 // = colon off
send 0x38 // = L

this will blink OIL on the first three digits at 2 Hz as a warning.

How about the same for a fuel warning.

send 0x85 // display on, blink = 1hz (not as critical as low oil pressure, so slower blink rate)
send 0x00 // starting RAM address
send 0x71 // = F
send 0x3E // = U
send 0x00 // = colon off
send 0x79 // = E
send 0x38 // = L

When a generic error condition is noted, I display four dashes, blinking
send 0x85 // display on, blink = 1hz
send 0x00 // starting RAM address
send 0x40 // = -
send 0x40 // = -
send 0x00 // = colon off
send 0x40 // = -
send 0x40 // = -



The bit I've left out of all of this is the generic i2c stuff. That is, you need to preface each sequence with a START and then the address of the device you're targeting. Don't forget that the devices use 7 bit addresses, and the 8th bit in the address byte must be set to whether you're sending or receiving (from the master's perspective). That means that if your i2c display is 0x70, you actually need to send 0xE0 (= 0x70 << 1 + 0x0). You'll then get an ack back from the display, which indicates that it's ready to receive your data. Once you're done transferring, don't forget to generate a STOP condition also.

I've been coding in C++, and if anyone is interested in my code, you're welcome to have a look, just respond here or send me a message.

Hope that someone else finds this useful. It was something I did in an hour or so on a Sunday night.

User avatar
sealyon
 
Posts: 283
Joined: Mon Jun 18, 2012 12:14 pm

Re: Help with I2C Control of 4-Digit 7-Segment Display w/I2C Backpack

Post by sealyon »

Here's a working link to my Backpack specification: http://www.keepandshare.com/doc/4368390 ... f-88k?da=y. The info contained in the last post is a bit more detailed but I believe we are saying the same things. Have fun.

Chris

User avatar
vortex
 
Posts: 8
Joined: Sun Sep 30, 2012 10:05 pm

Re: Help with I2C Control of 4-Digit 7-Segment Display w/I2C Backpack

Post by vortex »

@High-Fidelity: Could you please post a link to your code? I'm working with this device on Linux in C++, but having a few issues with it. My LCD's work ok on Arduino, just having a few issues working with the i2c functions in C++ and Linux. Other than the Adafruit Arduino code, working code is hard to come by.
FWIW; I'm interested in reading about your track car project too, I've done some racing myself (karts and some time attack circuit racing) :)

Locked
Please be positive and constructive with your questions and comments.

Return to “Glowy things (LCD, LED, TFT, EL) purchased at Adafruit”