So far I have not been able to get any LEDs to light.westaust55 did a tutorial for the WS2801 which is the 3 channel chip
http://www.picaxeforum.co.uk/showthread.php?22713-Getting-Started-with-the-WS2801-3-Channel-RGB-LED-Driver-with-PWM-output
if they work in a similar manner then it should be along the same routines.
if you post some of your code and a little more info about the issues you are encountering with it then the large number of knowledgeable people on here should be able to get you pointed in the right direction and on your way.
tony
setfreq m32
label1:
low c.1
pauseus 400
high c.1
'pause 1
high c.2
high c.4
low c.4
for w13=1 to 288
toggle c.1
next w13
low c.1
pauseus 400
high c.1
pause 1
low c.1
pause 5000
low c.1
toggle c.2
pause 5000
'debug
goto label1
; -----[ I/O Definitions ]--------------------------------------------------
; - - - DIGITAL INPUT PINS - - -
; none used
;
; - - - DIGITAL OUTPUT PINS - - -
SYMBOL SData = pin[COLOR="#FF0000"]C.2[/COLOR] ; SDI Pin on WS2801 - used to transfer 1 bit of data to a pin
SYMBOL S_Data = [COLOR="#FF0000"]C.2[/COLOR] ; SDI Pin - also defined this way to use with the LOW command in Init:
SYMBOL SClock = [COLOR="#FF0000"]C.1[/COLOR] ; CKI Pin on WS2801
Did you try using the code for the 18M2 that I had posted previously as a basis -see post 3 at the link provided by tony_g above (at post 2) with a few IO re-assigned?
I suspect your code even at 32 MHz PICAXE clock speed will not clock out the data fast enough when in a FOR...NEXT loop. With the M2 parts you need to open out the loop tp load a bytes and send all the bits very quickly. The WS datasheets are a little vague on some time requirements. FOr the WS2803, the only clear time duration I saw at a glance was that 600us stop in transmissions was enought to cause the WS2801 to reset if the clock input line is held low.
Suggest you try a modified very of my 18M2 code as a starting point.
; =================================================
; File....... 18M2 3xWS2801
; Purpose.... A demo program to show control of a WS2801 RGB LED drivers
; Author..... Westaust55
; E-mail.....
; Started.... 25-11-2012
; Updated.... DD-MM-YYYY
; =================================================
; 'Modified by Rob Bell
'Jan 29 2013
' For use with a WS2803 18 channel LED driver.
'This program will drive 16 LEDs.
'Outputs 0 and 17 on the WS2803 are NOT used.
; -----[ Program Description ]---------------------------------------------
; A program to demonstrate the control of a short string of three WS2801 RGB LED driver chips
;
; -----[ Revision History ]---------------------------------------------------
;
; A = 25-11-2012 First release total program size = 113 bytes
#PICAXE 18M2
SETFREQ M32
; -----[ I/O Definitions ]--------------------------------------------------
; - - - DIGITAL INPUT PINS - - -
; none used
;
; - - - DIGITAL OUTPUT PINS - - -
SYMBOL SData = pinB.6 ; SDI Pin on WS2801 - used to transfer 1 bit of data to a pin
SYMBOL S_Data = B.6 ; SDI Pin - also defined this way to use with the LOW command in Init:
SYMBOL SClock = B.7 ; CKI Pin on WS2801
; -----[ Constants ]-------------------------------------------------------
SYMBOL TotalMods = 6
SYMBOL Data_Sets = 14
SYMBOL SeqStep_Delay = 4000 ; for 0.75 sec delay at 16 MHz
SYMBOL DataBaseAddr = $80
; -----[ Variables ]-------------------------------------------------------
SYMBOL LED_Data = b0 ; NOTE: - this must be b0 for SendData sub routine to work
SYMBOL DataTransf = b1
SYMBOL No_LEDs = b2
SYMBOL CycleLen = b3
SYMBOL MemAddr = b4
SYMBOL Cntr = b5
SYMBOL AllSent = b6
; -----[ EEPROM Data ]-----------------------------------------------------
; Put the RGB LED data into EEPROM as 3 bytes per LED at quarter intensity - $FF for max intensity
EEPROM $00, ($00,$3F,$00, $00,$00,$00, $00,$00,$00, $00,$00,$00, $00,$00,$00, $00,$3F,$00) ; LED dataset 1
EEPROM $12, ($00,$00,$3F, $00,$00,$00, $00,$00,$00, $00,$00,$00, $00,$00,$00, $3F,$00,$00) ; LED dataset 2
EEPROM $24, ($00,$00,$00, $3F,$00,$00, $00,$00,$00, $00,$00,$00, $00,$00,$3F, $00,$00,$00) ; LED dataset 3
EEPROM $36, ($00,$00,$00, $00,$3F,$00, $00,$00,$00, $00,$00,$00, $00,$3F,$00, $00,$00,$00) ; LED dataset 4
EEPROM $48, ($00,$00,$00, $00,$00,$3F, $00,$00,$00, $00,$00,$00, $3F,$00,$00, $00,$00,$00) ; LED dataset 5
EEPROM $5A, ($00,$00,$00, $00,$00,$00, $3F,$00,$00, $00,$00,$3F, $00,$00,$00, $00,$00,$00) ; LED dataset 6
EEPROM $6C, ($00,$00,$00, $00,$00,$00, $00,$3F,$00, $00,$3F,$00, $00,$00,$00, $00,$00,$00) ; LED dataset 7
EEPROM $7E, ($00,$00,$00, $00,$00,$00, $00,$00,$3F, $3F,$00,$00, $00,$00,$00, $00,$00,$00) ; LED dataset 8
EEPROM $90, ($00,$00,$00, $00,$00,$00, $00,$3F,$00, $00,$3F,$00, $00,$00,$00, $00,$00,$00) ; LED dataset 9
EEPROM $A2, ($00,$00,$00, $00,$00,$00, $3F,$00,$00, $00,$00,$3F, $00,$00,$00, $00,$00,$00) ; LED dataset 10
EEPROM $B4, ($00,$00,$00, $00,$00,$3F, $00,$00,$00, $00,$00,$00, $3F,$00,$00, $00,$00,$00) ; LED dataset 11
EEPROM $C6, ($00,$00,$00, $00,$3F,$00, $00,$00,$00, $00,$00,$00, $00,$3F,$00, $00,$00,$00) ; LED dataset 12
EEPROM $D8, ($00,$00,$00, $3F,$00,$00, $00,$00,$00, $00,$00,$00, $00,$00,$3F, $00,$00,$00) ; LED dataset 13
EEPROM $EA, ($00,$00,$3F, $00,$00,$00, $00,$00,$00, $00,$00,$00, $00,$00,$00, $3F,$00,$00) ; LED dataset 14
; -----[ Initialization ]--------------------------------------------------
Init:
Low S_Data ; by using LOW command we automatically also set the pin as an output
Low Sclock ; by using LOW command we automatically also set the pin as an output
MemAddr = 0 ; set the EEPROM data pointer to the first location
No_LEDs = 3 * TotalMods ; calculate the total number of individual LED channels
AllSent = DataBaseAddr + No_LEDs ; the upper RAM location for M2 RAM "scratchpad" area
CycleLen = No_LEDs * Data_Sets ; calculate the number of bytes of EEPROM data in the cycle
;
; -----[ Program Code ]----------------------------------------------------
Main:
DO
GOSUB FetchData
IF MemAddr = CycleLen THEN
MemAddr = 0
ENDIF
GOSUB SendData
PAUSE SeqStep_Delay ; provide a delay between updates so user can see new pattern
LOOP
;
; -----[ Subroutines ]-----------------------------------------------------
;
; ***** Subroutine to fetch the data from EEPROM and save into Scratchpad for 2 RGB LED modules
FetchData:
bptr = DataBaseAddr
DO
READ MemAddr, LED_Data ; fetch a byte of data from EEPROM
@bPtrInc = LED_Data ; and save into the scratchpad area
INC MemAddr ; increment the EEPROM address pointer
LOOP UNTIL bPtr = AllSent ; loop until a complete new set of data has been obtained
RETURN
;
; Subroutine to serially clock out the data through the SW2801 chips for the RGB LEDs
SendData:
bptr = DataBaseAddr ; set the RAM start location for RGB LED string data
DO
LED_Data = @bptrinc ; load the data into b0 so we can extract each bit quickly
SData = bit7 : PulsOut SClock, 1 ; msb first to the data pin and clock out
SData = bit6 : PulsOut SClock, 1
SData = bit5 : PulsOut SClock, 1
SData = bit4 : PulsOut SClock, 1
SData = bit3 : PulsOut SClock, 1
SData = bit2 : PulsOut SClock, 1
SData = bit1 : PulsOut SClock, 1
SData = bit0 : PulsOut SClock, 1 ; lsb of the current data byte to be clocked out
LOOP UNTIL bptr = AllSent ; continue until all data is sent for all RGB LEDs in string
RETURN
Right you are!!For an 08M2 you will need to change this:
SYMBOL DataBaseAddr = $80
as it only has addresses 00-7F so you are out of range.
That note served to remind me I am a complete newbie with the picaxe hardware.Great to read that you have the WS2803 circuit/code working.
I will make a note on the RAM capacity of the 08M2 being less than 18M2.
I Should in fact recheck for all M2 parts.
EDIT:
I have now added a note in my WS2801 thread about the reduced available RAM capacity of the 08M2 and need to define a new starting address for the temp storage of the "current data" in the SYMBOL statement.
RAM has no limitations on how many times you can write to it.Any reason why one could not modify the contents of the EEPROM between cycles?
Ok, Plan B will have to be created.RAM has no limitations on how many times you can write to it.
EEPROM has a limitation on how many time you can write to a location before the possibility of failure occurs.
If you were only writing now an again to EEPROM this is not a problem, but writing new data to EEPROM for each step of a pattern cycle may expedite failure of the EEPROM locations to which you keep rewriting every millisecond or so.
Ok, Plan B will have to be created.
; =================================================
; File....... 18M2 3xWS2801
; Purpose.... A demo program to show control of a WS2801 RGB LED drivers
' modified Jan 29 2013 to drive WS2803
; Author..... Westaust55
'Modified by Rob Bell
; E-mail.....
; Started.... 25-11-2012
; Updated.... DD-MM-YYYY
; =================================================
; ' Modifications
; -----[ Program Description ]---------------------------------------------
; A program to demonstrate the control of a short string of three WS2801 RGB LED driver chips
;
; -----[ Revision History ]---------------------------------------------------
;
; A = 25-11-2012 First release total program size = 113 bytes
#PICAXE 08M2
SETFREQ M32
; -----[ I/O Definitions ]--------------------------------------------------
; - - - DIGITAL INPUT PINS - - -
; none used
;
; - - - DIGITAL OUTPUT PINS - - -
SYMBOL SData = pinC.2 ; SDI Pin on WS2801 - used to transfer 1 bit of data to a pin
SYMBOL S_Data = C.2 ; SDI Pin - also defined this way to use with the LOW command in Init:
SYMBOL SClock = C.1 ; CKI Pin on WS2801
; -----[ Constants ]-------------------------------------------------------
SYMBOL TotalMods = 6
SYMBOL Data_Sets = 14
SYMBOL SeqStep_Delay = 4000 ; for 0.75 sec delay at 16 MHz
SYMBOL DataBaseAddr = $10
; -----[ Variables ]-------------------------------------------------------
SYMBOL LED_Data = b0 ; NOTE: - this must be b0 for SendData sub routine to work
SYMBOL DataTransf = b1
SYMBOL No_LEDs = b2
SYMBOL CycleLen = b3
SYMBOL MemAddr = b4
SYMBOL Cntr = b5
SYMBOL AllSent = b6
SYMBOL Bright = b7
; -----[ EEPROM Data ]-----------------------------------------------------
; Put the RGB LED data into EEPROM as 3 bytes per LED at quarter intensity - $FF for max intensity
EEPROM $00, ($00,$3F,$00, $00,$00,$00, $00,$00,$00, $00,$00,$00, $00,$00,$00, $00,$3F,$00) ; LED dataset 1
EEPROM $12, ($00,$00,$3F, $00,$00,$00, $00,$00,$00, $00,$00,$00, $00,$00,$00, $3F,$00,$00) ; LED dataset 2
EEPROM $24, ($00,$00,$00, $3F,$00,$00, $00,$00,$00, $00,$00,$00, $00,$00,$3F, $00,$00,$00) ; LED dataset 3
EEPROM $36, ($00,$00,$00, $00,$3F,$00, $00,$00,$00, $00,$00,$00, $00,$3F,$00, $00,$00,$00) ; LED dataset 4
EEPROM $48, ($00,$00,$00, $00,$00,$3F, $00,$00,$00, $00,$00,$00, $3F,$00,$00, $00,$00,$00) ; LED dataset 5
EEPROM $5A, ($00,$00,$00, $00,$00,$00, $3F,$00,$00, $00,$00,$3F, $00,$00,$00, $00,$00,$00) ; LED dataset 6
EEPROM $6C, ($00,$00,$00, $00,$00,$00, $00,$3F,$00, $00,$3F,$00, $00,$00,$00, $00,$00,$00) ; LED dataset 7
EEPROM $7E, ($00,$00,$00, $00,$00,$00, $00,$00,$3F, $3F,$00,$00, $00,$00,$00, $00,$00,$00) ; LED dataset 8
EEPROM $90, ($00,$00,$00, $00,$00,$00, $00,$3F,$00, $00,$3F,$00, $00,$00,$00, $00,$00,$00) ; LED dataset 9
EEPROM $A2, ($00,$00,$00, $00,$00,$00, $3F,$00,$00, $00,$00,$3F, $00,$00,$00, $00,$00,$00) ; LED dataset 10
EEPROM $B4, ($00,$00,$00, $00,$00,$3F, $00,$00,$00, $00,$00,$00, $3F,$00,$00, $00,$00,$00) ; LED dataset 11
EEPROM $C6, ($00,$00,$00, $00,$3F,$00, $00,$00,$00, $00,$00,$00, $00,$3F,$00, $00,$00,$00) ; LED dataset 12
EEPROM $D8, ($00,$00,$00, $3F,$00,$00, $00,$00,$00, $00,$00,$00, $00,$00,$3F, $00,$00,$00) ; LED dataset 13
EEPROM $EA, ($00,$00,$3F, $00,$00,$00, $00,$00,$00, $00,$00,$00, $00,$00,$00, $3F,$00,$00) ; LED dataset 14
; -----[ Initialization ]--------------------------------------------------
Init:
Low S_Data ; by using LOW command we automatically also set the pin as an output
Low Sclock ; by using LOW command we automatically also set the pin as an output
MemAddr = 0 ; set the EEPROM data pointer to the first location
No_LEDs = 3 * TotalMods ; calculate the total number of individual LED channels
AllSent = DataBaseAddr + No_LEDs ; the upper RAM location for M2 RAM "scratchpad" area
CycleLen = No_LEDs * Data_Sets ; calculate the number of bytes of EEPROM data in the cycle
Bright = $02
; -----[ Program Code ]----------------------------------------------------
Main:
DO
GOSUB FetchData
IF MemAddr = CycleLen THEN
MemAddr = 0
Bright = Bright + Bright
ENDIF
if bright =0 then
bright =02
endif
GOSUB SendData
'GOSUB Brightloop
if bright=$FF then
Bright=$1F
endif
debug
PAUSE SeqStep_Delay ; provide a delay between updates so user can see new pattern
LOOP
;
; -----[ Subroutines ]-----------------------------------------------------
;
; ***** Subroutine to fetch the data from EEPROM and save into Scratchpad for 2 RGB LED modules
FetchData:
bptr = DataBaseAddr
DO
READ MemAddr, LED_Data ; fetch a byte of data from EEPROM
if led_data<>$00 then
led_data =Bright
b9=led_data
@bptrinc = led_data
else
@bPtrInc = LED_Data ; and save into the scratchpad area
b10 = led_data
endif
INC MemAddr ; increment the EEPROM address pointer
LOOP UNTIL bPtr = AllSent ; loop until a complete new set of data has been obtained
RETURN
#rem
Brightloop:
bptr = DataBaseAddr
DO
LED_Data = @bptrinc
if led_data<>$00 then
led_data = b9
led_data = Bright
@bptrinc = led_data
b8=b8+1
endif
LOOP UNTIL bptr = AllSent
;
Return
#endrem
; Subroutine to serially clock out the data through the SW2801 chips for the RGB LEDs
SendData:
bptr = DataBaseAddr ; set the RAM start location for RGB LED string data
DO
LED_Data = @bptrinc ; load the data into b0 so we can extract each bit quickly
SData = bit7 : PulsOut SClock, 1 ; msb first to the data pin and clock out
SData = bit6 : PulsOut SClock, 1
SData = bit5 : PulsOut SClock, 1
SData = bit4 : PulsOut SClock, 1
SData = bit3 : PulsOut SClock, 1
SData = bit2 : PulsOut SClock, 1
SData = bit1 : PulsOut SClock, 1
SData = bit0 : PulsOut SClock, 1 ; lsb of the current data byte to be clocked out
LOOP UNTIL bptr = AllSent ; continue until all data is sent for all RGB LEDs in string
RETURN