May 15, 2024, 10:51:28 AM

News:

Be sure to checkout our Vixen interfaces in the Library forum -- if you want PC automation at near zero cost, EFX-TEK and Vixen is a great combination of tools.


Flickering lamp after delay

Started by jukingeo, October 12, 2013, 09:26:46 PM

Previous topic - Next topic

jukingeo

October 12, 2013, 09:26:46 PM Last Edit: October 12, 2013, 09:46:44 PM by jukingeo
Hello All,

It has been a while since I posted here in regards to a program.  But I will say that I have not been programming the Prop-1 or 2 for a long time now  :o.

I am building a light post for my latest Halloween display, I thought why not add a little pizazz by having it do something.   So I thought it was time to dust off the Prop-1 and put it to good use.

Ok, so I have the Prop-1 and for output I have the RC-4.  This is what I would like to do:

I have a lamp that is illuminating a warning sign and for the most part I want the lamp to stay on.  However every minute or so, for a brief interval, I would like the light to flash as if it had a loose connection.   I would like it to do this for about 3 or 4 seconds and then revert back to the on state.

After doing some searching I found a program that uses the Prop-1 to randomly flash the outputs of two RC-4's.  The program was very simple and I have attempted to modify it for my scenario.

This is the result:

' =========================================================================
'
'   File...... On-Delayed Random_RC4s.BS1
'   Purpose...
'   Author.... Jon Williams, EFX-TEK
'              Copyright (c) 2008 EFX-TEK
'              Some Rights Reserved
'              -- see http://creativecommons.org/licenses/by/3.0/
'   E-mail.... jwilliams@efx-tek.com
'   Started...
'   Updated... Jukingeo
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


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


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


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

SYMBOL  Sio             = 7                     ' SETUP = out; no ULN


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

SYMBOL  IsOn            = 1                     ' for active-high in/out
SYMBOL  IsOff           = 0

SYMBOL  Baud            = OT2400


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

SYMBOL  idx             = B2
SYMBOL  timer           = B3
SYMBOL  relays          = B4
SYMBOL  lottery         = W5


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

Reset:
  PINS = %00000000                              ' clear all outputs
  DIRS = %00000000                              ' make P0-P5 outputs


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

Main:
  relays = %11111111

  GOSUB Leds
  PAUSE 60000


  FOR idx = 1 TO 50
    RANDOM lottery                              ' really shake it up
    timer = lottery // 41                         ' random, 0 to 40
    PAUSE timer
    RANDOM lottery
    relays = lottery & $000F
    GOSUB Leds
  NEXT

  GOTO Main

Leds:

  SEROUT Sio, OT2400, ("!RC4", %00, "S", relays)
  relays = lottery / 16 & $0003
  SEROUT Sio, OT2400, ("!RC4", %01, "S", relays)

  RETURN



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


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


Now while the program does work and would look great for a set of malfunctioning fluorescent lamps it doesn't seem right for a single flashing incandescent lamp.  The off times during the flashing seem to be very long.  I would rather it be the opposite.

Doing some more digging in my programs for the Prop-1, I came across this one that Jon wrote for me a while back:


' =========================================================================
'
'   File...... Hallway-v2.BS1
'   Purpose...
'   Author.... (originally) Jon Williams, EFX-TEK (www.efx-tek.com)
'   E-mail.... jwilliams@efx-tek.com
'   Started...
'   Updated... Jukingeo
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


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


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


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

' SYMBOL  Motion          = PIN6                  ' SETUP = DN
SYMBOL  Lights          = PINS                  ' use P0..P5


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

SYMBOL  Yes             = 1
SYMBOL  No              = 0

SYMBOL  AllOn           = %00000001             ' all lamps on
SYMBOL  AllOff          = %00000000             ' all lamps off


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

SYMBOL  idx             = B2                    ' loop control
SYMBOL  flicks          = B3                    ' flick events
SYMBOL  flkDelay        = B4                    ' delay between flickers
SYMBOL  timer           = B5                    ' for variable delays
SYMBOL  lottery         = W5                    ' random value


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

Reset:
  DIRS = %00111111                              ' allow all on
  GOTO Cycle_On

  flkDelay = 100                                ' set for 2.5 secs


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

Main:
  FOR idx = 1 TO 3                              ' stir random value
    RANDOM lottery
  NEXT

  IF flkDelay = 0 THEN Flicker_Cycle
    PAUSE 25
    flkDelay = flkDelay - 1
    GOTO Main

Flicker_Cycle:
  RANDOM lottery                                ' stir again
  flicks = lottery // 4 + 1                     ' 1 to 4 flicks

Flicker:
  FOR idx = 1 TO 2
    Lights = AllOff                             ' light out
    RANDOM lottery
    timer = lottery // 26 + 10                  ' 10 to 25 ms
    PAUSE timer
    Lights = AllOn                              ' back on
    RANDOM lottery
    timer = lottery // 51 + 50                  ' 50 to 100 ms
    PAUSE timer
  NEXT
  flicks = flicks - 1
  IF flicks > 0 THEN Flicker                    ' finished?

Reset_Flicker_Timer:
  RANDOM lottery
  flkDelay = 81 + 40                           ' set 1 to 3 seconds

Cycle_On:
  Lights = AllOn
  PAUSE 60000

  GOTO Main


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


' -----[ EEPROM Data ]-----------------------------------------------------


THIS one has the flickering pattern I like.  I altered it to my needs, but it poses two problems:

1) It doesn't output to the RC-4
2) I would like the flickering to go on a little longer.

Finally.  I don't necessary have to use the RC-4.  I DO have some really nice huge 20 amp solid state relays in which I could hook the Prop-1 to directly.  However, the Prop-1 output pins are on the order of 12 volts.  Whereas the relays I have are 5 volts.  I would assume that I could hook up the relay to the outputs at 12 volts if a resistor is used. 

I know I could use a separate 5volt power supply and it wire up V+ on the Prop-1 and keep the power switch in the (1) position, but:  a) that would really complicate things having to need another power supply for a single relay and b) if someone accidentally thrown the switch to the 12v position, that would nicely fry my relay.

Would it be possible to hook up the 5v relay directly to the pin header?  I believe the header is 5volts, correct?

Any assistance would be appreciated.

Thank You,

Geo

JackMan

October 13, 2013, 07:02:57 AM #1 Last Edit: October 13, 2013, 07:41:23 AM by JackMan
Yeah, you can connect the relay to any "R" pin for 5v+ and then use whatever OUT terminal you have in the program to energize it.
If you want the flicker cycle to go on a little longer, just change the values in red below to higher numbers. For example, 6 + 3 would give you 3 to 6 flicks.

Flicker_Cycle:
  RANDOM lottery                                ' stir again
  flicks = lottery // 4 + 1                     ' 1 to 4 flicks

If you want to use the RC-4, I think this will work.



'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


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


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


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

SYMBOL Sio    = 7                            'Serial connection SETUP = UP; no ULN

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

SYMBOL  Yes             = 1
SYMBOL  No              = 0

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

SYMBOL  idx             = B2                    ' loop control
SYMBOL  flicks          = B3                    ' flick events
SYMBOL  flkDelay        = B4                    ' delay between flickers
SYMBOL  timer           = B5                    ' for variable delays
SYMBOL  lottery         = W5                    ' random value


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

Reset:
  PINS = %00000000                              ' clear all outputs
  DIRS = %00111111                              ' make P0-P5 outputs
  GOTO Cycle_On

  flkDelay = 100                                ' set for 2.5 secs


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

Main:
  FOR idx = 1 TO 3                              ' stir random value
    RANDOM lottery
  NEXT

  IF flkDelay = 0 THEN Flicker_Cycle
    PAUSE 25
    flkDelay = flkDelay - 1
    GOTO Main

Flicker_Cycle:
  RANDOM lottery                                ' stir again
  flicks = lottery // 4 + 1                     ' 1 to 4 flicks

Flicker:
  FOR idx = 1 TO 2
    SEROUT Sio, OT2400, ("!RC4", %00, "R", 1, 0) ' turn off relay 1
    RANDOM lottery
    timer = lottery // 26 + 10                  ' 10 to 25 ms
    PAUSE timer
    SEROUT Sio, OT2400, ("!RC4", %00, "R", 1, 1)  ' turn on relay 1
    RANDOM lottery
    timer = lottery // 51 + 50                  ' 50 to 100 ms
    PAUSE timer
  NEXT
  flicks = flicks - 1
  IF flicks > 0 THEN Flicker                    ' finished?

Reset_Flicker_Timer:
  RANDOM lottery
  flkDelay = 81 + 40                           ' set 1 to 3 seconds

Cycle_On:
  SEROUT Sio, OT2400, ("!RC4", %00, "R", 1, 1)  ' turn on relay 1
  PAUSE 60000

  GOTO Main

JonnyMac

The RC-4 has direct control inputs which would allow you to skip the serial transmission (which creates a delay) and control the relay directly, same as your hockey puck SSR. For flickering this is best.

