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). 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 >