I am hoping to find a schematic / program to have a PIC run a reocuring timer that closes a relay randomly at times from 3-9 minutes (no need to be super accurate)
You can simply use a random routine to create a pseudo-random interval between 3 and 9 minutes (in reality between 0 and 6 minutes, and add three to it ). Obviously you do it in seconds, not minutes.
C:
// Generates random number in range (lower - upper).
unsigned int GetRandom(unsigned int lower, unsigned int upper)
{
unsigned int num = (unsigned int)(rand() % (upper - lower + 1)) + lower;
return num;
}
So use "random value = GetRandom(180, 540);"
The main issue is creating a decently random starting point - a simple way is to have a start button.
As the program initialises, have it start a fast timer running, then wait for a start button to be pressed - once the start button is pressed read the fast timer, and use that to initialise the random seed using srand().
Here's a simple test I used recently, which utilised the RTTC to set the random seed.
C:
// Use current time as seed for random generator during testing
srand((unsigned int)rtcc.time.seconds*rtcc.time.minutes*rtcc.time.hour);
Quick and dirty with Arduino or an ATTINY85 using mBlock graphical programming.
Drag and drop function blocks into 3'rd window, configure, then program part.
mBlock generates Arduino code from the block configuration. Use a Nano board,
~$3, or a Nano board as programmer for an ATTINY85.