How to Control Christmas Lights - How to do almost anything with Christmas Displays.
  March 12, 2010 - Friday |Id: Visitor|Login|Prefs|Register| 287 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: How To Build A Parallel Port Controller Box  (Hill Robertson)


    << Previous Page       Page 1    Page 2   Page 3    Page 4       Next Page >>

Step 6 : The 374 Flip Flops


The flip flops are basically just memory. When the IC receives a clock signal on pin 11, the chip latches whatever data is present on the inputs 1D through 8D and holds it on the outputs (1Q through 8Q) until another clock signal is received. Flip Flops are used for each 8 circuit box to keep each circuit on or off until they are specifically told to change.

Here is the pinout of the 374 flip flop.

Step 7 : 374 Truth Table


Here is the truth table for the 374 flip flop.

Step 8 : General Control


Here is the top left of the schematic so you can see how the signaling works. As you can see, there are two major databuses in the schematic. The first is indicated by the blue and green connections between the parallel port, the first flip flop (374) chip and all of the decoder chips (138). The second is indicated by the blue connections between the output of the first flip flop (374) and the input of all other flip flops.

This first databus is used to transfer the data for each box and select which 8 circuit box receives the byte of data. The second databus puts the byte of circuit box data to the inputs of all flip flops. The control bits are used as enables (or chip select) for the flip flop data buffer and the decoders.

Step 9 : Write Sequence


The way it works is as follows:

1. (First Write) The data byte (8 bits) is set on the 8 data bits of the parallel port

2. (Second Write) The flip flop control bit is set low (0V) which is inverted. This latches the data in the flip flop and is stored (like memory) in the FF.

3. (Third Write) The flip flop control bit is set back to high (+5V) to keep the flip flop data from changing before it is sent to the box flip flops.

4. (Fourth Write) The steering data byte is set on the port.

5. (Fifth Write) The decoder control bit is set high to send out a clock (low) to the specific box flip flop.

6. (Sixth Write) The destination flip flop latches the data and turns on or off the lights via the 8 circuit boxes and holds it's state until the next instruction is sent to change it.

Step 10 : Software Write Function

Here is the C function that outputs the 6 write sequence to the control box.


set_box(int data, int box){

// set_box function by Hill Robertson
//
// This function sends the 6 writes for each parallel port instruction
// to control (currently) 40 8-circuit Christmas light SSR controller
// boxes. The box and bank data are selected and then the write sequence
// begins.

int bank;
int bankbox;

if(box>=1&&box<=8){ bank=8; bankbox=box-1; }
if(box>=9&&box<=16){ bank=16; bankbox=box-9; }
if(box>=17&&box<=24){ bank=32; bankbox=box-17; }
if(box>=25&&box<=32){ bank=64; bankbox=box-25; }
if(box>=33&&box<=40){ bank=128; bankbox=box-33; }

// base=0x378 for first parallel port base address
// control=base+2 for first parallel port control address

outb(data, base); // Write 1:
// Outputs data byte (D0-D7) on pins 2-9
// of parallel port

outb(0, control); // Write 2:
// Outputs a 1 (high) on C0 and C1
// (pins 1 and 14) since they are inverted
// without changing any states on the data pins

outb(1, control); // Write 3:
// Outputs a 0 (low) on C0 and a 1 (high) on
// C1 since they are inverted. Again, not
// changing any states on the data pins

outb(bankbox+bank, base); // Write 4:
// Outputs the steering (addressing) data on
// the data pins

outb(3, control); // Write 5:
// Outputs a 0 (low) on both C0 and C1
// since they are inverted

outb(1, control); // Write 6:
// Outputs a 0 (low) on C0 and a 1 (high) on
// C1 since they are inverted. Again, not
// changing any states on the data pins

}
 

Anytime lights need to be turned on or off, this function is called. For example, let's say we want the 2nd, 4th, and 5th light circuits on box 2 to come on. We simply call the function with the following code:

   set_box(26,2);

The 26 is the binary equivalent of 00011010. Looking at this binary code from right to left, you'll notice light circuits 2,4, and 5 are 1 (high) turning them ON. The second parameter "2" indicates the SSR circuit box number.



    << Previous Page       Page 1    Page 2   Page 3    Page 4       Next Page >>
 

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