Quote Originally Posted by mark_s View Post
Hi Mark,
Those error messages are okay.

If I am reading your code correctly you are not off setting the index value. Each lookup2 table has a possible index address of 0 - 85. In your case you need to offset each table by 64

Something like this

If index > 64 then table2
if index > 128 then table3
if index > 192 then table4

Table1: 'No offset

Lookup2 index[1-64]var
return

Table2:

Index = index -64 'offset
Lookup2 index[65 -128]var
return
Exactly right Mark! I was forgetting to offset the Measurement variable back to zero relative to each table.

The Page Boundary errors went away too!

Thanks for the tips. I've been working on this for hours!

I think my vector is still off by one count, but substantially working code below:

Code:
'*******************************************************************************
' 
DwellTable1:
if measurement > 63 then goto DwellTable2 
'
Vector = measurement
'
lookup2 Vector,     [$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,_ '0 - 7       
                     $0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,_ '8 - 15 
                     $0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,_ '16 - 23
                     $0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,_ '24 - 31 
                     $0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,_ '32 - 39
                     $0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,_ '40 - 47
                     $0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,_ '48 - 55
                     $0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000],dacdwell '56 - 63
goto Endtable
'
DwellTable2:
if measurement > 127 then goto DwellTable3 
'
Vector = measurement - 64
'
lookup2 Vector,     [$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,_ '64 - 71
                     $0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,_ '72 - 79
                     $0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,_ '80 - 87
                     $0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,_ '88 - 95
                     $0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,_ '96 - 103
                     $0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,_ '104 - 111
                     $0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,_ '112 - 119
                     $0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000],dacdwell '120 - 127
goto Endtable
'
DwellTable3:
if measurement > 191 then goto DwellTable4
'
Vector = measurement - 128
'
lookup2 Vector,     [$5161,$4c48,$47ce,$43d1,$403f,$3d09,$3a21,$377d,_ '128 - 135  1.5pps - 2.2pps
                     $3513,$32dd,$30d4,$2ef3,$2d36,$2b99,$2a18,$28b1,_ '136 - 143  2.3pps - 3.0pps
                     $2761,$2626,$24fe,$23e7,$22e1,$21e9,$20fe,$2020,_ '144 - 151  3.1pps - 3.8pps
                     $1f4d,$1e85,$1dc6,$1d10,$1c63,$1bbe,$1b20,$1a89,_ '152 - 159  3.9pps - 4.6pps
                     $19f9,$196e,$18ea,$186a,$17ef,$177a,$1708,$169b,_ '160 - 167  4.7pps - 5.4pps
                     $1632,$15cc,$156a,$150c,$14b1,$1458,$1403,$13b0,_ '168 - 175  5.5pps - 6.2pps
                     $1360,$1313,$12c8,$127f,$1238,$11f4,$11b1,$1170,_ '176 - 183  6.3pps - 7.0pps
                     $1131,$10f4,$10b9,$107f,$1047,$1010,$0fda,$0fa6],dacdwell '184 - 191  7.1pps - 7.8pps
goto Endtable
'
DwellTable4:
'
Vector = measurement - 192
'
lookup2 vector,     [$0f74,$0f42,$0f12,$0ee3,$0000,$0000,$0000,$0000,_ '192 - 199  7.9pps - 8.2pps & 900Hz w/ no mod
                     $0000,$0000,$0000,$0000,$0000,$0000,$5161,$4c48,_ '200 - 207  900Hz w/no mod & 1.5pps - 1.6pps
                     $47ce,$43d1,$403f,$3d09,$3a21,$377d,$3513,$32dd,_ '208 - 215  1.7pps - 2.5pps
                     $30d4,$2ef3,$2d36,$2b99,$2a18,$28b1,$2761,$2626,_ '216 - 223  2.6pps - 3.3pps
                     $24fe,$23e7,$22e1,$21e9,$20fe,$2020,$1f4d,$1e85,_ '224 - 231  3.4pps - 4.1pps
                     $1dc6,$1d10,$1c63,$1bbe,$1b20,$1a89,$19f9,$196e,_ '232 - 239  4.2pps - 4.9pps
                     $18ea,$186a,$17ef,$177a,$1708,$169b,$1632,$15cc,_ '240 - 247  5.0pps - 5.7pps
                     $156a,$150c,$14b1,$1458,$1403,$13b0],dacdwell     '248 - 253  5.8pps - 6.3pps             
Endtable:
'
return
'
end