The standard random number in TOS, are like many in computer-science, are pseudo-random. That is, they use some feedback of previous state(s) to generate new state. There are some rather complex approaches (Mersene-Twister, etc) but there are also rather simple approaches ... like RandonLfsrC.
(I use TOS 2.x and the following may or may not apply to TOS 1.x) Anyway, the trick is to start at "new places" in the sequence generated by the random number generator. Looking at RandomLfsrC, it is seeded with TOS_NODE_ID. That is, each time it starts, it uses the TOS_NODE_ID to get the initial state. At least multiple nodes should start with the same sequence ;) On the other hand, RandomMlcgC allows you to set the seed (and, while slower than Lfsr, I believe it has a longer sequence). See RandomMlcgC and SeedInit (ParamInit<uint16-t> interface). It will allow you to set the seed to a different value (and hence change the following sequence start). You could, for instance, take a reading from a sensor to get input. On Thu, May 15, 2008 at 8:11 PM, Hazem Al- Ojeh <[EMAIL PROTECTED]> wrote: > > > I am trying to generate random numbers, however I keep getting the same > numbers > over and over, I did find people with similar problems but I did not > understand > how I can solve the problem!? any suggestions? > > What i am doing now is > > number = (Random.rand16() % 100) + 1; > to get a number between 1 and 100, but as I mentioned, I keep getting the same > sequence of numbers!! > _______________________________________________ > Tinyos-help mailing list > [email protected] > https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help > _______________________________________________ Tinyos-help mailing list [email protected] https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
