We’ll Take The Fries.

fjdkalfjdklajfdaflj

We’ve all been there; hardest decision we’ve ever had to make. College and debt or freedom but no career? Start a family or live out alone? The number 2 with a small shake or side of fries?!

[Leon] sent in his random number generator, oddly enough not to just generate a number, but help us through with those life altering decisions. Using a noise diode like setup he’s able to generate random bits, which an ATtiny24 then converts and displays on a 7 segment LED. His generator also has the ability to set upper and lower limits. Seems like an awful lot of work to avoid the freedom of choice paradox, but we enjoyed the project none the less. Check out a video after the break.

[youtube http://www.youtube.com/watch?v=UwrfKvZFOuk&feature=player_embedded%5D

32 thoughts on “We’ll Take The Fries.

  1. I’m actually more intrigued by the form factor than the circuit itself. (both are cool imo)

    I haven’t run across any hacks utilizing custom keyfobs before. I looked over his part list and see the fob is a part available from digikey. I hadn’t realized they carried such things :)

    Now I’ve got ideas running through my head for home / car automation ran from these sort of things.

  2. @smilr

    I was surprised to find how many different key fobs are easily available — just google “key fob enclosure”. Some, manufactures will even sell any quantity directly (polycase) or give you some samples. That Serpac case fit my requirements (2 buttons, room for a display, location of buttons, overall size), but it might not fit yours, so look around to find a best match (or just make a random choice…)

  3. @Franklyn

    I looked in to it but decided that wasn’t the way to go. I’d probably need the op-amp for amplification anyway — the signal right out of the transistor is only a couple mV, and the maximum resolution of the 10 bit ADC would be 3/2^10~=3mV (assuming that the ADC is really that good).

    Since the op-amp chip had two op-amps on it, using the second one to make the signal digital seemed like the way to go.

    Moreover, even if I did use the ADC directly, I’d still need to do work in software to take in the one or two useful bits per reading, debias them, make sure the number is in the right range, etc.

    If there’s a version two, I may well look in to a controller with a better ADC for this purpose, since getting rid of the op-amp would keep the part count down (although I seem to recall that AVRs with 10 bit ADCs were my only options due to size constraints… although I might be misremembering.)

  4. Nice little project, well written up. The bound setting is a nice embelshment. Hat tip to Leon {and thanks for the Pad2Pad link}.

    I’ve actually done a fair bit with practical randomisation problems, so if anyone is inspired by this hack, a few protips;

    * A pseudo-random number (PRN) generator, such as the CRC16 polynomial, either based in hard or software, isn’t *actually* random. It’s simply a count in an odd order, but *repeating*, and the first and second half of the count are mirror-images offset by one.

    For most applications a PRN is quite random enough, but in some applications a basic rule asserts itself, a digital computer cannot *alone* produce a truly random (“Stochastic”) number (i.e. where the next state cannot be determined from the current state).
    {Windoze is an exception}

    In fact it is exactly this predictability in PRN generators that is exploited in Spread Spectrum radio techniques to get the receiver PRN to slide into lock with the transmitter PRN.

    * A flicked coin toss is not truly random unless the coin is flicked strongly enough to make it rise at least a foot (30cm), it *rings* {and you quickly get a sore thumb}.

    * A simple but very effective way of generating a truly random number is to put a human in the loop. We ended up running an overflowing s/w counter flat out while waiting for button presses, rediscovering the old Apple-II trick. You could build a simple decision-maker just using a 4060 running fast, but here the microcontroller is justified by the hex range, and ease of bound setting {I really like the human>pot>micro}.

    * Multiplying random numbers together does not make them more random.

    It’s a very inviting idea that if you have a random number routine, the more often you call it, the more random it will be. Sounds logical.

    But it isn’t so.

    a) If you are using a PRN and you call it repeatedly it becomes *LESS* random, rather like the moiré effect with “watered silk”, due to self-correlation. (One odd outcome of this was a routine that never once produced the two of clubs over 30,000 deals)

    b) With stochastic noise sources (mostly analogue) multiple readings make no difference at all, the first reading of the noise diode voltage is as random as any other.

    A variation of (a) is to get a random number, then get random numbers that number of times (rand x rand), grabbing the last. As above.

    But In Real Life tossing a coin, rattling dice, or shuffling cards, it is surprising how much tossing, rattling, or shuffling is required to *actually* (not just apparently) randomise the process. {Solitaire on W95 plays quite differently to a real deck and I am very sus of their dealing routine}

    HTHH :)

  5. leon-
    You mentioned that you moved away from the PIC line because there was no free C compiler for linux and OSX. The PIC16F support looks recent but you may be interested in SDCC – sdcc.sourceforge.net .

  6. I can see it now. 2 D&D geeks are standing on a sidewalk some ware, one says something worthy of being flogged, the other reaches into his pocked dials up a key-chain to 6 (representing d6x1) and says “Roll you charisma!”

  7. People complain they need to pay for studying but meanwhile once they have a degree they are assured a high income forever basically, get over yourself eh, you can only complain if you were actually prevented by the cost, not if you could make it but just don’t like to pay.

Leave a Reply to nave.notnilcCancel reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.