Keep in mind that all SSRs switch on the zero-cross, so your light output will not exaclty match control output. With the zero-cross circuitry in the SSR, your minimum on and off time is about 8 milliseconds. Thermal inertial of the filament will play into the flicker as well; incandescent lamps are slow to light and slow to dim.
Jon McPhalen
EFX-TEK Hollywood Office

jukingeo

October 13, 2013, 09:18:21 AM #3 Last Edit: October 13, 2013, 09:35:15 AM by jukingeo
Quote from: JackMan on October 13, 2013, 07:02:57 AM
Yeah, you can connect the relay to any "R" pin for 5v+ and then use whatever OUT terminal you have in the program to energize it.

Oh, OK.  I figured I could go directly as that is what the Prop trainer board does.  While the RC-4 is great for multiple AC outputs, the thing is that for one lamp it is overkill.  But it was good to post it here in the event someone does want to use it with the RC-4.  It is just that I have come across some really nice Crydom SS relays I had stuffed away in the same box as my EFX-TEK stuff.  I just forgot about them.  But one of them would do the job nicely.

The relay has all screw terminals on them.  I think I am best off hacking one of the shorter servo connector cables I have laying around and connecting the relay that way.  So then I would go out to the relay with the 5v (red wire) and come back on the white wire.  Then I would just plug the wire into the '0' position on the header.

Quote
If you want the flicker cycle to go on a little longer, just change the values in red below to higher numbers. For example, 6 + 3 would give you 3 to 6 flicks.

Flicker_Cycle:
  RANDOM lottery                                ' stir again
  flicks = lottery // 4 + 1                     ' 1 to 4 flicks

Thank you...that was a big help.   After studying the program a bit more and saw the pattern of how the timing was handled, I made some more alterations in regards to how the flickering is handled.  (I have to give Jon a nod of thanks for coming up with this program).   I finally altered the on delay time.  I thought 60 seconds would be good, but found that it was a bit too long and somewhere between 30 to 40 seconds seems right.

Anyway...this is the final program with the necessary adjustments in place for a direct output. 

' =========================================================================
'
'   File...... Delayed Flicker (single channel)
'   Purpose...
'   Author.... (originally) Jon Williams, EFX-TEK (www.efx-tek.com)
'   E-mail.... jwilliams@efx-tek.com
'   Started...
'   Updated... Jukingeo
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


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


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


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

' SYMBOL  Motion          = PIN6                  ' SETUP = DN
SYMBOL  Lights          = PINS                  ' use P0..P5


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

SYMBOL  Yes             = 1
SYMBOL  No              = 0

SYMBOL  AllOn           = %00000001             ' all lamps on (change 0 to 1 to add more)
SYMBOL  AllOff          = %00000000             ' all lamps off


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

SYMBOL  idx             = B2                    ' loop control
SYMBOL  flicks          = B3                    ' flick events
SYMBOL  flkDelay        = B4                    ' delay between flickers
SYMBOL  timer           = B5                    ' for variable delays
SYMBOL  lottery         = W5                    ' random value


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

Reset:
  DIRS = %00111111                              ' allow all on
  GOTO Cycle_On

  flkDelay = 100                                ' set for 2.5 secs


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

Main:

  FOR idx = 1 TO 3                              ' stir random value
    RANDOM lottery
  NEXT

  IF flkDelay = 0 THEN Flicker_Cycle
    PAUSE 25
    flkDelay = flkDelay - 1
    GOTO Main

Flicker_Cycle:
  RANDOM lottery                                ' stir again
  flicks = lottery // 5 + 2                     ' 2 to 5 flicks (changed from 1 to 4 flicks)

Flicker:
  FOR idx = 1 TO 2
    Lights = AllOff                             ' light out
    RANDOM lottery
    timer = lottery // 46 + 5                   ' 5 to 45 ms (orig set to 26 + 10)
    PAUSE timer
    Lights = AllOn                              ' back on
    RANDOM lottery
    timer = lottery // 71 + 50                  ' 50 to 100 ms (orig set to 51 + 51)
    PAUSE timer
  NEXT
  flicks = flicks - 1
  IF flicks > 0 THEN Flicker                    ' finished?

Reset_Flicker_Timer:
  RANDOM lottery
  flkDelay = 81 + 40                           ' set 1 to 3 seconds

Cycle_On:
  Lights = AllOn
  PAUSE 30000

  GOTO Main


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


' -----[ EEPROM Data ]-----------------------------------------------------


