Page 1 of 2

LED Matrix 8x8 based on ht16K33 I2C

Posted: Thu Apr 05, 2018 3:50 pm
by medelec35
https://thepihut.com/products/adafruit- ... llow-green
Datasheet
Code Links
I will be getting one soon.
Would be nice if there is a component available for it.

Thank you.

Martin

Re: LED Matrix 8x8 based on ht16K33 I2C

Posted: Thu Apr 05, 2018 4:19 pm
by Benj
Hi Martin,

Looks nice, I'll see if I can squeeze this one in for you. I've been busy making components today so I'm on a roll.

Hopefully shouldn't take too long.

Re: LED Matrix 8x8 based on ht16K33 I2C

Posted: Thu Apr 05, 2018 4:47 pm
by medelec35
Thank Ben,
That would be fantastic!
Glad your on a roll anyway.
I'm looking forward to having a play.

Re: LED Matrix 8x8 based on ht16K33 I2C

Posted: Fri Apr 06, 2018 12:25 pm
by Benj
Hi Martin,

Right this seems to work, at least in simulation. I used the datasheet more than the library so things might not be quite right for the download but let me know how you get on.
LEDMatrixHT16K33.fcpx
(8.65 KiB) Downloaded 376 times

Re: LED Matrix 8x8 based on ht16K33 I2C

Posted: Fri Apr 06, 2018 12:50 pm
by medelec35
Hi Ben,
Wow that was fast!, thank you.
As soon as matrix arrive,
I will test it and report back.
In the component how do you select address, if using more than one?
I know you can solder the links on the PCB to change starting address.
When you say simulation,
are you referring to Flowcode or something like Proteus?

Re: LED Matrix 8x8 based on ht16K33 I2C

Posted: Fri Apr 06, 2018 2:28 pm
by Benj
Hi Martin,
I will test it and report back.
Brill thanks 8)
In the component how do you select address, if using more than one?
I know you can solder the links on the PCB to change starting address.
There is a Slave Address property which allows you to specify the address, for multiple matrices you can use multiple components and connect them all to the same I2C peripheral. Let me know if this is too restrictive.
When you say simulation,
are you referring to Flowcode or something like Proteus?
I've tested it using the Flowcode sim. I've had a good go at the embedded side of things but I wouldn't hold my breath for it to be seamless at the moment. The memory seemed to be interlaced but I'm not 100% on it so for now I have ignored this to avoid adding unnecessary complications.

Re: LED Matrix 8x8 based on ht16K33 I2C

Posted: Mon Apr 09, 2018 2:02 pm
by medelec35
Hi Ben,
I have tried both your component and my code with just initialization and getting the same results:
LEDs on start up.jpg
(257.36 KiB) Downloaded 5361 times
I don't know why LED's lighting up with no Row/Col commands?
For my code (Flowchart attached) using I2C I used:

Code: Select all

Start
TB 0xE0
TB 0x21 //Internal RC Osc
Stop
200uS delay
Start
TB 0xE0
TB 0x81 \\Display On, Blinking Off
Stop
200uS delay
Start
TB 0xE0
TB 0xEF \\Full Brightness
Stop
It could be the module is faulty?
I have sent a message to Where the Matrix board was purchased from.

I would have thought after initializing, all LED's would be in the off state?

It's funny how different decoders choose to display values differently.
For example with your component:
Scope Decode1.png
(40.97 KiB) Downloaded 5356 times
EB070 Decode.png
(160.3 KiB) Downloaded 5359 times
I think it should show 0x70 as E0 is the 70 shifted so its E0 write?

Re: LED Matrix 8x8 based on ht16K33 I2C

Posted: Mon Apr 09, 2018 3:16 pm
by Benj
Hi Martin,
I would have thought after initializing, all LED's would be in the off state?
Hmm not necessarily, with the smart LEDs I use they often power up in to a random state. The IC has 16-bytes of dedicated RAM to drive the LEDs, this RAM is unlikely to be being initialised to 0's on power up, presumably to avoid brown out resetting issues. If you unplug the LEDs for a while and then plug them back in does the same pattern appear? I can add a routine to the initialise function to loop through and clear the RAM.
It's funny how different decoders choose to display values differently.
Looks like your Rigol trace is trying to be clever and is leaving off the LSb read/write bit and only showing the I2C address. Presumably that's why it's W: 70 it's I2C address 0x70 in Write mode.

