Searching \ for '[PIC]: Pseudo-Random numbers' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/math/index.htm?key=random
Search entire site for: 'Pseudo-Random numbers'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: Pseudo-Random numbers'
2001\08\18@233533 by Ron Anthony

flavicon
face
Hello all.  I need to generate numbers that appear to be ranomized, it makes
no difference if they are truly random.  I can seed it with a value culled
from ram before i wipe the ram, but it's not necessary.

Any simple code to generate a seemingly random number, from 0 to 255?

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email spam_OUTlistservTakeThisOuTspammitvma.mit.edu with SET PICList DIGEST in the body


2001\08\19@003419 by David VanHorn

flavicon
face
At 11:36 PM 8/18/01 -0400, Ron Anthony wrote:
>Hello all.  I need to generate numbers that appear to be ranomized, it makes
>no difference if they are truly random.  I can seed it with a value culled
>from ram before i wipe the ram, but it's not necessary.
>
>Any simple code to generate a seemingly random number, from 0 to 255?

I have a 19 bit PN generator implementation in AVR code on my web site.
It's in the "getting started" firmware, under microcontrollers.
You shouldn't have any trouble porting it over to picish.


--
Dave's Engineering Page: http://www.dvanhorn.org

I would have a link to http://www.findu.com/cgi-bin/find.cgi?KC6ETE-9 here
in my signature line, but due to the inability of sysadmins at TELOCITY to
differentiate a signature line from the text of an email, I am forbidden to
have it.

--
http://www.piclist.com hint: To leave the PICList
.....piclist-unsubscribe-requestKILLspamspam@spam@mitvma.mit.edu


2001\08\19@041533 by Ron Anthony

flavicon
face
Dave, any 8 bit prefab for PIC?  call me lazy...

-----Original Message-----
From: pic microcontroller discussion list
[PICLISTspamKILLspamMITVMA.MIT.EDU]On Behalf Of David VanHorn
Sent: Sunday, August 19, 2001 12:34 AM
To: .....PICLISTKILLspamspam.....MITVMA.MIT.EDU
Subject: Re: [PIC]: Pseudo-Random numbers


At 11:36 PM 8/18/01 -0400, Ron Anthony wrote:
>Hello all.  I need to generate numbers that appear to be ranomized, it
makes
>no difference if they are truly random.  I can seed it with a value culled
>from ram before i wipe the ram, but it's not necessary.
>
>Any simple code to generate a seemingly random number, from 0 to 255?

I have a 19 bit PN generator implementation in AVR code on my web site.
It's in the "getting started" firmware, under microcontrollers.
You shouldn't have any trouble porting it over to picish.


--
Dave's Engineering Page: http://www.dvanhorn.org

I would have a link to http://www.findu.com/cgi-bin/find.cgi?KC6ETE-9 here
in my signature line, but due to the inability of sysadmins at TELOCITY to
differentiate a signature line from the text of an email, I am forbidden to
have it.

--
http://www.piclist.com hint: To leave the PICList
EraseMEpiclist-unsubscribe-requestspam_OUTspamTakeThisOuTmitvma.mit.edu

--
http://www.piclist.com hint: To leave the PICList
piclist-unsubscribe-requestspamspam_OUTmitvma.mit.edu


2001\08\19@113024 by Jeff DeMaagd

flavicon
face
----- Original Message -----
From: Ron Anthony <@spam@ronantKILLspamspamOPTONLINE.NET>


> Dave, any 8 bit prefab for PIC?  call me lazy...

A better thing to do would be to search the PIClist site.  There is a lot of
good stuff there and code or algorithms to solve most common problems.  It
saved me a post or two looking there _before_ asking a question.

Jeff

--
http://www.piclist.com hint: To leave the PICList
KILLspampiclist-unsubscribe-requestKILLspamspammitvma.mit.edu


2001\08\19@120714 by Olin Lathrop

face picon face
> Any simple code to generate a seemingly random number, from 0 to 255?

See HAL_RAND.ASPIC at http://www.embedinc.com/pic/hal.htm.


********************************************************************
Olin Lathrop, embedded systems consultant in Littleton Massachusetts
(978) 742-9014, RemoveMEolinTakeThisOuTspamembedinc.com, http://www.embedinc.com

--
http://www.piclist.com hint: To leave the PICList
spamBeGonepiclist-unsubscribe-requestspamBeGonespammitvma.mit.edu


