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.

PIC Christmas Light Project

Status
Not open for further replies.
Hi guys-
I will start off by saying that i have never worked with micro controllers in general. I took a course with the Motorola HC12 and i loved it and loved what i could do with it. I recently had an idea and though to myself it would be easily done using a micro controller. I want to put Christmas lights (during christmas) on the outside of the house and have the micro controller switch thou various patterns. I am guessing this probably can be done using simple loops and a bunch of relays.
Is this something that can be easily done ? What micro controller would be suggested to use ? I would need one that would have a large amount of output pins..
After reading the sticky it seems that i can either start by building a programmer or purchase something simple like the pickit2 that will probably suite my needs. I can probably couple that with a 16 series chip and use its outputs to trip the relays.

Any suggestions ideas ? Are there any simulators out there that would allow me to work on it until i get started with the actual hardware..

Thanks
pete
 
A very smart move by first reading the sticky before asking for help.

On all common microcontrollers there are PORTs which are 8-bits wide where user can set as either input or as output. If user send a value(0~255) to an output port, the value will appear on the eight port pins as either 0 or 1. These logic levels can then be used to drive eight external parts such as LEDs or relays.

The PIC(or indeed any microcontroller) is good for such task. The amount of output depends on the model of the chip used. How many different outputs you would like to have? For a 18-pin PIC 16F628A, one can have a max. of 15 outputs available.

Please download the datasheet and the MPLAB from Microchip. The MPLAB contains an integrated development which one can create, assemble and simulate the program before sending the object file into the chip. You can observe the actual port pin logic levels changing while stepping through your code. All these without the need of any hardware.

Programmers are not expensive. Some comes with debugging features too. Whether you would build/buy the programmer depends on a lot of consideration. Someone like me would find building programmers a lot of fun while others who have built a non-working one would swear they never would have tried. Without the ability to troubleshoot the circuit if it doesn't work when built, their time would be more well spent on the task of creative programming instead. Look up the schematic of the programmer circuit. It is up to you to decide.

When you have made your decision on build/buy, there are still some choices and other members would be happy to advise on what to choose.

Edited: For 16F628A, only 15 outputs available as one pin can only be input.
 
Last edited:
Christmas light controllers are not uncommon projects. They are often built by cascading 74HC595 serial in parallel out chips together. With this setup you only use 3 processor pins to run each 595 controller which can have a lot of (dimmable) lights. If you Google for "Olsen 595 light" you can find more info.

You can either roll your own or build one based on existing work. Here are some interesting ones.

**broken link removed** Schematic.pdf
A good place to start reading.

**broken link removed**
Original article on Olsen 595
**broken link removed**
**broken link removed**

Uses a 18F2550 as a USB interface between a PC and an Olsen 595 type controller.



**broken link removed**

Or you could look at the UBW aka USB Wacker see sparkFun.com. Which uses a similar setup but not specifically targeted at this app.

HTH
 
Thanks for the suggestions 3Vo but it seems their projects are using standard ready made ttl/cmos chips and basically just incorporate a dimming circuit.
I am looking for something where i can more or less split my house into For example 10 vertical sectors and have the PIC chip have them flash in various sequences. I dont think their circuits would be of assistance in doing that ?? Maybe ?

Are there websites that discuss the instruction set and thier function, maybe some simple program examples.

thanks
pete
 
Let me try again.

What you want is very easy. You should be able to bang the hardware out in a hour or two.

If you want to use a 16F chip I suggest the 18 pin 16F88. It has enough pins and an internal oscillator.

You hook each pin to a transistor that drives a relay. You may know how to do that. For people who do not I suggest.
**broken link removed**

You did not indicate if the PIC was to communicate with anything else. My guess is that you want a PC to actually determine the sequencing.

If you do want a PC to sequence the lights and you would like to advoid programming the PIC look at the from sparkfun. Build a second board with the transistors and relays and you are done. You do not have to program the PIC.

The way the UBW works is that you send it a command and it toggles its I/O pins. It is actualy more capable then that but that is what you need.

Communication is done over USB. The driver software on the PC creates a virtual com port. From a programming standpoint you treat it exactly like RS232 but it is much faster. Examples exist using Liberty Basic but you can use any language that can open a com port.

Is that closer to what you have in mind.
 
Thats great information..

Actually i was thinking along the lines of writing some assembly and programing the PIC so its self sufficient. I am guessing i can probably program a few sequences to run in nested loops so it would run a specific pattern for 30 sec or so then switch to another for another 30 sec and so on.

I think this may be a great project to kinda get me into this stuff...

Hey eblc1388 thanks for the mplab suggestion i am currently downloading it and reading the user guide for the simulator. Is their a guide that lists the various asm commands and a brief explanation ?

PEte
 
Sounds like a good application for 'tables'.

Each table entry could include bytes for light pattern and duration and your interrupt routine or loop routines (the Scheduler) would simply sequence through the table entries until it's time to move on to another table.

You're gonna have so much fun (grin).

Regards, Mike
 
Mike said:
Sounds like a good application for 'tables'.

