Searching \ for 'generating random intervals?' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: techref.massmind.org/techref/method/math.htm?key=random
Search entire site for: 'generating random intervals?'.

Truncated match.
PICList Thread
'generating random intervals?'
1998\01\04@172130 by Tom Sgouros

flavicon
face
Does anyone have any clever ways to generate essentially random long
intervals (between 1 and 30 minutes).  I am already using Timer1 and
the PWM module on a PIC16c65, but I think there is a lot of computing
power and peripheral capacity left over.

-tom

----------------------------------------------------------------------
tomss at ids.net - 401-861-2831 - 42 Forge Rd, Potowomut, RI 02818 USA

1998\01\05@013538 by Mike Keitz

picon face
On Sun, 4 Jan 1998 17:26:42 -0500 Tom Sgouros
<spam_OUTtomfoolTakeThisOuTspamCIRCUS.GSO.URI.EDU> writes:
>Does anyone have any clever ways to generate essentially random long
>intervals (between 1 and 30 minutes).

There are two parts to this problem, generating a random number and
timing a long interval.

The complexity of the first part depends on the quality of randomness
needed.  For casual use the conventional feedback shift register maximum
length sequence generator is very easy to implement on a PIC.  A
psuedorandom generator should be "seeded" with a random number after
reset.  This is a little more difficult, but not necessary in many cases
especially if the results aren't going to be observed until a long time
after reaset.

Timing a long interval is often done with a timer interrupt that
increments software counters.  On PICs that don't have interrupts, the
timer register can be polled.  Every time it rolls over, the software
would increment the software counters.

When time expires, (which the program detects by finding the software
timing registers have reached their final value), the program would
generate an output and compute a new psuedorandom number.  The new number
would be conditioned to produce the range of times required, then loaded
to the timer registers.

 I am already using Timer1 and
>the PWM module on a PIC16c65, but I think there is a lot of computing
>power and peripheral capacity left over.

Any PIC is easily capable of this task, with a lot of computing capacity
left over.

>
>-tom
>
>----------------------------------------------------------------------
>tomss at ids.net - 401-861-2831 - 42 Forge Rd, Potowomut, RI 02818 USA
>

1998\01\05@104110 by Tom Sgouros

flavicon
face
> On Sun, 4 Jan 1998 17:26:42 -0500 Tom Sgouros writes:

>>Does anyone have any clever ways to generate essentially random long
>>intervals (between 1 and 30 minutes).

>On Mon, 5 Jan 1998 01:23:06 -0500, Mike Keitz wrote:

> There are two parts to this problem, generating a random number and
> timing a long interval.

<snip>

> A pseudorandom generator should be "seeded" with a random
> number after reset.

Ok then, how about a hardware way to make the seed?  I would like a
slightly higher quality random number generator than I can get by
putting the seed in ROM.  And does anyone have a reference for an
eight-bit pseudo-random number generator?

-tom

----------------------------------------------------------------------
tomss at ids.net - 401-861-2831 - 42 Forge Rd, Potowomut, RI 02818 USA

1998\01\05@122359 by Mike Keitz

picon face
On Mon, 5 Jan 1998 10:40:33 -0500 Tom Sgouros
<.....tomfoolKILLspamspam@spam@CIRCUS.GSO.URI.EDU> writes:

>Ok then, how about a hardware way to make the seed?  I would like a
>slightly higher quality random number generator than I can get by
>putting the seed in ROM.

If the project has asyncronous external inputs such as a user pressing
buttons or data from an external source, the exact time they arrive will
be pretty much random.  If not, the value in RAM at power-on is somewhat
random from chip to chip, but probably very consistent for a particular
chip.  The exact time the WDT expires is not synchronized with the PIC
clock.  Set the WDT for maximum duration and increment a counter as fast
as possible until it is stopped by the WDT expiring.  The value in the
low few bits of the counter should be rather random.

Using the WDT, it can take several seconds to collect the 20 or 30 bits
to make a good seed mumber.  Maybe this could be the primary random
generator in the random interval generator though.  Using the WDT as the
primary timebase, the distribution of interval times will shift with
temperature, voltage, etc.  Use all the bits of the counter to correct
for this by computing the number of WDT timeouts per minute, multiply by
the (random) number of minutes desired, and count down.


>-tom
>
>----------------------------------------------------------------------
>tomss at ids.net - 401-861-2831 - 42 Forge Rd, Potowomut, RI 02818 USA
>

1998\01\05@173323 by Harold Hallikainen

picon face
       I'd probably add a software counter to your existing timer1
routine so that every so many timer1 interrupt calls something happens.
You can then put random numbers in youyr "ram timers" during the reload.
Actually generating random numbers seems a bit more difficult.  I tried
doing stuff that I thought would be random based on apparently
independent timing loops, but they always ended up synching up with each
other giving a nonrandom pattern.  I finally wrote a little C program to
generate a table of 256 random numbers between 0 and 255, then put these
in a PIC lookup table.  Looked pretty random.

Harold



On Sun, 4 Jan 1998 17:26:42 -0500 Tom Sgouros
<tomfoolspamKILLspamCIRCUS.GSO.URI.EDU> writes:
>Does anyone have any clever ways to generate essentially random long
>intervals (between 1 and 30 minutes).  I am already using Timer1 and
>the PWM module on a PIC16c65, but I think there is a lot of computing
>power and peripheral capacity left over.
>
>-tom
>
>----------------------------------------------------------------------
>tomss at ids.net - 401-861-2831 - 42 Forge Rd, Potowomut, RI 02818 USA
>

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