picaxe too slow

pbunyan

Member
ok, so i dont know what to do

im trying to control an LED array of 10 cloumns and ten rows using a 32bit output expander and a pixace 18X, communicating over I2C

i havent got the output expanders yet (in the post) but i wrote a program to see if the led's would refresh fast enough to seem constantly on, and here it is:
main:
i2cslave %10100000, i2cslow, i2cbyte
goto loop

loop:
high 3
writei2c b1, (b1,b1,b1,b1,b1,b1,b1,b1)
low 3
writei2c %10100000, (b1,b2,b3,b4,b5)
writei2c %10100000, (b1,b2,b3,b4,b5)
writei2c %10100000, (b1,b2,b3,b4,b5)
writei2c %10100000, (b1,b2,b3,b4,b5)
writei2c %10100000, (b1,b2,b3,b4,b5)
writei2c %10100000, (b1,b2,b3,b4,b5)
writei2c %10100000, (b1,b2,b3,b4,b5)
writei2c %10100000, (b1,b2,b3,b4,b5)
writei2c %10100000, (b1,b2,b3,b4,b5)
goto loop

the first part sets up the I2C bus, then lights up an led, simulationg the first column, sends an I2C command, then turns it off, and then sends 9 more I2c commands, simulating changing the leds in all of the columns,then turns the first LED back on. i was hoping that it would happen fast enough that POV would kick in, and the LED would seem like its on all of the time, but its not. and this is only controlling a 10 * 10 grid, i was hoping to go bigger than that. so what i need to know now is, is thwere anything i can do to make this a worthwile project still, or should i just find another use for 100 leds, a picaxe 18x and 9 output expanders?
 

pbunyan

Member
what i did think of was having a latch of some sort on each LED, so that it latches untill its next changed, but it would cost more in latches than for the rest of the project! and i really cant afford that. oh well, one thing ive also just realsed is that inetween every I2C command, there will also be a serin command to get the byte data from a PC, wich would take even longer. oh well.

so basically, any ideas of what i can use 100 leds, a picaxe 18X, 9 32-bit output expanders, and a picaxe 28a ive just found for?
 

Rickharris

Senior Member
try this <A href='http://www.instructables.com/ex/i/CB3E1E2C20851029BC6B001143E7E506/?ALLSTEPS' Target=_Blank>External Web Link</a>

or

<A href='http://www.instructables.com/ex/i/CDDBE0821A0010299AD7001143E7E506/?ALLSTEPS' Target=_Blank>External Web Link</a>


or indeed a 100 LED version of this <A href='http://www.makezine.com/blog/archive/2006/04/chris_lomonts_led_cube.html' Target=_Blank>External Web Link</a>

Edited by - rickharris on 20/04/2006 22:28:57
 

hippy

Ex-Staff (retired)
A 'SETFREQ M8@ at the start of the program will make a PICAXE-18X run twice as fast. You'll probably have to adjust the I2CSLAVE parameters.
 

Jeremy Leach

Senior Member
What are you going to try to display on the LEDs? 50Hz refresh would be ideal, but I expect slower might just work. At 50Hz you only have a 20ms window in which to manipulate some sort of bitmap for the 100 LEDs - I would have though this is a VERY challenging thing to do.

Of course you might want to change, say, just two LEDs at a time, which is much more acheivable. So maybe your refreshes don't need to refresh all the LEDs, only a small subset??
 

andrewpro

New Member
From a purely theoretical and mathematical standpoint, it SHOULD be possible to update at 50hz using 100khz I2C and carefully written code.

The expander chip being used was never mentioned, so I cant give any exact timings, but tranferring 16 bytes, just from the I2C side, should take ~1.6ms. Add on the device address (only 4 of them using a 32 output chip) and your up to maybe ~2ms.

Crafting the needed bytes prior to changing the LED's, and sending them all in a for..next loop Should be able to do things fast enough. If you want to do full motion LED video that's going to be a bit more difficult but going down to 25hz update it might actually be possible!! You'd need alot of big EEPROMS, but basically just sucking and chucking data could do it.

What is the chip that your using to do the interfacing?

--Andy P
 

pbunyan

Member
yes, theoretically it should work, but i dont know. maybe as i havent actually got the chips in the circuit yet, the picaxe stalls a bit while waiting for acknolwedgement, then just carries after a bit when it doesnt get it.

here is a PDF for the chip im using:http://www.semiconductors.philips.com/acrobat_download/datasheets/PCF8577C_4.pdf

