Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

computer Christmas lights

Status
Not open for further replies.

MrDEB

Well-Known Member
years ago I assembled a Compurterized Christmas light display but since sold the entire setup.
I recall the SSR or triac boards used an opti-isolator, couple resistors but instead of using a computer, I want to just use a PIC to drive the opti_isolator. Just started looking for leftover plans and parts but figure would ask first.
 
I guess I've been told. Please carry on and post videos when it's done.
 
I should have done this long ago.

I think you've just about burned through all the suckers who have tried to help you.

Screenshot_20230103_134847_Gallery.jpg
 
I think I found a solution to sequence the 4x4 matrix ?
found a code snippet that has 4 timers. Change the timing on 3 of the rows then end up with 3 x 4 matrix which is OK.
tried to get popcorns code post #269 to work but ?
tried using a counter but not good results.
now to figure out how to address the rows(x) so just increment X to change rows


Device = 18F2221
Clock = 8
#option DIGITALIO_INIT = true// ------------------------------------tell compiler to automatically call SetAllDigital
Include "setdigitalio.bas"
Include "intosc.bas"
#option SWORDFISH_SE = true
Include "utils.bas"
Include "Convert.bas"
Include "ledmatrix_4x4.bas"
Include "ISRTimer.bas" //--------------------------------------------for flashing the headlight to apear like MOTION




//Dim Time_delay As LongWord
Dim X As Byte
//12 VOLT LED STRIPS
Dim R As PORTA.0
Dim Y As PORTA.1
Dim D As PORTA.2
Dim E As PORTA.3
Dim R_1 As PORTA.4
Dim W As PORTA.5
Dim O As PORTA.6
Dim D_1 As PORTA.7
//dim row(5) as byte
Dim Red_Candle_STRIPS As PORTB.0 //--------------------------------turn on mosfet Q10
Dim Flames_ENABLE As PORTB.1 //-------------------------------------------TOGGLE SWITCH PORT

//CAKE SPRINKLES CATHODES CONNECTED TO PORT PINS
Dim Row4() As PORTB.2
Dim Row3 As PORTB.3
Dim Row2 As PORTB.4
Dim Row1 As PORTB.5

//HEADLIGHT ON TRAIN ENGINE
Dim Head_light As PORTC.7

//CANDLE FLAMES
Dim Flame1 As PORTC.0
Dim Flame2 As PORTC.1
Dim Flame3 As PORTC.2

// SPRINKLES ANODES
Dim RED As PORTC.3
Dim WHITE As PORTC.4
Dim BLUE As PORTC.5
Dim GREEN As PORTC.6
Dim TICKS As Byte

// constant ID to 4 * 16 bit timers...
Const
Timer1 = 0,
Timer2 = 1,
Timer3 = 2,
Timer4 = 3

Sub OnTimer()
TICKS = TICKS +1
End Sub

//Sub Initialize(pCount As Byte = 5)
//Timer.Items(Timer1).Enabled = true
//End Sub
//Timer.Items(Timer2).Enabled = true
// OnTimer1 event...
Event OnTimer1()
Toggle(Row2)
End Event

// OnTimer2 event...
Event OnTimer2()
Toggle(Row3)
End Event

// OnTimer3 event...
Event OnTimer3()
Toggle(Row4)
End Event


// start processing all timers...

//Timer.Start
RED = 0
WHITE = 0
BLUE = 0
GREEN = 0
Row1 = 1
Row2 =1
Row3 = 1
Row4 = 1
TICKS = 0
Output(Head_light)
SetAllDigital

// main program loop...

//While true




// activate the timer module...
Timer.Initialize

// initialise the timers - refresh every 1000Hz (1ms)...
Timer.Items(Timer1).Interval = 20 // 50ms
Timer.Items(Timer1).OnTimer = OnTimer1 // timer event handler
Timer.Items(Timer2).Interval = 30 // 250ms
Timer.Items(Timer2).OnTimer = OnTimer2 // timer event handler
Timer.Items(Timer3).Interval = 40 // 500ms
Timer.Items(Timer3).OnTimer = OnTimer3 // timer event handler
Timer.Items(Timer4).Interval = 50 // 2000ms, no event handler

// enable the timers...
Timer.Items(Timer1).Enabled = true
Timer.Items(Timer2).Enabled = true
Timer.Items(Timer3).Enabled = true
Timer.Items(Timer4).Enabled = true

// start processing all timers...
Timer.Start
// start processing all timers...

//Timer.Start
RED = 0
WHITE = 0
BLUE = 0
GREEN = 0
Row1 = 1
Row2 =1
Row3 = 1
Row4 = 1
TICKS = 0
Output(Head_light)
SetAllDigital

// main program loop..
// main program loop...
While true
// this is a polled timer, not event driven - check to see
// if it has timeout...
If Not Timer.Items(Timer4).Enabled Then
Toggle(Row2)//-------------------------------------row1
blue = 1
Toggle(Row3)
white = 1
Toggle(Row4)
green = 1

Timer.Items(Timer4).Enabled = true
EndIf

// background flash LED...
High(PORTC.7)
DelayMS(500)
Low(PORTC.7)
DelayMS(500)
Wend
//QuoteReport Edit[/CODE]
 
