WS2812B Without SPI #3055
Replies: 23 comments
-
|
Posted at 2019-07-06 by Robin Sat 2019.07.06
Hi @gustav, a little puzzled by your comment, as 7/8 down the page, "Note: The nRF52 port has one available I2C, SPI and USART (and infinite software SPI and I2C). Unlike other Espruino boards, these peripherals can be used on any pin." On the MDBT42Q breakout board, I use the code from: Note that you will need a separate supply for the WS2812B strip as the onboard regulator won't be able to drive that many, 9 x ~60ma or roughly half an amp at full on white. Although it doesn't appear to be stated on that page, I believe the regulator is the same as the one used on the Pixl:
Also note that pinMode has given some bewildering pondering. |
Beta Was this translation helpful? Give feedback.
-
|
Posted at 2019-07-07 by @allObjects You may build an array of pulses... you should have enough memory to do that: 9 x 24 x 2 pulses... For the timing see http://forum.espruino.com/comments/14612306/ using https://www.espruino.com/Reference#l__global_digitalPulse . Composing the array may be a bit nifty... but it is all just a matter of 'thinking - bit-banging - it thru'. You make yourself a function that can put the pulses for a byte out and you append for each byte to an array... with arry.push(). Times in digitalPulse() are [ms], and you have to do [us]... like 0.003, 0.006 and 0.009.... I do not know if digitalPulse() can get them out fast enough... you may need to look at the signal with a scope and adjust - shorten - the times to take into account the time of the code that has to run on every transition. - It is though easier to make a custom build that includes neopixel module. |
Beta Was this translation helpful? Give feedback.
-
|
Posted at 2019-07-07 by @MaBecker The build for MDBT42Q does include Neopixel You can follow the sample from API reference |
Beta Was this translation helpful? Give feedback.
-
|
Posted at 2019-07-07 by @allObjects Oooops, took @gustav 's
at face value... @MaBecker, absolutely, since MDBT42Q build includes neopixel... then there is to go with... |
Beta Was this translation helpful? Give feedback.
-
|
Posted at 2019-07-07 by Gustav Thanks for the responses, I don't seem to get it working, I know the ws2812b is rated for 5v but it should work with 3.3 as signal and 5v for vcc. I wired it to pin D30 and tested . |
Beta Was this translation helpful? Give feedback.
-
|
Posted at 2019-07-07 by Robin Sun 2019.07.07 For level shifting the reason why and solutions, See discussions at: PinMode af_opendrain Use of diode or pullup for level shifting I prefer the use of a $0.01 transistor while using these high current demand Neopixels. Get it wrong, and the transistor fuse should go first, hopefully protecting the $35 Espruino microcontroller. I highlighted the references above, but read the entire blog post. Also check out the datasheet to see and understand why: REFERENCE table of RGB Led datasheets Neopixel Second table on page 3 |
Beta Was this translation helpful? Give feedback.
-
|
Posted at 2019-07-07 by @MaBecker Yes, some work with 3.3v but make sure you have enough current, to drive them 😉 Set D30 as output and than try again. |
Beta Was this translation helpful? Give feedback.
-
|
Posted at 2019-07-07 by @allObjects First of all, MDBT42Q module and breakout board ** It though may still work when MDBT42Q output is high enough to be detected as high by WS2812B input. Put WS2812B on power and measure voltage over GND and input (IN). If it floats or shows 0V and for sure equal or less than 3.3V (3.6V is absolute max), you are ok to direct connect MDBT42Q output to WS2812B input... ***Make sure you do connect not just INput but also GND,... with separate power supplies this is often missed, and then there is no definitive current flowing in/out of IN (and GND) between MDBT42Q and WS2812B. If above does not help, you may need to add some switching transistors... see conversation about Logically invert a pin?, where Espruino is driving WSB2812B 'string' to lighten a Nixie Tube Clock. There are multiple options as you will notice. |
Beta Was this translation helpful? Give feedback.
-
|
Posted at 2019-07-10 by @gfwilliams
This hasn't been the case in my experience. There's some info about this in the As a starter I'd try running your neopixels off a LiPo battery (so 3.8v-ish). That lowers their input voltage requirements and tends to make them work great off 3.3v IO. If you then decide you need 5v you can look at level shifting and at least you'll know the hardware is working. As @allObjects says, you can't do the simple |
Beta Was this translation helpful? Give feedback.
-
|
Posted at 2019-07-11 by @allObjects I'm not sure about mentioning
because as @gfwilliams points out it is not 3.3V safe. I did talk about a simple Tran sistor hack as discussed in linked conversation. While writing this I though see an option to get away with just resistors... and to play safe adding a zener. The trick is to shift / offset the low up to just below low detection by the neopixel input so that the high is up as well. In my recent neopixel project I used Pico directly connected and had no issuewhat so ever. Pico is 3.3V driven (but its pins are 5V tolerant). The difference of 3.3V vs 3V on MDBT42Q makes obviously a big difference. The additional issue is that max input is (usualy) defined as supply voltage plus (usually) 0.3V... see 5.1 Absolute Maximum Ratings at http://www.espruino.com/datasheets/MDBT42Q-E.pdf . Based on that a level shifter either as dedicated chip or RYO with transistors is the only real safe way. |
Beta Was this translation helpful? Give feedback.
-
|
Posted at 2019-07-15 by Gustav Alright, great stuff. Will go with a dedicated logic level shift circuit. |
Beta Was this translation helpful? Give feedback.
-
|
Posted at 2019-07-15 by maze1980 My favorite logic level shifter is the BSS138. With two resistors it works bi-directional, if you use only one resistor it's unidirectional. It doesn't invert the signal. |
Beta Was this translation helpful? Give feedback.
-
|
Posted at 2019-08-07 by Gustav Hey so i got it to work thanks to the logic level shifter. But 2 other problem arose. I can't write to 2 different pins, which drives 2 different neopixel strips. Both are 9 leds long. Also cant seem to get the first LED lit up on either of the strips. So once i write to 2 the API freezes and i need to reset the board before i can write to any again. Im using pin D16 and D18 |
Beta Was this translation helpful? Give feedback.
-
|
Posted at 2019-08-07 by maze1980 I'd say it's an electrical problem, most likely you didn't connect ground, data or 5V properly (not getting pin 1 to work). |
Beta Was this translation helpful? Give feedback.
-
|
Posted at 2019-08-07 by Robin Wed 2019.08.07 Hi @gustav, I'm surprised at the frustration you must be going through as this shouldn't be that difficult. I have successfully driven three rows, two of those strings containing 60 Neopixels each. Rest assured, the MDBT42Q can handle what you are attempting.
Any of the GPIO pins will work. D16 and D18 are fine.
What is the result of using the code line in your #6 post? Replace the referenced pin with either of the above, and please explain what is seen.
Might be electrical noise on the data line, could be in the way code is sent to the pin. Bad data, Null data. Endless loop. Poorly constructed setInterval(). Could be if arrays are accessed that element zero is missed. Post some code here please. Things to check: Has the datasheet been reviewed. There are many variants of Neopixel. If they were purchased from an offshore discount site, be aware that many claim to be selling WS2812B and in reality have one of these variants: Post an image of the Neopixel please. Here is an example even using software SPI The onboard regulator is rated between 80-150ma. Attempting to power more than two individual Neopixels as @maze1980, points out, will most likely fry the regulator and possibly rendering the MDBT42Q a smoke detector tester. |
Beta Was this translation helpful? Give feedback.
-
|
Posted at 2019-08-08 by @allObjects ...weird that you do not get the 1st LED lit... I recall something similar... I did set the pin mode and may be something else... see Post #2, code lines #23, #383 ff and #125. I know that you use different board / pin, but code should work the same way. Btw, you can always send more than 9 x 3 bytes / LEDs, the last 9 will lite your 9-LEDs string. Btw, what is the reason to do 2 string rather than just 1 with 18 x 3 bytes? --- Check out my game setup / change / update of buffer and pushing buffer out... It is all mapping... In a different setup I use the Graphics object which allows me nice addressing - see post #26 in same thread. Yours will be 9 cols and 2 rows... |
Beta Was this translation helpful? Give feedback.
-
|
Posted at 2019-08-08 by @gfwilliams Just to add, on a recent version of Espruino on MDBT42 I did: And it works fine - so as others have said this could well be an electrical issue. Those LED strings can draw a bunch of power when on. |
Beta Was this translation helpful? Give feedback.
-
|
Posted at 2019-08-09 by Gustav Thanks for your replies ! I did some investigation based on your answers and then it hit me.. I was driving the 3.3v side of the logic level shifter from Pin D25 with pinMode as 'input_pullup'.. bad idea. Moved it to normal 3.3 v pin. Now everything works smooth, first led works, dual strips. |
Beta Was this translation helpful? Give feedback.
-
|
Posted at 2019-08-09 by Robin Fri 2019.08.08 Glad it's now working, easy isn't it!!
What was the mode of that ('normal') pin? 'auto' maybe?
Any GPIO pin will work. So no real need to move away from D25 > 'driving the 3.3v side of the logic level shifter' Would you please post a link to the level shifter pinout and schematic, so that we may answer that accurately for you. Now that everything is working, what are the plans for the visual output. Running tracer, sparkles, random, train sequencer, meteor, color changer? I may have some code snippets I can dig up. |
Beta Was this translation helpful? Give feedback.
-
|
Posted at 2019-08-13 by Gustav I would love some code snippets ;) They dont seem to provide the schematic directly but i bought this one What i mean with the normal 3.3v pin is the pin that always just supplies 3.3v, i dont know how to target that pin through code. I will upload some videos of the application. |
Beta Was this translation helpful? Give feedback.
-
|
Posted at 2019-08-13 by Gustav VidsAttachments: |
Beta Was this translation helpful? Give feedback.
-
|
Posted at 2019-08-13 by Gustav Vid1Attachments: |
Beta Was this translation helpful? Give feedback.
-
|
Posted at 2019-08-13 by Robin Tue 2019.08.13 Too cool!! Congratulations on a successful project solution! The ingenuity of the human mind to apply ideas never ceases to amaze. I think this application on a 'hover' board ;-) is a first. Might want to add your solution to the Projects forum. > 'They don't seem to provide the schematic directly' Thanks for the purchase site link. Was able to grab the BSS138 datasheet using Google: |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2019-07-06 by Gustav
Is there anyway i can use a very short strip of WS2812B (9 leds) with the MDBT42Q module i see it doesn't have SPI, but can i send a signal any other way ?
Beta Was this translation helpful? Give feedback.
All reactions