STM32 LED Strip (WS2812b) control 1: Theory and implementation

Поділитися
Вставка
  • Опубліковано 7 сер 2024
  • Source code and PDF document:
    www.patreon.com/user?u=80399744
    Website:
    www.steppeschool.com
    This video is about controlling NeoPixel (WS2812) LEDs using the STM32 MCUs. The idea is to generate a PWM signal with varying duty cycles:
    HAL_TIM_PWM_Start_DMA
    HARDWARE:
    NeoPixel Board:
    www.digikey.fr/fr/products/de...
    STM32 Board: STM32F411E-DISCO
    00:00 Introduction
    00:29 WS2812 Theory
    02:50 CubeMx PWM configuration for WS2812
    04:50 Code explanation

КОМЕНТАРІ • 6

  • @steppeschool3629
    @steppeschool3629  Рік тому

    I am happy to announce that I have a Patreon page🙂 where you can access projects' source code, including this one: patreon.com/user?u=80399744&Link&

  • @brianblasius
    @brianblasius 7 місяців тому +3

    I understand how these addressable LEDs work after watching this video. Keep doing great work. 💪

  • @user-ox4qj7ue9x
    @user-ox4qj7ue9x Місяць тому

    hey I have one doubt I want to connect more led stripes in parallel then i want use the different timer pwm but I have problem in the configuration DMA request another timer dma does not show that dma trigger option But I will change the code like that but my code run only single timer In my main c this for tim 2 reset_all_leds(leds, NUMBER_OF_LEDS);
    HAL_TIM_PWM_Start_DMA(&htim2, TIM_CHANNEL_3, (uint32_t*)leds, NUMBER_OF_LEDS1 * 24 + 24);
    HAL_Delay(300);
    set_all_leds(leds, NUMBER_OF_LEDS1);
    HAL_TIM_PWM_Start_DMA(&htim2, TIM_CHANNEL_3, (uint32_t*)leds, NUMBER_OF_LEDS1 * 24 + 24); and
    this one is same code
    tim 3
    led_pos_counter++;
    if(led_pos_counter == NUMBER_OF_LEDS)
    {
    led_pos_counter = 0;
    }
    temp_neo_pixel = circular_pattern_led[led_pos_counter + NUMBER_OF_LEDS];
    circular_pattern_led[led_pos_counter + NUMBER_OF_LEDS];
    circular_pattern_led[2* NUMBER_OF_LEDS];
    HAL_TIM_PWM_Start_DMA(&htim3, TIM_CHANNEL_1, (uint32_t*)&circular_pattern_led[led_pos_counter], NUMBER_OF_LEDS * 24 + 24);
    HAL_Delay(100);
    circular_pattern_led[led_pos_counter + NUMBER_OF_LEDS] = temp_neo_pixel;

  • @amiral3187
    @amiral3187 6 місяців тому +1

    It works well but I'm a bit confused about the data structure newpixel_led, why are you using uint16_t instead of uint8_t? and why a 3 elements of that size if every color is represented with only 8-bits?

    • @steppeschool3629
      @steppeschool3629  6 місяців тому

      Hi,
      If we look at the data structure:
      typedef struct
      {
      uint16_t g[8];
      uint16_t r[8];
      uint16_t b[8];
      } neopixel_led;
      Each member is an array with 8 elements, corresponding to the number of bits per color. For each bit, we need to generate a PWM signal with a particular duty cycle. For that purpose, we need 16-bit values. Hope I could answer your question.