Roomlight

a computer controlled RGB light panel


Edsard Boelen, 05-march-2007
this project is to create a panel with bright full colour leds to iluminate a room. It will be controlled by a computer, and later on by a micro controller.

the idea

The rgb led usually has 4 pins, one common ground, and for each color a separate pin. It should be possible to generate all the colors of the rainbow with a rgb led, if the intensity of the 3 sources are changed.
the TLC 5620 is a quad 8bit-da converter, ranged 0-5v. it has a simple 3 wire interface, and it accepts words of 11 bits.
my idea is to place 8 rows of rgb leds, each with an da converter. the clock and load line are global, each data output from the parallel cable will be a row.

see this schematic


second idea

it might be easier to program a PIC right away and make use of PWM to control the colors. the 12f629 is below €2,- and some low voltage mosfets will do just fine. the only problem is that a pic programmer is needed. here is the schematic:


I also made a test board with 3 lm317 voltage regulators. set to max 3,5V for the green and blue, and 2.5 for red (red has an extra diode to drop 0v7)
with the 3 variable resistors, it is posible to create any color there is.





the programmer

The wisp628 from voti.nl is a very nice in-circuit programmer. I ordered the kit, and got it operational without a lot of problems.



the sweex connector on the right is a USB to rs232 adapter, I also draw the 5V supply from it.



I used the program bumblebee to test if the programmer could identify itself.


This is the prototype, the three topmost leds are controlled by the 3 buttons. The bright green led at the bottom is driven by a mosfet.


The assembly code is below:
; dimm4.asm
; a button dims a led in 8 steps
;

	list P = 16F628a	;microcontroller identity
		; e.g: 0x033 = hex value

	__Config 3F18h 

;****************************************************************
;Equates
;****************************************************************
status	equ	0x03
cmcon	equ	0x1F
rp1	equ	0x06	;this is bit 6 in file 03
rp0	equ	0x05	;this is bit 5 in file 03

flags	equ	0x30	;flag file



	cblock 	0x20 			;start of general purpose registers
		count1 			;used in delay routine
		counta 			;used in delay routine 
		countb 			;used in delay routine
    CountR  
    CountRoff
    CountGoff 
    CountBoff
    Acount 
    aDel	  
   endc

; countvalues they are all 255 by default



;****************************************************************
;Beginning of program
;****************************************************************
reset:	org	0x00	;reset vector address	
	goto	SetUp	;goto set-up
	nop
	nop
	nop
	org	4	;interrupts go to this location 
	goto	isr1	;goto to Interrupt Routine  - not used
			;    in these experiments.
			;isr1 must be written at address 004
			;   otherwise bcf status,rp1 will be 
			;   placed at address 01 by assembler!	

;****************************************************************
;* Port A and B initialisation			*
;****************************************************************

SetUp	bcf	status,rp1		;select bank 1 
	bsf	status,rp0

	movlw	0xFF		;make all Port A inputs
	movwf	0x05			
	movlw	0x0F		; out out out out  in in in in 
	movwf	0x06		; 

	bcf	status,rp0		;select programming area - bank0
	movlw	0x07		;turn comparators off and enable
	movwf	cmcon		;    pins for I/O functions
	
    movlw	0x86 ; set w to 150
    movwf   CountRoff ; counterOff is 150
    movwf   CountGoff ; green off is 150
    movlw	0x06
    movwf   CountBoff
    movlw   0xFE;
    movwf   CountR
    goto 	Main

;****************************************************************
;* Interrupt Service Routine will go here (not used)	*
;****************************************************************
isr1

;****************************************************************
;* Main 					*
;****************************************************************

Main
   	bsf	0x06,5	;Port B, output bit 5 = turn on red LED pin 11
    bsf	0x06,4	;Port B, output bit 4 = turn on green LED pin 11
    bsf	0x06,6

;*** begin pwm ***********************************
	movf CountR,0  ; move 'on' time in W
    movwf Acount ;  move W into the counter
CRon    decfsz Acount,1 ; decrease acount until its zero
    goto CRonn
    goto CRonc
CRonn 
    movf CountRoff,0 ; 
    XORWF Acount,0 ;XOR cuurent count and CountRoff
    BTFSC 03,2   ;Test Z flag  If Z flag is SET (ie 1) the two files are the SAME!  
    bcf	0x06,5 ; then turn off red
    
    movf CountGoff,0 ; 
    XORWF Acount,0 ;XOR current count and Count green off
    BTFSC 03,2   ;Test Z flag  If Z flag is SET (ie 1) the two files are the SAME!  
    bcf	0x06,4 ; then turn off green

    movf CountBoff,0 ; 
    XORWF Acount,0 ;XOR current count and Count green off
    BTFSC 03,2   ;Test Z flag  If Z flag is SET (ie 1) the two files are the SAME!  
    bcf	0x06,6 ; then turn off blue
;**** end pwm ********************************************

    goto CRon
;**** begin check buttons ********************************
CRonc ;movf CountR,0
    ;movwf Acount ; set Acount back to its original value
 	btfsc	0x06,0	;Port B, input bit 0 = red button pushed?
    goto PushRed
    btfsc   0x06,1 ; portb = green button pushed
    goto PushGreen
    btfsc   0x06,2 ; portb = green button pushed
    goto PushBlue


    clrf	flags	;clear flag file
    goto	Main


;*******************************************************
;************ subroutines              ******************

; push red button routine
PushRed btfsc	flags,0	;test flag (button has been pushed previous loop) 
	goto	Main
    movlw 0x0A ;  
    addwf CountRoff,1
    MOVLW 0xA0 
    SUBWF CountRoff,0
    btfsc 03,0
    call RedCarry

    bsf	flags,0	;set the flag
	goto Main

RedCarry
   movlw	0x02 ; set w to 150
   movwf   CountRoff ; counterOff is 150 
   return

; push green button routine
PushGreen btfsc	flags,0	;test flag (button has been pushed previous loop) 
	goto	Main
    movlw 0x0B ;  
    addwf CountGoff,1
 
    bsf	flags,0	;set the flag
	goto Main

; push green button routine
PushBlue btfsc	flags,0	;test flag (button has been pushed previous loop) 
	goto	Main
    movlw 0x0B ;  
    addwf CountBoff,1

    bsf	flags,0	;set the flag
	goto Main
;*******************************************************
; delay
Dels    movlw 0x10 ; 32 counts
        movwf aDel
Loop1   decfsz  aDel,1     ;
        goto Loop1    
     
     return  

	
Del  movlw	d'2'			;delay 250 ms (4 MHz clock)
	movwf	count1
d1	movlw	0xC7
	movwf	counta
	movlw	0x01
	movwf	countb
Delay_0
	decfsz	counta, f
	goto	$+2
	decfsz	countb, f
	goto	Delay_0

	decfsz	count1	,f
	goto	d1
	retlw	0x00

	END




This is the first version of the board.


This is the current working and installed version