need help in lookup


Closed Thread
Results 1 to 28 of 28
  1. #1
    Join Date
    Apr 2009
    Posts
    36

    Default need help in lookup

    please help i want to shiftout numbers from 0 to 9 .i used data eeprom it works good but it pause at 0 , now i want to use lookup or somthi9ng without saving data in eeprom .i want to shift out numbers to the leds using ic 74hc 164.it works when i use this (data @ 0,252,96,218,242,102,182,190,224,254,246) but i want to use lookup or other way not to save in the eeprom please
    this my code but doesnt work it sends unknown digit .


    define _HS_OSC & _LVP_OFF & _WDT_OFF & _CP_OFF
    define _BODEN_OFF & _MCLRE_ON & _PWRTE_ON
    DEFINE SHIFT_PAUSEUS 1000

    DEFINE OSC 4

    Include "modedefs.bas"

    B2 var word
    B1 var word

    SDO VAR PortB.0
    SCLK var PortB.1

    TRISB = 0
    porta = %00111
    SCLK = 8
    main:

    for b1 = 1 to 10

    b1 = b1+1
    b2 = b1
    pause 1000
    SHiftOUT SDO,SCLK,0,[b2]

    pause 1000

    next b1

    goto main


    lookup2 b1,[252,96,218,242,102,182,190,224,254,246],b2 'these numbers i want to shoutout them to the leds from 0 tro 9
    end
    Last edited by malwww; - 7th May 2009 at 18:17.

  2. #2
    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
    please help i want to shiftout numbers from 0 to 9 .i used data eeprom it works good but it pause at 0 , now i want to use lookup or somthi9ng without saving data in eeprom .i want to shift out numbers to the leds using ic 74hc 164.it works when i use this (data @ 0,252,96,218,242,102,182,190,224,254,246) but i want to use lookup or other way not to save in the eeprom please
    this my code but doesnt work it sends unknown digit .


    define _HS_OSC & _LVP_OFF & _WDT_OFF & _CP_OFF
    define _BODEN_OFF & _MCLRE_ON & _PWRTE_ON
    DEFINE SHIFT_PAUSEUS 1000

    DEFINE OSC 4

    Include "modedefs.bas"

    B2 var word
    B1 var word

    SDO VAR PortB.0
    SCLK var PortB.1

    TRISB = 0
    porta = %00111
    SCLK = 8
    main:

    for b1 = 1 to 10

    b1 = b1+1
    b2 = b1
    pause 1000
    SHiftOUT SDO,SCLK,0,[b2]

    pause 1000

    next b1

    goto main


    lookup2 b1,[252,96,218,242,102,182,190,224,254,246],b2 'these numbers i want to shiftout them to the leds from 0 through 9
    end
    Looks as if you almost got it, move your lookup routine up in your code to somewhere before the shiftout statement.
    Code:
    Include "modedefs.bas"
    
    B2 var byte
    B1 var byte
    
    SDO VAR PortB.0
    SCLK var PortB.1
    portB = 0          'set port latches low prior to tris
    TRISB = 0          'set all portB as outputs
    porta = %0000111   'set this way because ???
    'SCLK = 8
    
    b1 = 0
    b2 = 0
    main:
    for b1 = 0 to 9 + 1
    lookup2 b1,[252,96,218,242,102,182,190,224,254,246],b2 'these numbers i want to shoutout them to the leds from 0 tro 9
    
    
    
    SHiftOUT SDO,SCLK,0,[b2]
    
    pause 1000
    
    next b1
    
    goto main
    I changed your vars to byte as the were all less than 0 to 255
    I cleared the vars before the main loop
    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.

  3. #3
    Join Date
    Apr 2009
    Posts
    36


    Did you find this post helpful? Yes | No

    Default

    thank you very much joe for helping me .have a great day .

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


    Did you find this post helpful? Yes | No

    Default

    Hello malwww,
    If you have been following other threads, you have seen a similar one to yours. If you are using byte variables only then use lookup instead of lookup2 as the code is 1/3 as big and you can use a table of up to 255 choices. Lookup2 gives only 85 choices, which can be byte or word variables.
    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

    Smile

    hi joe thank you again for explaining to me ,i have another question please if you dont mind...i i want to write atring (lookup) to the external eeprom then i read it and send it out just to get more ideas bcz im new in pbp ,but its easy to lern than asm. have a great weekend joe


    '' 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

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

    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
    Last edited by malwww; - 10th May 2009 at 08:10.

  6. #6
    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.

  7. #7
    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,

  8. #8
    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.

  9. #9
    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.

  10. #10
    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 .!

  11. #11
    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.

  12. #12
    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

  13. #13
    Join Date
    Apr 2009
    Posts
    36


    Did you find this post helpful? Yes | No

    Default

    hi again joe.
    im trying to make a counter from 0 to 9999, i want to use the same code u fixed for me' well i use 74hc164 and 4 digit l7segment leds now i want to write a variables for 4 digits and shiftout, if it will works please im putin digits in porta.0 to 3, im confused how to use a variable works with shiftout, have a great day Joe .!

    ' 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; - 12th May 2009 at 18:03.

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


    Did you find this post helpful? Yes | No

    Default more info required

    Hi malwww,
    are you using the eeprom in this counter or just a display? Are you wanting to load count into eeprom and then display the results or just count to 9999? Am I correct in assuming SDO & SCLK are for the display ?

    It is pretty easy once you get the hang of it, overflow your counter variable into another variable and sort @ display time using the DIG statement. Look at this thread to see how, post #9 is where I posted the code to which I refer. http://www.picbasic.co.uk/forum/showthread.php?t=9037
    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.

  15. #15
    Join Date
    Apr 2009
    Posts
    36


    Did you find this post helpful? Yes | No

    Default

    hi joe im using the eeprom to save data and count them,just want to know how to vary the digits when enable digit 1 it shift out the data or number to digit 1 then digit 2 so on and remember im using shiftout to 74hc164 to drive 7 sigment digits,i want to drive 4 digit with shiftout, i will check this thread you gaved me thank you so much joe
    Last edited by malwww; - 12th May 2009 at 23:32.

  16. #16
    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 I'm using the eeprom to save data and count them,just want to know how to vary the digits when enable digit 1 it shift out the data or number to digit 1 then digit 2 so on and remember im using shiftout to 74hc164 to drive 7 sigment digits,i want to drive 4 digit with shiftout, i will check this thread you gaved me thank you so much joe
    I buy 4 digit displays from http://www.sureelectronics.net/ , usually through their eBay store. For about 15 US you get an spi display that works exactly with the code in your lookup table and it is about 32mm tall, 1 1/2 inches tall. These displays can be hooked together using cables supplied with them to make several digit displays. BTW, God helps us every day, that's why we do not starve.
    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.

  17. #17
    Join Date
    Apr 2009
    Posts
    36


    Did you find this post helpful? Yes | No

    Default

    hello joe i wrote this code now it works the 7segment and shiftout .but when i vary things it doesnt works and it doesnt show me things, i want to know where i put a variables and how, is pic cant run 2 things in the same times ? (variables and shiftout with digit out) and i keep the shiftout how it is now , please help now it show me 3210 on leds 7segments ,sorry i cant find lcds in my country and i cant send money to buy from europ or usa bcz they dont alow us to send money out, i need to call my friends in spain to buy me them but it will take long 'now im new in pbp i want to learn a bit good and sorry about my english , thank you joe


    ' I2CREAD and I2WRITE Commands

    Include "modedefs.bas"
    'DEFINE SHIFT_PAUSEUS 1

    DEFINE OSC 4
    SDO VAR PortB.0
    SCLK var PortB.1
    DPIN var PORTA.0
    CPIN var PORTA.1
    B0 var byte
    B1 var byte
    B2 var byte
    B3 var byte
    B4 var byte

    symbol Digit_1 = portb.4
    symbol Digit_2 = portb.5
    symbol Digit_3 = portb.6
    symbol Digit_4 = portb.7
    SCLK = 8

    TRISB = 0
    ' i did a variable here lookup or read but it dont work or shiftout,

    main:
    Digit_2 = 1
    Digit_3 = 1
    digit_4 = 1
    SHiftOUT SDO,SCLK,0,[252]
    Digit_1 = 0

    pause 1
    Digit_1 = 1
    Digit_3 = 1
    digit_4 = 1
    SHiftOUT SDO,SCLK,0,[96]
    Digit_2 = 0

    pause 1
    Digit_1 = 1
    Digit_2 = 1
    digit_4 = 1
    SHiftOUT SDO,SCLK,0,[218]
    Digit_3 = 0

    pause 1
    Digit_1 = 1
    Digit_2 = 1
    digit_3= 1
    SHiftOUT SDO,SCLK,0,[242]
    Digit_4 = 0

    pause 1
    goto main

    end
    Last edited by malwww; - 13th May 2009 at 18:17.

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


    Did you find this post helpful? Yes | No

    Default

    Here is what your code is doing

    Quote Originally Posted by malwww View Post
    hello joe i wrote this code now it works the 7segment and shiftout .but when i vary things it doesnt works and it doesnt show me things, i want to know where i put a variables and how, is pic cant run 2 things in the same times ? (variables and shiftout with digit out) and i keep the shiftout how it is now , please help now it show me 3210 on leds 7segments ,sorry i cant find lcds in my country and i cant send money to buy from europ or usa bcz they dont alow us to send money out, i need to call my friends in spain to buy me them but it will take long 'now im new in pbp i want to learn a bit good and sorry about my english , thank you joe


    ' I2CREAD and I2WRITE Commands

    Include "modedefs.bas"
    'DEFINE SHIFT_PAUSEUS 1

    DEFINE OSC 4
    SDO VAR PortB.0
    SCLK var PortB.1
    DPIN var PORTA.0
    CPIN var PORTA.1
    B0 var byte
    B1 var byte
    B2 var byte
    B3 var byte
    B4 var byte

    symbol Digit_1 = portb.4 <font color=red> renaming portb.4 to Digit_1, These can only hold the value 1 or 0</font color>
    symbol Digit_2 = portb.5
    symbol Digit_3 = portb.6
    symbol Digit_4 = portb.7

    SCLK = 8 <font color=red> attempt to give portb.1 the value of 8 ???</font color>

    TRISB = 0 <font color=seagreen> set all port b as outputs</font color>
    ' i did a variable here lookup or read but it dont work or shiftout,

    main:
    Digit_2 = 1 <font color = blue> Make renamed ports HIgh. </font color>
    Digit_3 = 1
    digit_4 = 1
    SHiftOUT SDO,SCLK,0,[252]
    Digit_1 = 0

    pause 1
    Digit_1 = 1
    Digit_3 = 1
    digit_4 = 1
    SHiftOUT SDO,SCLK,0,[96]
    Digit_2 = 0

    pause 1
    Digit_1 = 1
    Digit_2 = 1
    digit_4 = 1
    SHiftOUT SDO,SCLK,0,[218]
    Digit_3 = 0

    pause 1
    Digit_1 = 1
    Digit_2 = 1
    digit_3= 1
    SHiftOUT SDO,SCLK,0,[242]
    Digit_4 = 0

    pause 1
    goto main

    end
    You need to put in the REQUIRED code to disable analog stuff for your chosen PIC too or it will not do the digital dance. You need to define the TRISA values to make the proper ports inputs or outputs.
    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.

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


    Did you find this post helpful? Yes | No

    Default

    OK I am not clear on what you want to do. Are you still wanting to retrieve your lookup from external eeprom? Because that is way more code than pulling it out of your main chip. Look at my tachometer code. I stored those values in the on chip eeprom, but I could have just as easily used a lookup table in code space, the primary immediate advantage to storing it in eeprom, is if you change to a different display you can easily change the eeprom data, to match.
    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.

  20. #20
    Join Date
    Apr 2009
    Posts
    36


    Did you find this post helpful? Yes | No

    Default

    thank you joe, the problem i have is not lookup or eeprom or lcd,the problem is when i put variables the code doesnt works, like when i put the variables with the code above. i have problem when the pic start it losts betweenm the main shiftout and the variable so it doesnt work bcz im pausing the variable 1000 and shiftout is too fast so can i see the numbers on lcd ,the lcd and numbers shown good but just i add any variables it doesnt work or shift out things , i use pic 16f84 i think it hasnt analog stuff , thank you joe for your best


    for b = 0 to 9
    lookup n, [...,...,...,],bo
    or read ..,..
    pause 1000
    next b
    example
    Include "modedefs.bas"
    'DEFINE SHIFT_PAUSEUS 1

    DEFINE OSC 4
    SDO VAR PortB.0
    SCLK var PortB.1
    DPIN var PORTA.0
    CPIN var PORTA.1
    B0 var byte
    B1 var byte
    B2 var byte
    B3 var byte
    B4 var byte

    symbol Digit_1 = portb.4 renaming portb.4 to Digit_1, These can only hold the value 1 or 0

    symbol Digit_2 = portb.5
    symbol Digit_3 = portb.6
    symbol Digit_4 = portb.7

    SCLK = 8 attempt to give portb.1 the value of 8 ???
    TRISB = 0 set all port b as outputs
    for b3 = 0 to 9
    I2CREAD DPIN,CPIN,$A0,b3,[B1]
    pause 1000
    next b
    main:
    Digit_2 = 1 Make renamed ports HIgh.
    Digit_3 = 1
    digit_4 = 1
    SHiftOUT SDO,SCLK,0,[b1]
    Digit_1 = 0

    pause 1
    Digit_1 = 1
    Digit_3 = 1
    digit_4 = 1
    SHiftOUT SDO,SCLK,0,[b2]
    Digit_2 = 0

    pause 1
    Digit_1 = 1
    Digit_2 = 1
    digit_4 = 1
    SHiftOUT SDO,SCLK,0,[..]
    Digit_3 = 0

    pause 1
    Digit_1 = 1
    Digit_2 = 1
    digit_3= 1
    SHiftOUT SDO,SCLK,0,[..]
    Digit_4 = 0

    pause 1
    goto main

    end

    and shiftout the variables it keeps just blinkin very slow no numbers nothings .
    Last edited by malwww; - 14th May 2009 at 04:32.

  21. #21
    Join Date
    Apr 2009
    Posts
    36


    Did you find this post helpful? Yes | No

    Default

    hi again joe i found this link it has a few projects maybe you'll like it http://www.compsys1.com/workbench/

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


    Did you find this post helpful? Yes | No

    Default

    I wrote you a counter, here is the code, would you like fries and a coke?
    Code:
    @ __config _INTRC_OSC_NOCLKOUT & _WDT_ON & _PWRTE_ON & _MCLRE_OFF &_CP_OFF & _BODEN_OFF & _LVP_OFF
    
    DEFINE OSC 4
    
    SDO  Var PortB.4
    SCLK Var PortB.5
    DLE  Var PortB.7
    EECON1 = 7
    B0      Var WORD
    B1      Var byte
    
    D1      Var byte
    D10     Var byte
    D100    Var Byte
    D1000   Var Byte
    ONES    Var Byte
    TENS    Var Byte
    HUNS    Var Byte
    THOUS   Var Byte
    'WPUA = %00110001
    'ANSEL   = 0  ' FOR USE IN 16F690
    'ANSELH  = 0
    CCP1CON = 0
    'CM1CON0 = 0
    'CM2CON0 = 0
    CMCON = 7   ' Disable comparators 16F648A
    OPTION_REG = 0     '16f628a       
            'OPTION_REG = %00111000     ' set for 16f690  
    data @0,252,96,218,242,102,182,190,224,254,246
    Pause 10
     PORTB = 0
     PORTA = 0
     TRISB = %00000000 ' lower 4 pins outputs
     TRISA = %00000001 ' RA2 = TMR0 clock input
     
    Main:
    count portA.0,100,b1
     B0 = B0+B1   'STORE THE RESULTS BETWEEN COUNTER LOOPS
     If B0 >= 9999 then B0 = 0
    
    D1    = b0 DIG 0        ' Load Thousands Digit
        Read D1, ONES           ' Convert and Load Thousands Variable
    d10   = B0 DIG 1        ' Load Hundreds Digit
        READ D10,TENS           ' Convert and Load Hundreds Variable
    D100  = B0 DIG 2        ' Load Tens Digit
        READ D100,HUNS          ' Convert and Load Tens Variable
    D1000 = B0 DIG 3        ' Load Ones Digit
        READ D1000,THOUS        ' Convert and Load Ones Variable
    Shiftout SDO,SCLK,4,[ONES\8,TENS\8,HUNS\8,THOUS\8]   ' Send digits to display module 0
    PAUSE 10
    HIGH PORTB.7
    pulsout DLE, 125 
    pause 12
    Goto MAIN
    
    end
    Last edited by Archangel; - 14th May 2009 at 10:12.
    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.

  23. #23
    Join Date
    Apr 2009
    Posts
    36


    Did you find this post helpful? Yes | No

    Default

    thank you joe for helping i did that code im still fighting with it it didnt work but its good i have took some more ideas about variables , have a great day .!

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


    Did you find this post helpful? Yes | No

    Default

    It works here, I tried it first on 16f690, and this version on 16f628A, 16f648A and it works on both, I uses a simple blinky to drive the count as it's output is clean unlike a switch.
    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.

  25. #25
    Join Date
    Apr 2009
    Posts
    36


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Joe S. View Post
    It works here, I tried it first on 16f690, and this version on 16f628A, 16f648A and it works on both, I uses a simple blinky to drive the count as it's output is clean unlike a switch.

    hi joe, im using dsr display which has ic 74hc164 and 4 wires for each digits now i know there no ports output to count digits throu the lcd ,and ur code it works just 1 digit when i plug 1 dgit wire to the GND, i wanted to enable each port to change digits for shiftout and i use pic16f84, sorry for bothering you that much joe and thank you so much for teaching me ,


    define _config _INTRC_OSC_NOCLKOUT & _WDT_ON & _PWRTE_ON & _MCLRE_OFF &_CP_OFF & _BODEN_OFF & _LVP_OFF

    DEFINE OSC 4

    SDO Var PortB.4
    SCLK Var PortB.5
    DLE Var PortB.7
    EECON1 = 7
    B0 Var WORD
    B1 Var byte

    D1 Var byte
    D10 Var byte
    D100 Var byte
    D1000 Var byte
    ONES Var Byte
    TENS Var Byte
    HUNS Var Byte
    THOUS Var Byte
    'WPUA = %00110001
    'ANSEL = 0 ' FOR USE IN 16F690
    'ANSELH = 0
    'CCP1CON = 0
    'CM1CON0 = 0
    'CM2CON0 = 0
    'CMCON = 7 ' Disable comparators 16F648A
    OPTION_REG = 0 '16f628a
    'OPTION_REG = %00111000 ' set for 16f690
    data @0,252,96,218,242,102,182,190,224,254,246
    Pause 10
    PORTB = 0
    PORTA = 0
    TRISB = %00000000 ' lower 4 pins outputs
    TRISA = %00001 ' RA2 = TMR0 clock input

    Main:

    B0 = B0+B1 'STORE THE RESULTS BETWEEN COUNTER LOOPS
    If B0 >= 9999 then B0 = 0

    D1 = b0 DIG 0 ' Load Thousands Digit
    Read D1, ONES ' Convert and Load Thousands Variable

    d10 = B0 DIG 1 ' Load Hundreds Digit
    READ D10,TENS ' Convert and Load Hundreds Variable

    D100 = B0 DIG 2 ' Load Tens Digit
    READ D100,HUNS ' Convert and Load Tens Variable

    D1000 = B0 3 ' Load Ones Digit
    READ D1000,THOUS ' Convert and Load Ones Variable

    Shiftout SDO,SCLK,4,[ONES\8,TENS\8,HUNS\8,THOUS\8] 'when it shiftout it needs to eneble each digits bcz i have 4 wires i 'donno where i add them in this code so when it shiftout the 0 dig it enebles digit 1 on lcd then 2 so on i use digital satellite receiver 7 segments 4 digit it has 74hc164 for serial input data and clock then paralil output to 7 segments and each 1 wire ,from each digit i wanted to plug them in the pic so i need to eddit the code im still trying lol'
    PAUSE 10
    HIGH PORTB.7
    pulsout DLE, 125
    pause 12
    Goto MAIN

    end
    Attached Images Attached Images  
    Last edited by malwww; - 16th May 2009 at 14:05.

  26. #26
    Join Date
    Apr 2009
    Posts
    36


    Did you find this post helpful? Yes | No

    Default

    still waiting help, in this 7 seg with 74 hc164 ,i drawed a sample schema , thanks

  27. #27
    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, im using dsr display which has ic 74hc164 and 4 wires for each digits now i know there no ports output to count digits throu the lcd ,and ur code it works just 1 digit when i plug 1 dgit wire to the GND, i wanted to enable each port to change digits for shiftout and i use pic16f84, sorry for bothering you that much joe and thank you so much for teaching me ,


    define _config _INTRC_OSC_NOCLKOUT & _WDT_ON & _PWRTE_ON & _MCLRE_OFF &_CP_OFF & _BODEN_OFF & _LVP_OFF

    DEFINE OSC 4

    SDO Var PortB.4
    SCLK Var PortB.5
    DLE Var PortB.7
    EECON1 = 7
    B0 Var WORD
    B1 Var byte

    D1 Var byte
    D10 Var byte
    D100 Var byte
    D1000 Var byte
    ONES Var Byte
    TENS Var Byte
    HUNS Var Byte
    THOUS Var Byte
    'WPUA = %00110001
    'ANSEL = 0 ' FOR USE IN 16F690
    'ANSELH = 0
    'CCP1CON = 0
    'CM1CON0 = 0
    'CM2CON0 = 0
    'CMCON = 7 ' Disable comparators 16F648A
    OPTION_REG = 0 '16f628a
    'OPTION_REG = %00111000 ' set for 16f690
    data @0,252,96,218,242,102,182,190,224,254,246
    Pause 10
    PORTB = 0
    PORTA = 0
    TRISB = %00000000 ' lower 4 pins outputs
    TRISA = %00001 ' RA2 = TMR0 clock input

    Main:

    B0 = B0+B1 'STORE THE RESULTS BETWEEN COUNTER LOOPS
    If B0 >= 9999 then B0 = 0

    D1 = b0 DIG 0 ' Load Thousands Digit
    Read D1, ONES ' Convert and Load Thousands Variable

    d10 = B0 DIG 1 ' Load Hundreds Digit
    READ D10,TENS ' Convert and Load Hundreds Variable

    D100 = B0 DIG 2 ' Load Tens Digit
    READ D100,HUNS ' Convert and Load Tens Variable

    D1000 = B0 3 ' Load Ones Digit
    READ D1000,THOUS ' Convert and Load Ones Variable

    Shiftout SDO,SCLK,4,[ONES\8,TENS\8,HUNS\8,THOUS\8] 'when it shiftout it needs to eneble each digits bcz i have 4 wires i 'donno where i add them in this code so when it shiftout the 0 dig it enebles digit 1 on lcd then 2 so on i use digital satellite receiver 7 segments 4 digit it has 74hc164 for serial input data and clock then paralil output to 7 segments and each 1 wire ,from each digit i wanted to plug them in the pic so i need to eddit the code im still trying lol'
    PAUSE 10
    HIGH PORTB.7
    pulsout DLE, 125
    pause 12
    Goto MAIN

    end
    OK, it took some hair pulling as I am not really good with arrays.
    here is a sample as to how to do this. What you want to do is load the variable with the value to display, and display that digit, then do the next and the next. Using an array to hold the value:
    Code:
    Goldfish var byte ' cause it's late and I am tired
    Digit var byte[4] ' 4 variables all named digit, an array
    index var byte    ' a counting variable
    displays var word ' from the program
    digit_output var byte 'from the program
    ' this code changed from program
    loop:
    DIGIT_OUTPUT = DISPLAYS dig 0 ' Load Thousands Digit
    READ DIGIT_OUTPUT, DIGIT.0    ' Convert and Load Thousands Variable
    DIGIT_OUTPUT = DISPLAYS DIG 1 ' Load Hundreds  Digit
    READ DIGIT_OUTPUT, DIGIT.1    ' Convert and Load Hundreds Variable
    DIGIT_OUTPUT = DISPLAYS DIG 2 ' Load Tens of Units Digit
    READ DIGIT_OUTPUT, DIGIT.2    ' Convert and Load Tens  Variable
    DIGIT_OUTPUT = DISPLAYS dig 3 ' Load Ones of Units Digit
    READ DIGIT_OUTPUT, DIGIT.3    ' Convert and Load Units Variable
    ' notice the digits were changed to reflect the array variable name
    'here is where we do the magic
    for index = 0 to 3  '  loop 4 times
    Goldfish = digit[index]  ' load goldfish with the digit values
    shiftout SDO,SCLK,4,[Goldfish\8]  ' send the values to display
    portC.0[index] = 1 ' here we energise each display digit in sequence
    PAUSEUS 900 ' this number alters the brightness verses display flash rate
    PORTC=0 ' this blanks the numbers between loading data so it does not read 8888
    next index ' select the next digit
     GOTO LOOP
    you notice the word index in red, this syncronizes the digit selection on portc with the data being shifted out.
    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.

  28. #28
    Join Date
    Apr 2009
    Posts
    36


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Joe S. View Post
    OK, it took some hair pulling as I am not really good with arrays.
    here is a sample as to how to do this. What you want to do is load the variable with the value to display, and display that digit, then do the next and the next. Using an array to hold the value:
    Code:
    Goldfish var byte ' cause it's late and I am tired
    Digit var byte[4] ' 4 variables all named digit, an array
    index var byte    ' a counting variable
    displays var word ' from the program
    digit_output var byte 'from the program
    ' this code changed from program
    loop:
    DIGIT_OUTPUT = DISPLAYS dig 0 ' Load Thousands Digit
    READ DIGIT_OUTPUT, DIGIT.0    ' Convert and Load Thousands Variable
    DIGIT_OUTPUT = DISPLAYS DIG 1 ' Load Hundreds  Digit
    READ DIGIT_OUTPUT, DIGIT.1    ' Convert and Load Hundreds Variable
    DIGIT_OUTPUT = DISPLAYS DIG 2 ' Load Tens of Units Digit
    READ DIGIT_OUTPUT, DIGIT.2    ' Convert and Load Tens  Variable
    DIGIT_OUTPUT = DISPLAYS dig 3 ' Load Ones of Units Digit
    READ DIGIT_OUTPUT, DIGIT.3    ' Convert and Load Units Variable
    ' notice the digits were changed to reflect the array variable name
    'here is where we do the magic
    for index = 0 to 3  '  loop 4 times
    Goldfish = digit[index]  ' load goldfish with the digit values
    shiftout SDO,SCLK,4,[Goldfish\8]  ' send the values to display
    portC.0[index] = 1 ' here we energise each display digit in sequence
    PAUSEUS 900 ' this number alters the brightness verses display flash rate
    PORTC=0 ' this blanks the numbers between loading data so it does not read 8888
    next index ' select the next digit
     GOTO LOOP
    you notice the word index in red, this syncronizes the digit selection on portc with the data being shifted out.
    thnk u joe i will try it out and try to pull some hair with it,lol

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 : 1

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