This technique is very interesting:
Tutorial on Programming the NeoPixel (WS2812) RGB LEDs
I'll test it with my oscilloscope someday...
This technique is very interesting:
Tutorial on Programming the NeoPixel (WS2812) RGB LEDs
I'll test it with my oscilloscope someday...
Hi,
actually I had idea to put few passive component for making one-shout for short period and one shut for longer period
after that i timed mssp module to average carrier frequency (positive + negative periode) this can be done using add register i done it with 16f1827 + internal osc +PLL
intention was to make it on both MSSP modules, but i have problem using both paralell.....
ok, this is working, and now timing and hw-accelerated sending is piece of cake for basic timings.....
but i miss memory, so i have to port all onto 46k22 which is still dual mssp internal 64mhz, cheap, need to read erratas frequently but almost always there is workaround
why more memory ? because i want to have ability to change any led, so you need 3 byte per led, and for 100 leds, this is 300 byte of ram....
this days i obtained psoc4 and i want to organize UDB module for hardware accelerator for sw led, but ah.... this is totally hardCore
http://www.element14.com/community/b...ioneer-dev-kit
noone for now is'n sharing code/project, so i can learn from working project.... there is actually other shared article as arduino or others...
i hope i at least point you in some direction....
reagards
Well guys..
I have been messing around with this issue all weekend.
Still working on the timing control.. very tight timing needed to drive these strips.
till then.. happy coding.
There are 10 kinds of people. Those that know binary and those that do not.
The link that MichelJasmin posted is interesting in the the author found that the ON timing was the most critical, and the OFF time didn't seem to affect it. I would like to play with this more when I'm not busy with other things.
Mark
I need your help. I've converted the Tutorial on Programming the NeoPixel to PICBASIC. I’m using a PIC18F25K22 at 40MHz. I get the right timings (400ns & 800ns) but I don’t have a NeoPixel! I’ve ordered a Led strip from AliExpress but it takes one month to get it…
So, if anyone of you can give it a try please. Keep the data line as short as possible with a short ground return. This will improve the rise and fall time. The nice thing about these pixels is when data is forwarded, it is passed through the internal reshaping mechanism. (Ref: Understanding the WS2812 ).
Thanks!
Code:'**************************************************************** '* Name : NeoPixel '* Author : Michel Jasmin '* Notice : Copyright (c) 2014 '* : All Rights Reserved '* Date : 2014-08-13 '* Version : 1.0 '* Notes : '* : '**************************************************************** 'PIC18F25K22 #CONFIG __CONFIG _CONFIG1H, _FOSC_HSHP_1H & _PLLCFG_OFF_1H & _PRICLKEN_ON_1H & _FCMEN_ON_1H & _IESO_ON_1H __CONFIG _CONFIG2H, _WDTEN_OFF_2H __CONFIG _CONFIG3H, _PBADEN_ON_3H & _CCP2MX_PORTB3_3H & _MCLRE_EXTMCLR_3H __CONFIG _CONFIG4L, _STVREN_OFF_4L & _LVP_OFF_4L & _XINST_OFF_4L __CONFIG _CONFIG5L, _CP0_ON_5L & _CP1_ON_5L & _CP2_ON_5L & _CP3_ON_5L __CONFIG _CONFIG5H, _CPB_ON_5H & _CPD_ON_5H #ENDCONFIG DEFINE OSC 40 DEFINE NO_CLRWDT 1 ' Don't waste cycles clearing WDT '------------ ALIAS ------------------------- LedPin VAR LATC.3 NeoPin VAR LATC.5 '------------ Const ------------------------- NEO_NUM CON 60 CR CON 13 LF CON 10 '------------ Variables ------------------------- NeoGreen VAR BYTE[NEO_NUM] NeoBlue VAR BYTE[NEO_NUM] NeoRed VAR BYTE[NEO_NUM] NeoPixel VAR BYTE BitCount VAR BYTE TempW VAR WORD 'Flags AppFlags VAR BYTE DataBit VAR AppFlags.0 '------------------------ Initialization ------------------------------- Clear ' Clear RAM before entry TRISC.3 = 0 'Led Pin TRISC.5 = 0 'NeoPin TRISC.6 = 1 'TX1 TRISC.7 = 1 'RX1 'The serial port is used only for debugging purpose. RCSTA = $90 ' Enable serial port & continuous receive TXSTA = $24 ' Enable transmit, BRGH = 1 SPBRG = 17 ' 9600 Baud @ 40 MHz -0.03% SPBRGH = 4 BAUDCON.3 = 1 ' Enable 16 bit baudrate generator PAUSE 100 HSEROUT [CR,LF,CR,LF,"Test NeoPixel v 17",CR,LF] 'Blink a LED just to say: Hello, I'm alive! LedPin = 0 FOR TempW = 0 TO 4 TOGGLE LedPin PAUSE 250 NEXT LedPin = 0 DataBit = 0 GOSUB NeoInit '------------ Main program ------------------------- Main: 'For testing purpose: 'DataBit = 1 'GOSUB NeoBit 'GOTO Main GOSUB NeoDraw GOSUB NeoRotate PAUSE 25 GOTO Main END NeoBit: IF DataBit = 1 THEN '400ns pulse required NeoPin = 1 '3 nop = 500ns @ 32MHz '2 nop = 376ns @ 32MHz '2 nop = 300ns @ 40MHz '3 nop = 400ns @ 40MHz ASM nop nop nop ENDASM NeoPin = 0 ELSE '800ns pulse required NeoPin = 1 '5 nop = 740ns @ 32MHz '6 nop = 880ns @ 32MHz '6 nop = 700ns @ 40MHz '7 nop = 800ns @ 40MHz ASM nop nop nop nop nop nop nop ENDASM NeoPin = 0 ENDIF RETURN NeoInit: FOR NeoPixel = 0 TO NEO_NUM IF NeoPixel < 10 THEN NeoGreen[NeoPixel] = 0 NeoBlue[NeoPixel] = 0 NeoRed[NeoPixel] = 64 ELSEIF NeoPixel < 20 THEN NeoGreen[NeoPixel] = 0 NeoBlue[NeoPixel] = 64 NeoRed[NeoPixel] = 0 ELSEIF NeoPixel < 30 THEN NeoGreen[NeoPixel] = 0 NeoBlue[NeoPixel] = 64 NeoRed[NeoPixel] = 64 ELSEIF NeoPixel < 40 THEN NeoGreen[NeoPixel] = 64 NeoBlue[NeoPixel] = 0 NeoRed[NeoPixel] = 0 ELSEIF NeoPixel < 50 THEN NeoGreen[NeoPixel] = 64 NeoBlue[NeoPixel] = 0 NeoRed[NeoPixel] = 64 ELSE NeoGreen[NeoPixel] = 64 NeoBlue[NeoPixel] = 64 NeoRed[NeoPixel] = 0 ENDIF NEXT RETURN NeoDraw: FOR NeoPixel = 0 TO NEO_NUM FOR BitCount = 7 TO 0 STEP -1 DataBit = NeoGreen.0[NeoPixel * BitCount] GOSUB NeoBit NEXT FOR BitCount = 7 TO 0 STEP -1 DataBit = NeoRed.0[NeoPixel * BitCount] GOSUB NeoBit NEXT FOR BitCount = 7 TO 0 STEP -1 DataBit = NeoBlue.0[NeoPixel * BitCount] GOSUB NeoBit NEXT NEXT NeoPin = 0 RETURN NeoRotate: FOR NeoPixel = 0 TO (NEO_NUM - 1) NeoGreen[NeoPixel] = NeoGreen[NeoPixel + 1] NeoBlue[NeoPixel] = NeoBlue[NeoPixel + 1] NeoRed[NeoPixel] = NeoRed[NeoPixel + 1] NEXT NeoGreen[NEO_NUM - 1] = NeoGreen[0] NeoBlue[NEO_NUM - 1] = NeoBlue[0] NeoRed[NEO_NUM - 1] = NeoRed[0] RETURN
Made a few mistakes, sorry...
Code:'**************************************************************** '* Name : NeoPixel '* Author : Michel Jasmin & The Signal Path dot com BLOG '* Notice : Ref: The Signal Path dot com BLOG '* : Tutorial on Programming the NeoPixel (WS2812) RGB LEDs '* : http://thesignalpath.com/blogs/2014/07/14/watcheditdeletetutorial-on-programming-the-neopixel-ws2812-rgb-leds-equipment-giveaway/ '* Date : 2014-08-13 '* Version : 1.0 '* Notes : '* : '**************************************************************** 'PIC18F25K22 @40MHz #CONFIG __CONFIG _CONFIG1H, _FOSC_HSHP_1H & _PLLCFG_OFF_1H & _PRICLKEN_ON_1H & _FCMEN_ON_1H & _IESO_ON_1H __CONFIG _CONFIG2H, _WDTEN_OFF_2H __CONFIG _CONFIG3H, _PBADEN_ON_3H & _CCP2MX_PORTB3_3H & _MCLRE_EXTMCLR_3H __CONFIG _CONFIG4L, _STVREN_OFF_4L & _LVP_OFF_4L & _XINST_OFF_4L __CONFIG _CONFIG5L, _CP0_ON_5L & _CP1_ON_5L & _CP2_ON_5L & _CP3_ON_5L __CONFIG _CONFIG5H, _CPB_ON_5H & _CPD_ON_5H #ENDCONFIG DEFINE OSC 40 DEFINE NO_CLRWDT 1 ' Don't waste cycles clearing WDT '------------ ALIAS ------------------------- LedPin VAR LATC.3 NeoPin VAR LATC.5 '------------ Const ------------------------- NEO_NUM CON 60 CR CON 13 LF CON 10 '------------ Variables ------------------------- NeoGreen VAR BYTE[NEO_NUM] NeoBlue VAR BYTE[NEO_NUM] NeoRed VAR BYTE[NEO_NUM] NeoPixel VAR BYTE BitCount VAR BYTE TempW VAR WORD 'Flags AppFlags VAR BYTE DataBit VAR AppFlags.0 '------------------------ Initialization ------------------------------- Clear ' Clear RAM before entry TRISC.3 = 0 'Led Pin TRISC.5 = 0 'NeoPin TRISC.6 = 1 'TX1 TRISC.7 = 1 'RX1 'The serial port is used only for debugging purpose. RCSTA = $90 ' Enable serial port & continuous receive TXSTA = $24 ' Enable transmit, BRGH = 1 SPBRG = 17 ' 9600 Baud @ 40 MHz -0.03% SPBRGH = 4 BAUDCON.3 = 1 ' Enable 16 bit baudrate generator PAUSE 100 HSEROUT [CR,LF,CR,LF,"Test NeoPixel v 18",CR,LF] 'Blink a LED just to say: Hello, I'm alive! LedPin = 0 FOR TempW = 0 TO 4 TOGGLE LedPin PAUSE 250 NEXT LedPin = 0 DataBit = 0 GOSUB NeoInit '------------ Main program ------------------------- Main: 'For testing purpose: 'DataBit = 1 'GOSUB NeoBit 'GOTO Main GOSUB NeoDraw GOSUB NeoRotate PAUSE 25 GOTO Main END NeoBit: IF DataBit = 1 THEN '400ns pulse required NeoPin = 1 '3 nop = 500ns @ 32MHz '2 nop = 376ns @ 32MHz '2 nop = 300ns @ 40MHz '3 nop = 400ns @ 40MHz ASM nop nop nop ENDASM NeoPin = 0 ELSE '800ns pulse required NeoPin = 1 '5 nop = 740ns @ 32MHz '6 nop = 880ns @ 32MHz '6 nop = 700ns @ 40MHz '7 nop = 800ns @ 40MHz ASM nop nop nop nop nop nop nop ENDASM NeoPin = 0 ENDIF RETURN NeoInit: FOR NeoPixel = 0 TO (NEO_NUM - 1) IF NeoPixel < 10 THEN NeoGreen[NeoPixel] = 0 NeoBlue[NeoPixel] = 0 NeoRed[NeoPixel] = 64 ELSEIF NeoPixel < 20 THEN NeoGreen[NeoPixel] = 0 NeoBlue[NeoPixel] = 64 NeoRed[NeoPixel] = 0 ELSEIF NeoPixel < 30 THEN NeoGreen[NeoPixel] = 0 NeoBlue[NeoPixel] = 64 NeoRed[NeoPixel] = 64 ELSEIF NeoPixel < 40 THEN NeoGreen[NeoPixel] = 64 NeoBlue[NeoPixel] = 0 NeoRed[NeoPixel] = 0 ELSEIF NeoPixel < 50 THEN NeoGreen[NeoPixel] = 64 NeoBlue[NeoPixel] = 0 NeoRed[NeoPixel] = 64 ELSE NeoGreen[NeoPixel] = 64 NeoBlue[NeoPixel] = 64 NeoRed[NeoPixel] = 0 ENDIF NEXT RETURN NeoDraw: FOR NeoPixel = 0 TO (NEO_NUM + 1) TempW = (NeoPixel * 8) FOR BitCount = 7 TO 0 STEP -1 DataBit = NeoGreen.0[TempW + BitCount] GOSUB NeoBit NEXT FOR BitCount = 7 TO 0 STEP -1 DataBit = NeoRed.0[TempW + BitCount] GOSUB NeoBit NEXT FOR BitCount = 7 TO 0 STEP -1 DataBit = NeoBlue.0[TempW + BitCount] GOSUB NeoBit NEXT NEXT NeoPin = 0 RETURN NeoRotate: FOR NeoPixel = 0 TO (NEO_NUM - 1) NeoGreen[NeoPixel] = NeoGreen[NeoPixel + 1] NeoBlue[NeoPixel] = NeoBlue[NeoPixel + 1] NeoRed[NeoPixel] = NeoRed[NeoPixel + 1] NEXT NeoGreen[NEO_NUM - 1] = NeoGreen[0] NeoBlue[NEO_NUM - 1] = NeoBlue[0] NeoRed[NEO_NUM - 1] = NeoRed[0] RETURN
Ordered strip recently, will see how this code works![]()
Bookmarks