I2C 4x7-segment display

smssms

New Member
Has anybody got this I2c 7-segment display (Ebay item 260597609525) working with a Picaxe?

I am very new to Picaxe, but got an I2c compass working in about 30 minutes. So far I've spent 4 hours with this 7-segment display and a 28x1 but it only shows its address (3).

There is a data sheet for the display here.

If anyone could give me a bit of code guidance, it would be much appreciated...
 

Chavaquiah

Senior Member
Hi! The author would probably be able to give better help. You may contact him at the (email) address given on his homepage: http://lietuvys.user.lt/?lang=en

(I'm not transcribing the address here since it's only shown as a graphic for spam prevention.)

Regarding the device's address, try to use 6 instead of 3 (meaning 3 in the left most 7 bits).

Anyway, if you understand C, the examples provided may explain what you have to do. If not, try something like the following, to see if it works:

I2CSLAVE 6, i2cslow, i2cbyte
WRITEI2C (63, 63, "1", "2", "3", "4", 0, 4)

If this works and you don't feel very confortable with C, someone could probably help translate the example code to Picaxe Basic.
 

smssms

New Member
Thank you :)

I have tried various i2cslave addresses including:
%0000110x
%0011000x
%1100000x
$3
$03
3
6

And I have tried using binary, hex and "text" for the i2cwrite 0-6 bytes in Picaxe Programming Editor.

As you suggested, I have also asked the author for advice.
 

westaust55

Moderator
If as you say in post 1 the slave address is 3,
then the correct value is
%00000110 = $6 = decimal 6 as indicated by Chavaquiah
 

Chavaquiah

Senior Member
Other than the correct address, you also have to send a checksum in the last byte, otherwise the whole message is ignored. Did you understand how to calculate that? With Picaxe, you have to XOR all bytes sent (except the checksum), including the address.
 

smssms

New Member
Other than the correct address, you also have to send a checksum in the last byte, otherwise the whole message is ignored. Did you understand how to calculate that? With Picaxe, you have to XOR all bytes sent (except the checksum), including the address.
Sorry, typo for the addresses above - fairly happy with that now.

Reading the compass module on i2c was so easy compared to writing to this display. I do not know how to calculate the checksum. I'm afraid the checksum issue is out of my league at the moment - I'm off to read up on it now...

I started all this to learn, so learn I will!
 

hippy

Technical Support
Staff member
From the datasheet you have to send 8 bytes of data in the I2CWRITE command and the last byte must be a properly calculated checksum, including the I2C device address.
 

westaust55

Moderator
(side tracked briefly) try some code like:


I2CSLAVE 6, i2cslow, i2cbyte
WRITEI2C ($FF, $7F, $30, $31, $32, $33, $0F, $xx)

now you need to calculate $xx

from the sample C code seems to be
Buffer[7] = address << 1;
for (i = 0; i <= 6; i++) Buffer[7] ^= Buffer;


$xx = address * 2 XOR byte1 XOR byte2 XOR byte3 XOR byte4.XOR byte5 XOR byte6

If $xx is not correct, then nothing will be displayed.

The above in theory will illuminate both LEDs at the side and the 4 x 7seg will show "0.1.2.3"
 
Last edited:

smssms

New Member
The author got back to me with the following code which does display 1 2 3 4 and two LEDs :D

Code:
SYMBOL ParityCheck = b10
symbol Byte0 = b1   ' 0 7s brightness LED 7=upper LED, 6=lower LED,5=-, 4321=7s brightness
symbol Byte1 = b2   ' 1 Brightness of LEDs 7=-, 6543210=LED brightness
symbol Byte2 = b3   ' 2 Char 1
symbol Byte3 = b4   ' 3 Char 2
symbol Byte4 = b5   ' 4 Char 3
symbol Byte5 = b6   ' 5 Char 4
symbol Byte6 = b7   ' 6 Char 5
' Byte7  =     ' 7 Parity = XOR of bytes 0 to 7

symbol slvAddrWR = $06   ' I2C write address
   
Main: '76543210 
Byte0 = %11011111
Byte1 = %01111111
Byte2 =  $31  '1 draw characters
Byte3 =  $32  '2
Byte4 =  $33  '3
Byte5 =  $34  '4
Byte6 =  $35  '5

ParityCheck = slvAddrWR XOR Byte0 XOR Byte1 XOR Byte2 XOR Byte3 XOR Byte4 XOR Byte5 XOR Byte6 

'Tell it which Slave to talk to
i2cslave slvAddrWR, i2cslow, i2cbyte 'Write the data out
writei2c (Byte0, Byte1,Byte2,Byte3,Byte4,Byte5,Byte6, ParityCheck)

goto Main

'That lights both LEDs and shows "1234" on the display.
 

MPep

Senior Member
The "ParityCheck" part of the code is what Westaust said.
Great minds think alike ........ and fools seldom differ.
In this case, I would go with the first half of that phrase :D.
 
Top