Experimenting trying to dimension Row and Columns but something isn't right?
the first 3 lines of code (AFTER WHILE TRUE) the led just very briefly blinks. The next four lines work correctly. WHY?
DID I NOT DIMENSION CORRECTLY??
dim Rw(4) as byte // ROWS
dim COL(4) as byte //COLUMS

RW(1)= ROW1
COL(1)=RED

While true
//FOR X = 0 TO 4
RW(1) = 0 //LED IS ON
COL(1)=1 //COLUM IS HIGH
DELAYMS(2000)
// NEXT
HEAD_LIGHT = 1
ROW1=0
RED = 1
DELAYMS(2000)
 
Not even close.

Code:
dim Rw(4) as byte    //  ROWS
dim COL(4) as byte    //COLUMS

RW(1)= ROW1  
COL(1)=RED

All you're doing there is creating "RW" and "COL" variables and setting them to the contents of some hardware ports.
They won't effect anything... setting them won't turn anything on or off.
 
Well how can I demension them if that's the correct term?
I am hoping that putting the rows and columns in an array then use a FOR NEXT loop to cycle the rows and columns on/off without any delays hopefully or I just go with the code in post#284. Johnny popcorns code in post# 269 looked really useful but can't get it working.
 
Over the past 10 years all of your programs have done the same thing... flash leds.
I'm not going to waste my time... just use a bunch of IF...THEN statements cause that's where it's going to end up anyway.
 
Since I put MrDEB on ignore, I don't even see this thread unless someone replies (since I was part of it already), and only then the replies. But the replies tell the entire story even without seeing what they are in response to! MrDEB's over 5,500 messages here all share a certain theme, have a certain character, so it's easy to guess what prompted replies.
 
Sharing one's knowledge is a wonderful thing. I have great respect for everyone who has helped me along.
Yes most if not all my projects deal with flashing LEDs but I have used ADC some timers and learned a little about coding. Tried Ardunio but not my forte.
Yes I know I have been a bother to most but my thirst for learning answers is unquenchable.
My "simple projects" seem trivial but my Christmas Stars brought lots of joy to many families n friends then the handheld game I call WICKED 8 has my 3-year-old grandson occupied as well as helping with the learning disability of a friend's 8-year-old grandson who had a brain tumor removed. ALL these projects were given free gratis.
WHY? because I find joy in helping others
I hope to make improvements to my projects even though they seem trivial to some.
My issue right now is the supply chain for chips and maybe circuit boards.
NOTE if anyone wants the Gerber files for the Christmas Stars will be happy to share and spread the joy of Christmas.
 
I understand why it takes 15 pages of comments to cover a relatively simple design with MrDEB . He does not ask the right questions and makes bad assumptions, but he tries hard!.

You need a gate supply voltage at least 2x and preferable 2.5V times the max Vgs(th) threshold voltage for the IRF xx series FETS (eg IRF520) . These are a poor choice for 5V expecting high current. OK for maybe 0.5A but NOT much more unless well heatsunk.

FETS have a very high impedance like 10 to 16 kohm at the threshold called Vgs(th) or Vt.
But the IRFxxx series are all old school Vgs(th)= 2 to 4V. If you are lucky to get parts that are Vt=2V , it works , 3V maybe and if they 4V never works well at Vg=5V. Thats a problem with FETS is the threshold has a 50% tolerance. So you need "LOGIC LEVEL" FETs which work well at 3.3 or 5V because the Vt threshold is about 1/3rd of the gate voltage used or less. So if you use no heat sink, consider 1/4Watt and I^2*Rdss = P even if it is a big TO220 to avoid hot parts.

So if you had 5m or 5A to keep the FET cool, RdsOn=Pmax/I^2= 0.25/25 = 10 milliohms with a Vgs(th) max < 2V (not minimum).. You may find these parts are rated for > 10x what you are using because I assume you might use no heatsink, using the thermal resistance Rja * P = Temp rise ['C]

This is important to understand when using enhancement FETs.

Lesson to learn: Not all resources on the web are reliable.
 
Last edited:
I FOUND A GOOD DESCRIPTION
"
41

Vgs is just the voltage from gate to source (with the red lead of the multimeter on the gate and the black one on the source). Everything else is from context.
The Absolute Maximum Vgs is the maximum voltage you should ever subject the MOSFET to under any conditions (stay well away). Usually the actual breakdown is quite a bit different (borrowing from this datasheet):
enter image description here

Vgs(th) is the voltage at which the MOSFET will 'turn on' to some degree (usually not very well turned on). For example, it might be 2V minimum and 4V maximum for a drain current of 0.25mA at Tj = 25°C (the die itself is at 25°C).. That means that if you want your 20A MOSFET to really turn on fully (not just conducting 250uA) you need a lot more voltage than 4V to be sure about it, but if your Vgs is well under about 2V you can be pretty sure it's well turned off (at least around room temperature).
Rds(on) is always measured at a specified Vgs. For example, it might be 77mΩΩ with Vgs = 10V and Id = 17A and Tj = 25°C. That 10V is the Vgs you need to feed your MOSFET for it to be happily turned on so it looks like a very low resistance.
Vgs also comes up when you want to know the gate leakage. Igss might be +/-100nA at Vgs = +/-20V and Tj = 25°C.
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top