Searching \ for '[PIC] Twinkling LED's and other randomized Effects' 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: 'Twinkling LED's and other randomized Effects'.

Exact match. Not showing close matches.
PICList Thread
'[PIC] Twinkling LED's and other randomized Effects'
2004\10\11@225409 by Martin McCormick

flavicon
face
       I have heard of shift registers being used along with feedback
to generate a pseudo-random bit pattern.  A PIC would be excellent for
setting up such a scheme because any two or three bytes can be shifted
left or right and ganged in to a shift register so that a bit at one
end marches through the register and ends up at the other end.  How
does the feedback loop work to scramble the bits so that the output at
least appears random?

       If the bits in the shift register start out as all high or all
low, will that prevent the entropy from starting?  In the project I am
thinking of, even the apparence of randomness is good enough.

Martin McCormick WB5AGZ  Stillwater, OK
OSU Information Technology Division Network Operations Group
_______________________________________________
http://www.piclist.com
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist

2004\10\11@230801 by Dave VanHorn

flavicon
face
At 09:54 PM 10/11/2004, Martin McCormick wrote:

>         I have heard of shift registers being used along with feedback
>to generate a pseudo-random bit pattern.  A PIC would be excellent for
>setting up such a scheme because any two or three bytes can be shifted
>left or right and ganged in to a shift register so that a bit at one
>end marches through the register and ends up at the other end.  How
>does the feedback loop work to scramble the bits so that the output at
>least appears random?

Someone mentioned my AVR code that does this, easily adaptable to the PIC.

>         If the bits in the shift register start out as all high or all
>low, will that prevent the entropy from starting?  In the project I am
>thinking of, even the apparence of randomness is good enough.

The only thing you can't do with a maximal length generator, is to start it
with all zeroes. That's a "stuck" state.  Anything else you load in will be
fine.
That means that an N bit register can only generate (2^N)-1 conditions, but
you can always make the PN gen longer, and then take some bits out of the
middle, and those will generate all 256 possible states with equal
distribution.

_______________________________________________
http://www.piclist.com
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist

2004\10\11@234916 by Kenneth Lumia

picon face
>How does the feedback loop work to scramble the bits so that the output at
> least appears random?

The feedback loop is basically an XOR of 2 or more bits in the shift
register.  The output of the XOR is connected to the start of the shift
register and will generate a pattern (depending on how many bits are
used and where the taps are placed).

Take a look at the following app note.  "Random" is relative; it depends
on the number of bits in the shift register before the pattern repeats.

http://www.maxim-ic.com/appnotes.cfm/appnote_number/1743/ln/en

> If the bits in the shift register start out as all high or all
> low, will that prevent the entropy from starting?

Starting all ones is ok, never preload with a zero, as the XOR will
never generate a 1 output to feed back into the shift register.

Also google on (random "shift register" "511 pattern") for other articles.

Ken
spam_OUTklumiaTakeThisOuTspamadelphia.net


{Original Message removed}

2004\10\12@000650 by Dave VanHorn

flavicon
face

>
>Take a look at the following app note.  "Random" is relative; it depends
>on the number of bits in the shift register before the pattern repeats.

It's not random at all.
It's completely and absolutely predictable.
Radioactive decay is random.
Although it's gaussian in large groups, the time between decays is totally
unpredictable.
OTOH, if I know the register configuration (tap points) and what state it
is now, or what state it was at any time previous, then I can predict the
next state exactly.

The interesting thing is that if you only look at a small subset of the
bits, then it appears random. If the register is long enough, and it
doesn't take that much, it's repeat time can exceed the age of the universe.

This makes it very useful for secure radio links.

_______________________________________________
http://www.piclist.com
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist

2004\10\12@022923 by William Chops Westfield

face picon face
On Oct 11, 2004, at 7:54 PM, Martin McCormick wrote:

> I have heard of shift registers being used along with feedback
> to generate a pseudo-random bit pattern.

there is some C code to do 5 PWM "random" outputs on a 12c675 here:
   http://www.geocities.com/westfw/electronics/flames.c

It's supposed to look like fire.  It worked pretty well, IMO.
On the other hand, I would think stars would be different.  In
particular, fire spends a lot of time down near zero brightness,
whereas stars, if they twinkle at all, tend to have very brief
lessenings of brightness, along the lines of
       brightness = min(128, 255-random(128))  (where 128 is max brightness)

BillW

_______________________________________________
http://www.piclist.com
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist

2004\10\12@033426 by Jinx

face picon face
> whereas stars, if they twinkle at all, tend to have very brief
> lessenings of brightness, along the lines of
> brightness = min(128, 255-random(128))  (where 128 is max
> brightness)

I've been using these as RNGs (by seeding timers with intervals)

http://home.clear.net.nz/pages/joecolquitt/white_noise.html

Data generated from the one on the left is used in a game of chance
and passes government requirements for randomness (NB Schottky
is now BAT46, +/- supply is from a MAX232 in the circuit)

In a starfield, attention is not likely to be on just one star, unless you
really really don't have a life, and something less than truly random
would do. A cinema in town has a starfield in the roof with what must
be a simple system and pattern of ons/offs - it's not as convincing as
in/out fades would be


_______________________________________________
http://www.piclist.com
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist

2004\10\12@075516 by Russell McMahon

face
flavicon
face
> Radioactive decay is random.

Even that's under fire :-)
New Scientist September 25 2004 has several articles on randomness and how
much of it isn't or mightn't be. People are attacking the randomness of
quantum mechanics *apparently* implicit in the outcomes of Bell's various
experiments.

________________

NB the following do NOT disprove randomness but are in fact a feature of it.

1.    Measure the distance between a randomly chosen pair of stars.
Measure another similarly chosen pair.
Express the distances in whole numbers.
See if the numbers so obtained have any common factors.
Do this for a large number of star pairs.
Take the proportion that don't have a common factor.
Multiply by 6.
Take the square root.

This gives you Pi :-)

Works with distances between "random" bomb craters too ;-)


________________

2.    Take a floor with regularly spaced  lines on it.
Drop a needle etc randomly on the floor.
Note fraction of drops where needle crosses a line.
Proportion is a factor of needle length, line spacing and, of course, Pi.
(That one's more obvious to me).




       Russell McMahon

_______________________________________________
http://www.piclist.com
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist

2004\10\12@085037 by Kenneth Lumia

picon face
> >Take a look at the following app note.  "Random" is relative; it depends
> >on the number of bits in the shift register before the pattern repeats.
>
> It's not random at all.
> It's completely and absolutely predictable.

True.  Hence the word "random" in quotes.  Actually, it is typically known
as a
psuedo-random sequence.

> OTOH, if I know the register configuration (tap points) and what state it
> is now, or what state it was at any time previous, then I can predict the
> next state exactly.
>

Absolutely.  A common usage is to send test patterns (such as the well
known 511 pattern) down a modem link to determine the bit error rate
of the link.  The receiver must know what the result should be in order
to determine how many errors occured.

Ken
.....klumiaKILLspamspam@spam@adelphia.net


{Original Message removed}

2004\10\15@153116 by Martin McCormick
flavicon
face
William "Chops" Westfield writes:
>there is some C code to do 5 PWM "random" outputs on a 12c675 here:
>    http://www.geocities.com/westfw/electronics/flames.c

Thank you very much.  I got it and will have to look it over to see
how it works, but that's the kind of problem I like.  

Martin McCormick WB5AGZ  Stillwater, OK
OSU Information Technology Division Network Operations Group
_______________________________________________
http://www.piclist.com
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist

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