The combined current draw of PortA plus PortB are 200mA. With the shcematics I posted, there are roughly 5mA is alocated to driving each NPN transistor for total of less than 15mA. That leaves 12 other pins among two ports. With resistors of 180 ohms on anodes, the maximum current per each RGB device is 15mA. So 15mA x 12 RGB= 180mA. So total comsumption for 15 pins is just 195mA at maximum peak usage. That is if R,G,B of all 15 modules are turned on at the same time (color white). If we are using R, G, B as 3 primary colors for colorrot then realistically we are using each color 2/3 of the time. Or 2/3 of 15mA x 12 = 120mA average cycle thru each frame. Similarly if we are doing rainbow across 12 channels, on average only two transistors are turned on for total of 10mA. So your total consumption is 120+10mA = 130mA. Way below 200mA chip's maximum operational current. But we are blasing the LED at 33% duty cycle, so your perception of brightness of each LED is close to full brightness.I think I understand what you're doing, although this is an unusual apprach.
Since it doesn't matter in what order values are loaded within the section, you could re-arrange bits so that there would be a similar number of 1s in each value.
For example, instead of b'11111111' and b'00000000' do b'11110000' and b'00001111' or b'10101010' and b'01010101'.
This will produce more even power draw.
No Iam driving each LED at 15mA. We are turning one color at a time at 15mA (actually specifically red at 17mA, Green at 14mA, and Blue at 14mA). Build the circuit and you see how bright the LED's are! You are thinking in PWM dimension with low duty cycle. That is the whole concept of this programming. And yes you can do dot correction setup for individual LED either thru hardware or software with a few added program lines to modulate each color at specific count!You are driving an LED @ 5mA @ 33% for brightness? Can you share the spec. sheet of the LEDs?
Thank you for simplifying your "colormorph" code down to a level that I could study.Mike let me know if you understand colormorph first. I walk you thru colorrot.
;
; untested example
;
radix dec
Morph
clrf step ;
movlw 1 ;
morphit
movwf duty ; set duty cycle
movlw 20000/1029 ; display each level for ~20-msecs
movwf speed ; (time spent at a single pwm level)
pwmstep
movf color2,W ; pwm period ~1029-us (971-Hz)
movwf PORTA ;
incf step,F ;
decfsz duty,F ;
goto $-2 ;
movf color1,W ;
movwf PORTA ;
decf duty,F ;
incfsz step,F ;
goto $-2 ;
decfsz Speed,F ;
goto pwmstep ;
incfsz duty,W ; fully morphed? yes, skip, else
goto morphit ; do next duty cycle iteration
return ;
Thanks Mike. I tested it with your changes and it works. I removed "Speed" from "Output"Thank you for simplifying your "colormorph" code down to a level that I could study.
North after Mosaic asked the question yesterday, I looked the brightness of two closely. ColorMorph is visually brighter (If I was to guess about 25% or so). Logic says 1/3 of the modulation would yield 33%. But looking at the ColorRot (pictures above), they don't look like 33% but more like 50% full brightness. At 15mA 33% brightness should be much dimmer, but it is not. I am pretty sure I am not over driving the LED's nor the PIC, because my PIC is cold to the touch and my anodes feed directly from PIC!Since the "Morph" is using 100% duty and "Rot" only 33%, does Morph look much brighter than the Rot?
Homemade. One sided copper. Here is copper and silk. Board is 3 inch round.Nice looking PCB. Got any extras?
I did look at them side by side. I have two boards made for this purpose.It's difficult to compare brightness when you cannot look at them at the same time. You can light different LEDs with different duty to see how this affect brightness.
list p=16F628A
#include <p16F628A.inc>
__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _INTOSC_OSC_NOCLKOUT & _LVP_OFF
errorlevel -302 ; supress banksel warning messages during assembly
errorlevel -311 ; supress HIGH operator warning messages during assembly
cblock 0x20
copyPORTA ;Declare variables used in the program
copyPORTB
FrameCount
LoopCount
Color1
Color2
Color3
endc
#define bank0 bcf STATUS,RP0
#define bank1 bsf STATUS,RP0
RESET_VECTOR org 0x000
START
movlw b'00000111' ;Set all ports as outputs
movwf CMCON ;Disable comparators
bank1
clrf TRISA
clrf TRISB
bank0
;-----------------------------------------------------------------------------------
; Main Program and Subroutines
;-----------------------------------------------------------------------------------
Sequence
call MegaColor
goto Sequence
;---------------------------------------------
MegaColor
movlw b'00010000'
movwf Color1
movlw b'01000000'
movwf Color2
movlw b'10000000'
movwf Color3
call Rainbow
;
movlw b'00010000'
movwf Color1
movlw b'01000000'
movwf Color2
movlw b'10000000'
movwf Color3
call Rainbow
;
movlw b'00010000'
movwf Color1
movlw b'01000000'
movwf Color2
movlw b'10000000'
movwf Color3
call Rainbow
;
movlw b'00010000'
movwf Color1
movlw b'11010000'
movwf Color2
movlw b'10010000'
movwf Color3
call Rainbow
;
movlw b'01010000'
movwf Color1
movlw b'00010000'
movwf Color2
movlw b'01010000'
movwf Color3
call Rainbow
;
movlw b'00010000'
movwf Color1
movlw b'01010000'
movwf Color2
movlw b'00010000'
movwf Color3
call Rainbow
;
movlw b'00010000'
movwf Color1
movlw b'01010000'
movwf Color2
movlw b'10010000'
movwf Color3
call Rainbow
;
movlw b'00010000'
movwf Color1
movlw b'01010000'
movwf Color2
movlw b'01000000'
movwf Color3
call Rainbow
;
movlw b'00010000'
movwf Color1
movlw b'01000000'
movwf Color2
movlw b'10000000'
movwf Color3
call Rainbow
;
movlw b'10010000'
movwf Color1
movlw b'11010000'
movwf Color2
movlw b'01000000'
movwf Color3
call Rainbow
;
movlw b'10000000'
movwf Color1
movlw b'11010000'
movwf Color2
movlw b'00010000'
movwf Color3
call Rainbow
;
movlw b'00010000'
movwf Color1
movlw b'11010000'
movwf Color2
movlw b'01000000'
movwf Color3
call Rainbow
;
movlw b'01000000'
movwf Color1
movlw b'11010000'
movwf Color2
movlw b'10000000'
movwf Color3
call Rainbow
;
return
;----------------------------------
Rainbow
call Frame1
Return
;--------------------------------------------------------------
Frame1 ;Each section modulates R,G,B
movlw d'160'
movwf FrameCount
FR1 call C1
call Sec1 ;Individual sections are shared by R, G,B calls
call C2
call Sec2
call C3
call Sec3
decfsz FrameCount,F
goto FR1
return
;--------------------------------------------------------------
Sec1
movlw d'100'
movwf LoopCount
loop1
movlw b'00001111' ;Values for Anodes (common) placed in B0-B7 & A0-A3
movwf copyPORTB
movlw b'00001110'
call Output
movlw b'00000111'
movwf copyPORTB
movlw b'00001100'
call Output
movlw b'00000011'
movwf copyPORTB
movlw b'00001000'
call Output
movlw b'00000001'
movwf copyPORTB
movlw b'00000000'
call Output
decfsz LoopCount,F
goto loop1
return
;---------------------------------------------
Sec2
movlw d'100'
movwf LoopCount
loop2
movlw b'11111110'
movwf copyPORTB
movlw b'00000000'
call Output
movlw b'01111100'
movwf copyPORTB
movlw b'00000000'
call Output
movlw b'00111000'
movwf copyPORTB
movlw b'00000000'
call Output
movlw b'00010000'
movwf copyPORTB
movlw b'00000000'
call Output
decfsz LoopCount,F
goto loop2
return
;---------------------------------------------
Sec3
movlw d'100'
movwf LoopCount
loop3
movlw b'11100000'
movwf copyPORTB
movlw b'00001111'
call Output
movlw b'11000000'
movwf copyPORTB
movlw b'00000111'
call Output
movlw b'10000000'
movwf copyPORTB
movlw b'00000011'
call Output
movlw b'00000000'
movwf copyPORTB
movlw b'00000001'
call Output
decfsz LoopCount,F
goto loop3
return
;-----------------------------------------------------------------------------------------
C1
movfw Color1 ;Sets the colors used in 3 chan, R,G,B
movwf copyPORTA ;Individual color for each section is stored
return ;in copyPORTA and added to anode bits (A0-A3)at "OUTPUT" call
;---------------------------------------------
C2
movfw Color3
movwf copyPORTA
return
;---------------------------------------------
C3
movfw Color2
movwf copyPORTA
return
;---------------------------------------------
Output
addwf copyPORTA,0 ;content of w from SEC# is added to copyPORTA which has color (Ex: 10000000 = Blue)
movwf PORTA ;the result of addition is placed in w and then transfered to PORTA directly
movfw copyPORTB
movwf PORTB
return
;---------------------------------------------
end
I don't think flowchart will tell you a lot more than said above. But here it is:Perhaps a flowchart is easier to follow. Reading details doesn't show structure as a flow chart or state diagram.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?