2001\08\19@124644 by David VanHorn
flavicon
face
At 04:17 AM 8/19/01 -0400, Ron Anthony wrote:
>Dave, any 8 bit prefab for PIC?  call me lazy...

Nope, sorry.
The closest would be a 7 bit version, and I don't have any pic code on my
site.
You can find the method in the later ARRL handbooks, under specialized
communications.

--
Dave's Engineering Page: http://www.dvanhorn.org

I would have a link to http://www.findu.com/cgi-bin/find.cgi?KC6ETE-9 here
in my signature line, but due to the inability of sysadmins at TELOCITY to
differentiate a signature line from the text of an email, I am forbidden to
have it.

--
http://www.piclist.com hint: To leave the PICList
TakeThisOuTpiclist-unsubscribe-requestEraseMEspamspam_OUTmitvma.mit.edu


2001\08\20@012244 by jeethur

flavicon
face
JAL has a library called random3, Which can generate Pseudo Random Bytes.
If you have a look at the code, Translating it to assembly could be easy.

Jeethu Rao

> {Original Message removed}

2001\08\20@040513 by Quentin

flavicon
face
From piclist.com:
www.piclist.com/techref/microchip/rand8bit.htm
I used:
LFSR:   RLF     RANDOM,W
                RLF     RANDOM,W
                BTFSC   RANDOM,4
                XORLW   1
                BTFSC   RANDOM,5
                XORLW   1
                BTFSC   RANDOM,3
                XORLW   1
                MOVWF   RANDOM
                RETLW   0

(Andrew Warren)
For extra confusion, TMR0 ran in the background with no prescaller.
Every time TMR0 interupted, I ran the above code and loaded RANDOM into
TMR0. When ever I needed a Random number, I load the value from TMR0.
You don't need to use TMR0 or interupt, it was free in this application
so I used it.

Quentin

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2001\08\20@092933 by Don Hyde

flavicon
face
The following code implements a linear feedback register type of
pseudo-random number generator.  This algorithm is frequently implemented in
hardware for spread-spectrum radio applications.

It will generate all possible bit combinations EXCEPT all zeroes, for
various lengths, if the value is Poly is chosen correctly, and Variable is
initialized with any non-zero number.  In other words, it will produce a
"maximal length sequence", in which each of 2^n-1 nonzero bit combinations
appear once and only once.  If Variable is initialized with 0, then it just
produces lots of zeroes.

This macro was used in an application where a pseudo-random stream of bits
was needed, hence its output of a bit in CY.  If you want up to an 8-bit
value, it will be contained in Variable after executing the macro.

Suitable values for Poly:
for 6 bits (sequence length 63): 0x21, 0x33, 0x36
for 7 bits (sequence length 127): 0x41, 0x44...
for 8 bits (sequence length 255): 0x8e, 0xb4...

For more suitable Poly values see: Dixon, Robert C., Spread Spectrum Systems
with Commercial Applications; (Table 3.7)
;------------------------------------------------------------
;  GenerateLRC Macro -- generates up to 8-bit LRC
;
;  Input:   Variable -- needs to be initialized (usually all ones to # of
bits)
;
;  Output:  Next output bit is in CY, Variable is updated for next cycle
;
;------------------------------------------------------------

GenerateLRC Macro Poly, Variable
  clrc
  rlf   Variable,f
  movlw Poly
  skpnc
  xorwf Variable,f
  endm

> {Original Message removed}

2001\08\20@111553 by David VanHorn

flavicon
face
At 08:26 AM 8/20/01 -0500, Don Hyde wrote:
>The following code implements a linear feedback register type of
>pseudo-random number generator.  This algorithm is frequently implemented in
>hardware for spread-spectrum radio applications.
>
>It will generate all possible bit combinations EXCEPT all zeroes, for
>various lengths, if the value is Poly is chosen correctly, and Variable is
>initialized with any non-zero number.

You're right, but as long as you use less than the full length of the shift
register, you can get all states.
In one app, I use 8 bits from the 19 bit version, picked more or less at
random, with some bit inversions and anding.  But the initial byte that I
grab can have any state.


--
Dave's Engineering Page: http://www.dvanhorn.org

I would have a link to http://www.findu.com/cgi-bin/find.cgi?KC6ETE-9 here
in my signature line, but due to the inability of sysadmins at TELOCITY to
differentiate a signature line from the text of an email, I am forbidden to
have it.

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


More... (looser matching)
- Last day of these posts
- In 2001 , 2002 only
- Today
- New search...