Lookup limitations

frank_p

Member
Are there any limitations on the amount of data the lookup command can use?

I have a table of 205 values but the lookup command only accepts up to 141 values. The values use are single byte values.

Any idea what is the problem?
 

Technical

Technical Support
Staff member
Technically no, but there is a limit to the maximum length of a single line of code and you have probably reached this!

Simply split into two lookups e.g. (0-127) and (128-255)

if b1 > 128 then
lookup b1....
else
b1 = b1 - 128
lookup b1....
end if
 

frank_p

Member
Unfortunately the solution didn't work out as expected. The following is the code i'm working on, maybe someone can do me a favour and provide me with a solution:

' target PICAXE - 18X
SYMBOL char = b2
SYMBOL pos = b3
SYMBOL byteOut = b4
SYMBOL col = b5
SYMBOL temp = b6

eeprom 0,("ABCD")



main:
for b1 = 0 to 255
read b1, char

' get index of character
lookdown char,("A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","1","2","3","4","5","6","7","8","9","0"),pos

' multiply by 5 to retrieve first index in 5*7 grid
pos = pos * 5

for col = 1 to 8

' 8x8 matrix and chars = 7x5 matrix
if col = 1 or col = 2 or col = 8 then goto skip

' get first value for index
if pos < 105 then
lookup pos, ($1F,$24,$44,$24,$1F,$7F,$49,$49,$49,$36,$3E,$41,$41,$41,$22,$7F,$41,$41,$41,$3E,$7F,$49,$49,$41,$41,$7F,$48,$48,$40,$40,$3E,$41,$49,$49,$2E,$7F,$08,$08,$08,$7F,$00,$41,$7F,$41,$00,$02,$01,$41,$7E,$40,$7F,$08,$14,$22,$41,$7F,$01,$01,$01,$01,$7F,$20,$10,$20,$7F,$7F,$10,$08,$04,$7F,$3E,$41,$41,$41,$3E,$7F,$48,$48,$48,$30,$3E,$41,$45,$42,$3D,$7F,$48,$4C,$4A,$31,$32,$49,$49,$49,$26,$40,$40,$7F,$40,$40,$7E,$01,$01,$01,$7E),byteOut
else
temp = pos - 105
lookup temp,($7C,$02,$01,$02,$7C,$7F,$02,$04,$02,$7F,$63,$14,$08,$14,$63,$60,$10,$0F,$10,$60,$43,$45,$49,$51,$61,$00,$21,$7F,$01,$00,$21,$43,$45,$49,$31,$41,41$,$49,$49,$36,$0C,$14,$24,$7F,$04,$71,$49,$49,$49,$46,$3E,$45,$49,$49,$26,$40,$40,$40,$40,$7F,$36,$49,$49,$49,$36,$30,$48,$48,$48,$3F,$3E,$51,$7F,$45,$3E,$00,$08,$08,$08,$00,$00,$7F,$41,$00,$00,$00,$00,$41,$7F,$00,$00,$08,$1C,$08,$00,$62,$64,$08,$13,$23),byteOut
end if

pins = byteOut ' assign value to pins
pos = pos + 1 ' move pos to next char
pause 1 ' pause 1 ms
skip: ' skip to next column
next col
pause 200
next b1
goto main
 

BeanieBots

Moderator
It might be better to explain what & why you are trying to do rather than to try and reverse engineer your code.
It may well be possible to get the desired result (whatever that might be) by making use of ASCII values and a little mathematical trickery.
 

eclectic

Moderator
Frank. To follow on from Beaniebots, exactly what is your problem?

Once the “lookup” lines have been re-spaced, your program passes a Syntax check.
It runs in the simulator, producing a variety of flashing outputs.
The “char” variable obviously only runs from 65 - 68 then remains at zero.

You must have taken HOURS to build the program, and you're probably
very close to finalising it.

e.
 

frank_p

Member
The program generates a set of bits which are output serially to a 74HC595 for a chained 8x8 matrix. The rest of the code was not added to this part because i'm testing separately.

To loop is only for valid values, the 255 needs to be changed to the length of data available (in this case ABCD).

The lookup contains the row values in Hex format.

Hope this is clear. The source data will be provided from an i2c slave chip, but this is not important at this stage.
 
Last edited:

hippy

Ex-Staff (retired)
The thing you haven't indicated so far is in what way your modified code doesn't work.

I haven't simulated or run your code but it looks like it should do what you intend, so what is it doing which isn't right ?
 

frank_p

Member
The current problem is that it gives a Compiler Error on the second lookup command.

As you might notice when there is a compiler error it just highlights the line but doesn't indicate the error type or cause.

I don't see any syntax or typing error.
 
Last edited:

frank_p

Member
Thanks for the help. I had a typing error on the second line of the second lookup. i had 41$ instead of $41.

Thanks for pointing this out. I spent 3 hours on this.
 
Top