Truncated match.
PICList
Thread
'Random number generator'
1997\05\13@125131
by
Antonio Almeida
I need a routine that returns a random number to implement something similar
to CSDMA/CD. I need it to make a random wait time after a collision, i've
seem some routines but how do i get different seeds to inicialize the
routine ?
Thanks,
Antonio Almeida
1997\05\13@134532
by
Tim Kerby
Hi
Get the seed from a timer value. It makes rnd# generation much better. I
had to implement it in a toy and it works really well.
Tim
At 17:17 13/05/97 +0000, you wrote:
>I need a routine that returns a random number to implement something similar
>to CSDMA/CD. I need it to make a random wait time after a collision, i've
>seem some routines but how do i get different seeds to inicialize the
>routine ?
>
>Thanks,
>Antonio Almeida
>

Personal Web Pages: http://web.ukonline.co.uk/members/tim.kerby/
PIC Site: web.ukonline.co.uk/members/tim.kerby/pic/
The PIC Pages are under construction and I am looking for projects

1997\05\13@212757
by
John Payson

> I need a routine that returns a random number to implement something similar
> to CSDMA/CD. I need it to make a random wait time after a collision, i've
> seem some routines but how do i get different seeds to inicialize the
> routine ?
Hmm... depending upon the number of nodes in your system and how they're
powered you /may/ have a problem. While using a timer to seed your RNG is
a nice concept, it won't do much good if several PICs happened to choose
the same seed (as would be quite possible if all the machines were powered
on simultaneously). If the seeds happen to match, it doesn't matter how
many times you cycle the RNG; all the "random" numbers are going to match
as well.
In many network topologies, a node's address is used to seed the
randomdelay routine (or else simply sets a fixed delay duration). Would
such an approach be feasible for you? If every node has a unique address,
that would provide a good way of producing the "random" delays without the
"bad" cases you could get with a timerseeded RNG.
1997\05\14@032210
by
Arne Hedevang

I have made a "random" routine for a CSMA/CD network in a
16C84. I used bit03 from TMR0, it gave me a 16 step
"random" number. With 208 uSec delay pr. step, it gave
a delay from the last collision, between 0 and 3.12 mSec. (to
that, I added 5 mSec). It works very well, due to the fact, that
all the 4 MHz xtal on the network, are not synchronized.
mvh
Arne Hedevang
Denmark
> I need a routine that returns a random number to
implement something similar
> to CSDMA/CD. I need it to make a random wait time after
a collision, i've
> seem some routines but how do i get different seeds to
inicialize the
> routine ?
Hmm... depending upon the number of nodes in your system
and how they're
powered you /may/ have a problem. While using a timer to
seed your RNG is
a nice concept, it won't do much good if several PICs
happened to choose
the same seed (as would be quite possible if all the
machines were powered
on simultaneously). If the seeds happen to match, it doesn't
matter how
many times you cycle the RNG; all the "random" numbers
are going to match
as well.
In many network topologies, a node's address is used to
seed the
randomdelay routine (or else simply sets a fixed delay
duration). Would
such an approach be feasible for you? If every node has a
unique address,
that would provide a good way of producing the "random"
delays without the
"bad" cases you could get with a timerseeded RNG.
1997\05\14@045249
by
obo (Ingenieria Fotonica)
At 17:17 13/05/97 +0000, you wrote:
>I need a routine that returns a random number to implement something similar
>to CSDMA/CD. I need it to make a random wait time after a collision, i've
>seem some routines but how do i get different seeds to inicialize the
>routine ?
Hello,
I've found that performing a XOR operation with all the uninisialized
values of the user RAM at startup (in the PIC16C84), you get a good random
seed.
Adolfo.

 Adolfo Cobo Garcia  UNIVERSIDAD DE CANTABRIA 
 E.T.S.I.I. y Telecomunicacion, Grupo de Ingenieria Fotonica 
 Avda. Los Castros s/n E39005 Santander SPAIN 
 Tfno. +3442201539 Fax +3442201873 Email: spam_OUTacoboTakeThisOuTteisa.unican.es 

1997\05\14@200638
by
John Payson
> At 17:17 13/05/97 +0000, you wrote:
> >I need a routine that returns a random number to implement something similar
> >to CSDMA/CD. I need it to make a random wait time after a collision, i've
> >seem some routines but how do i get different seeds to inicialize the
> >routine ?
>
> Hello,
> I've found that performing a XOR operation with all the uninisialized
> values of the user RAM at startup (in the PIC16C84), you get a good random
> seed.
Yes, but if two PICs happen to XOR to the same value you're sunk. Even
using a 2byte XOR of user RAM is no guarantee of safety; depending upon
the characteristics of the chips you may find that certain chips tend
toward the same stuff. For a CSDMA/CD application, that would be a
killer.
1997\05\16@090839
by
Antonio Almeida

