Fullfilling lookup tables


Closed Thread
Results 1 to 16 of 16
  1. #1
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,648

    Question Fullfilling lookup tables

    Hi, Everybody

    Suppose we want to have a 250 values LOOKUP table ....

    Writing all values by hand is quite boring and not error-free guaranteed ... isn't it ???

    Now, working with MPLAB ( or else ) permits to locate the beginning of the RETLW xx list in the ASM listing .... and we know how to include a text file containing RETLW xx 's , ... coming from an Excel page or so ... precomputing media.

    Would it be possible to find something to include the DATA file into the PbP brackets ( easiest solution !!! ), or a modifier, i.e " REP x\250 ", or another trick to keep free space in the ASM Listing to allow including the DATA file .... ????

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Or i'm dumb or i need more cofee but i can't figure out what you ask for.

    Please, help the old Quebecer guy to understand. It sounds an interesting idea overall, it's just unclear to me...

    Un dessin, un dessin, un dessin
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,648


    Did you find this post helpful? Yes | No

    Wink Bad trip ???

    Hi, Steve

    No design needed .... just strong coffee.

    You want a big lookup table ... how to fill automatically, from an existing text file, the values between the brackets ???

    Of course with a PbP source program ...

    1St way : a modifier in the LOOKUP statement, plus including the file at the right ASM line ???
    2Nd way : include the text file between the brackets ...????
    3Rd way : ????

    Last way: Modify the Lookup routine !!!
    Lazy way : Copy and Paste .....

    PbP 's hard point is there is a L 00001 label that is inserted by the compiler just past the LOOKUP routine ... so, impossible to only use the ORG directive to make room !!! The brackets must contain the right number of constants ...

    Alain
    Last edited by Acetronics2; - 25th July 2006 at 15:04.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  4. #4


    Did you find this post helpful? Yes | No

    Default

    Hi Alain. If you figure out a way to do this, it would help alot. Right now I'm using about 8K of code space that repeats the same opcode to an ISD5008 using the shiftout command. However, each opcode has a different address. To put these different addresses between the brackets into a lookup table re-using one opcode would shorten the code much.

  5. #5
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,648


    Did you find this post helpful? Yes | No

    Default

    Hi,Peter

    The only way I see at the moment is to create a simple program ( GW or QBasic ...) that gives your DATA bytes separated by a comma ... into a .txt file.

    Then, you copy it and paste between the brackets. so simple as this !!!

    Of course it must exist a mathematical relation between input and output ... or the loading can't be made else than by-hand !!!

    I think I'll have a look to the SIN routine in the PbP libs ... to see if it's possible to modify it. ( or a similar routine )

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  6. #6


    Did you find this post helpful? Yes | No

    Default

    Hi Alain. I guess I wasn't being clear in my last post. For example, someone pushes a series of buttons. Each button is a different ISD address. Now comes playback time. What I have done that is memory intensive is this:

    ShiftOut PORTC.5,PORTC.3,0,[FIRST\16] 'first is variable for 1st playback address
    ShiftOut PORTC.5,PORTC.3,0,[SECOND\16] 'second is variable for 2nd playback address
    ShiftOut PORTC.5,PORTC.3,0,[THIRD\16] 'third is variable for 3rd playback address

    Now, if those variables were written into the program by itself such as [224,132,188] I could use the lookup command, put it into X and use something like:

    ShiftOut PORTC.5,PORTC.3,0,[X\16] 'X is variable for all addresses
    next X

    Right now I have 20 address variables & 20 shiftout commands and a large block of code that says LET FIRST = 111, LET SECOND = 222, etc. I even thought of using read & write but the problem is getting those numbers into brackets. - Peter

  7. #7
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    the only thing that spring to mind is the use of dt or da... for now. Kind of variation of embedded string in your codespace. But you'll have to use readcode instead... too bad
    Code:
    DEFINE LOADER_USED 1
    DEFINE OSC 20
    DEFINE HSER_RCSTA 90h
    DEFINE HSER_TXSTA 24h
    DEFINE HSER_SPBRG 129 ' 9600 Bauds
    
    
    @CSize=CODE_SIZE  ; get the PIC Codespace size
    CSize con ext     ' make it available in PBP
    LookupSize  con 50     
    ZAData      VAR word
    ZAAddr      VAR word
    LookupStart var word
    
    LookupStart=(CSize*1024)-512 ' get the Lookup first address
                                 ' As i used the bootloader i just move 
                                 ' the adress to a x place
    
    Start:
        FOR ZAAddr=LOOKUPSTART TO LOOKUPSTART+lookupsize
            READCODE zaaddr, zadata
            zadata=zadata&$FF
            HSEROUT [dec zadata,13,10]
            pause 500
            NEXT
        pause 500
        goto start
    
    
    
        asm
        org ((CODE_SIZE*D'1024')-D'512')
        dt 10 ,20 ,30 ,40 ,50 
        dt 60 ,70 ,80 ,90 ,100
        dt 110,120,130,140,150
        dt 160,170,180,190,200
        dt 210,220,230,240,250
        dt 240,230,220,210,200
        dt 190,180,170,160,150
        dt 140,130,120,110,100
        dt 90 ,80 ,70 ,60 ,50
        dt 40 ,30 ,20 ,10 ,0
        endasm
    even there, there's no gain in time and on nothing about typing IMHO. You should do a cute app in VB or else who write the whole LOOKUP line for you and send it to the clipboard... then just paste it to your code. It's still easy to read any ACCESS or EXCEL speadsheet from VB.

    Anyways, you can also export the excel sheet in text format and select the separator you want. No need fr a VB app or else OR once again i miss something?
    Last edited by mister_e; - 25th July 2006 at 21:07.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  8. #8
    Join Date
    Oct 2004
    Location
    Hangover, Germany
    Posts
    289


    Did you find this post helpful? Yes | No

    Exclamation

    Use Excel!

    the first column contains the data (numbers), the second a formula like ="RETLW " & A1


    I prefer to use "@ DE" to put data inside the programcode and READBYTE to get them back.
    Usind more than 8 bit is a little bit tricky - processor - pbp - assembler don't realy fit together in every combination.
    PBP 2.50C, MCS+ 3.0.0.5, MPLAB 8, MPASM 5.14, ASIX Presto, PoScope, mE mikroBasic V7.2, PICKIT2

  9. #9
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by BigWumpus
    I prefer to use "@ DE" to put data inside the programcode and READBYTE to get them back.
    Usind more than 8 bit is a little bit tricky - processor - pbp - assembler don't realy fit together in every combination.
    As far as i'm aware of... @ DE store into the EEPROM, not the codespace at all. and there's not benefit to use it unless you want to specify some label. DATA do the same thing.

    And READBYTE don't exist in PBP.. just READ
    Last edited by mister_e; - 25th July 2006 at 21:15.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  10. #10
    Join Date
    Oct 2004
    Location
    Hangover, Germany
    Posts
    289


    Did you find this post helpful? Yes | No

    Default

    Ups....

    I have to return the last 4000 controllers tomorrow ? ;-)

    Use READCODE instead of READBYTE (it's the name of my sub)
    PBP 2.50C, MCS+ 3.0.0.5, MPLAB 8, MPASM 5.14, ASIX Presto, PoScope, mE mikroBasic V7.2, PICKIT2

  11. #11
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,648


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mister_e
    Anyways, you can also export the excel sheet in text format and select the separator you want. No need fr a VB app or else OR once again i miss something?
    Hi, Steve

    I already do have such application .... LOL !!! May be I'll post you for a barrel of Maple syrup or two ...

    I had a look to Lookup Macro .... Ayayaye, quel malheur !!! ... easier to write my own Assembler Macro locating the table(s) in the very high part of the memory.

    Just a filter on Pic number or MAXRAM value to set the table address ... and that should be much,much,much,much faster than a Lookup !!! ( Stopwatch made me reddish ...)

    Thinking also to add an interpolation between successive values ... but that can easily be made with PbP.

    Readcode ...??? might have been nice ... if working with all common Pics.

    Alain
    Last edited by Acetronics2; - 26th July 2006 at 11:03.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  12. #12
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    All i can say is usually when i need to use Lookup Table, i store them in a external EEPROM, using Excel or whatsoever else custom program make life easy. Well case by case i guess. I try to keep codespace for what it's suppose to be used... code.

    What PIC do you plan to use? Any 18Fs? if so there's already some built-in TABLR plah plah stuff.

    I already do have such application .... LOL !!! May be I'll post you for a barrel of Maple syrup or two ...
    Hehe they're still some available 'round here. The best time is always in spring... after that it's mostely called Sirop de poteau
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  13. #13
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,648


    Did you find this post helpful? Yes | No

    Default

    Hi,Steve

    I do not use 18F devices to that day ... small 18 pins packages show too many bugs !!!

    .... and EEPROMS are really too slow for what I do ... // FRam could be used !!!

    Back to the subject,

    the goal is just to add " include C:\ .... table.txt " to the listing !!!

    here, a clean XL / VB Sheet, just the print-to-file work to add !!!

    Cheese ...

    Alain
    Attached Files Attached Files
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  14. #14
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Thumbs up

    Neat! well done!
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  15. #15
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,648


    Did you find this post helpful? Yes | No

    Wink Finally, What that gives ....

    Hi, Steve

    After lots ( LOL ) of trails, I went to commit that ...

    The table loads great !!! ... full Program hasn't been " live tested" yet ... ( re LOL )

    Alain

    PS: IF PIR1.2 THEN ... at the beginning, has being modified for simulation ( good read is : IF NOT PIR1.2 ... of course, dear Mr Watson ... )
    Attached Files Attached Files
    Last edited by Acetronics2; - 31st July 2006 at 14:58.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  16. #16
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    hehe... way to go Monsieur!
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

Similar Threads

  1. PICs can do more if use others than delays instructions
    By hardcore in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 24th February 2010, 19:52
  2. ADCIN and LOOKUP ...
    By Acetronics2 in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 16th June 2007, 21:02
  3. problem with USART
    By leemin in forum Serial
    Replies: 4
    Last Post: - 11th December 2006, 17:56
  4. Confused On Dig & Lookup
    By SOMRU in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 5th December 2006, 21:49
  5. Using large lookup tables
    By speck in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 16th April 2006, 21:40

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts