Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
Thread Tools Display Modes
Old 16th June 2007, 04:08 AM   (permalink)
Experienced Member
amdkicksass is on a distinguished road
Question PIC Christmas Light Project

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
amdkicksass is offline   Reply With Quote
Old 16th June 2007, 06:28 AM   (permalink)
Experienced Member
 
eblc1388 is just really niceeblc1388 is just really niceeblc1388 is just really nice
Default

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.
__________________
L.Chung

Last edited by eblc1388; 16th June 2007 at 07:36 AM.
eblc1388 is offline   Reply With Quote
Old 16th June 2007, 07:47 AM   (permalink)
3v0
Moderator
 
Blog Entries: 3
3v0 is a splendid one to behold3v0 is a splendid one to behold3v0 is a splendid one to behold3v0 is a splendid one to behold3v0 is a splendid one to behold3v0 is a splendid one to behold3v0 is a splendid one to behold
Default

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.

Computer Christmass Schematic.pdf
A good place to start reading.

Build a 1024 Port Controller for $100
Original article on Olsen 595

USB – Olsen 595 Translator


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





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
__________________
search engine for electronic parts
Junebug USB PIC programmer kit. USB Bit Wacker
3v0 is online now   Reply With Quote
Old 16th June 2007, 05:22 PM   (permalink)
Experienced Member
amdkicksass is on a distinguished road
Default

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
amdkicksass is offline   Reply With Quote
Old 16th June 2007, 06:07 PM   (permalink)
3v0
Moderator
 
Blog Entries: 3
3v0 is a splendid one to behold3v0 is a splendid one to behold3v0 is a splendid one to behold3v0 is a splendid one to behold3v0 is a splendid one to behold3v0 is a splendid one to behold3v0 is a splendid one to behold
Default

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.
Controlling a relay with a digital logic level.

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 UBW 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.
__________________
search engine for electronic parts
Junebug USB PIC programmer kit. USB Bit Wacker
3v0 is online now   Reply With Quote
Old 16th June 2007, 06:37 PM   (permalink)
Experienced Member
amdkicksass is on a distinguished road
Default

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
amdkicksass is offline   Reply With Quote
Old 16th June 2007, 07:07 PM   (permalink)
Experienced Member
Mike, K8LH is a name known to allMike, K8LH is a name known to allMike, K8LH is a name known to allMike, K8LH is a name known to allMike, K8LH is a name known to allMike, K8LH is a name known to all
Default

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, K8LH is offline   Reply With Quote
Old 16th June 2007, 07:43 PM   (permalink)
3v0
Moderator
 
Blog Entries: 3
3v0 is a splendid one to behold3v0 is a splendid one to behold3v0 is a splendid one to behold3v0 is a splendid one to behold3v0 is a splendid one to behold3v0 is a splendid one to behold3v0 is a splendid one to behold
Default

There are so many ways one could go with this project.

Have fun and let us know if you have problems or how it comes out.
__________________
search engine for electronic parts
Junebug USB PIC programmer kit. USB Bit Wacker
3v0 is online now   Reply With Quote
Old 16th June 2007, 07:55 PM   (permalink)
Super Moderator
 
Nigel Goodwin is a splendid one to beholdNigel Goodwin is a splendid one to beholdNigel Goodwin is a splendid one to beholdNigel Goodwin is a splendid one to beholdNigel Goodwin is a splendid one to beholdNigel Goodwin is a splendid one to beholdNigel Goodwin is a splendid one to behold
Default

Quote:
Originally Posted by Mike, K8LH
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
http://www.derbyshire-photographs.co...lockbath3.html
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline   Reply With Quote
Old 17th June 2007, 12:51 AM   (permalink)
Experienced Member
amdkicksass is on a distinguished road
Default

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 is offline   Reply With Quote
Old 17th June 2007, 07:25 AM   (permalink)
Experienced Member
 
eblc1388 is just really niceeblc1388 is just really niceeblc1388 is just really nice
Default

Quote:
Originally Posted by amdkicksass
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
__________________
L.Chung
eblc1388 is offline   Reply With Quote
Old 17th June 2007, 08:12 AM   (permalink)
Experienced Member
amdkicksass is on a distinguished road
Default

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 is offline   Reply With Quote
Old 17th June 2007, 11:07 AM   (permalink)
Super Moderator
 
Nigel Goodwin is a splendid one to beholdNigel Goodwin is a splendid one to beholdNigel Goodwin is a splendid one to beholdNigel Goodwin is a splendid one to beholdNigel Goodwin is a splendid one to beholdNigel Goodwin is a splendid one to beholdNigel Goodwin is a splendid one to behold
Default

Quote:
Originally Posted by amdkicksass
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)

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.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline   Reply With Quote
Old 18th June 2007, 05:02 AM   (permalink)
Experienced Member
amdkicksass is on a distinguished road
Default

Ok,,,well is there any examples written that display the usage of tables in assembly ?

pete
amdkicksass is offline   Reply With Quote
Old 18th June 2007, 05:33 AM   (permalink)
Experienced Member
HarveyH42 is a name known to allHarveyH42 is a name known to allHarveyH42 is a name known to allHarveyH42 is a name known to allHarveyH42 is a name known to allHarveyH42 is a name known to all
Default

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...
HarveyH42 is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Latest
Project: Strobe Light ElectroMaster Electronic Projects 17 16th July 2007 03:55 PM
PIC to PIC and output on LCD pouchito Micro Controllers 20 7th June 2007 08:43 AM
max232 and pic data logger mini project mabauti General Electronics Chat 1 21st March 2007 10:54 PM
need help for senior project jay_zee General Electronics Chat 5 17th August 2004 11:46 AM
brake light/ turn signal andrew8485 Electronic Projects Design/Ideas/Reviews 13 11th November 2003 12:48 AM



All times are GMT. The time now is 03:36 AM.


Electronic Circuits  |  Radio Controlled
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.