On Wed, 14 May 1997, John Payson wrote:
> > At 17:17 13/05/97 +0000, you wrote:
> > >I need a routine that returns a random number to implement something
similar
{Quote hidden}> > >to CSDMA/CD. I need it to make a random wait time after a collision, i've
> > >seem some routines but how do i get different seeds to inicialize the
> > >routine ?
> >
> > Hello,
> > I've found that performing a XOR operation with all the uninisialized
> > values of the user RAM at startup (in the PIC16C84), you get a good random
> > seed.
>
> Yes, but if two PICs happen to XOR to the same value you're sunk. Even
> using a 2byte XOR of user RAM is no guarantee of safety; depending upon
> the characteristics of the chips you may find that certain chips tend
> toward the same stuff. For a CSDMA/CD application, that would be a
> killer.
>
I think i found a solution to make a random seed generator, at least one
to solve this problem. It's something like this:
Vdd

  The function will work like this:
   PIC
   1. Pin R (output) = 0
  2. Pin R (input)
  3. Start counter
+ R 4. While R == 0 increment counter
  5. Stop counter
  6. Return counter
 
 We only need to use some very cheap components
 (with big tolerances) to get a fair random
seed generator :).
Antonio Almeida
1997\05\16@103604
by
Bob Fehrenbach
some time ago someone posted a suggestion for generating a RNG seed
using the watch dog. Essentially, the processor was allowed to
generate a watch dog reset at power up and the timer was read when
the processor was restarted. I haven't tried it but it sounds like
in may have merit.

Bob Fehrenbach Wauwatosa, WI .....bfehrenbKILLspam@spam@execpc.com
1997\05\16@120806
by
Gerhard Fiedler
At 19:06 14/05/97 +0000, John Payson wrote:
>> Hello,
>> I've found that performing a XOR operation with all the uninisialized
>> values of the user RAM at startup (in the PIC16C84), you get a good random
>> seed.
>
>Yes, but if two PICs happen to XOR to the same value you're sunk. Even
>using a 2byte XOR of user RAM is no guarantee of safety; depending upon
>the characteristics of the chips you may find that certain chips tend
>toward the same stuff. For a CSDMA/CD application, that would be a
>killer.
I'm not familiar with all the details of what you're doing, but wouldn't it
help to include some kind of a serial number in your code (that changes
with every device), and use this, maybe together with other "randomizing"
measures? Wouldn't you need some kind of individual id anyway? So just
include it in your seed calculations, and you (almost) never get two identical.
'random number generator'
1997\09\03@172301
by
Marc R Boehlen
Folks
I am new to this community and would like to ask if anyone has a routine
for a 16C84 to generate random numbers?
thanks, marc bohlen
1997\09\03@181928
by
Dave Reinagel

> Folks
>
> I am new to this community and would like to ask if anyone has a routine
> for a 16C84 to generate random numbers?
>
> thanks, marc bohlen
>
For a 16 bit pseudorandom number (2**161 states):
random res 2; reserve space for number
...
; on powerup, initialize the number to any nonzero value
movlw 1;
movwf random+1;
...
; to get the next pseudorandom number
clrf temp1; to make the next value
movfw random; get high byte
andlw 0xB4; isolate bits for exclusive or
movwf temp2;
loop: movfw temp2;
addwf temp2,f; shift temp and set Z when done
btfsc STATUS,C; check if next bit is set
incfsz temp1,f;
btfss STATUS,Z; check if temp2 is now zero
goto loop;
rrf temp1,f; get parity of random ^ 0xB4 into C
rlf random+1,f; now shift random number to the left
rlf random,f;
...
Now if you initialize the random number to the same seed everytime,
you will always get the same pattern of numbers out. So you might
want to try using the value of a timer initially to seed the pseudo
random number generator, but make sure it is not zero.
Dave Reinagel
1997\09\04@014032
by
Peter Homann

Marc R Boehlen wrote:
>
> Folks
>
> I am new to this community and would like to ask if anyone has a routine
> for a 16C84 to generate random numbers?
>
> thanks, marc bohlen
This is a routine Dave Reinagel posted a while ago.
For a 16 bit pseudorandom number (2**161 states):
random res 2; reserve space for number
...
; on powerup, initialize the number to any nonzero value
movlw 1;
movwf random+1;
...
; to get the next pseudorandom number
clrf temp1; to make the next value
movfw random; get high byte
andlw 0xB4; isolate bits for exclusive or
movwf temp2;
loop: movfw temp2;
addwf temp2,f; shift temp and set Z when done
btfsc STATUS,C; check if next bit is set
incfsz temp1,f;
btfss STATUS,Z; check if temp2 is now zero
goto loop;
rrf temp1,f; get parity of random ^ 0xB4 into C
rlf random+1,f; now shift random number to the left
rlf random,f;
...
Now if you initialize the random number to the same seed everytime,
you will always get the same pattern of numbers out. So you might
want to try using the value of a timer initially to seed the pseudo
random number generator, but make sure it is not zero.
Enjoy,
Peter.

Peter Homann email: peterhKILLspamadacel.com.au Work : +61 3 95962991
Adacel Pty Ltd Fax : +61 3 95962960
250 Bay St, Brighton 3186, VIC, AUSTRALIA Mobile : 014 025925
http://www.adacel.com.au Australian Software Engineering Excellence
More... (looser matching)
 Last day of these posts
 In 1997
, 1998 only
 Today
 New search...