PDA

View Full Version : LOOKUP2 please help



emilhs
- 7th May 2009, 04:13
lookup2 not counting all table. who can help?
is there any way to devide into wo parts?
or is there any way that count goes until sutain figure and then start counting backward?



Freq var word
say var byte
countera var word


loop:

If PORTB.7 =0 THEN
CounterA = 0
Yelp3:
Lookup2 CounterA,[902,902,902,884,884,884,851,851,835,820,820,806,80 6,792,778,765,_
752,740,740,716,716,705,705,683,683,653,663,663,64 4,635,618,627,602,594,578,578,557,_
564,549,531,531,519,513,501,492,475,465,465,456,44 2,434,422,414,406,389,389,373,373,_
352,334,329,318,307,296,283,279,263,252,249,238,23 2,232,238,249,252,263,279,283,296,_
307,318,329,334,352,373,373,389,389,406,414,422,43 4,442,456,465,465,475,492,501,_
513,519,531,531,549,564,557,578,578,594,602,627,61 8,635,644,663,663,653,683,683,_
705,705,716,716,740,740,752,765,778,792,806,806,82 0,820,835,851,851,884,884,884,_
902,902,902],Freq

For say=1 to 25
High PORTa.0
PauseUS Freq
Low PORTa.0
PauseUS Freq
Next say
pause 50

if PORTB.7=0 then
CounterA = CounterA + 1
if Countera < 142 then goto yelp3

endif
ENDIF
goto loop

emilhs
- 7th May 2009, 11:48
please give a hand

sayzer
- 7th May 2009, 12:08
May be something like this can/could/possibly/hopefully help !





<font color="#000000">Loop:

<font color="#000080"><b>IF </b></font>PORTB.<font color="#FF0000">7 </font>= <font color="#FF0000">0 </font><font color="#000080"><b>THEN
</b></font>CounterA = <font color="#FF0000">0

</font>Yelp3:
<font color="#000080"><b>LOOKUP2 </b></font>CounterA,[<font color="#FF0000">902</font>,<font color="#FF0000">902</font>,<font color="#FF0000">902</font>,<font color="#FF0000">884</font>,<font color="#FF0000">884</font>,<font color="#FF0000">884</font>,<font color="#FF0000">851</font>,<font color="#FF0000">851</font>,<font color="#FF0000">835</font>,<font color="#FF0000">820</font>,<font color="#FF0000">820</font>,<font color="#FF0000">806</font>,<font color="#FF0000">806</font>,<font color="#FF0000">792</font>,<font color="#FF0000">778</font>,<font color="#FF0000">765</font>,_
<font color="#FF0000">752</font>,<font color="#FF0000">740</font>,<font color="#FF0000">740</font>,<font color="#FF0000">716</font>,<font color="#FF0000">716</font>,<font color="#FF0000">705</font>,<font color="#FF0000">705</font>,<font color="#FF0000">683</font>,<font color="#FF0000">683</font>,<font color="#FF0000">653</font>,<font color="#FF0000">663</font>,<font color="#FF0000">663</font>,<font color="#FF0000">644</font>,<font color="#FF0000">635</font>,<font color="#FF0000">618</font>,<font color="#FF0000">627</font>,<font color="#FF0000">602</font>,<font color="#FF0000">594</font>,<font color="#FF0000">578</font>,<font color="#FF0000">578</font>,<font color="#FF0000">557</font>,_
<font color="#FF0000">564</font>,<font color="#FF0000">549</font>,<font color="#FF0000">531</font>,<font color="#FF0000">531</font>,<font color="#FF0000">519</font>,<font color="#FF0000">513</font>,<font color="#FF0000">501</font>,<font color="#FF0000">492</font>,<font color="#FF0000">475</font>,<font color="#FF0000">465</font>,<font color="#FF0000">465</font>,<font color="#FF0000">456</font>,<font color="#FF0000">442</font>,<font color="#FF0000">434</font>,<font color="#FF0000">422</font>,<font color="#FF0000">414</font>,<font color="#FF0000">406</font>,<font color="#FF0000">389</font>,<font color="#FF0000">389</font>,<font color="#FF0000">373</font>,<font color="#FF0000">373</font>,_
<font color="#FF0000">352</font>,<font color="#FF0000">334</font>,<font color="#FF0000">329</font>,<font color="#FF0000">318</font>,<font color="#FF0000">307</font>,<font color="#FF0000">296</font>,<font color="#FF0000">283</font>,<font color="#FF0000">279</font>,<font color="#FF0000">263</font>,<font color="#FF0000">252</font>,<font color="#FF0000">249</font>,<font color="#FF0000">238</font>,<font color="#FF0000">232</font>,<font color="#FF0000">232</font>,<font color="#FF0000">238</font>,<font color="#FF0000">249</font>,<font color="#FF0000">252</font>,<font color="#FF0000">263</font>,<font color="#FF0000">279</font>,<font color="#FF0000">283</font>,<font color="#FF0000">296</font>,_
<font color="#FF0000">307</font>,<font color="#FF0000">318</font>,<font color="#FF0000">329</font>,<font color="#FF0000">334</font>,<font color="#FF0000">352</font>,<font color="#FF0000">373</font>,<font color="#FF0000">373</font>,<font color="#FF0000">389</font>,<font color="#FF0000">389</font>,<font color="#FF0000">406</font>,<font color="#FF0000">414</font>,<font color="#FF0000">422</font>,<font color="#FF0000">434</font>,<font color="#FF0000">442</font>,<font color="#FF0000">456</font>,<font color="#FF0000">465</font>,<font color="#FF0000">465</font>,<font color="#FF0000">475</font>,<font color="#FF0000">492</font>,<font color="#FF0000">501</font>,_
<font color="#FF0000">513</font>,<font color="#FF0000">519</font>,<font color="#FF0000">531</font>,<font color="#FF0000">531</font>,<font color="#FF0000">549</font>,<font color="#FF0000">564</font>,<font color="#FF0000">557</font>,<font color="#FF0000">578</font>,<font color="#FF0000">578</font>,<font color="#FF0000">594</font>,<font color="#FF0000">602</font>,<font color="#FF0000">627</font>,<font color="#FF0000">618</font>,<font color="#FF0000">635</font>,<font color="#FF0000">644</font>,<font color="#FF0000">663</font>,<font color="#FF0000">663</font>,<font color="#FF0000">653</font>,<font color="#FF0000">683</font>,<font color="#FF0000">683</font>,_
<font color="#FF0000">705</font>,<font color="#FF0000">705</font>,<font color="#FF0000">716</font>,<font color="#FF0000">716</font>,<font color="#FF0000">740</font>,<font color="#FF0000">740</font>,<font color="#FF0000">752</font>,<font color="#FF0000">765</font>,<font color="#FF0000">778</font>,<font color="#FF0000">792</font>,<font color="#FF0000">806</font>,<font color="#FF0000">806</font>,<font color="#FF0000">820</font>,<font color="#FF0000">820</font>,<font color="#FF0000">835</font>,<font color="#FF0000">851</font>,<font color="#FF0000">851</font>,<font color="#FF0000">884</font>,<font color="#FF0000">884</font>,<font color="#FF0000">884</font>,_
<font color="#FF0000">902</font>,<font color="#FF0000">902</font>,<font color="#FF0000">902</font>],Freq

