To the question of LEDs and their control via MK

There is a whole line of very interesting devices - three-color LEDs with built-in control circuit (ws2811, ws2812, ws2812b, ws2813 ...). Their characteristic feature is the price, which can hardly be called anything other than ridiculous, which determines their extraordinary popularity among amateurs. For some reason, they are often called addressable LEDs, which, in my opinion, is not entirely true, since these devices do not have their own unique address and are addressed by a position in the connection chain, but let's leave the subtleties of terminology outside the brackets.





Marginal note (PNP): This family is produced, which is quite natural, outside of our vast Motherland. As a specialist directly related to this topic, I cannot but express my bewilderment about the absence of such products in the range of electronic devices produced by domestic manufacturers. I understand that the manufacture of microcircuits according to standards of 90 or less in the Russian Federation is impossible, despite repeated statements about the development of these processes by Angstrem, but components like those described in this post simply cannot require the use of such advanced technologies, so the answer to the question lies, probably more economically than technologically. But, nevertheless, our southern neighbors make such devices and, for sure, not at a loss for themselves.





All devices of this family provide the user with the most simple hardware interface - one-wire (in fact, of course, three-wire, since a common ground is assumed, and it will not be easy to do without power supply) and fewer conductors are hardly possible. But for everything in this world you have to pay, in this case the payment is the message protocol, which is a serial protocol with the encoding of information with the duration of the pulse. The solution is well-known, if certain requirements are met, it is reliable, but the devil, as always, is hidden in the details.





In this case, the details lie in the durations of the coding pulses - to achieve high transmission rates, they are taken very, very small (of course, depending on what to compare with) - on the order of hundreds of nanoseconds, we will see specific values ​​later. In combination with a non-standard transmission format ("Lord, England, then what did not please him"), the implementation of such a protocol on standard MCUs presents a certain problem, and we will talk about possible solutions to this problem.





- - () , () . 8 /*3 = 24 ( , 32). n ( N) . , . , ", ".





. , , 150*2=600, , : - 150 , - 150 , - 600 . , , , , " ".





: 400 () 800 () , - 800 . , , ": 2 , (reset time) ", , , . : , / " " - , , .





( /?) , . , , , .





()





WS2811





WS2812





WS2813









T0H





0.22-0.38





0.2-0.5





0.3-0.45





0.375





T1H





0.58-1.0





0.75-1,05





0.75-1.0





0.875





T0L





0.58-1.0





0.75-1,05





0.3-100





0.875





T1L





0.58-1.0





0.2-0,5





0.3-100





0.375





TH+TL









1.1-1.4





0.95-1.55





1.25





Res





>280





>50





>300





>300





: , , 4 1 2 , 1 ). , , , .





, ( , ), , .





, (, ), . 300-380 , 800-900 , 640-760 500-600 . /: (800+380)/380:(900+300)/300 = 3.1:4 10/3:4/1, (640+600)/600:(760+500)/500=2.06:2.5 10/6:10/4. , .





, 1/80 ( ) = 12.5 . , , , . , 8 3 = 375 7 = 875 (" ? - "), - 6 4 . : , , , . , , .





, - .

:





  1. - , ,





  2. , ( , , ).





    :





  3. ,





  4. ,





  5. (, ),





  6. 100% , ,





  7. . , , 2813 . : , - . 64 , 64 * 32/ *1.25/ = 2.56.





( , ) - . , . , . ( 8 ), 3 . , , , , , . , - , 2-3 . : 2-3 80, 12.5 *3=37.5 .





, . :





  1. ( ),





  2. - . - .





. ( AVR, ARM , , ) 4-6 , 4-5 , 6-7 , 4-5 , 4-5 , 4, - 5-6. 38 , , 375 , 1/=1/(37510**-9/38)=38/37510**9~100. , .





, , , , .





( " ") . , , , 51 48 . (PWM), , , . 3 7 ( 10 , 3 , ) ( ), , , . , , , .





, - , , . ( ) , , , (, , ).





- "" , ( , , ) . , - , .





:









  1. .





    :





  2. , ( ),





  3. , . - - 375 , - 1250 , 38/(1250*10**9) = 31 .





- (STM XMEGA), . - . ( 32 , ), . , , , (ping pong round robin) " ". , 32*(5-10)/=160-320 32*1250/, 320/32*125*10*-9 = 10*10/1250=8 , , . , 2*32 , , .





- . , , , , , , 8/*32*50/( 20 )=12.5 ( 40). , , , , . , , , .





. - , , " ". - , ( , , ).





. , , , . , , , ( ). , - , ( ) - ( , ), , ( ) . , , "" . : , , , , .





, , ... . . 32*n( N) , , . , , , =64 32/*64*1/ = 2, , ( - 15 , , ). : , ( 16), , , ( ). , , , 32/*64 *(1/8)/=256 . , ( ).





, . , I2C/TWI ( , ), SPI ( , ) UART ( ).





I2C ( , ) - , , (, , ) ( 8 ) .





SPI, . - ( 1-2 ) , 10- . , 8- (- 10 ), . : ", , " - , 2 , 8 .





UART - , ( ) . ", , ", , , , 1 0 , . , 0b00000011 b00011111, 0 1 8 (, , ). : , UART . - , , . , , .





- . UART, 10 (3/10 6/10), 5 (2/5 3/5), . UART 4 ( ), , .





, 8 32 , (, ) .





, , . , ( ) .





P.S. , - .








All Articles