Let me know how you're getting on. It could be my component is missing something critical. Do you have an Arduino you can try with the sample code to see if that works?

Re: LED Matrix 8x8 based on ht16K33 I2C

Posted: Mon Apr 09, 2018 3:55 pm
by medelec35
Hi Ben,
Benj wrote:If you unplug the LEDs for a while and then plug them back in does the same pattern appear?
Fairly similar, 4 or so LED's are different.
Benj wrote:I can add a routine to the initialise function to loop through and clear the RAM.

If it is what you state then that would be a great idea as I added.
I just tried an experiment.
With your component, I have just added

Code: Select all

WriteLED 1,3,2  (Data, Row & Column)
Before:
Before.jpg
Before.jpg (257.55 KiB) Viewed 13686 times
After:
After.jpg
After.jpg (256.1 KiB) Viewed 13686 times
Odd, Looks like it shifted the row and all other LED's Kept on.

Benj wrote: Do you have an Arduino you can try with the sample code to see if that works?
I can give it a shot when I get home, very new to Arduino.
Benj wrote:W: 70 it's I2C address 0x70 in Write mode.
Yes, I'm assuming that too.
Shame there is no standard way of either must show 0xE0 or must show 0x70.

Martin

Re: LED Matrix 8x8 based on ht16K33 I2C

