how can I caculate with numbers bigger than a word using 16F88 ?


Closed Thread
Results 1 to 10 of 10

Hybrid View

  1. #1
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    I'm trying to rid the world of 16F chips, but try this

    http://www.picbasic.co.uk/forum/show...ght=n-bit_math
    Charles Linquist

  2. #2
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    969


    Did you find this post helpful? Yes | No

    Default

    What is x20?
    what is f0?
    what is x?

    A little more detail and it is possible that a different solution exists.

    The last time I did something similar, I had a pulses per mile count. After that the mile count would increase by 1. To handle numbers as big as 99999999 you can do it in code like I did

    Pseudo code begins
    Code:
    miles[4]    var    byte         ' lsb to msb
    
            on input pulse,  pulses=pulses+1
            
            if pulses >= Pulsespermile
                  pulses = 0                               ' start counting again till we reach pulses per mile
    
                  miles[0] = miles[0]+1
                  if miles[0] > 99 then
                       miles[0]  =0
                       miles[1] = miles[1]+1
                       if miles[1] > 99 then
                            miles[1] = 0
                            miles[2] = miles[2]+1
                            if miles[2] > 99 then
                                  miles[2] = 0
                                  miles[3] = miles[3]+1
                                  if miles[3] > 99 then
                                       miles[3] = 0   ' roll over to all zero
                                  endif
                            endif
                        endif
                  endif
           endif
    Now, displaying this is easy.
    Code:
          Num = miles[0] dig 1                ' first digit to display
          digitpos = 0
          gosub displaynum                   ' show the number
    
          Num = miles[0] dig 0                ' 2nd digit to display
          digitpos = 1
          gosub displaynum                   ' show the number
    
          Num = miles[1] dig 1                ' 3rd digit to display
          digitpos = 2
          gosub displaynum                   ' show the number
    
          Num = miles[1] dig 0                ' 4th digit to display
          digitpos = 3
          gosub displaynum                   ' show the number
    
    and so on

  3. #3
    Join Date
    May 2010
    Location
    Royston Vasey, UK
    Posts
    3


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Charles Linquis View Post
    I'm trying to rid the world of 16F chips...
    I'm with you, Charles, but is there a PIC18 that is nearly the same price as a PIC16F88? I'm doing a low cost consumer product right now where 40 cents makes a big difference. Until that time, that evil PIC16F architecture lives on.
    These are the good old days.

  4. #4
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    In some cases,(like high-volume applications), the 16F series makes sense. But too often I see people that work hours (or tens of hours) longer to get something to work because they started out with an inadequate chip on a one-off project.
    Charles Linquist

  5. #5
    Join Date
    May 2007
    Posts
    604


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by NullDevice View Post
    I'm with you, Charles, but is there a PIC18 that is nearly the same price as a PIC16F88? I'm doing a low cost consumer product right now where 40 cents makes a big difference. Until that time, that evil PIC16F architecture lives on.
    According to here PIC16F88 the lowest cost device is $2.20 - if you go here PIC18 Product Family and do a sort on ascending price, you will find about 45 PIC18's that cost less than a PIC16F88. That said, I use several competitive 32-bit devices that are about half that price.

  6. #6
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Not sure, but maybe you can just change 1-line.

    Code:
    '---[INT - interrupt handler]---------------------------------------------------
    ToggleLED1:
       cnt = cnt +1
       cntb = cnt * 20 ; could be * 1000
       meter = DIV32 f0 
       If meter = x Then  
         meter = 0
         km = km + 1
         cnt = 0
       Endif
    @ INT_RETURN
    Depends on what f0 and x are.
    DT

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


    Did you find this post helpful? Yes | No

    Cool

    If you are looking for costs ... forget all this old 16F... or 18F...-devices.

    Take new cheap dsPic33 or ...J... or ...K... -devices.
    The new devices are very cheap, the old stuff is expensive !!!!
    PBP 2.50C, MCS+ 3.0.0.5, MPLAB 8, MPASM 5.14, ASIX Presto, PoScope, mE mikroBasic V7.2, PICKIT2

  8. #8
    Join Date
    Nov 2007
    Location
    South-West of Australia. A small town called Denmark. 'Where the forest meets the sea.'
    Posts
    136


    Did you find this post helpful? Yes | No

    Default Big Numbers

    Not an economic solution but great fun is the 'floating point co-processor' from Micromega. Costs about $20. the free IDE make developing the code a doddle.

    Regards Bill Legge

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