Yes. It's not the easiest of datasheets to follow but it seems to me that the command byte is 8 bits and represents a location so the address mode should be I2CBYTE.Thanks Hippy, so would you suggest something like:
i2cwrite command_byte, (data_byte)?
And’The default slave address is factory-set to 0000000
Slave address %00000000 is a general call address for all i2c devices and is not supported by the PICAXE chips.If this feature is used, 2 of the 16 key readback nodes can be left open or shorted for self-addressing. This is done with KEYA together with SEGG and SEGF. This two nodes cannot be used for key-readback in this case. After startup all devices have the predefined address 0000000. A single command for self-addressing will update all connected AS1115.
Well, the obvious answer is max7219. Problem is if you pay $5 you will be getting a "fake". You might be lucky, like I was, and find it works fine. Or you might not be lucky.... Genuine max7219 cost in the $10-15 range. There was a thread on spotting the fakes, do a forum search for "fake". Max7219 has an SPI/serial type interface.Any other 64 led drivers you've used successfully? Something in the $5 range would be best.
Same Austria Microsystems AS family - AS1107 - pin compatible (plus a bit more) as MAX7219 but a lot cheaper. Available in DIP and SOICAny other 64 led drivers you've used successfully? Something in the $5 range would be best.
I think it also says that this has to be done each time power is applied, ie not persistent. Very inconvenient!I got the impression from the word I quoted from the AS1115 Datasheet that an alternate address may be possible by connecting a keys an line to a couple of segment lines.
Not too inconvenient though. I did not study the datasheet in depth but it appears that a single command sent to all chips causes each to load their address from whatever external links have been made; then it's just a matter of using the right address for the right chip. If there's only one chip then no addressing configuration to be done - I think; Goeytex's useful code will help there.I think it also says that this has to be done each time power is applied, ie not persistent. Very inconvenient!
Could it be possible to "bit-bang" that first command? All following comms between the 2 chips could use the updated address and the normal i2c commands.But there is the problem as I mentioned earlier that the default slave address is the general call address $00 which PICAXE does not support.
I cannot recall exactly what the details are - whether that is related to giving an I2C Slave such an address or a more widespread not supported - but it is definitely not a good idea to use a %0000xxxx device address.But there is the problem as I mentioned earlier that the default slave address is the general call address $00 which PICAXE does not support.
Certainly a possibility.Could it be possible to "bit-bang" that first command? All following comms between the 2 chips could use the updated address and the normal i2c commands.
Self-addressing is not applicable; you only need to worry about it if you have enabled it and there is no need to do that.Thoughts?
From page 15 in the datasheet....As the “SEG” outputs on the AS1115 are sourcing current to the anodes of the LEDs,
I suspect (guess) that no connection will be treated as a zero for the two i2c slave address bits. Links from the KEYA line to the SEGF and SEGG lines will be treated as “1” bits,
#picaxe 20x2
#no_table
'=======================================================================================================================================================
'===[TITLE & DESCRIPTION]===============================================================================================================================
'=======================================================================================================================================================
'AS1115 Test Code
'This is test code to figure out how to use the AS1115 LED driver.
'The "counter" variable counts from 0 to 999 and the result is shown on a 3-digit 7-segment LED display with common cathode.
'
'=======================================================================================================================================================
'===[PIN DEFINITIONS]===================================================================================================================================
'=======================================================================================================================================================
'outputs:
SYMBOL SCL = b.7
SYMBOL SDA = b.5
'=======================================================================================================================================================
'===[CONSTANTS]=========================================================================================================================================
'=======================================================================================================================================================
SYMBOL ONES_DIGIT = %00000001 'digit 0 command byte on the AS1115
SYMBOL TENS_DIGIT = %00000010 'digit 1 command byte on the AS1115
SYMBOL HUNDREDS_DIGIT = %00000011 'digit 2 command byte on the AS1115
SYMBOL ZERO = %01111110 'data byte. individual control of each segment to produce the desired number
SYMBOL ONE = %00110000
SYMBOL TWO = %01101101
SYMBOL THREE = %01111001
SYMBOL FOUR = %00110011
SYMBOL FIVE = %01011011
SYMBOL SIX = %01011111
SYMBOL SEVEN = %01110000
SYMBOL EIGHT = %01111111
SYMBOL NINE = %01111011
SYMBOL DASH = %00000001
SYMBOL BLANK = %00000000
'=======================================================================================================================================================
'===[VARIABLES]=========================================================================================================================================
'=======================================================================================================================================================
SYMBOL ONES_DIGITVAL = b1
SYMBOL TENS_DIGITVAL = b2
SYMBOL HUNDREDS_DIGITVAL = b3
SYMBOL counter = W9
SYMBOL STEP1LIM = W10
SYMBOL STEP2LIM = W11
SYMBOL STEP3LIM = W12
SYMBOL STEP4LIM = W13
SYMBOL STEP5LIM = W14
SYMBOL STEP6LIM = W15
SYMBOL STEP7LIM = W16
SYMBOL STEP8LIM = W17
SYMBOL STEP9LIM = W18
SYMBOL STEP10LIM = W19
'=======================================================================================================================================================
'===[INITIALIZATION]====================================================================================================================================
'=======================================================================================================================================================
hi2csetup i2cmaster, %00000000, i2cslow_8, i2cbyte 'prepare for data transfer with LED controller
hi2cout %00001001, (0x00) 'set AS1115 LED controller to no-decode mode
hi2cout %00001010, (0x0F) 'set AS1115 LED controller to max brightness
hi2cout %00001011, (0x07) 'set AS1115 LED controller to display 8 of the 8 digits even though only using 3 digits in this example code.
'=======================================================================================================================================================
'===[MAIN ROUTINE: (DEFINITION)]===============================================================
'=======================================================================================================================================================
do
for counter = 0 to 999
ONES_DIGITVAL = counter dig 0 'get the tenths digit of the counter variable
TENS_DIGITVAL = counter dig 1 'get the ones digit of the counter variable
HUNDREDS_DIGITVAL = counter dig 2 'get the tens digit of the counter variable
select ONES_DIGITVAL
case 0:ONES_DIGITVAL=zero
case 1:ONES_DIGITVAL=one
case 2:ONES_DIGITVAL=two
case 3:ONES_DIGITVAL=three
case 4:ONES_DIGITVAL=four
case 5:ONES_DIGITVAL=five
case 6:ONES_DIGITVAL=six
case 7:ONES_DIGITVAL=seven
case 8:ONES_DIGITVAL=eight
case 9:ONES_DIGITVAL=nine
endselect
if counter >=10 THEN
select TENS_DIGITVAL
case 0:TENS_DIGITVAL=zero
case 1:TENS_DIGITVAL=one
case 2:TENS_DIGITVAL=two
case 3:TENS_DIGITVAL=three
case 4:TENS_DIGITVAL=four
case 5:TENS_DIGITVAL=five
case 6:TENS_DIGITVAL=six
case 7:TENS_DIGITVAL=seven
case 8:TENS_DIGITVAL=eight
case 9:TENS_DIGITVAL=nine
endselect
ELSE: TENS_DIGITVAL = zero
ENDIF
if counter >=100 THEN
select HUNDREDS_DIGITVAL
case 0:HUNDREDS_DIGITVAL=zero
case 1:HUNDREDS_DIGITVAL=one
case 2:HUNDREDS_DIGITVAL=two
case 3:HUNDREDS_DIGITVAL=three
case 4:HUNDREDS_DIGITVAL=four
case 5:HUNDREDS_DIGITVAL=five
case 6:HUNDREDS_DIGITVAL=six
case 7:HUNDREDS_DIGITVAL=seven
case 8:HUNDREDS_DIGITVAL=eight
case 9:HUNDREDS_DIGITVAL=nine
endselect
ELSE: HUNDREDS_DIGITVAL = BLANK
ENDIF
hi2cout ONES_DIGIT, (ONES_DIGITVAL)
hi2cout TENS_DIGIT, (TENS_DIGITVAL)
hi2cout HUNDREDS_DIGIT, (HUNDREDS_DIGITVAL)
pause 100
next
loop
#picaxe 14M2
#no_Data
#com 1
setfreq M8
pause 1000 'allow slave to get ready
sertxd ("RESETTING PICAXE",cr,lf) 'Test for reset
hi2csetup i2cmaster,%00000000,i2cslow_8,i2cbyte 'This hangs or reset Picaxe
hi2csetup i2cmaster,%00000001,i2cslow_8,i2cbyte 'This works ok. Sets address to 0x00
b0 = 85 'Data
b1 = 0 'Location
do
hi2cout b1,(b0)
inc b0
inc b1
pause 15
loop while b0 < 91
stop
'===================================
#Picaxe 20X2
#No_Table
#com 2
Pause 100
'=====================================
'// HI2CSETUP I2CSLAVE,%00000000 ' This will hang or reset Picaxe
HI2CSETUP I2CSLAVE,%00000001 'This works ok. Sets address to "0"
main:
if hi2cflag = 0 then main ; poll flag, else loop
hi2cflag = 0 ; reset flag
get hi2clast,b1 ; get last byte written from SP
sertxd (#b1,cr,lf)
goto main
From PICAXE manual 2 under the HI2CSETUP command:Not sure if it is bug or not. But both the 14M2 and 20X2, when set as a MASTER , will either hang or reset if the slave address is set to %00000000.
The fact that address $00 (the general call address under the i2c specs) does not work on the PICAXE chips falls into the above category and I believe has been confirmed previously by Technical.Some special i2c addresses (0, %1111xxx, %0000xxxx) have special meanings under the i2c protocol and so are not recommended as they may cause unexpected behaviour on third party devices.