Random number generator on a keychain..

modi123

Supreme [H]ardness
Joined
Sep 6, 2006
Messages
7,255
Initially I was looking portable random number generator - something that would fit on my keychain and do nothing but chunk out a number at the press of a button or a setup like the RSA key fobs (which I know use a hash to generate a specific number).

http://www.rsa.com/node.aspx?id=1156

Nothing big, just a nice geek trinket, but it seems noone sells'em. I then looked into making my own as a pet project.. well.. er... yeah.. I never took a PIC programming class (damn EE kids), and I am curious on a few things:

First, are there commerically available chips I can buy - if so, where?
Second, if there are chips how difficult would it be for a novice to wire up bread board with a LCD, battery, and one of these chips?
Third, worst case - PIC programming - I am seeing a few tutorials on the net - how much of a pain in the ass is it going to be for a n00b to pick it up quick enough and hit up a one time project?
http://www.mstracey.btinternet.co.uk/index.htm

Any advice is welcomed!
 
The RSA keys don't generate a specific number; they generate a specific series.

Your questions are pretty vague. I guess you want to buy a "commercially available chip" to generate a pseudorandom number. Your best approach to this is to use a microcontroller. It's not hard to find microcontrollers these days that very easily interface to USB ports with little extra hardware.

You'll then need to make a PC board, and a solid industrial design (that is, a case) for the module so you can carry it around without breaking it.

After that, you'll need to make a driver to get the random number from the USB on the host machine, which ever OSes you want to support, and then get it in front of the user or into the program where it's targeted.

Are you just tryin' to learin something by doing a project that interests you, or are you trying to solve some specific problem?
 
The RSA keys don't generate a specific number; they generate a specific series.

Your questions are pretty vague. I guess you want to buy a "commercially available chip" to generate a pseudorandom number. Your best approach to this is to use a microcontroller. It's not hard to find microcontrollers these days that very easily interface to USB ports with little extra hardware.

You'll then need to make a PC board, and a solid industrial design (that is, a case) for the module so you can carry it around without breaking it.

After that, you'll need to make a driver to get the random number from the USB on the host machine, which ever OSes you want to support, and then get it in front of the user or into the program where it's targeted.

Are you just tryin' to learin something by doing a project that interests you, or are you trying to solve some specific problem?

I apologize for the vagueness, I am just somewhat unsure of where to start.

Ok.. let me try and clarify - this isn't for any particular problem, I just want a random number to be generated on a small LCD, about the size of my remote entry for my car, to hang with my keys, and that's that.

I don't need any USB interface for a PC... just a self contained unit that supports a LCd, a battery, and a random number generator. I guess I will need a timer so every X seconds a new random number is created and displayed on the LCD.

Any more clear?
 
The LCD is always on, then? And always generating new numbers every few seconds? I think, then, that your biggest issue will be battery life.

It's not hard to find 1x16 characters LCD screens that have serial interfaces. I don't think I've seen any that are appropriately sized for a key chain, though.

The code to write and display the number should be less than five or seven pages long in assembly language.
 
The LCD is always on, then? And always generating new numbers every few seconds? I think, then, that your biggest issue will be battery life.

It's not hard to find 1x16 characters LCD screens that have serial interfaces. I don't think I've seen any that are appropriately sized for a key chain, though.

The code to write and display the number should be less than five or seven pages long in assembly language.

Yeah.. I was somewhat concerned about the battery life.. I guess a on/off button would be good, but that's an accessory.. lol...

As for the size, I guess my naive look at it was thinking displays off a pager or something.. I am going to guess and say those are not easy to mash into a something home brewed..

Buy a cheap Dreamcast VMU, program it and cut off anything unnecessary. http://www.maushammer.com/vmu.html

Wow.. I didn't even know this existed... interesting option..
 
www.digikey.com has some lcd modules that might work. They had 5, 6 and 8 digit modules for under $15 each. The ones I looked at briefly would require some kind of circuit board or breadboard to at least hold the leads in place. The leads coming off the module looked fairly fine and putting the chip on board like it's designed to be would make soldering a lot easier.

Here's the 6 digit one I looked as an example: http://rocky.digikey.com/scripts/ProductInfo.dll?Site=US&V=153&M=VI-602-DP-RC-S

I didn't see a voltage spec for the module but it did have the pinout. The pinout is fairly standard for segmented displays, it has a common lead then one lead for each segment of the display. Tie the common lead to ground then to turn on a segment you put a positive voltage on its corresponding lead. (Some modules are reversed where common lead is Vcc then put the other leads to ground to turn them on) As long as you have enough outputs on your controller for each segment you want to control displaying characters is easy.
 
www.digikey.com has some lcd modules that might work. They had 5, 6 and 8 digit modules for under $15 each. The ones I looked at briefly would require some kind of circuit board or breadboard to at least hold the leads in place. The leads coming off the module looked fairly fine and putting the chip on board like it's designed to be would make soldering a lot easier.

Here's the 6 digit one I looked as an example: http://rocky.digikey.com/scripts/ProductInfo.dll?Site=US&V=153&M=VI-602-DP-RC-S

I didn't see a voltage spec for the module but it did have the pinout. The pinout is fairly standard for segmented displays, it has a common lead then one lead for each segment of the display. Tie the common lead to ground then to turn on a segment you put a positive voltage on its corresponding lead. (Some modules are reversed where common lead is Vcc then put the other leads to ground to turn them on) As long as you have enough outputs on your controller for each segment you want to control displaying characters is easy.

That was pretty much the most intimidating thing I have read all day long. Arg. Ok.. I will have to dig the old 'intro to electronics' book out of my closet and start tring to remember how it all went..
 
The LCD is always on, then? And always generating new numbers every few seconds? I think, then, that your biggest issue will be battery life.

My wife has one of the RSA ones. She uses it as a secondary authentication measure for her company's intranet login. She was assigned hers when she started with the company (about two years ago) and it's still going strong.
 
My wife has one of the RSA ones. She uses it as a secondary authentication measure for her company's intranet login. She was assigned hers when she started with the company (about two years ago) and it's still going strong.

Yeah, I had one for a previous employer as well and that's where the idea came from - instead of a predefined hash just a nice random number. *shrug*
 
The LCD is always on, then? And always generating new numbers every few seconds? I think, then, that your biggest issue will be battery life.

It's not hard to find 1x16 characters LCD screens that have serial interfaces. I don't think I've seen any that are appropriately sized for a key chain, though.

The code to write and display the number should be less than five or seven pages long in assembly language.

Those RSA Key fobs work for years and you cant change any battery.
 
Those RSA Key fobs work for years and you cant change any battery.

I am going out on a limb here and saying anything I may or may not construct will not have the.... reasearch.. or optimization that RSA has put into their keychains. :D
 
Another thing I just thought of is instead of writing some algorithm to produce a purely random number, you design a Linear Feedback Shift Register which would provide you with a pseudo-random number generator.

The only two downsides are that it'll always reset back to a defined state and you'll need to test your LFSR to make sure your design doesn't get stuck at one value (such as the all-zero state)
 
Another thing I just thought of is instead of writing some algorithm to produce a purely random number, you design a Linear Feedback Shift Register which would provide you with a pseudo-random number generator.

The only two downsides are that it'll always reset back to a defined state and you'll need to test your LFSR to make sure your design doesn't get stuck at one value (such as the all-zero state)

very easy to do. Microchip has very low power and very small quad-pack PIC1845J series components that could do the trick and be lower power enough to still last many years. Or you could find very low-power small-form-factor discrete components and construct the LFSR yourself. But, doing on a uConntroller give more easy of programming.
 
Those RSA Key fobs work for years and you cant change any battery.

And LCD wristwatches have run for years on one set of batteries. I was indirectly saying that, if your biggest problem has already been solved, then you're on easy street for the rest of the project.

The smallest of the displays on the DigiKey page is an inch high across the pins, which seems a bit big for a key chain. The good news about a microcontroller is that it is a single component; using several small components to build a shift register-based generator would take more real estate.
 
