Pages: [1]   Go Down
Author Topic: Random Flashing Strobe Control  (Read 573 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 18
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have been away from the Arduino for about a year and am just getting back into it.  The project I am making is a random strobe controller for 8 strobe units.  The strobes I am using are self-contained and have a self-triggering circuit.  They have a ground and positive and flash at a fixed rate of 2.5 times per second.  You can control the flash sequence by controlling power (there is no manual trigger).  You to have power the circuit for a second before it will initially flash. 

So...Controlling the random sequence is fairly simple, but I will need to hold the output open for a second plus some additional time for for the circuit to charge.  Now here comes the tricky part.  If I want the strobes to fire faster than a second apart I will need to overlap when my outputs go high.  I think I will need to use some sort of psuedo mutitasking or timer variables?  I will also need to bias my random outputs so that I do not repeat the same strobe twice in a row.  Anyone have any slick ideas?

Scott
Logged

Offline Offline
Edison Member
*
Karma: 32
Posts: 1290
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I think I will need to use some sort of psuedo mutitasking or timer variables?
By using the Blink Without Delay technique, you can have multiple delays that don't interfere with each other.

Or, they can relate to each other...  But in any case, you can have more than one timer running at the same time, since your loop runs continuously without any delays in the actual loop.

So you can trigger the 1st strobe

... Then after some delay, send a trigger to the 2nd strobe before the 1st one actually fires.

... Then, after enough time has passed for the 1st on to fire, turn it off before it can fire again.
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 474
Posts: 18696
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

http://www.gammon.com.au/blink
Logged

Offline Offline
Edison Member
*
Karma: 32
Posts: 1290
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I will also need to bias my random outputs so that I do not repeat the same strobe twice in a row.
Probably the easiest solution is to put your random-variable selection in a loop (probably a while() loop) and loop 'till the random next lamp is different from the current lamp.

i.e. Pick a random NextLamp number and if NextLamp == CurrentLamp, continue looping and get another random Next Lamp.   If they are not equal (which will be true most of the time), break out of the loop.   As long as this loop is running fast enough (relative to your flash interval), you can randomly pick the same number several times in a row and you'd never see a problem.

Of course when the time is up, CurrentLamp will be assigned the value of NextLamp and you'll have to find a new-random NextLamp.

Another way to do it is to make an array which excludes the CurrentLamp, and then pick a random element from the array.   (Something like this is often done to simulate a deck of cards, where you can't select the same card again after it's removed from the deck.)
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 18
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks to everyone for their responses!  Lots of good ideas to keep me busy for a while.

Scott
Logged

Pages: [1]   Go Up
Jump to: