November 24, 2024, 02:46:32 PM

News:

Got VSA?  Want to use your Prop-SX?  Now you can!  See the VSA section of the Library forum for Prop-SX code that works with VSA.


Random, non-repeating triggers

Started by Patrick, June 14, 2013, 06:06:51 AM

Previous topic - Next topic

Patrick

I have a Fright Ideas media player, it is a hardware based video player with 7 dry contact input switches that trigger 7 different video files.  I am running some Halloween portraits, I have seven media files displaying different portraits.  What I would like to do is run each of the 7 with a random sequence, but not repeat any video until all 7 have run (this is for a queue line).

For instance, first sequence would be 3-1-2-7-6-4-5, then next it would be 2-7-4-1-3-5-6, etc.   Each video is a different length, the longest is 21 seconds so there would need to be at least a 30 second wait before triggering the next video.  This loop would keep running throughout the night.  I am trying to make sure that all 7 videos get seen, just not in the same sequence each time.  I have access to a Prop-2 if this cannot be done / easily done on a Prop-1.  Would appreciate any programming help anyone can provide.

Thanks,

Patrick

JonnyMac

You need t check with the folks at Fright Ideas about connecting that device to a controller like ours -- I may need to adjust the code.

We do lots of randomizing and play-all-before-repeating type programs. This one is tailored to your request. You will have to edit the line that starts with LOOKUP to change the timing for each portrait.

Note that the only way to get truly random output is to have an external trigger. Still, from your customer's point-of-view this will appear random to them. The code also prevents the same file from running back-to-back (which could happen between two play list cycles).


' =========================================================================
'
'   File...... Random_Portaits
'   Purpose...
'   Author.... JonnyMac
'   E-mail....
'   Started...
'   Updated... 14 JUN 2013
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


' -----[ Program Description ]---------------------------------------------


' -----[ Revision History ]------------------------------------------------


' -----[ I/O Definitions ]-------------------------------------------------

SYMBOL  Trigger         = PIN7                  ' SETUP = DN  (not used)


' -----[ Constants ]-------------------------------------------------------

SYMBOL  Yes             = 1
SYMBOL  No              = 0

SYMBOL  TrOn            = 1                     ' active-high trigger
SYMBOL  TrOff           = 0

SYMBOL  IsOn            = 1                     ' active-high I/O
SYMBOL  IsOff           = 0


' -----[ Variables ]-------------------------------------------------------

SYMBOL  portrait       = B2                    ' portrait # this cycle
SYMBOL  last           = B3                    ' last selected
SYMBOL  mask           = B4                    ' bit mask for testing
SYMBOL  check          = B5                    ' for testing play list
SYMBOL  played         = B6                    ' portaits played in cycle
SYMBOL  secs           = W4                    ' seconds to hold
SYMBOL  lottery        = W5                    ' random #


' -----[ Initialization ]--------------------------------------------------

Power_Up:
  ' put code here that only happens at power-up/hard reset

Reset:
  PINS = %00000000                              ' all off
  DIRS = %01111111                              ' P6..P0 are outputs

  lottery = 1031                                ' seed random #


' -----[ Program Code ]----------------------------------------------------

Main:
  RANDOM lottery                                ' stir random #
  portrait = lottery // 7                       ' select 0..6
  IF portrait = last THEN Main                  ' no back-to-back repeats
  READ portrait, mask                           ' convert to bit mask
  check = played & mask                         ' test for played
  IF check <> 0 THEN Main                       ' try again if played

  ' lookup up time slot for portrait

  LOOKUP portrait, (30,30,30,30,30,30,30), secs

  HIGH portrait                                 ' activate
  PAUSE 1000
  LOW portrait

  secs = secs * 1000                            ' convert to millis
  PAUSE secs

  last = portrait                               ' save for next cycle

  played = played | mask                        ' mark played
  IF played <> %01111111 THEN Main              ' back if not done
    played = %00000000                          ' reset played list
    GOTO Main


' -----[ Subroutines ]-----------------------------------------------------


' -------------------------------------------------------------------------


' -----[ User Data ]-------------------------------------------------------

Bits:
  EEPROM (%0000001,%0000010,%0000100,%0001000,%0010000,%0100000,%1000000)
Jon McPhalen
EFX-TEK Hollywood Office

JackMan

I could be wrong but I think you may need 7 relays for this to work with a Prop-1.

Patrick

Jon,

Thank you for the quick turnaround, I will give it a test this evening.  It always seems clearer after you write the code, I just could not wrap my head around changing up the sequence.

JackMan

I am using 7 relays for this to replace the dry contact switches.  Fright Ideas has some pretty small (about 2.75 x 1) 12V single relay boards that I picked up from their site that should work perfectly for this.

Thanks again!

Patrick

JackMan

June 14, 2013, 02:25:04 PM #4 Last Edit: June 14, 2013, 02:29:11 PM by JackMan
Patrick,
   Jon is the programming Guru for sure, his coding for your prop is pretty high-tec. Here's a low-tec version that will give you 14 minutes of random video that plays each of the 7 videos 4x and then starts over. They're arranged so that there's almost always at least 3 minutes before any video replays. Jon's version is set up so that the last video of any 7 file sequence cannot be immediately replayed but it could possibly be replayed as the 2nd video of a new random sequence.