using a PIC would be pretty straightforward. the code would be simple, and PIC assembly has a fairly manageable instruction set (assuming you have a good reference for the various configuration registers). the only problem i see is utilizing a display. for a really simple design you could just use a 7 segment display for a total of 16 outputs (if you use hex digits). and i guess it depends on the model (you'd need 14 dedicated i/o), but i think stringing together two 7 segment displays should pose much of a problem either, and it would be pretty straightforward as well.

there's alot of options as far as how you might do the random number generator. i might use a little state machine that display the current number on the display until a button is pressed, at which point it would generate a new number based on it's current state and clock cycle, then just sits there looping till you press the button again.

my first and last pic project involved reading in input from a potentiometer, powering a servo based on the input value, and displaying the scaled value on a 7 segment display. learning PIC assembly from scratch, and completing the project took about 3 (intense) days start to finish, so it's certainly something most people can take on and finish in a reasonable amount of time. pretty fun as well.

to fit it into a small enough form factor to use on a keychain or something you'd probably need to get a circuit board etched though. you can do this yourself, but it does require a bit of hardware (laser printer) and some practice. otherwise i think you can order them. might be able to do it with a small breadboard though iunno. i dont know much about this electronics stuff.
 
using a PIC would be pretty straightforward. the code would be simple, and PIC assembly has a fairly manageable instruction set (assuming you have a good reference for the various configuration registers).

That's what I was hoping. Glancing at some of the freeware PIC interfaces I wasn't too concerned. It's like .NET. By that I mean completely dissimilar. lol

the only problem i see is utilizing a display. for a really simple design you could just use a 7 segment display for a total of 16 outputs (if you use hex digits).

Ok.. I am loosing touch here.. 7 segements means seven digits, right? Oh, nevermind.. that's the seven bars that create the classic digital number. 16 outputs = pins.. alrighty, maybe I am not that lost.. Oh, and no hex.

and i guess it depends on the model (you'd need 14 dedicated i/o), but i think stringing together two 7 segment displays should pose much of a problem either, and it would be pretty straightforward as well.

Wait.. 14 i/o? I thought it was 16 pins.. Arg.. After a quick search it appears I might be able to do this.. Yeah.. at least a two digit display would be nice.. My new goal is to do this rough with a bread board and two seven segment displays then optimize from there.

http://www.iguanalabs.com/7segment.htm

there's alot of options as far as how you might do the random number generator. i might use a little state machine that display the current number on the display until a button is pressed, at which point it would generate a new number based on it's current state and clock cycle, then just sits there looping till you press the button again.

Clock cycles? I was thinking how to get the program to activate by a button, and a statemachine sounds grand. Additionally, I would imagine constant running won't be THAT bad for the battery.

my first and last pic project involved reading in input from a potentiometer, powering a servo based on the input value, and displaying the scaled value on a 7 segment display. learning PIC assembly from scratch, and completing the project took about 3 (intense) days start to finish, so it's certainly something most people can take on and finish in a reasonable amount of time. pretty fun as well.

Ok.. this gives me a bit of hope that I should try.. three days for assembly refresher isn't that bad.. I am more worried about the hardware side.

to fit it into a small enough form factor to use on a keychain or something you'd probably need to get a circuit board etched though. you can do this yourself, but it does require a bit of hardware (laser printer) and some practice. otherwise i think you can order them. might be able to do it with a small breadboard though iunno. i dont know much about this electronics stuff.

Yeah, I might have fibbed about the fob size. A keychain was my initial goal - maybe with a refined LCD display - but something around that big.. you know.. pocket portable.. The etching doesn't worry me that much. That's WAAY down the line.

Now the question is where to start collecting parts.. Radioshack? I think at least one of my local stores might have shit... the others are just overly large cellphone kiosks..
 
Indeed, the segments are a part of the digits. If you have eight seven-segment digits, you have to control 56 individual blocks on the display. The easiest way to do this is called multiplexing; you use seven lines in common to all the digits, then turn only one digit on at a time, changing the seven segment lines when you activate the next digit.

This way, you can use seven outputs for the segments, then three outputs (or eight, if you have to) to control the common line to the eight digits.

Some displays require bias, which makes the signalling harder, but doesn't change the idea of multiplexing.
 
Indeed, the segments are a part of the digits. If you have eight seven-segment digits, you have to control 56 individual blocks on the display. The easiest way to do this is called multiplexing; you use seven lines in common to all the digits, then turn only one digit on at a time, changing the seven segment lines when you activate the next digit.

This way, you can use seven outputs for the segments, then three outputs (or eight, if you have to) to control the common line to the eight digits.

Some displays require bias, which makes the signalling harder, but doesn't change the idea of multiplexing.

Aug, my required digital computing class is coming back to me.. and the computer architecture.. I hope my precious .NET programs do not get offended.. :)
 
Ok.. I was poking around radioshack for bits and parts, and here's what I gathered I will initially need..

Power supply:
Battery holder (0.99)
Initial layout:
breadboard ($8.39)
Display:
7 - segment display (1.79)
Pretty LEDs because I guess I can't have enough of these..
Random colorful LEDs (2.59)
I guess these will work..
Random wires (6.29)
For last part of the project when it gets real.. potentially for power on/off, or used in conjunction with the timer below and to only display/not display on the 7-segment
On/off push switch (3.99)
Timer (1.99)

Then I was looking at this, but for 80 I am not sure if I just want to go with something a bit more advanced and less frilly.. *shrug* Also it's not a "PIC" but in some varient of BASIC..
Microcontroller BASIC Stamp Kit


My general goal is to take those intial components and poke at them until I feel like moving to the more advanced, and moderatly expensive, step of the PIC..

Is there anything else I am missing - transistors, capacitors, resistors, a different power source? I would almost be happy to show up at radioshack and see they have an 'intro kit' with a majority of this crap already in it..
 
Or i could just buy...

Lotto kit

they plans are f ree, the code is as well.. hell I just gut the code I don't need, flip a few constants, and off i go..

it feels like cheating, but meh..
 
The BASIC stamp is a good place to start. You'll find the tutorials in the kit helpful since you've not done this before. The Stamp kit might seem expensive, but it includes a prototyping board and a programmer -- things you'll have to buy seperately if you get a "real" microcontroller.
 
The BASIC stamp is a good place to start. You'll find the tutorials in the kit helpful since you've not done this before. The Stamp kit might seem expensive, but it includes a prototyping board and a programmer -- things you'll have to buy seperately if you get a "real" microcontroller.

would a BASIC stampped IC operate the same way, in terms of wiring, as a PIC ic?
 
There's no standard pin out for microcontrolers, including the BASIC stamp, so I guess the answer is "no". But I'm not sure what you mean by "in terms of wiring".
 
Back
Top