0
\$\begingroup\$

I have an ATmega328P (16MHz extern, GBoard with SIM900 module). I bought 10 LEDs with WS2812B module. My ATmega works with 3.3V but for LEDs I need 5V so I decided to connect TXB0104.

I connected TXB0104 with C1 output pin from ATmega. My LEDs work randomly. I cannot set proper color and brightness using light_ws2812 library.

My code is very simple. I know I have 10 diodes but for now I just want to test first in the row. What is the problem this doesn't work? Maybe TXB0104 is not convenient for this purpose? I know light_ws2812 uses bit banging and assembler code. Maybe it is too fast for TXB0104? By the way, I didn't connect OE pins of TXB0104 but it should be fine anyway.

#define F_CPU 16000000
#include <util/delay.h>
#include <avr/io.h>
#include "light_ws2812.h"



struct cRGB led[1];

int main(void)
{
    while(1)
    {
            led[0].r = 255;
            led[0].b = 00;
            led[0].g = 0;
            ws2812_setleds(led, 1);
            _delay_ms(500);

            led[0].r = 0;
            led[0].b = 255;
            led[0].g = 0;
            ws2812_setleds(led, 1);
            _delay_ms(500);

            led[0].r = 0;
            led[0].b = 00;
            led[0].g = 255;
            ws2812_setleds(led, 1);
            _delay_ms(500);
    }
}

The problem is TXB0104! I connected my GBoard directly to WS2812B.It works as expected.

Can anybody tell me if this is because 16MHz is too fast for TXB0104 or maybe OE pins should be somehow connected?

I cannot use 3,3V from GBoard but some converter instead. @user263983, you suggested to use BJT. Which one should I use for this purpose? I'm newbie. Thanks in advance.

\$\endgroup\$
4
  • \$\begingroup\$ You do not need bidirectional level shifter. Just one BJT is enough. \$\endgroup\$
    – user263983
    Nov 23, 2021 at 12:51
  • \$\begingroup\$ do you have an oscilloscope? that would be great for troubleshooting whether it's a hardware or software problem \$\endgroup\$ Nov 23, 2021 at 12:59
  • \$\begingroup\$ No, I don't have oscilloscope. With this source code my first and second led light up randomly. It means 24 bits are spread to 2 diodes - "too long" signal. I reduced my parameters of number of clocks but the result is still random. Based on source code for 16MHz there shoud be following number of clock cycles: #define w_zerocycles 7 // 16*0,4 = 6,4 #define w_onecycles 13 // 16*0,8 = 12,8 #define w_totalcycles 20 //16*1,25 =20 \$\endgroup\$
    – sticker
    Nov 23, 2021 at 13:11
  • 1
    \$\begingroup\$ have you tried one of the example sketches for your library? have you tried a different library (e.g. Adafruit_NeoPixel) and is examples? If that works you know you have a software problem. \$\endgroup\$
    – vicatcu
    Nov 23, 2021 at 13:39

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.