Led strip connection


#1

I was thinking about connecting a led strip to the propboard.
In a practical lightsaber use you have two strips of 120leds in parallel.
Each led drains around 60mA at full brightness and in the worst condition means 14,4 A of current.

Looking at the led strip connection schematic in the manual, the GND is connected to the board pad, I do not think he could sustain such a high current.
I think is better to connect the GND wire directly to the supply voltage, with a proper section wire.
Or at least advise people to take care about this before build something.


#2

Hi @Mangaman,

That’s a different strip than the LedStrip library manages. The LedStrip library works with serially addressable LEDs, specifically WS2812B.

LEDs in parallel should be connected where you connect now the High-Brightness LED (LED power output) and used with the same functions (i.e. HBLED::begin, HBLED::setValue, etc.). Remember that they can handle up to 1A each. Even if the LED outputs are optimized for HB LEDs, to use a LEDs in parallel could be a nice BETA test. :wink:

Back to the LedStrip library: should the picture in the manual be more clear? It should and will be corrected. In any case, the GND pads share a ground plane (a layer dedicated to ground) in the board, so it should be OK. The thing is that the pad is small an may be difficult to solder a thick wire.

Just out of curiosity: how you power-up a setup that eats 14A? Because with a 3000mA/H battery you will have a nice ~12 minutes lightsaber.


#3

We are talking on the same led strip.
For sabers they use the 144 led/mt and if you look at Adafruit type for example https://www.adafruit.com/product/1506, they rate a maxuimum current around 60mA each led for the white combination at full brightness, with the real application it should be less (I agree with you)

I got today from amazon to test a 30 led WS2812B led strip. They rate it at 2,7W so it means 18mA maximum each led.
With the numbers I mentioned in the first post (240 leds) the maximum current could be 4,3 A

I was only worried about people frying the ground plane of the board draining a lot of current.
The picture is perfect, maybe think about adding a note about the currents used in the project.


#4

Hi @Mangaman,

Have you implemented the LED strip? Does it work well?


#5

Yes, all your functions work good.
I was trying to do a shimmer like function using timers but probably I messed up with other function timers, probably a wrong NVIC setting.

What I wanted to do was to “stress” the board having a lightsaber with both led strip and power leds working together (and motion and sound of course) and see if runs stable.

Haven’t much time these days, probably in the weekend I will continue :smiley:


#6

Great! Thank you @Mangaman.

I’m finishing Core version 1.0.1 and the last thing that’s left is the shimmering function for the LedStrip library.

By the way, if you want to use your own interrupts, take into consideration the priorities of the interrupts used for the other functionalities. You can find a list of them in the \variants\propboard_v1\variant.h file. That is:

#define VARIANT_PRIO_LEDSTRIP	0
#define VARIANT_PRIO_I2S_DMA	1
#define VARIANT_PRIO_SDIO		2
#define VARIANT_PRIO_SYSTICK	3
#define VARIANT_PRIO_ST			4
#define VARIANT_PRIO_UART		5
#define VARIANT_PRIO_USER_EXTI	10
#define VARIANT_PRIO_PENDSV		255

At long as your interrupts have a higher value of 5 (priority lower than 5) you shouldn’t be interrupting any other critical functions. Note that calling LedStrip::update inside an interrupt would block the program flow until it finishes (I’m working on an asynchronous version of the function for the shimmering).


#7

Thanks for the infos.
Actually I have problems with interrupt and the standard functions.

For example: This code runs and I have an interrupt driven shimmer function

#include <stm32f4xx_gpio.h>
#include <stm32f4xx_tim.h>
#include <stm32f4xx_rcc.h>
#include <misc.h>
#include <LedStrip.h>

LedStrip myLedStrip;

GPIO_InitTypeDef  GPIO_InitStructure;
TIM_TimeBaseInitTypeDef  TIM_TimeBaseStructure;

uint8_t ind = 0;
bool flagINT = false;

void setup()
{
  Serial.begin(115200);
  // A WS2812B strip with 30LEDs
  myLedStrip.begin(30);
  
  swOn();

  initIrqTimer();
}