Quote from: JonnyMac on October 13, 2013, 09:13:07 AM
The RC-4 has direct control inputs which would allow you to skip the serial transmission (which creates a delay) and control the relay directly, same as your hockey puck SSR. For flickering this is best.

Hello Jon,

Yes,  I had noticed the delay just now when I was doing some more testing with the RC-4 and I have to add to those reading that you would have to alter the timer range variables to a lower number for faster response to keep in time with the settings I have in the final program.

Good point on the direct connect points on the RC-4.  I actually forgot they were there and went through the trouble of hooking up the Prop Trainer, for the 'standard output' program. LOL!  I guess in this case the serial transmission method would be a moot point.  It just was there initially since this program was one you wrote for me a while ago and back then the program was controlling SIX lamps which were to be situated down a hallway and other than the flickering they did other things too.  I just altered that program from there.

Quote
Keep in mind that all SSRs switch on the zero-cross, so your light output will not exaclty match control output. With the zero-cross circuitry in the SSR, your minimum on and off time is about 8 milliseconds. Thermal inertial of the filament will play into the flicker as well; incandescent lamps are slow to light and slow to dim.

Thank you for that info, I will keep it in mind and more then likely I play with the programming again once the circuit is hooked up to the actual light bulb.

Thanx again guys and have a Happy Halloween!

JonnyMac

We do our best to offer options. Have you seen the Amigo boards? We have a new board called the SSR-2 that has two AC SSRs that use direct connections. It's inexpensive, handles a fair bit of current, and is easy to use (plug-and-play).

-- http://www.efx-tek.com/topics/ssr-2.html
Jon McPhalen
EFX-TEK Hollywood Office

jukingeo

October 13, 2013, 11:39:38 AM #5 Last Edit: October 13, 2013, 11:43:52 AM by jukingeo
Quote from: JonnyMac on October 13, 2013, 11:05:37 AM
We do our best to offer options. Have you seen the Amigo boards? We have a new board called the SSR-2 that has two AC SSRs that use direct connections. It's inexpensive, handles a fair bit of current, and is easy to use (plug-and-play).

-- http://www.efx-tek.com/topics/ssr-2.html

Yes, not too long ago I saw the Amigo boards up on the site and started to check them out.  I was most interested in the RC-2 as that can switch high currents (AC or DC), or even trigger items that just need a contact closure.  The SSR-2 is nicer packaged version of the "hockey puck" relays I have.  The thing is though, on a heatsink, those hockey pucks can switch 20 amps  :o.  I do have six of those Crydom relays, so it will be while before I need more.  (As I recall, I think I bought those big SSR's for a theatre marquee project I was going to do, which didn't pan out.  That does explain why they were in the box with the prop controllers.  You might recall a few moons ago that you helped me out with a number of chaser circuits).

The other thing that is a grand slam is the TD-1.  Since I already do synchronizing to music with Vixen the thing is for something on a small scale it is ridiculous to have an entire computer rig for.  The TD-1 certainly will fit the bill here being able to use tones recorded on a track to trigger events.  I have not read the documentation yet, but will do so soon.

As of now, I can't wait until the new FC-4+ will be released.  I am assuming that could be hacked like the HC-8+.  I need a good dimming controller for the Prop1 & 2 as of now.  Next year I am going to do a 'Mad Lab' setup, so I will be using your products quite extensively.

Anyway, thanx for the heads up.

Geo


JackMan

Geo,
     DO NOT connect to the "W" pin for your 5v relay! Those pins are TTL ONLY! You can grab 5v+ by connecting to any "R" pin but you need to use an OUT terminal for the GND as I outlined in the earlier post.

jukingeo

Quote from: JackMan on October 13, 2013, 04:51:05 PM
Geo,
     DO NOT connect to the "W" pin for your 5v relay! Those pins are TTL ONLY! You can grab 5v+ by connecting to any "R" pin but you need to use an OUT terminal for the GND as I outlined in the earlier post.

Really, even for a solid state relay?  I thought these just have a LED inside of them, so it would like driving the LEDs on the Trainer board?  Jon mentioned that you could connect an output directly to a channel on the RC-4 bypassing the need for serial transmission.  Wouldn't it be the same thing with the solid state relay?    Now, I know if I were using a REGULAR mechanical relay, then hooking that up directly would be a no no as the coil of wire draws more current.

Anyway I looked up the datasheet on my SSR (see attached).  (I was wrong saying it was Crydom, the relay is Omron).