Each table entry could include bytes for light pattern and duration and your interrupt routine or loop routines (the Scheduler) would simply sequence through the table entries until it's time to move on to another table.

You're gonna have so much fun (grin).

Yes, tables are an obvious and simple way of doing it, here's a little sequencing program I threw together using the WinPicProg BASIC Compiler, the data statements consist of the bit pattern to feed to the port (in this case only four channels were used), and the time between steps (in 10mS intervals). I built it for a friend at work for moving lights on a rowing boat.

At Matlock Bath every year there's a competition, with rowing boats made up as various models, complete with lights, which parade up and down the river. It goes back a LONG time (back to when they used candles for the lights), and moving lights are normal now. Power is from car batteries, and most use motor driven switches to do the timing - I built a simple PIC based one, and wrote this code, for a friend at work.

So it can be as simple as this, yet be very effective.

Code:
Device 16F628
Freq=4

Data 4, 200, 2, 200, 1, 200, 2, 200, 4, 200, 2, 200, 1, 200, 2, 200, 4, 200, 2, 200 ,1 Data 200, 2, 200 ,4, 200

Data 2, 200, 1, 200, 2, 200, 4, 200, 5, 200, 2, 200, 5, 200, 2, 200, 5, 200, 2, 200 ,5 Data 200, 2, 200 ,5, 200

Dim A, CL, B
Define PortB=%00000000
Loop:
For CL=1 To 52
    Read A
    Read B
    B=B*10
    OutB(A)
DelayMS(B)
Next CL
Restore 0
Goto Loop
Stop
End

BTW, did a quick google, it started in 1897 - here's a page with sample photos
**broken link removed**
 
Indeed very interesting stuff with the boats.
Can u briefly explain what each line in this simple code does ? I am a bit confused ...

Thanks
pete
 
amdkicksass said:
Is their a guide that lists the various asm commands and a brief explanation ?

The detail explanation of each asm command is included in each and every datasheet of individual chip. You will need to download a few of these datasheets besides MPLAB IDE.

Get these four as a start: 12F683, 16F628A, 16F88 and 16F877A
 
Thanks for the suggestion eblc i am currently looking at the datasheets for the PICs. looks like a lot of info...lol

Nigel, why is it that program you have here above wont compile ? Is it bc its in Basic format ? How do i turn it to assembly...boy am i confused..lol

Help me out...
Thanks guys
pete
 
amdkicksass said:
Nigel, why is it that program you have here above wont compile ? Is it bc its in Basic format ? How do i turn it to assembly...boy am i confused..lol

Because it's written in a specific BASIC compiler dialect, which isn't available anywhere (because I wrote it, and it's never been released) :p

I only posted it as a simple example of how it could be done, it's a very simple type of program to write in any language, including assembler.
 
Surprised somebody just didn't list all 36 PIC assembly instructions off the top of their head...

I could probably do about half the AVR set...
 
I tried explaining it earlier but maybe i didnt explain it well enough. Let me try again. Originally my thought was to have the PIC control a set of relays via its outputs. The relay board would switch on pattern of lights on the house. Each set of lights, possibly 200-300 lights per relay (120VAC).
It was then suggested that what i wanted would be perfectly suited for the table function. I would have a bunch of patterns stored in the table and have it cycle thru them for a specific duration.
I was asking if anyone has any examples in assembly language on how to incorporate tables ?

Pete
 
ok...thanks for the help... I think its time for me to get my hands a bit dirty and try the stuff hardware wise.
I am going to need a programmer and a few PIC chips to start with. I am interested in a ready made programmer, hopefully for under 50$. I saw the pickit2 but i am not sure if thats something good to start with. Suggestions,where to buy ?
Also for the PIC chips, i see that they are generally very cheap, i would like to buy a few probably- I will buy a few 16F628A (Whats with the A in the end) anything else ?

Anything else i should buy ...

THanks
pete
 
amdkicksass said:
ok...thanks for the help... I think its time for me to get my hands a bit dirty and try the stuff hardware wise.
I am going to need a programmer and a few PIC chips to start with. I am interested in a ready made programmer, hopefully for under 50$. I saw the pickit2 but i am not sure if thats something good to start with. Suggestions,where to buy ?
The pickit2 is a very good choice. It can act as either a debugger or programmer. The price is right and I have heard that Microchp is good about replacing broken ones.

It workes with MPLAB so you can compile/assemble and program (or debug) from the same UI. Microchip upgrades the software to ensuring that their it works with their new chips.

amdkicksass said:
Also for the PIC chips, i see that they are generally very cheap, i would like to buy a few probably- I will buy a few 16F628A (Whats with the A in the end) anything else ?
"A" chips are an update of the non "A" chips. Generally runs faster (20MHz instead of 4), internal oscillator, use less power, and newer flash technology. Either would work for you but the newer chips are often less expensive. See this table.

amdkicksass said:
Anything else i should buy ...
pete
As I said earlier this is an easy build.

A few LEDs to use in place of the relays to start with.
The relays and transistors to drive them.

Use the internal oscillator, 4MHz should be fast enough and it frees up 2 more pins for driving lights. If you need to go faster get a 20MHz resonator. (you could also use a crystal and caps)
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top