hpwit / I2SClocklessVirtualLedDriver

MIT License
31 stars 4 forks source link

Can each LED strip be set with a different number of LEDs? #21

Open junkao opened 4 months ago

junkao commented 4 months ago

Hi, Yves BAZIN

Can each LED strip be set with a different number of LEDs?

thks.

hpwit commented 4 months ago

HelloWith the virtual driver not it’s not possible in its current state Even if that is not a real issue you can send more leds to a strip than the length of strip. What do you have in mind ?On 21 May 2024, at 13:04, Laok @.***> wrote: Hi, Yves BAZIN Can each LED strip be set with a different number of LEDs? thks.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you are subscribed to this thread.Message ID: @.***>

junkao commented 3 months ago

Thank you for your reply. I have just set up an environment and tried it out with two demos, but the I2SClocklessVirtualLedDriver is not working properly and no signals are output. The other demo outputs data normally, indicating that the 74hc595 is working. I am only using an ESP32 and one 74hc595, so is this affecting the normal operation of the driver?

test ok.

`//Pin connected to ST_CP of 74HC595 int latchPin = 27;

//Pin connected to SH_CP of 74HC595 int clockPin = 26;

////Pin connected to DS of 74HC595 int dataPin = 18; void setup() { //set pins to output so you can control the shift register pinMode(latchPin, OUTPUT); pinMode(clockPin, OUTPUT); pinMode(dataPin, OUTPUT); } void loop() { // count from 0 to 255 and display the number // on the LEDs for (int numberToDisplay = 0; numberToDisplay < 256; numberToDisplay++) { // take the latchPin low so // the LEDs don't change while you're sending in bits: digitalWrite(latchPin, LOW); // shift out the bits: shiftOut(dataPin, clockPin, MSBFIRST, numberToDisplay); //take the latch pin high so the LEDs will light up: digitalWrite(latchPin, HIGH); // pause before next value: delay(1); } }`

test faild, no signals are output.

`#define NBIS2SERIALPINS 4 //the number of virtual pins here mavimum 32 strips // #define STATIC_COLOR_GRB 1 //set the strip color

define NUM_LEDS_PER_STRIP 400

define NUM_LEDS (NUM_LEDS_PER_STRIPNBIS2SERIALPINS8)

define CLOCK_PIN 26

define LATCH_PIN 27

define NUM_STRIPS 32

include "I2SClocklessVirtualLedDriver.h"

//here we have 3 colors per pixel uint8_t leds[NUM_STRIPSNUM_LEDS_PER_STRIP3];

int pins[4]={18,5,22,23};

I2SClocklessVirtualLedDriver driver; void setup() { Serial.begin(115200);

driver.initled((uint8_t*)leds,pins,CLOCK_PIN,LATCH_PIN); driver.setBrightness(10);

}

int off=0; long time1,time2,time3; void loop() { time1=ESP.getCycleCount(); for(int j=0;j<NUM_STRIPS;j++) {

    for(int i=0;i<NUM_LEDS_PER_STRIP;i++)
    {

        driver.setPixel((i+off)%NUM_LEDS_PER_STRIP+NUM_LEDS_PER_STRIP*j,(NUM_LEDS_PER_STRIP-i)*255/NUM_LEDS_PER_STRIP,i*255/NUM_LEDS_PER_STRIP,(((128-i)+255)%255)*255/NUM_LEDS_PER_STRIP);

    }
    for(int i=0;i<(j+1);i++)
    {
     // driver.setPixel(i+j*NUM_LEDS_PER_STRIP,255,0,0);
    }
}
time2=ESP.getCycleCount();
driver.showPixels();
time3=ESP.getCycleCount();
Serial.printf("Calcul pixel fps:%.2f   showPixels fps:%.2f   Total fps:%.2f \n",(float)240000000/(time2-time1),(float)240000000/(time3-time2),(float)240000000/(time3-time1));
off++;

}`

hpwit commented 3 months ago

Hello You need to have the clock and latch signal going through an 74hc245 or 74hc125 before going to the 74hc595. It's not only for level shifting but it induces a delay that is necessary for the signals to be latched correctly. Ps the data signal goes directly to the 595. Yves