void loop() {

    if (flagINT == true){
      myLedStrip.set(0,random(35)+220,random (5),0);
      myLedStrip.update();
      flagINT = false;
      TIM_ITConfig(TIM9, TIM_IT_Update, ENABLE);
    }


}

void swOn ()
{
  for(int ciclo = 1; ciclo < 31; ciclo ++){
    myLedStrip.set(ciclo, 255,0,0);
    myLedStrip.update();
    delay(30);
  }
}
  
void swOff ()
{
  for(int ciclo = 30; ciclo > 0; ciclo --){
    myLedStrip.set(ciclo, 0,0,0);
    myLedStrip.update();
    delay(30);
  }
}

void initIrqTimer()
{
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM9, ENABLE);
  
  NVIC_InitTypeDef nvicStructure;
  nvicStructure.NVIC_IRQChannel = TIM1_BRK_TIM9_IRQn;
  nvicStructure.NVIC_IRQChannelPreemptionPriority = 11;
  nvicStructure.NVIC_IRQChannelSubPriority = 11;
  nvicStructure.NVIC_IRQChannelCmd = ENABLE;
  NVIC_Init(&nvicStructure);
  NVIC_EnableIRQ(TIM1_BRK_TIM9_IRQn);

  TIM_TimeBaseInitTypeDef timerInitStructure; 
  timerInitStructure.TIM_Prescaler = 4200 -1;              // CLK 84MHz diviso 4200 -> 20KHz (50 usec)
  timerInitStructure.TIM_CounterMode = TIM_CounterMode_Up;
  timerInitStructure.TIM_Period = 200 -1;                  // Durata 200 ticks -> 10 msec interrupt
  timerInitStructure.TIM_ClockDivision = TIM_CKD_DIV1;
  timerInitStructure.TIM_RepetitionCounter = 0;
  TIM_TimeBaseInit(TIM9, &timerInitStructure);
  TIM_Cmd(TIM9, ENABLE);
  TIM_ITConfig(TIM9, TIM_IT_Update, ENABLE);
}

extern "C" void TIM1_BRK_TIM9_IRQHandler()
{
  if (TIM_GetITStatus(TIM9, TIM_IT_Update) != RESET)
  {
    TIM_ITConfig(TIM9, TIM_IT_Update, DISABLE);
    TIM_ClearITPendingBit(TIM9, TIM_IT_Update);
    flagINT = true;
  }
}

But if I add a hum effect in the background, I got the audio scrambled.
Here is the code:

#include <stm32f4xx_gpio.h>
#include <stm32f4xx_tim.h>
#include <stm32f4xx_rcc.h>
#include <misc.h>
#include <LedStrip.h>

LedStrip myLedStrip;
WavPlayer hum;

GPIO_InitTypeDef  GPIO_InitStructure;
TIM_TimeBaseInitTypeDef  TIM_TimeBaseStructure;

uint8_t ind = 0;
bool flagINT = false;

void setup()
{
  Serial.begin(115200);
  // A WS2812B strip with 30LEDs
  myLedStrip.begin(30);
  
  Audio.begin();
  Audio.setVolume(-10); // No noise for testing..
  
  swOn();

  initIrqTimer();
  hum.play("hum.wav", PlayModeLoop);
}

void loop() {

    if (flagINT == true){
      myLedStrip.set(0,random(35)+220,random (5),0);
      myLedStrip.update();
      flagINT = false;
      TIM_ITConfig(TIM9, TIM_IT_Update, ENABLE);
    }


}

void swOn ()
{
  for(int ciclo = 1; ciclo < 31; ciclo ++){
    myLedStrip.set(ciclo, 255,0,0);
    myLedStrip.update();
    delay(30);
  }
}
  
void swOff ()
{
  for(int ciclo = 30; ciclo > 0; ciclo --){
    myLedStrip.set(ciclo, 0,0,0);
    myLedStrip.update();
    delay(30);
  }
}

