??? 08/23/08 03:43 Read: times |
#157677 - 8051 random numbers revisted - tested |
It was a simple 6 LED project.
Push a button, the LED's flash, then one led lights up representing the random number generated. set a register with 00 0001 rotate left check for overflow reset value if overflow Running on a AT89C4051 at 12 MHz using assembly language. Button press interrupts generator and stores number for display after a "random" LED flashing routine (you know, for show). The project was submitted to a lab in South Africa who tested the unit for randomness and failed their test. 30,000 manual button presses produced a propability that lamp #1 would light up 4% less then the other 5. I talked to their math expert and he theorizes that the generator was running to fast. I should put a delay (1000 x) into the assembly code slowing the random number generator down. Any thoughts on this scheme fixing the problem? I used a ring counter so I could plug the value right into the serial LED driver and display the "win". The other alternative was to set a seed of #06H and DJNZ the number. Catch it on a button press and convert it to a single bit location for display. A little more software but I don't see the difference in performance in randomness between RL and DJNZ at effectively 12 MHz. No time for a hardware change as the testing facility already has the board and expects a software change to fix the problem. Does anyone have one of those fancy software simulators, and the time, to try both methods and see which one would solve this problem? |