[DIY106]
Do it yourself !

Zedomax Party Light II-
Make a computer controlled
Party Light Part II
Okay, last time I made a computer controlled party light in 90 seconds but I ran into some problems. The party light was an experiment and I needed something that would be more realistic.
Something that has isolation to protect against electrical surges and what not that could cause pre-mature device failure and all that jazz.
So I just took the idea and went a little deeper.

Here's a video of Party Light II in Action:
Parts List:
6(or more) Clip-on bulb thingee $30
Available at Home Depot
1 Din-rail $1
Available at www.din-rail.com
1 CuSB-22R $129
Available at cubloc.com
Estimated Time to Assemble: 1 hour
Estimated Time to Program: 20 minutes (or none if you use my source code)
Connections

(Wiring, notice I have a yellow wire between label COM and L)

(Sticking it on the DIN rail w/ the clip on bulbs)

(The CuSB has a DIN-rail mount, so
you can just stick it on the DIN-rail)
Here's a simple diagram for connections:
.
(When a relay turn On, the blue line gets connected w/ the red line via the green line)

(party time~)
Program Source...
You can simply copy and paste the code to your CublocStudio and then download to your CuSB PLC.
You can play around with it by changing the numbers of For...Next loops and the delay times of sub functions.
BASIC Source Code:
[relay002.cul]
Const Device = CB280
Dim a As Byte
Do
For a=0 To 2
Program1 100
Next
For a=0 To 2
Program2
Next
For a=0 To 2
Program2B
Next
For a=0 To 2
Program3
Next
For a=0 To 2
Program4 100
Next
For a=0 To 5
Program4 50
Next
For a=0 To 5
Program4 40
Next
For a=0 To 10
Program1 30
Next
Loop
End
Sub Program1(d As Integer)
one
Delay d
two
Delay d
one
Delay d
two
Delay d
one
Delay d
two
Delay d
one
Delay d
End Sub
Sub Program2()
Dim B As Byte
Out 42,1
Out 43,1
Out 44,1
Out 45,1
Out 46,1
Out 47,1
For B=41 To 47
Out B,(Outstat(B) Xor 1)
Delay 100
Next
For B=47 To 42 Step -1
Out B,(Outstat(B) Xor 1)
Delay 100
Next
End Sub
Sub Program2B()
Dim B As Byte
Out 42,1
Out 43,1
Out 44,1
Out 45,1
Out 46,1
Out 47,1
For B=47 To 42 Step -1
Out B,(Outstat(B) Xor 1)
Delay 100
Next
For B=41 To 47
Out B,(Outstat(B) Xor 1)
Delay 100
Next
End Sub
Sub Program3()
oneA
Delay 200
twoA
Delay 400
oneA
Delay 200
twoA
Delay 400
oneA
Delay 200
twoA
Delay 400
oneA
Delay 200
twoA
End Sub
Sub Program4(d As integer)
one
Delay d
Out 42,0
Out 43,0
Out 44,0
Delay d
one
Delay d
Out 42,0
Out 43,0
Out 44,0
Delay d
one
Delay d
Out 42,0
Out 43,0
Out 44,0
Delay d
one
Delay d
Out 42,0
Out 43,0
Out 44,0
Delay d
two
Delay d
Out 45,0
Out 46,0
Out 47,0
Delay d
two
Delay d
Out 45,0
Out 46,0
Out 47,0
Delay d
two
Delay d
Out 45,0
Out 46,0
Out 47,0
Delay d
two
Delay d
Out 45,0
Out 46,0
Out 47,0
Delay d
End Sub
Sub one()
Out 42,1
Out 43,1
Out 44,1
Out 45,0
Out 46,0
Out 47,0
End Sub
Sub oneA()
Out 42,1
Out 43,0
Out 44,1
Out 45,0
Out 46,1
Out 47,0
End Sub
Sub twoA()
Out 42,0
Out 43,1
Out 44,0
Out 45,1
Out 46,0
Out 47,1
End Sub
Sub two()
Out 42,0
Out 43,0
Out 44,0
Out 45,1
Out 46,1
Out 47,1
End Sub