<font color="#000080"><b>FOR </b></font>Say = <font color="#FF0000">1 </font><font color="#000080"><b>TO </b></font><font color="#FF0000">25
</font><font color="#000080"><b>HIGH </b></font>PORTA.<font color="#FF0000">0
</font><font color="#000080"><b>PAUSEUS </b></font>Freq
<font color="#000080"><b>LOW </b></font>PORTA.<font color="#FF0000">0
</font><font color="#000080"><b>PAUSEUS </b></font>Freq
<font color="#000080"><b>NEXT </b></font>Say

<font color="#000080"><b>PAUSE </b></font><font color="#FF0000">50

</font>CounterA = CounterA + <font color="#FF0000">1
</font><font color="#000080"><b>IF </b></font>Countera &lt; <font color="#FF0000">142 </font><font color="#000080"><b>THEN </b></font>Yelp3

<font color="#000080"><b>ENDIF


GOTO </b></font>Loop


<font color="#000080"><b>END

</b></font>

emilhs
- 7th May 2009, 16:16
Tried this one not working

emilhs
- 7th May 2009, 23:08
is there any way to devide one table into two parts and count one part and then the second one?

Archangel
- 7th May 2009, 23:56
is there any way to divide into two parts?
Or is there any way that count goes until certain figure and then start counting backward?

In the short answer Yes sort of.
something like