Checking the specs on the DC 5v side it appears the internal resistance is 250 ohms.  Simple ohms law puts this at .02 amps or 20 milliamps.  That certainly sounds like TTL range to me.  Looking up the specs on the Prop-1's TTL outputs, it looks like it can do this.  If I have to hook it up to the main output, then so be it,  I just have to do a bit more hacking on the cable.  But perhaps Jon could chime in on this to verify.

Geo


JackMan

At 20mA you're probably OK, but I'd connect to the OUT terminal just to be safe. 

JonnyMac

The Prop-1 has a 220-ohm resistor inline with the IO pin so you'll probably be safe.
Jon McPhalen
EFX-TEK Hollywood Office

JackMan

I have a couple of Revision E Prop-1's that have 100-ohm inline resistors, my older ones have 220's.

JonnyMac

Jon McPhalen
EFX-TEK Hollywood Office

jukingeo

Quote from: JonnyMac on October 14, 2013, 09:55:12 AM
The Prop-1 has a 220-ohm resistor inline with the IO pin so you'll probably be safe.

Ok, just wanted to be sure it was OK even though the documentation said it was safe.

Thanx,

Geo

Jeff Haas

I just tried this flickering effect out with a long rope light.  It's a great atmospheric bit, very impressive!

jukingeo

October 25, 2013, 04:09:11 PM #14 Last Edit: October 26, 2013, 08:43:07 PM by jukingeo
Quote from: Jeff Haas on October 20, 2013, 03:13:53 PM
I just tried this flickering effect out with a long rope light.  It's a great atmospheric bit, very impressive!

Yes, it is!  Originally the program was intended for a hallway consisting of 6 vapor proof light fixtures (also known as "ship" lights...you know the kind with the cage over the bulb).   Like this:

http://www.amazon.com/Sunlite-VT100-5-5-Inch-Outdoor-Metallic/dp/B004WSNUIA/ref=sr_1_4?ie=UTF8&qid=1382841603&sr=8-4&keywords=vapor+light+fixture

The six lights were supposed to go on in succession and then after a while they start to flicker as if it was a short circuit.  When someone enters the hall the lights would go out one at a time in order.  Once dark, a 'scare' would present itself.   I never got to the last part as this was just a concept for a haunt.  Since I liked the flickering effect so much, I wanted to adapt it to a 'street lamp' that I have in my display this year.  The light would stay on for a while, then flicker for a bit and the go back on for a while.  The reason for the long 'on' times is because the light is serving double duty illuminating a warning sign.

Edit:  Last night I did a dry run of the completed circuit on a 120v candle light which I use on my Halloween display.   The effect looks great!  It reacts pretty fast due to the small filament of the candle type light.   However the lamp it will actually be on has a 60 watt bulb which has a much longer filament which might create more of the 'dimming' action I am looking for.

Regardless, the intermittent flashing DOES draw attention which will be good for the sign it is lighting up.  The sign is a warning sign, so I do want to draw attention to it.  It should work out good.  Once I have the lamp completed and set up I will post a link to the video of it.

Oh!  I forgot to mention that since I am coming (semi) directly off the BS1 chip using the pin header, I had to wire up the relay's led with the BLACK to negative and the white to positive.  I initially had it red wire going to positive and white wire going to negative.  In this manner the operation of the relay was in REVERSE.   So instead of the lamp being mostly on and flickering, the lamp was mostly off and flickered.   I figured I would mention that here for those interested in the event that you want the output to be opposite without having to change the programming.

Edit2:  Tonight I completed the actual lamp prop and did a full test of it.  All I can say is WOW!  The effect works like a charm and the timing interval is great too, I didn't have to make any adjustments to the program either.  It really does look like a lamp that has a loose connection.  Having the longer filament on the 60 watt bulb is an improvement as well.  My guess is that using a 75 or 100 watt bulb might even be better.   It is just in my case I have to watch my current consumption.  I am already drawing enough juice from one outlet.

I am thinking for next year, I might expand on this.  Since the relay can handle up to 5 amps without a heatsink (20 amps with one) I could run up to 7 lamps (60 watt bulb each).   I would only need four lamps to cover my entire walkway and having the whole row blink would be awesome.  It could be a mild scare in itself for those waiting on line.

I just had another thought as I probably could put the whole program into a FOR-NEXT loop and after a few iterations of on-flicker, on-flicker, on-flicker, then after the 6th or 7th time...BOOM!  The lights DO actually go completely OFF for about 10 seconds or so and then jump back on.  THAT would be cool.

Something to think about for the future.

Geo