James Ward
New Member
I am using a picaxe 40x2 at 64MHz to drive a 5x5x5 LED cube i made a few years ago but the problem is that the cube needs to have a high refresh rate so that the user does not perceive any flicker. However, i am using the get and put commands to store a map of 0s and 1s which shows which leds are on in each layer and then i have an if chain that turns on the corresponding LED. However, this if chain seems to be unbearably slow and i cannot find a reason for it other than that if commands must be slow on PICAXE. The first few leds light up very quickly as they are in the top layers of the if chain, however the further from the top of the elseif chain i get, the longer the led takes to light up until right at the end of even just one level there is about a 100ms delay in the led lighting up. Can anyone think of any way in which i could speed this up? The led cube works via multiplexing and thus to power an led it powers the layer and column that the led is in (it is also useful to note that for the columns, C1 C2 etc, low is on and high is off whereas for the layers, L1 L2 etc, high is on and low is off)
here's my code:
so in this code, the line:
elseif b2 = 24 then
low C25
takes about 100ms to be first called from when the loop is started. this is unacceptable as for the persistence of vision effect to be visible this needs to be at most 7 ms.
here's my code:
Code:
RENDER:
for b0 = 0 to 124
'debug
let b1 = b0 % 25
if b1 = 0 then gosub DEACTIVATE_ALL
get b0,b1
if b1 = 1 then
if b0 >= 100 then
high L5
elseif b0 >= 75 then
high L4
elseif b0 >= 50 then
high L3
elseif b0 >= 25 then
high L2
else
high L1
endif
b2 = b0 % 25
if b2 = 0 then
low C1
elseif b2 = 1 then
low C2
elseif b2 = 2 then
low C3
elseif b2 = 3 then
low C4
elseif b2 = 4 then
low C5
elseif b2 = 5 then
low C6
elseif b2 = 6 then
low C7
elseif b2 = 7 then
low C8
elseif b2 = 8 then
low C9
elseif b2 = 9 then
low C10
elseif b2 = 10 then
low C11
elseif b2 = 11 then
low C12
elseif b2 = 12 then
low C13
elseif b2 = 13 then
low C14
elseif b2 = 14 then
low C15
elseif b2 = 15 then
low C16
elseif b2 = 16 then
low C17
elseif b2 = 17 then
low C18
elseif b2 = 18 then
low C19
elseif b2 = 19 then
low C20
elseif b2 = 20 then
low C21
elseif b2 = 21 then
low C22
elseif b2 = 22 then
low C23
elseif b2 = 23 then
low C24
elseif b2 = 24 then
low C25
endif
endif
'PAUSE 1
next
return
elseif b2 = 24 then
low C25
takes about 100ms to be first called from when the loop is started. this is unacceptable as for the persistence of vision effect to be visible this needs to be at most 7 ms.