the thing is, then only one leds row will be on at any one time, because the only other way to control it would be to have each LED with its own output (although if i use 8 32bit chips, i could control 256 seperate LEDs, but the program would be big, and use a lot of power if all the leds are on!

anyway, i have a parcel waiting at the RM depot, and im hoping its my controller chips, so ill be able to test it with all the equipment soon.

i was thinking of using an EEPROM chip to store the data, buy then i though 'hey, its going into a computer mod. why not use the computer?' so ill need around 9 variables, and just use serin from the pc to get the data for a row, send the data via I2C, then repeat, with new serin values.

actually, i hadnt thought of running the chip at 8mHz, but the I2C commands wont work :( (ah hah! yes, you can modify it to work! ill go try that now! thanks hippy!)

thanks for all your suggestions so far, and also, some nice links there, Rickharris! i may have to do some of them even if i get this working :) if my wallet allows that is :(
 

pbunyan

Member
wow! setfreq m8 really does make it seem possible! the I2C still sends at the same speed as it is set to I2Cslow8. i think it must be the reading of the byte variable that holds it up then. next i need to try it with serin, to see if its actually possible, which i believe it is! also, serin will work at higher speeds with adjustment! its my day today :)

thanks for the help so far!
 

pbunyan

Member
yet again, triple post. sorry!

ok, so its just too slow with the serin commands. maybe i could do a simple display with an EEPROM chip holding the variables though. here is the code im using at the moment (the serin command is set to 4800, but the VB program ending the data is set to 9600, as the picaxe is running at 8MHz

main:
setfreq m8
serin 1, N4800, b1
high 3
I2Cslave %11111111, i2cslow8, i2cbyte
serin 1, N1200, b1,b2,b3
writei2c b0, (b1,b2,b3)
low 3
serin 1, N1200, b1,b2,b3
writei2c b0, (b1,b2,b3)
serin 1, N1200, b1,b2,b3
writei2c b0, (b1,b2,b3)
serin 1, N1200, b1,b2,b3
writei2c b0, (b1,b2,b3)
serin 1, N1200, b1,b2,b3
writei2c b0, (b1,b2,b3)
serin 1, N1200, b1,b2,b3
writei2c b0, (b1,b2,b3)
serin 1, N1200, b1,b2,b3
writei2c b0, (b1,b2,b3)
serin 1, N1200, b1,b2,b3
writei2c b0, (b1,b2,b3)
serin 1, N1200, b1,b2,b3
writei2c b0, (b1,b2,b3)
serin 1, N1200, b1,b2,b3
writei2c b0, (b1,b2,b3)
goto main

although you can see it flashing, it may not be so bad when there are ten columns doing it in order, although i dont know.

i have an EEPROM version of the code written, where it gets the data froma EEPROM, but my batteries gone dead, so ill have to charge it and test it later. also, ill hopefully have my output expanders be then

thanks again for your help!
 

andrewpro

New Member
Actually...youd be surprised how fast you can get the I2C to go. I've had it up to 1.6mhz with my 40X at 16mhz. Alot of times even chips that are rated for only 100khz will work at much higher speeds, but with a chance of messing up the farther overclocked it gets.

Check this out:
<A href='http://research.plistin.com/picaxe/overclocki2c.html' Target=_Blank>External Web Link</a>


Edit: I looked over your code again. As I dont know what's going on in the rest of the grand picture this may be a silly question, but why only send 3 bytes at a time? And is your serin actually only running at 1200 baud?

If you have the variables available, you can technically get 100 LED's with an incrementing address variable into one block of 14.5 bytes (15 actually). Then you only have to read values in once per page refresh. If your going to get the data all from the PC, then I woudlg et as many bytes as possible.

Another option, or an added feature, would be to use an eeprom to store the array of LED's of the common used setups, and get yourself an FC series eeprom as they can be used to 1mhz I believe. &quot;sucking and chucking&quot; from the eeprom to the expanders should be pretty quick given that I2C will easily kill picaxe serial connections speed wise. Then all you have to send fromt he PC is the &quot;page number&quot; of the display you want up.

--Andy P

--Andy P

Edited by - andypro on 22/04/2006 08:39:13
 

pbunyan

Member
wow, that links interesting, thanks!

the srial is set to 1200, but as the picaxe is running twice as fast, it was actually running at 2400. i had it running at 4800, which gave me a real spped of 9600, but that didnt really make a significant difference.

the thing is, that as the picaxe inscreases the address byte by one, it actually increases the output expanders address. all the chips have the same slave address, and then they have seperate start addresses. as this is increased by one it goes to the next set of outputs, but then after its done all of its outputs, itll switch to the next chip. i suppose if i have enough variables i could just read the data in one go, then send it different time.

anyway, im now going to try to optimise botht he serin type code, and the EEPROM code, to see how fast i can get it to go. and im sytill waiting for the output expanders in the post! thanks againfor all your help!
 

pbunyan

Member
ok, i think ive got it. at the start of the program, either a serin or EEPROM chip is used to load the display data into registers using the poke command, then a loop is run to get the info via two peek commands and put it into b0 and b1, send b0 and b1, then do it again, using 2 different register address in the peek command. of course it is somewhat more complicated than that. also i will only use the registers that the BASIC command datasheet says it is ok to use! ($50 to $7F, and then $C0 to $EF because its an 18X). and all of this will give me the the grand total of 5 frames of storage space. &lt;sarcasm&gt; woohoo &lt;/sarcasm&gt;. i suppose that 5 frames is ok, as it will only really be for simple animations, and i can use the same frame several times in a row to make it last longer. now im going to see if loading the data straight from an EEPROM chip is slower/the same as/faster than using peek. maybe if i buy a fast EEPROM chip and overclock the I2C bus (thanks again for the link!) it may work!

also, now im starting to realise how easy this would be if i had a PIC programmer (but im too cheap to buy one), and could do it directly on a PIC. faster, more outputs, and i could use a shift register approach. maybe ill buy a 40X picaxe chip and see what thats like after ive gone as far as i can with the 18X.
 
Top