void initIrqTimer()
{
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM9, ENABLE);
  
  NVIC_InitTypeDef nvicStructure;
  nvicStructure.NVIC_IRQChannel = TIM1_BRK_TIM9_IRQn;
  nvicStructure.NVIC_IRQChannelPreemptionPriority = 11;
  nvicStructure.NVIC_IRQChannelSubPriority = 11;
  nvicStructure.NVIC_IRQChannelCmd = ENABLE;
  NVIC_Init(&nvicStructure);
  NVIC_EnableIRQ(TIM1_BRK_TIM9_IRQn);

  TIM_TimeBaseInitTypeDef timerInitStructure; 
  timerInitStructure.TIM_Prescaler = 4200 -1;              // CLK 84MHz diviso 4200 -> 20KHz (50 usec)
  timerInitStructure.TIM_CounterMode = TIM_CounterMode_Up;
  timerInitStructure.TIM_Period = 200 -1;                  // Durata 200 ticks -> 10 msec interrupt
  timerInitStructure.TIM_ClockDivision = TIM_CKD_DIV1;
  timerInitStructure.TIM_RepetitionCounter = 0;
  TIM_TimeBaseInit(TIM9, &timerInitStructure);
  TIM_Cmd(TIM9, ENABLE);
  TIM_ITConfig(TIM9, TIM_IT_Update, ENABLE);
}

extern "C" void TIM1_BRK_TIM9_IRQHandler()
{
  if (TIM_GetITStatus(TIM9, TIM_IT_Update) != RESET)
  {
    TIM_ITConfig(TIM9, TIM_IT_Update, DISABLE);
    TIM_ClearITPendingBit(TIM9, TIM_IT_Update);
    flagINT = true;
  }
}

I do not understand if I did something wrong or there is a interrupt management problem


#8

I’ll run your code as soon as I can. In the meantime try with nvicStructure.NVIC_IRQChannelSubPriority = 0;

Or delete all the nvicStructure and NVIC_EnableIRQ part and just use NVIC_SetPriority(TIM1_BRK_TIM9_IRQn, 11);


#9

Thanks!
I will try and let you know


#10

I forgot. If you go with the second option, add also NVIC_EnableIRQ(TIM1_BRK_TIM9_IRQn);

After

NVIC_SetPriority(TIM1_BRK_TIM9_IRQn, 11);


#11

Tried, no success.
The defect is every time passes on the TIM1_BRK_TIM9_IRQHandler() routine, I hear a “tick” on the audio.

Tried also with TIM3, same result.


#12

I discovered this: the audio “tick” disappears if you comment this line in the LOOP routine

myLedStrip.set(0,random(100)+155,random (5),0);

So I have done another test, excuded the TIM use and done the shimmer in the main loop.
same result, the “tick” happens every “set” command.

Here is the code I used.

#include <LedStrip.h>

LedStrip myLedStrip;
WavPlayer hum;

void setup()
{
  Serial.begin(115200);
  // A WS2812B strip with 30LEDs
  myLedStrip.begin(30);
  
  Audio.begin();
  Audio.setVolume(-10); // No noise for testing..
  
  swOn();

  hum.play("hum.wav", PlayModeLoop);
}

void loop() {

    myLedStrip.set(0,random(100)+155,random (5),0);
    myLedStrip.update();
    delay(500);


}

void swOn ()
{
  for(int ciclo = 1; ciclo < 31; ciclo ++){
    myLedStrip.set(ciclo, 255,0,0);
    myLedStrip.update();
    delay(30);
  }
}
  
void swOff ()
{
  for(int ciclo = 30; ciclo > 0; ciclo --){
    myLedStrip.set(ciclo, 0,0,0);
    myLedStrip.update();
    delay(30);
  }
}

#13

Hi @Mangaman

Ok. The noise doesn’t come from interrupts. There is a silly bug in the LedStrip library overflowing the audio output buffers.

Change the \artekit\hardware\stm32f4\1.0.0\libraries\LedStrip\src\LedStrip.cpp file, in the LedStrip::setWS2812B function, where it says:

	if (index == 0)
		count = led_count * 3;

to

	if (index == 0)
		count = led_count;

Led strip function
[BETA] Known issues, TBDs and feature requests
#14

Thanks, is working now.


#15

will be much lower current if power the digital led strip shorter section,as about 2m extra power,
I have try with the sk6812 and ws2813b led strips.