| Swordfish Library - RandGen |
|
|
| Saturday, 04 April 2009 09:37 | |
|
This module implements a simple modulo-based PSEUDO Random Number Generator for Swordfish Basic. It's difficult to generate true random numbers from a deterministic machine like PIC. Hopefully, some mathematical methods let us have a series of numbers that seems really random, although they have all a fixed cycle upon which they restart to give the same series of values. this is why they are all called Pseudo random number generators. The cycling behaviour has the advantage to give you the possibility to repeat the same experience despite the fact that it's based on (pseudo) random numbers.
Usage example
Device = 18F4620 Clock = 20 Include "usart.bas" Include "convert.bas" Include "RandGen.bas" Dim RandomNumber As Byte SetBaudrate(br9600) // initialize the generator Initial Seed Value to 2 // for Full Random value you can use an ADC read on // a floating AN PIC Pin RandGen.Initialize(2) TRISB = 0 'All output While true // generates a number RandomNumber = RandGen.Rand() // write to RS233 Write(DecToStr(RandomNumber),13,10) // visualise number on PORTB leds (on my EasyPic Board) LATB = RandomNumber DelayMS(600) Wend Written by Ahmed Lazreg (octal). A simple Pseudo Random Number Generator module (modulo based).
|
|
| Last Updated ( Saturday, 18 April 2009 06:42 ) |
Whos Online
- MrDEB
Forum Activity
simulation program - mrdeb Thursday, 11 March 2010 22:52 - [0 replies]
MARCHING ledS - mrdeb Thursday, 11 March 2010 19:13 - [3 replies]
REALISTIC LED candle flicker - mrdeb Wednesday, 10 March 2010 05:48 - [0 replies]
the LCD demo hello world - mrdeb Wednesday, 10 March 2010 05:41 - [29 replies]
USB problem - jon chandler Tuesday, 09 March 2010 11:31 - [3 replies]
Servo Module - andyo Tuesday, 09 March 2010 03:39 - [3 replies]
pic to ps2 communication - roshan Friday, 05 March 2010 01:30 - [7 replies]



If this wasn't a class project that had to be done on a PIC16F690 u...
I am going to send two data from ADC to USART(async mode) to serial...
I was thinking of battery with powered routers or powered for every...
50 rooms - wow. The XBee modules are very easy to use but I'm not ...
Thanks AndyO. What I have to do is design a device to monitor temp...
The circuit used for the remote sensor can be found here: [url]http...
plz i need help do u know from where i could download it or how cou...
hello everyone i'm trying to finish my final project and i want to ...