need help in lookup


Closed Thread
Results 1 to 28 of 28

Hybrid View

  1. #1
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by malwww View Post
    hi Joe thank you again for explaining to me ,I have another question please if you dont mind...I want to write a string (lookup) to the external eeprom then I'll read it and send it out just to get more ideas because I'm new in pbp ,but its easier to learn than asm. have a great weekend Joe
    Code:
    '' I2CREAD and I2WRITE Commands
    
      Include "modedefs.bas"          
      DEFINE I2C_SLOW 1
      DEFINE SHIFT_PAUSEUS 1000
    SDO VAR PortB.0
    SCLK var PortB.1
             
    SCLK = 8
    SO      con     0                      
    DPIN    var     PORTA.0                 
    CPIN    var     PORTA.1               
    B0      var     byte
    B1      var     byte
    B2      var     byte
    B3      var     byte
    n       var     byte 
    portB = 0          
    TRISB = 0 
     'for n = 0 to 15 <font color = red>' commented out </font color>
    
    <font color=green>you have setup your variables, and stored nothing in them yet, and are proceeding to lookup the value of "n" which is unknown to you,</font color>
    lookup  n,[252,96,218,242,102,182,190,224,254,246],b0 ' numbers from 0 to 9
     <font color=green>'the following loop will output the value stored in "n" filtered through the lookup table 15 times,
    always the same number,in each eeprom location. 
    why the str modifier? 
    Seems to me the numbers in the lookup table are
    not string values, as they would be arranged between
    quotation marks like so "252","96" . . .</font color>
            For B2 = 0 To 15
                            
                    I2CWRITE DPIN,CPIN,$A0,b2,[str B0\8]  
                    Pause 20                
            
            
            Next B2
            'next n
    
    loop:   For B3 = 0 To 15          
                    I2CREAD DPIN,CPIN,$A0,B3,[B1] 
                     pause 1000
                    
                    SHiftOUT SDO,SCLK,0,[b1]
                           '
                          
            Next B3
    
            
    
            Goto loop
            end
    i wrote this code but it doesnt shiftout the numbers from 0 to 9 like i have in the string .but it works good with last programe you fixed for me .see u joe
    are you seeing what you need to change ?
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  2. #2
    Join Date
    Apr 2009
    Posts
    36


    Did you find this post helpful? Yes | No

    Default

    I DIDNT UNDERSTAND GOOD JOE, DO I HAVE TO PUT QUOTATIONS?
    BCZ I HAVE A PROBLEM TO WRITE IN THE EEPROM ,WHEN I READ THEM IT SHOW MW DEFFIRENT DATA,I STORED THOSE NUMBERS IN THE EEPROM USING THE PROGRAMER WHEN I READ THEM IT WORKS GOOD ,THE PROBLEM I HAVE IS TO WRITE TO THE EEPROM AND WHEN I WRITE JUST 1 NUMBER IT WORKS GOOD ,

    lookup n,[252,96,218,242,102,182,190,224,254,246],b0 ' numbers from 0 to 9
    For B2 = 0 To 9

    I2CWRITE DPIN,CPIN,$A0,b2,[str B0\8]
    Pause 20


    Next B2

    THANK YOU FOR HELPING ME JOE,

  3. #3
    Join Date
    Apr 2009
    Posts
    36


    Did you find this post helpful? Yes | No

    Default

    [thank you joe got it now it works have a great day ...


    ' I2CREAD and I2WRITE Commands

    Include "modedefs.bas"

    DEFINE SHIFT_PAUSEUS 1000
    SDO VAR PortB.0
    SCLK var PortB.1

    SCLK = 8

    DPIN var PORTA.0
    CPIN var PORTA.1
    B0 var byte
    B1 var byte
    B2 var byte

    N var byte
    portB = 0
    TRISB = 0

    pause 100

    For B2 = 0 To 9
    lookup b2,[252,96,218,242,102,182,190,224,254,246],b0
    I2CWRITE DPIN,CPIN,$A0,b2,[ b0]
    Pause 20
    Next B2

    loop: For B3 = 0 To 9
    I2CREAD DPIN,CPIN,$A0,b3,[B1]
    pause 1000

    SHiftOUT SDO,SCLK,0,[b1]
    '
    Next B3

    Goto loop
    end
    Last edited by malwww; - 10th May 2009 at 22:05.

  4. #4
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    GOOD ! Glad you have it working the way You want it.
    Now I am curious, what are you making? I am guessing
    you intend to do more than store 0 - 9 in the eeprom.
    There are dozens of examples here to do something similar
    to what you have in mind, whatever it is. Google can search
    just this forum if you use this link.
    http://www.google.com/custom?hl=en&c...ch&sitesearch=
    just check the check box that says, Search picbasic.co.uk. and you are set.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  5. #5
    Join Date
    Apr 2009
    Posts
    36


    Did you find this post helpful? Yes | No

    Default

    thank you joe for explaining to me things ,im always here,i really want to lern pbp good bcz im interesting,i posted another thread about VGA box if you have any ideas i want to share with everyone so we can build it , hope you are doing good .!

  6. #6
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Hi malwww,
    I just added to this post based upon helping you, you may recognise some of it

    http://www.picbasic.co.uk/forum/show...4040#post74040
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  7. #7
    Join Date
    Apr 2009
    Posts
    36


    Did you find this post helpful? Yes | No

    Default

    thank you so much joe,its good i got more ideas from that thread you added,see you soon joe

Similar Threads

  1. Graphic LCD with PICbasic pro
    By amindzo in forum mel PIC BASIC Pro
    Replies: 41
    Last Post: - 25th November 2012, 11:45
  2. Lookup Table
    By yasser hassani in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 11th March 2008, 10:38
  3. ADCIN and LOOKUP ...
    By Acetronics2 in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 16th June 2007, 21:02
  4. problem with USART
    By leemin in forum Serial
    Replies: 4
    Last Post: - 11th December 2006, 17:56
  5. Confused On Dig & Lookup
    By SOMRU in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 5th December 2006, 21:49

Members who have read this thread : 0

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

Tags for this Thread

Posting Permissions

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