![]() |
Forum Index : Microcontroller and PC projects : MM2 random number on startup
Author | Message | ||||
GoodToGo!![]() Senior Member ![]() Joined: 23/04/2017 Location: AustraliaPosts: 188 |
Howdy all, I hope you are all well in these trying times. I have multiple LED lighting modules powered by E28's that are designed to flash 3-wire Xmas lights. As a part of the Basic routine, there are multiple sub-routines with the flashing sequences. Upon startup I seed the Random generator with the Timer and then use it to select 1 of the 5 routines as a starting point. Reason being I don't want all the modules to start at the same routine. Great in theory, doesn't work in practice due to all modules seeding the same timer time of course. I was thinking of maybe using a 'programming resistor' and measure the analog input voltage and use that as a seed? Different resistors should give different voltages, meaning different seed values meaning different random numbers meaning different starting points.... Can anyone else think of a way to generate differing random numbers on module start? Cheers, GTG! ![]() ...... Don't worry mate, it'll be GoodToGo! |
||||
OA47 Guru ![]() Joined: 11/04/2012 Location: AustraliaPosts: 982 |
GtG, could you use the onboard clock to supply current uS value to start as your seed? OA47 |
||||
Phil23 Guru ![]() Joined: 27/03/2016 Location: AustraliaPosts: 1667 |
How many E28 Modules?, And I'm Guessing they don't talk to each other. Just boot & then run one of the 5 sequences & then switch to an alternate random one after a random time? |
||||
Turbo46![]() Guru ![]() Joined: 24/12/2017 Location: AustraliaPosts: 1638 |
Could you have a 'start' button for each that you must press to start the sequence? That would add randomness to the startup. CaptainBoing has discussed random number generation using a noise generator on the Fruit of the shed, see here and here. You can find more circuits on the web. Bill Keep safe. Live long and prosper. |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6266 |
> AUTOSAVE spare = 23 ' any spare analog pin left floating. setpin spare, ain RANDOMIZE pin(spare)*1000 print rnd() Saved 53 bytes > RUN 0.300794 > RUN 0.0807553 > RUN 0.830729 > RUN 0.62072 > RUN 0.270705 > RUN 0.170715 > RUN 0.370797 > Jim VK7JH MMedit |
||||
GoodToGo!![]() Senior Member ![]() Joined: 23/04/2017 Location: AustraliaPosts: 188 |
I originally did, using RANDOMIZE(TIMER). But because all the E28's are connected to the same time switch, they all appeared to use the same TIMER value. 5 so far, they are all independent except for their power source which is switched on by a 230VAC timer. They all run through the sequences in turn, and then repeat. Jim, that's perfect! I did try using a high-ish value resistor between pin 7 and the 3.3v supply, which worked, but I also found it worked with the resistor removed! Much better than seeding from the TIMER value in my case. Thanks for all your help everyone! Cheers, GTG! ![]() ...... Don't worry mate, it'll be GoodToGo! |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |