From: Go Rf on
Hello all



I need a function, when called returns a pseudo random number between X and
Y.



I have many boards that periodically broadcasts their board addresses on an
RF link. All boards use the same RF-channel frequency, so data collisions is
going to happen. So I need to randomly delay between those broadcasts to be
able to avoid collisions with other boards broadcasts.



I want to make a pseudo random delay (X ms - Y ms) before sending the
package again.






From: Paul Keinanen on
On Tue, 17 Nov 2009 14:06:07 +0100, "Go Rf" <Rf(a)Rf.org> wrote:

>Hello all
>
>
>
>I need a function, when called returns a pseudo random number between X and
>Y.
>
>
>
>I have many boards that periodically broadcasts their board addresses on an
>RF link. All boards use the same RF-channel frequency, so data collisions is
>going to happen. So I need to randomly delay between those broadcasts to be
>able to avoid collisions with other boards broadcasts.
>
>
>
>I want to make a pseudo random delay (X ms - Y ms) before sending the
>package again.

Why not just use some microsecond counter and use some of the lower
order bits as delay, if receivers detect a collision situation.

Even with mains powered systems, a typical microprocessor crystal will
soon drift so much that collisions do not occur frequently after a
mains failure.

Paul

From: Paul Keinanen on
On Tue, 17 Nov 2009 15:22:28 +0200, Paul Keinanen <keinanen(a)sci.fi>
wrote:

>On Tue, 17 Nov 2009 14:06:07 +0100, "Go Rf" <Rf(a)Rf.org> wrote:
>
>>Hello all
>>
>>
>>
>>I need a function, when called returns a pseudo random number between X and
>>Y.
>>
>>
>>
>>I have many boards that periodically broadcasts their board addresses on an
>>RF link. All boards use the same RF-channel frequency, so data collisions is
>>going to happen. So I need to randomly delay between those broadcasts to be
>>able to avoid collisions with other boards broadcasts.
>>
>>
>>
>>I want to make a pseudo random delay (X ms - Y ms) before sending the
>>package again.
>
>Why not just use some microsecond counter and use some of the lower
>order bits as delay, if receivers detect a collision situation.
>
>Even with mains powered systems, a typical microprocessor crystal will
>soon drift so much that collisions do not occur frequently after a
>mains failure.

I would like to add that the microprocessor system crystal drift is so
bad that in one system with identical processor cards distributed over
a large area, the drift was so bad after a reset signal on the common
serial line (break) the system became useless after a few seconds due
to the crystal drift at various boards.

We had to use the 50 Hz mains (with very bad short time accuracy) as
our common timing reference.

Paul

From: Wil Taphoorn on
Go Rf wrote:

> I have many boards that periodically broadcasts their board addresses on an
> RF link. All boards use the same RF-channel frequency, so data collisions is
> going to happen. So I need to randomly delay between those broadcasts to be
> able to avoid collisions with other boards broadcasts.
>
> I want to make a pseudo random delay (X ms - Y ms) before sending the
> package again.

The boards use different addresses I assume. Should a delay calculated
from (part of) the board's address not suffice?

--
Wil
From: Go Rf on

"Wil Taphoorn" <wil(a)nogo.wtms.nl> wrote in message
news:WTMSB29E82BE(a)wtms.nl...

> The boards use different addresses I assume. Should a delay calculated
> from (part of) the board's address not suffice?

The boards use a 32-bit address that is unique. So I should be able to use
it. If I for example take 8-bits from theboard address to specify a delay.
And the next time I take the next 8 bits.

For example

delay = bit(7 to 0) of address
delay = bit(8 to 1) of address
delay = bit(9 to 2) of address
....
delay = bit(31 to 24) of address

and then start again at:

delay = bit(7 to 0) of address

But some combinations of addresses works better than others. And it gets bad
if i enumerate all boards starting at address 1 and the 2, 3, 4, 5 etc.