How to Control Christmas Lights - How to do almost anything with Christmas Displays.
  July 5, 2008 - Saturday |Id: Visitor|Login|Prefs|Register| 171 more shopping days until Christmas  
Home
About
Story
Forum
Forum Pro
How To
Photos
Videos
Classifieds
Community
Score Board

High Scorer
Hill Robertson
Featured Pics
Featured HowTo
Curtain Strobe Modification




HowTo: Simple PIC-Based 8-Port Dimmer  (Phil Short)


                              

Step 1 : Overview

This How-To describes how to build a simple PIC16F688-based dimmer. It is controlled through the PC's serial port, and they can be cascaded up to about 100 channels. This project/design is named 'renard'.

Various disclaimers:

1) The design is currently at alpha-test status, and so everything here should be taken with a grain of salt. If you are in a position to check things out and would like a copy of the program to be placed in Flash inside the PIC16F688, send me an email at justswitch @ yahoo.com.

2) As with most of the designs on this site, this one is intended for temporary, seasonal use.

3) You should be familiar with with electricity, electrical construction techniques and electrical safety before attempting these projects.

4) This How-To also assumes familiarity with electronic design techniques, and omits a lot of background material about constructing electronic devices. You may advised to take a look at relevant books in your local library or bookstore before starting in.

NOTE (Sept 8, 2006). Significant changes were made today to allow higher channel counts in the future. An ad-hoc discrete serial interface circuit was replaced by the MAX232, and a crystal oscillator was added. Both changes are needed in order for the baud rate to be increased from 19200 to 115200 in the future (the firmware doesn't actually use the oscillator at the moment).

There are a number of possible design variations that can be made, although they do need some electronic and/or programming knowledge. Some ideas for changes include replacing the H11AA1 zero-crossing circuit (see below) with a transformer and transistor circuit, changing to a PIC with a larger pincount for use with a crystal and/or diagnostic LEDs, and replacing the RS232 interface with a RS485 interface.

Step 2 : Build the Hardware


Build the hardware shown in the attached schematic. The schematic shows a single PIC, but multiple PIC chips can be daisy chained together on one PCB by wiring pin 6 of each PIC to pin 5 of the next one (all of the pin 2's can be connected together, as can the pin 4's).

The top connector J2 is to be connected to 110VAC for detecting the AC-Line zero-crossing. This part of the circuit is basically the same as in the 'Dimming the Olsen-595' How-To.

Pins 1 and 2 of the next connector (J3) are connected to TxD and ground on the RS-232 serial output port of the controlling computer (or to pins 1 and 2, respectively, of the J4 output of the previous controller in the chain).

Power is provided to the controller through J5. This should be connected to a source of regulated 5VDC using a circuit of your choice. Plan on providing about 5mA of current for each PIC (the duty cycle on the SSR opto-isolators is 1:256, so the average current for each SSR input is below 1/16 mA) plus about 45 mA for the oscillator.

J4 on the right side of the schematic is connected to J3 of the next controller in the chain.

J1 is the connector to the SSRs (sink-type connection). These SSRs can be similar to those described in the Howto: '4-channel SSR to go with the controller in the "How To"' (by Sean Bowf), although an adapter cable would be required in this case. J1 could also be directly connected to a Triac8 board from simpleio.com configured for sink-type connection and using non-zero crossing opto-isolators (although I haven't tested this, so there are no guarantees).

Step 3 : Programming the PIC chips

The program can be found --->here<---. This source code can be assembled and the PIC can be programmed using any one of a number of possible tools. The one that I used came as part of the PicKit1 Flash Starter Kit from Microchip.

Step 4 : Talking to the controllers

At this point you will have to use the appropriate plugin for vixen or write your own program for controlling the dimmers.

The protocol for talking to these dimmers is as follows:

Data is sent in asynchronous serial format at 19200 baud, with one start bit, eight data bits, no parity bits, and one stop bit, using RS-232 signal levels. As indicated elsewhere, the PIC chips are connected together in a daisy-chain, the serial output of one chip connected to the serial input of the next one.

The data is formatted into packets which are delimited by 0x7E sync characters. If a sync character must be sent as part of the data stream, it is encoded as the two characters 0x7F-0x30, and the escape character (0x7F, in this case) is represented by the two-character sequence 0x7F-0x31. The first non-sync character of each packet is the address byte, with the most-significant-bit set (what happens when the MSB is clear is undefined), followed by the data characters. If address byte is not 0x80, the PIC controller decrements it and re-transmits the entire packet (with the new address byte). If the address byte has the value 0x80, the controller removes the next eight characters from the packet and transmits the remaining portion of the packet (including the sync character and the original address). The eight characters that it has removed from the packet are interpreted as dimmer levels for the eight channels controlled by the given PIC, with 0xFF as full-brightness and 0x00 as 'off'.

[5/21/2006 - update]The character 0x7D is quietly discarded when it is received in the data stream. This character must be encoded as 0x7F-0x2F if it is to be sent as a 'dimmer' level.

[9/8/2006 - update]There is a new (and incompatible) protocol in the process of being implemented that will provide better worst case performance. This will be be released until next year, though, so as to minimize confusion this year.

Step 5 : Diagnostics

There is also a special version of the firmware available that can assist in troubleshooting when the controller doesn't work at first and you don't have access to an oscilloscope or logic analyzer. This firmware assumes that the SSRs have been replaced with LEDs (with series current limit resistors), which are used to indicate whether the PIC is 'alive', whether it is getting the proper zero-crossing signal, and whether it is receiving serial data.



                              
 

 
Designed, Hosted, and Coded by Hill Robertson
Computer Christmas - Copyright © 2001 Hill Robertson