Posted: Mon Apr 09, 2018 8:48 pm
by medelec35
Hi Ben,
Display is working just fine!
I think I have figured it out?
There is a bit of a gotch you.
To clear dispaly you will need 0xE0, 0x00 then 16 lots of 0x00
With 8x8 (the matrix i'm using)
It misses every other row.
So if I wanted row 2 ( using rows 0 to 7) and the second LED to light, I used

Code: Select all

Row = Row * 2 

the sequence is:

Code: Select all

Start, 0xE0, 4, 1 , stop
The column is where it gets a bit weird.
Assuming from right to left, it misses the first (column 0) and starts from column 1.
If column 4 is required you will need to use 8 ect.
Ie. 0xE0,4,8 will light up Row 2, Column 4
The odd thing is to light fist column 128 is required.
To light last column 64 is required!
How I enable/ disable any Single LED within 8x8 Matrix:
Control LED.png
(96.01 KiB) Downloaded 5222 times
Appears to work well.

Martin

Re: LED Matrix 8x8 based on ht16K33 I2C

Posted: Tue Apr 10, 2018 12:13 pm
by Benj
Hi Martin,

I've added the clear command to the initialise and also changed the clear function so it should work correctly now.

Not sure what to do regarding the rows and columns, it sounds like the LED matrix might be connected to the controller IC in a rather strange way. I suppose we could change the component so that it's specifically for the array product rather than the controller IC? Or make 2 versions of the component? Or have a property that sets the addressing mode? :?: :mrgreen:
LEDMatrixHT16K33.fcpx
(8.23 KiB) Downloaded 309 times

Re: LED Matrix 8x8 based on ht16K33 I2C

Posted: Tue Apr 10, 2018 2:39 pm
by medelec35
Thanks Ben,
Benj wrote:I've added the clear command to the initialise and also changed the clear function so it should work correctly now.
Yes, confirmed working.
Benj wrote:Not sure what to do regarding the rows and columns,
Perhaps have a Drop-down list to select either 8 x 8 or 8 x 16?
Write LED is not correct for 8 x 8:
1,0,0 [Data,Row, Column]
1,0,0.jpg
1,0,0.jpg (258.03 KiB) Viewed 13591 times
1,3,2 [Data,Row, Column]
1,3,2.jpg
1,3,2.jpg (260.16 KiB) Viewed 13591 times
On hardware Row = 1, Column = 4
The Star is at the bottom as its like that on the website purchased matrix from.

Martin

Re: LED Matrix 8x8 based on ht16K33 I2C

Posted: Wed Apr 11, 2018 7:45 am
by medelec35
Added a decision branch so Col is never lower than 1 when LED is enabled.
Routine works even better:
Control LED.png
(93.28 KiB) Downloaded 5192 times

Re: LED Matrix 8x8 based on ht16K33 I2C

Posted: Tue May 29, 2018 10:57 am
by medelec35
Hi Ben,
The 16x8 LED Matrix + Backpack works a bit differently to other 8x16.
The one I have is address like this:
16x8 LED Matrix + Backpack.png
(194.02 KiB) Downloaded 4779 times
Would it be possible to add to component please?

Re: LED Matrix 8x8 based on ht16K33 I2C

Posted: Wed May 30, 2018 9:11 am
by medelec35
Hi Ben,
You may already know this but if column is set say value of 10 (Column with Green LED in above image) then transmit 255, then 32, all 8 LEDs on block 1 and 3rd from top on block 2 will be lit.

The situation is reversed if you did the column as 11 with same values.
Then 8LEDs will be lit on block 2 and 3rd from top on block 1 will be lit.

Re: LED Matrix 8x8 based on ht16K33 I2C

Posted: Mon Jun 04, 2018 5:30 pm
by Benj
Hi Martin,

This one has me scratching my head a bit.

I take it you have an 8x8 module and a 16x8 module, is there also a 8x16 module?

Would it be possible for you to send me pictures of the addressing bytes and bits for the three various displays? This should help me get things together and create a more universal working component with sim that matches.

I might also need to rethink the addressing for the sim so that it's more obvious which LED will light?

Re: LED Matrix 8x8 based on ht16K33 I2C

Posted: Tue Jun 05, 2018 10:05 am
by medelec35
Hi Ben,
There are two different 16x8 variants.
There is the one I posted above called Backpack.
Backpack longest edge vertical.
There are 2 blocks of 8x8
For direct access then bottom left is 0,1
The top left of the lower block is 0,128.
If you then just transmit say 3 then the far left of upper block also lights first two LEDs.
For direct accessing of upper block only e.g first 2 LED's then its 1,3.
So lower block columns are 0 then all even numbers.
Upper Blocks are all odd numbers.

The other 16x8 is called Feather.
Again has two blocks of 8x8.
The difference is instead of long edge being vertical, its rotated so long edge is horizontal.
Left block is 0 and all even numbers.
So far left and bottom is 0,1
Counting along the bottom column the 9th LED i.e first LED of 2nd Block is 1,1
Ect.
The confusion is the websites call the Featherwing 8x16 yet the PCB calls it 16x8.

The Final thing that works with HT16K33 which I have not got are seven seg LEDs.

The great thing about using HT16K33 for matrix's and driving 7seg displays is you don't need any current limiting resistors and the brightness can be controlled in 16 steps.


Hope this Helps

Martin

Re: LED Matrix 8x8 based on ht16K33 I2C

Posted: Tue Jun 05, 2018 10:20 am
by Benj
Hi Martin,

I've made a simple excel file to try and master the layout of the various modules.

I've started with the 8x16 backpack, I'm assuming the first number is across or X and the second is up in Y.

Can you add the other display modules you have to the document so I can hopefully get things right first time :D I've listed the byte address as well as indicating the MSB (Orange) and LSB (Yellow) in the bytes.
HT16K33_Excel.png
(8.9 KiB) Downloaded 4709 times
HT16K33.xlsx
(9.33 KiB) Downloaded 197 times
I'll add a drop down selection instead of the numeric rows and columns and this should let you choose from a set list of module layouts.

Re: LED Matrix 8x8 based on ht16K33 I2C

Posted: Tue Jun 05, 2018 10:43 am
by medelec35
Hi Ben,
I believe attached is what you're after?
Featherwing.png
(11.58 KiB) Downloaded 4705 times
Benj wrote:'m assuming the first number is across or X and the second is up in Y.
Yes that's correct.
Benj wrote:I'll add a drop down selection instead of the numeric rows and columns and this should let you choose from a set list of module layouts
I agree with that.
But with Backpack you do need to state if 8x8 version or not as 8x8 is for the one you have already completed.

Re: LED Matrix 8x8 based on ht16K33 I2C

Posted: Tue Jun 05, 2018 1:54 pm
by Benj
That's brilliant thanks, working on it now...

Re: LED Matrix 8x8 based on ht16K33 I2C

Posted: Tue Jun 05, 2018 4:44 pm
by medelec35
That's great, Thanks Ben.
As the component count is very low,
What about using these for 8 x 16 LED Matrix on EBlocks2?

Re: LED Matrix 8x8 based on ht16K33 I2C

Posted: Wed Jun 06, 2018 10:38 am
by Benj
Hi Martin,

Right I've managed to make some changes now and have rebuilt the component from the ground up, it seems a lot more stable and reflective of the modules now. I've also added column labels to simplify the addressing for the various modules.

I've pushed the new component to the updates system now so it should be available in v8 for you to have a play. Let me know if you would like the new updates available in v7 too.

Good idea as a replacement for the EB1 LED Matrix board, I'll have a bit of a look into this and see if we could pull it off.

Re: LED Matrix 8x8 based on ht16K33 I2C

Posted: Wed Jun 06, 2018 11:18 am
by medelec35
Hi Ben,
Thanks for the update, sounds brilliant!
With attached flowchart, got the following errors:

Code: Select all

HT16K33 Test.c: FCD_0d541_LEDMatrixHT16K33__DisplayString()
   260:	FCD_0d541_LEDMatrixHT16K33__ShiftColumns(0);
	^ (361) function declared implicit int (warning)
   282:	FCL_DBYTE = FCD_0d541_LEDMatrixHT16K33__ReadASCIILUT(FCL_POS_STR, FCL_COUNT);
	            ^ (361) function declared implicit int (warning)
   295:	FCD_0d541_LEDMatrixHT16K33__WriteColumn(14, FCL_DBYTE);
	^ (361) function declared implicit int (warning)
HT16K33 Test.c: FCD_0d541_LEDMatrixHT16K33__SetBrightness()
   370:	FCD_0d541_LEDMatrixHT16K33__WriteCommand(0xE0 | FCL_BRIGHTNESS);
	^ (361) function declared implicit int (warning)
HT16K33 Test.c:
   476:	{
	^ (984) type redeclared
	^ (1098) conflicting declarations for variable "FCD_0d541_LEDMatrixHT16K33__ShiftColumns" (HT16K33 Test.c:475)
(908) exit status = 1
(908) exit status = 1

Error returned from [xc8.exe]

C:\Program Files (x86)\Flowcode\Common\Compilers\pic\batch\pic_xc8_comp.bat reported error code 1

Re: LED Matrix 8x8 based on ht16K33 I2C

Posted: Wed Jun 06, 2018 12:28 pm
by medelec35
Hi Ben,
Featherwing... Perfect so far with

Code: Select all

Hello World
scrolling across both blocks.
Will continue to test.

8x16 Backpack... The

Code: Select all

Hello World
does scroll, but it scrolls along the the lower block only. From 14 to 0
I believe it would be better if Chars scrolled across both blocks like it does with Featherwing.
Is that doable?

8x8 if you look at the excel sheet you can see that the lowest row (LSB) does not start with 0 like it does with the other two matrix's.
There LSB is 128, so the chars have shifted up one level, cropping the top and displaying top of chars on the bottom row.

Martin

Re: LED Matrix 8x8 based on ht16K33 I2C

Posted: Wed Jun 06, 2018 2:55 pm
by Benj
Brilliant thanks Martin,
does scroll, but it scrolls along the the lower block only. From 14 to 0
I believe it would be better if Chars scrolled across both blocks like it does with Featherwing.
Is that doable?
Anything is possible, I'll say it's problematic but I'll have a go :wink:
8x8 if you look at the excel sheet you can see that the lowest row (LSB) does not start with 0 like it does with the other two matrix's.
There LSB is 128, so the chars have shifted up one level, cropping the top and displaying top of chars on the bottom row.
Oh wow yes I see it now, That is crazy I wonder why they laid it out like that!