Shop OBEX P1 Docs P2 Docs Learn Events
First Open Object(ID generator) — Parallax Forums

First Open Object(ID generator)

mctriviamctrivia Posts: 3,772
edited 2009-02-05 16:00 in Propeller 1
I just finished my first object that I put in the object exchange.

obex.parallax.com/objects/410/

It generates a unique and permanent ID number for each board you make. Any suggestions on things to make it better?

Comments

  • grasshoppergrasshopper Posts: 438
    edited 2009-01-30 15:08
    Nice. This will come in handy. Great idea
  • scottascotta Posts: 168
    edited 2009-01-30 17:20
    Hey,

    Great idea. I have a question ?

    Should this:

    if Long[noparse][[/noparse]MemoryLocation]|Long[noparse][[/noparse]MemoryLocation+4]==0

    really read like this:

    if Long[noparse][[/noparse]MemoryLocation]|Long[noparse][[/noparse]MemoryLocation+3]==0

    (swapped +4 for +3)

    Scott
  • mctriviamctrivia Posts: 3,772
    edited 2009-01-31 00:45
    nope 4 is correct. what that does is checks to see if the first 2 longs are 0. if so then it generates an id number. I could check all 8 longs but it is stetistically unlikely 1 in 2^62 that the first 2 longs would be 0
  • scottascotta Posts: 168
    edited 2009-01-31 15:47
    very cool.
  • mctriviamctrivia Posts: 3,772
    edited 2009-01-31 17:24
    thanks.
  • grasshoppergrasshopper Posts: 438
    edited 2009-02-05 15:02
    I thought about this for a bit and think that this object can not work as you expect it to. If the number is random then there is a chance that the number will repeat because it is limited by the range of the number system i.e. 0 to 32 bits. If i had a dice that had 32bits /or sides in my example/ and I kept rolling the dice ill eventually get repeats.

    Am i thinking correctly?
  • mctriviamctrivia Posts: 3,772
    edited 2009-02-05 15:09
    technically it is possible to get the same number but very unlikely. 32 bits will almost never repeat(i would bet on it for under 10,000,000) just to be safe I generate 256 bits(you could make 1 for every computer chip on earth and even randomly not get 2 the same.)
  • grasshoppergrasshopper Posts: 438
    edited 2009-02-05 15:29
    I like this object idea and agree that its a low percentage that numbers will repeat. I implemented this object and did not like the 256bit version only due to the long number that my co-workers would have to log in the log book ( even displaying it as HEX). This is when I modified it to 32 bits and it worked great as a (hex). This is when I thought that the number would repeat.

    Hum, Maybe using some letters would decrease the size and yet still able to use the 256 version.
  • mctriviamctrivia Posts: 3,772
    edited 2009-02-05 15:46
    I return it as 8 longs so you can use the number you need without Modifying.

    use x longs for you project.

    d=2^(32*x-12)

    gives only 0.02% chance of repeat. d is max devices you will build
  • mctriviamctrivia Posts: 3,772
    edited 2009-02-05 15:52
    if you want a denser coding scheme look up


    php base 64

    in google
  • grasshoppergrasshopper Posts: 438
    edited 2009-02-05 16:00
    Hum, Thanks - Ill check it out.
Sign In or Register to comment.