junkao commented 3 months ago

Hello You need to have the clock and latch signal going through an 74hc245 or 74hc125 before going to the 74hc595. It's not only for level shifting but it induces a delay that is necessary for the signals to be latched correctly. Ps the data signal goes directly to the 595. Yves

Hi, I tried adding 74hc125 and the problem is the same as the original. The logic analyzer shows that clock, latch, and data have signals. I connect the data directly to the led strip , not through 595, the strip shows OK, it looks like the signal works serially, not in parallel.

i use I2SClocklessVirtualLedDriver 2.0/2.1 arduino-esp32 2.0.17

Did I mis something?

hpwit commented 3 months ago

hello When you send the data via the 595 then nothing appears ? what does your logic analyser is seing when you send the data signal via the 595 and look at the output of the 595? it's looks like it's working but it's not you 've got light only because te data signal is a pulse that looks like what should be sent.

junkao commented 3 months ago

Yes, the logic analyzer tests the ESP pin to have signal pulses. d192fe00-a185-4a13-9c56-e7f3785430e1x

but only all high or all low levels when passing 595

hpwit commented 3 months ago

Please download the latest version of the library that I have push last week. Correction for esp idf5. And let me know if you have the same behaviour

junkao commented 3 months ago

he latest version of the library that I have push last week. Correction for esp idf5. And let me know if you have the same behaviou

Upgraded to the latest version and it's still the same err.

1 esp32 pin-8 vpin

447aa041-f64c-42ef-94a9-b82b7c318d59

hpwit commented 3 months ago

Can you give me the speed of the clock pin and the speed of the latch pin ? If you do not see anything at the output of your 595 that is strange you should see something at least garbage Have you checked your wiring or maybe switch the 595 for a new one. Because that is really strange

hpwit commented 3 months ago

Which ide are you using ?

junkao commented 3 months ago

Because that is really strange... i agree .

I'm very confused, there is no garbage signal 。

latchPin latch

clockPin clk

led sig led sig

other demo 595 output is ok, `

int latchPin = 27;

int clockPin = 26;

int dataPin = 18; void setup() { //set pins to output so you can control the shift register pinMode(latchPin, OUTPUT); pinMode(clockPin, OUTPUT); pinMode(dataPin, OUTPUT); } void loop() { // count from 0 to 255 and display the number // on the LEDs for (int numberToDisplay = 0; numberToDisplay < 256; numberToDisplay++) { // take the latchPin low so // the LEDs don't change while you're sending in bits: digitalWrite(latchPin, LOW); // shift out the bits: shiftOut(dataPin, clockPin, MSBFIRST, numberToDisplay); //take the latch pin high so the LEDs will light up: digitalWrite(latchPin, HIGH); // pause before next value: delay(1); } }` testaa

junkao commented 3 months ago

It may be that there is a problem with the quality of the 595 components, and the speed is not enough, so I will re-order a few 595s to try at that time

hpwit commented 3 months ago

The clock signal is wrong it should be around 20Mhz not 8mhz try to put the clock on another pin like 25 for instance and look at the output. The code is correctly functioning as I see the latch is well at 2.4 MHz

hpwit commented 3 months ago

Ps I am using arduino ide with the latest arduino core. I have tried with 2.0.17 and it's working too

hpwit commented 3 months ago

Can you measure sur clock pin directly out of the esp32 and not at the output of the 125 ? It should be 19.2 MHz and the latch 19.2/8 =2.4 MHz.

junkao commented 3 months ago

Test the clock directly from the esp32 pin with only 4.8MHz

hpwit commented 3 months ago

with the esp32 unplugged ?from the hc125 ? Screenshot 2024-06-10 at 14 46 21

Clock Latch One data signal you Seee that you have 8 clock pulses between each latch. that fast that the latch as the ocrrect frequency tells me that the code is working. so either there is something with your vboard . which board are you using ?

junkao commented 3 months ago

yes,unpluged from hc245. I use esp32-wroom-32e/esp32-wrover-e If you're using a wrover do not use pin 18 for output because it's linked to the psram. Maybe change this in your code

junkao commented 3 months ago

Thank you for your answer. I'll try again

hpwit commented 3 months ago

Oki let me know