AnalogWrite stops working when I call FastLED.show

Hello!

I am using the FastLED library to drive a bunch of WS2812B Leds with an ARDUINO DUE.

I use pins 2 to 9 to analogWrite values to a DAC.

Whenever I call FastLED.show to apply values to the LEDS, analogWrite stops working, and never works again.

The weird thing, it is that the problem appeared when i started powering the LEDS with an external +5V supply instead of Arduino's 5V.

I'm going crazy. Anyone ever had this issue?

Thank you!

That doesn't make much sense. You don't use analogWrite to send stuff to a DAC. The analogWrite function simply sends out a PWM signal.

So did you connect the ground of this external supply to the Arduino ground?

Also the Due is a 3V3 system and has not got a big enough voltage output to correctly drive LED strips being powered by 5V.

Can you please post a schematic of your circuit, hand drawn is fine Fritzing is not.

Hello, thank you for your answer!

the DAC is external (the 8 PWMs gets filtered to get a fluctuating 0-3.3V DC). It's part of a much bigger circuit (multiple PCB's) (tuner for a synth), the schematic is just impossible to understand if you are not working on it :slight_smile:

The 5V is supplyed by a filtered 78M05 wich ground is properly connected to Arduino's GND.

The DUE regulates its 3.3V from the 5V it regulates from the 12V supply. It is capable of driving 5V leds to my knowledge. Doesn't it?

Here is a simple code to illustrate the problem :

The values get outputted ONCE (strange because it is after the FastLED.show call) and then PWM stops working.

#include <FastLED.h>

#define NUM_LEDS 10
#define DATA_PIN 32

CRGB leds[NUM_LEDS];

void setup() { 
//	Serial.begin(57600);
	FastLED.addLeds<WS2812,DATA_PIN,RGB>(leds,NUM_LEDS);
//	FastLED.setBrightness(84);
}

void loop() { 
	static uint8_t hue = 0;

	for(int i = 0; i < NUM_LEDS; i++) {
		leds[i] = CHSV(hue++, 255, 255);
		FastLED.show(); 
	}
		analogWrite(2, 4000);
		delay(200);
		analogWrite(2, 0);
        delay(200);
}

Then it is not a valid schematic diagram.

But it sounds like there are several other user-created problems in your lashup, so good luck with the project!

It is valid. It's just that it has hundreds of parts on multiple PCB boards.

UPDATE :

WEIRD

It works with NeoPixel's Library. Must be a problem with how FastLED handles it's output...
I'd still want to understand because i'd prefer to use FastLED.

#include <Adafruit_NeoPixel.h>

#define PIN        32 
#define NUMPIXELS 10 

Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);


void setup() {

  pixels.begin(); // INITIALIZE NeoPixel strip object (REQUIRED)
}

void loop() {
  pixels.clear(); // Set all pixel colors to 'off'

  for(int i=0; i<NUMPIXELS; i++) { // For each pixel...

    // pixels.Color() takes RGB values, from 0,0,0 up to 255,255,255
    // Here we're using a moderately bright green color:
    pixels.setPixelColor(i, pixels.Color(0, 150, 0));

    pixels.show();   // Send the updated pixel colors to the hardware.

    analogWrite(2, 4000);
		delay(1000);
		analogWrite(2, 0);
		delay(1000);
  }
}

The first sentence seems to be irrelevant, a 3V3 processor produces a 3V3 signal often less depending on the load it is driving.

The standard input signal to drive something is 0.7 Vcc, which for a 5V circuit is 3V5, so no it is not guaranteed to drive an WS2812 strip. It might work but you are In the flakey region of operations.

So in what way does these fluctuating voltages affect the DAC? An ADC I could understand but not an DAC.

More likely is that you have not set the data rate at 800KHz like you have done for the Adafruit version.

Thanks again for the reply!

I mean, I used the DUE 5V output for my leds, but when the load increased (leds full bright), it affected the 3V3, so i switched to a external supply... wich outputs 5.2V.

But yeah you are very right!! I use the 3V3 to control them, and it's well beyond VCC-0.7... It still works to control the leds! From what i read, the first LED raises the signal to 5V. But do you think that some current my flow back to the PWM pin and mess with it?

Anyway if I have to reprint the PCB i'll add a level shifter.

So in what way does these fluctuating voltages affect the DAC? An ADC I could understand but not an DAC.

No no, the DAC converts PWM to a signal between 0v and 3V3, sorry I wasn't clear. But indeed, the leds loading arduino's 5V did lower the 3V3 PWM output wich is internally regulated from the 5V.

More likely is that you have not set the data rate at 800KHz like you have done for the Adafruit version.

I will look into this, but I think that Fastled does it when you set led type to WS2812. You think it could mess with analogwrite?

Thank you very much for your time

You were clear in what you said but I can't see what you did. Can you draw a schematic of the bit of the circuit between the PWM pin and the DAC.

Basically you don't need a DAC to do this, and given the nature of a PWM signal a DAC will not convert it into an analogue voltage.
Why use a DAC when a simple RC filter on the PWM pins will do this for you?

It could seeing you are on a Due which as a different clock speed.

Maybe something like THIS? But I wouldn't call it a "DAC".

Oh... It IS just a RC filter i am using... I'm abusively calling it a DAC, sorry for the confusion.

Screenshot 2022-06-21 at 15.13.50

Oh! Good idea. I check this

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.