Shop OBEX P1 Docs P2 Docs Learn Events
Working with a 10 digit number — Parallax Forums

Working with a 10 digit number

JonathanJonathan Posts: 1,023
edited 2009-04-13 00:42 in BASIC Stamp
Hi All,

I'm helping a friend with an art project. It's a cool sounding big installation, and one part of it is a Nixie counter that is tracking the population of the world. So, we need to use a 10 digit number, then shift it out to five 74HC595's. So the question is, how do we increment a 10 digit number, then break it up into nibs?

He has been busting his but to get it done by openeing, which is tomorrow. Last jnight at 4:00 AM he got the nixies working. So help would be much appreciated!

Jonathan


▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.madlabs.info - Home of the Hydrogen Fuel Cell Robot

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2009-04-12 22:09
    Easiest thing to do is use a Nibble array like:
    counter VAR nib(10)
    i VAR nib
    carry VAR bit
    
    initialize:
      for i = 0 to 9
        counter(i) = 0
      next
      return
    
    addOne:
      carry = 1
      for i = 0 to 9
        counter(i) = counter(i) + carry
        if counter(i) = 10 then
          counter(i) = 0
          carry = 1
        else
          carry = 0
        endif
      next
      return
    
  • SRLMSRLM Posts: 5,045
    edited 2009-04-12 22:11
    The most that a BS2 can handle is 16 bits, or some 5 digit numbers, or all 4 digit numbers. My suggestion would be to break it the 10 digit number into 2 + 4 + 4. The 2 and maybe first four will be constant, the last four will change. You'll have to write your own over flow testing routines to increment the next group of numbers (ie, if word 3 > 9999 then word 2 += 1). Mostly, it's straight forward programming.
  • JonathanJonathan Posts: 1,023
    edited 2009-04-13 00:42
    Perfect Mike! Perfect! Took about two minutes to get working. Thanks!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    www.madlabs.info - Home of the Hydrogen Fuel Cell Robot
Sign In or Register to comment.