repeat
counterA = counterA + 1
LOOKUP2 CounterA,[902,902,902,884,884,884,851,851,835,820,820,806,80 6,792,778,765,_
752,740,740,716,716,705,705,683,683,653,663,663,64 4,635,618,627,602,594,578,578,557,_
564,549,531,531,519,513,501,492,475,465,465,456,44 2,434,422,414,406,389,389,373,373,_
352,334,329,318,307,296,283,279,263,252,249,238,23 2,232,238,249,252,263,279,283,296,_
307,318,329,334,352,373,373,389,389,406,414,422,43 4,442,456,465,465,475,492,501,_
513,519,531,531,549,564,557,578,578,594,602,627,61 8,635,644,663,663,653,683,683,_
705,705,716,716,740,740,752,765,778,792,806,806,82 0,820,835,851,851,884,884,884,_
902,902,902],Freq
until counterA = 75
repeat
counterA = counterA - 1
LOOKUP2 CounterA,[902,902,902,884,884,884,851,851,835,820,820,806,80 6,792,778,765,_
752,740,740,716,716,705,705,683,683,653,663,663,64 4,635,618,627,602,594,578,578,557,_
564,549,531,531,519,513,501,492,475,465,465,456,44 2,434,422,414,406,389,389,373,373,_
352,334,329,318,307,296,283,279,263,252,249,238,23 2,232,238,249,252,263,279,283,296,_
307,318,329,334,352,373,373,389,389,406,414,422,43 4,442,456,465,465,475,492,501,_
513,519,531,531,549,564,557,578,578,594,602,627,61 8,635,644,663,663,653,683,683,_
705,705,716,716,740,740,752,765,778,792,806,806,82 0,820,835,851,851,884,884,884,_
902,902,902],Freq
until countera = 0

Darrel Taylor
- 8th May 2009, 00:28
lookup2 not counting all table. who can help?

The limitation of 85 values only applies to the LOOKUP2 statement.

The plain old LOOKUP can have up to 255.

Remove the 2, and your there.
<br>

Archangel
- 8th May 2009, 00:30
The limitation of 85 values only applies to the LOOKUP2 statement.

The plain old LOOKUP can have up to 255.

Remove the 2, and you're there.
<br>I didn't know about that limitation Darrel, Thank You.
EDIT: it's in the book alright! It also takes up 3 times the space as lookup.

emilhs
- 8th May 2009, 01:03
in my table only 142 figures.
I have to use one of pic18cXX controllers

Darrel Taylor
- 8th May 2009, 01:19
You don't need an 18?.

The LOOKUP statement .. NOT the LOOKUP2, will do exactly what you want, even if it's a 12F.
<br>

emilhs
- 8th May 2009, 01:24
but at the moment I use 16f84

emilhs
- 8th May 2009, 01:26
Is there any way to save count. I mean when you unpress button the count stops and when you press again the count starts from the moment it stoped before?

emilhs
- 8th May 2009, 01:30
it gives warning [202] argument out of range Least significant bits used

mister_e
- 8th May 2009, 01:42
from the manual


The LOOKUP statement can be used to retrieve values from a table of 8-bit constants.
8 bits = byte, max value = 255
so you need to use 2 LOOKUP2 table

split your lookup table in two, duplicate your code and your ready to go.

Darrel Taylor
- 8th May 2009, 01:52
Yup, your right!

LOOKUP only works with byte sized values. Woops. :o

Time for a vacation. cyaz
<br>

emilhs
- 8th May 2009, 02:23
how make simple count from 902 to 232 with step -10 and back if button is pressed?

emilhs
- 8th May 2009, 13:15
is there any way to save count? I mean if button pressed counter is counting the figures from table if button unpressed i want it to be saved some where and when button is pressed for second time i want the counting continue from the figure it stopped is it possible?

emilhs
- 8th May 2009, 13:16
from the manual


The LOOKUP statement can be used to retrieve values from a table of 8-bit constants.
8 bits = byte, max value = 255
so you need to use 2 LOOKUP2 table

split your lookup table in two, duplicate your code and your ready to go.

can you show me the sample please?

Darrel Taylor
- 8th May 2009, 22:35
Perhaps something like this ...
Freq var word
say var byte
countera var byte
PlayButton var PORTB.7
SoundOut var PORTA.0

loop:
If PlayButton = 0 THEN
For countera = 0 to 70 ; Siren UP
Gosub PlayTone
if PlayButton = 1 then ButtonUp
Next countera

For countera = 69 to 1 step -1 ; Siren Down
Gosub PlayTone
if PlayButton = 1 then ButtonUp
Next countera
endif
ButtonUp:
Pause 50
goto loop

PlayTone:
LOOKUP2 CounterA,[902,902,902,884,884,884,851,851,835,820,820,806,80 6,_
792,778,765,752,740,740,716,716,705,705,683,683,65 3,663,663,644,635,_
618,627,602,594,578,578,557,564,549,531,531,519,51 3,501,492,475,465,_
465,456,442,434,422,414,406,389,389,373,373,352,33 4,329,318,307,296,_
283,279,263,252,249,238,232],Freq

For say=1 to 25
High SoundOut
PauseUS Freq
Low SoundOut
PauseUS Freq
Next say
Return

emilhs
- 12th May 2009, 23:13
Thanks Darrel I have done slightly different way I will post it in few days may be usefull to some body