Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Mehrdad K
@mkeyno

I run the POV project with teensy1.2 which is read image lines from SD card and show it in LED strip , each image consist of 300 line 144 pixel 3 byte (about 127 Kbyte)of data which is show in less than 40ms (25 fps)
Then I’ve tried to port it to ESP module , the loop function consist three condition along with wifi websocket service
The first condition check whether duration of show is passed and is time to close last file and open the new file

if( (millis()- OpenlastTime) > DURATION[image_index]*1000L )
        {
          FILe.close();
          image_index++; 
          if(image_index>IMAGE_NUM)    image_index=0;          
           FILe=SPIFFS.open("/SHOW/"+IMAGES[image_index], "r");
          if(!FILe) Serial.println("FILE NOT OPEN");
          OpenlastTime=millis();
        }

The second condition check whether new revolution started and time duration of last line has been passed , it read one chunk of data (number of LED * 3) and fed to show function to display it

if(!Start_new_round && (micros()-lastLineShow)> lineInterval)
        {
        int i = 0; 
           while( (i < NUM_LEDS*3) && FILe.available())
          { 
               i += FILe.readBytes( ((char*)leds) + i, (NUM_LEDS*3)-i);
            }

        FastLED.show(); 
        lastLineShow=micros();
        Current_imageLine++;                                        
        }

The third condition check whether it reach the total line of frame or not , if yes set the file read as beginning and reset to show the frame again

if(Current_imageLine >= IMAGES_LINES)   
          { 
            Serial.print("[frame]"); Serial.println((micros()-lastFrameShow));
            Current_imageLine = 0;
            lastFrameShow=micros(); 
            Start_new_round=false; 
            FILe.seek(0, SeekSet);
           }

But when I calculate the time of each frame it is huge and beyond expectation
More than 1 second for each frame , following is the serial output
i=0 New Image=1.bin duration=4
[frame]1639135
[frame]1571890
i=1 New Image=3.bin duration=4
[frame]1580551
[frame]1038532
[frame]1038509
[frame]1038295
i=2 New Image=2.bin duration=4
[frame]1064185
[frame]1083934
[frame]1085061
[frame]1085059

I don’t know where my time is wasted or which procedure took so long

Mehrdad K
@mkeyno
according to https://github.com/bbx10/esp-spiffs-test test it should read each line less than 1 micro second , but I don't know why this took so long
even when disable wifi (WIFI_OFF)
SteveToulouse
@SteveToulouse

Just an extra data point for you, for comparison. Running Arduino 1.6.9/ESP8266 2.3.0 on a NodeMCU Amica 1.0, 3MByte SPIFFS (80MHz), I get an average of 1.5Mbyte/s read (M=1000), max 2.1MB/s, min 1.1Mbit/s, median 1.4 - values are rather variable for the 7 successful test loops before write error.

What type is your ESP-xx module exactly ?

SteveToulouse
@SteveToulouse

Errr sorry, my flash chip is given as 40MHz speed by the example "CheckFlashConfig.ino" sketch.

Wonder why the speed test fails after 7 loops however, because it seems to reuse the same file over and over again?

Mehrdad K
@mkeyno
thanks @SteveToulouse for your note but I read the post the ESP chip is around 460 Kbayte per second
my chip is ESP-01
SteveToulouse
@SteveToulouse
'''
Flash ide size: 4194304
Flash ide speed: 40000000
Flash ide mode: DIO
Flash Chip configuration ok.
Mehrdad K
@mkeyno
also tested on ESP-12F the fram rate around 1 second
I think for 25 frame 200 line 144 pixel * 3 byte need around 2 Mbayte per second
I don't know whether ESP can handle it or not
SteveToulouse
@SteveToulouse
Only 1fps does seem strange. If your ESP12F is running like my NodeMCU (I think it has a 12E onboard) you should be getting more than 10fps. Maybe your code is reading in too small "chunks"? The testing code uses 8KB buffer. Maybe try reading several of your "lines" in each call to readBytes? Or it coud be the writing out to the LED strip takes a long time?
Mehrdad K
@mkeyno
FastLED is really fast library , and my loop code consist three simple part
The first condition check whether duration of show is passed and is time to close last file and open the new file
if( (millis()- OpenlastTime) > DURATION[image_index]*1000L )
        {
          FILe.close();
          image_index++; 
          if(image_index>IMAGE_NUM)    image_index=0;          
           FILe=SPIFFS.open("/SHOW/"+IMAGES[image_index], "r");
          if(!FILe) Serial.println("FILE NOT OPEN");
          OpenlastTime=millis();
        }
The second condition check whether new revolution started and time duration of last line has been passed , it read one chunk of data (number of LED * 3) and fed to show function to display it
if(!Start_new_round && (micros()-lastLineShow)> lineInterval)
        {
        int i = 0; 
           while( (i < NUM_LEDS*3) && FILe.available())
          { 
               i += FILe.readBytes( ((char*)leds) + i, (NUM_LEDS*3)-i);
            }

        FastLED.show(); 
        lastLineShow=micros();
        Current_imageLine++;                                        
        }
The third condition check whether it reach the total line of frame or not , if yes set the file read as beginning and reset to show the frame again
if(Current_imageLine >= IMAGES_LINES)   
          { 
            Serial.print("[frame]"); Serial.println((micros()-lastFrameShow));
            Current_imageLine = 0;
            lastFrameShow=micros(); 
            Start_new_round=false; 
            FILe.seek(0, SeekSet);
           }
More than 1 second for each frame , following is the serial output
i=0 New Image=1.bin duration=4
[frame]1639135
[frame]1571890
i=1 New Image=3.bin duration=4
[frame]1580551
[frame]1038532
[frame]1038509
[frame]1038295
i=2 New Image=2.bin duration=4
[frame]1064185
[frame]1083934
[frame]1085061
[frame]1085059
each file about 75 KByte size
I did it with teensy 2.1 and SD card ,
the approach is the same
maybe its due to DMA feature of teensy
Shelby Merrick
@forkineye
isn't FastLED just bit banging?
Mehrdad K
@mkeyno
not this code use APA102 which is use software SPI
Shelby Merrick
@forkineye
ah
Mehrdad K
@mkeyno
bitbang so slow compare to Data-clock type LED chip
Shelby Merrick
@forkineye
i just took a quick look at the clockless code from them and seemed to be bit-banging at first glance. didn't know you were using a clocked one
Mehrdad K
@mkeyno
this code work on the teensy very well , but I didn't know ESP can't handle it
I also disable wifi but no change
Shelby Merrick
@forkineye
how many files you have? each open has to scan SPIFFS
Mehrdad K
@mkeyno
for this test only 3 and as you may checked I've just open new file when duration show passed and after reading the total image line just back to beginning the file FILe.seek(0, SeekSet);
do you think ESP can read about 2Mbyte per second along with process other instructions
SteveToulouse
@SteveToulouse

I just ran a test using a 3144 byte read buffer. I get a very stable 1.2MByte/s (M=10241024) when reading a whole 2MBytes file.
Using a 16KB (K=1024) buffer I get a stable 2MBytes.

But I'm just open,read all,closing. No seeks or anything in there.

Mehrdad K
@mkeyno
how to set the specific buffer
16kB buffer is pretty high
specially when you need more room for other process such as wifi services
@SteveToulouse can you test my code with your presumption
Mehrdad K
@mkeyno
File FILe;
void loop() {


  if(SHOW)
      {
        if( (millis()- OpenlastTime) > DURATION[image_index]*1000L )
        {
          FILe.close();
          image_index++; 
          if(image_index>IMAGE_NUM)    image_index=0;          
           Serial.print(F(" i="));  Serial.print(image_index); 
          Serial.print(F(" New Image="));  Serial.print(IMAGES[image_index]);
          Serial.print(F(" duration="));  Serial.println(DURATION[image_index]);

           FILe=SPIFFS.open("/SHOW/"+IMAGES[image_index], "r");
          if(!FILe) Serial.println("FILE NOT OPEN");
          OpenlastTime=millis();
          Current_imageLine = 0;
        }
        if(!Start_new_round && (micros()-lastLineShow)> lineInterval)
        {
        int i = 0; 
           while( (i < NUM_LEDS*3) && FILe.available())
          { 
               i += FILe.readBytes( ((char*)leds) + i, (NUM_LEDS*3)-i);
            }

        FastLED.show(); 
        lastLineShow=micros();     
        Current_imageLine++;                                        
        }
       {read_line(Current_imageLine++,image_index); FastLED.show(); lastLineShow=micros(); }
          if(Current_imageLine >= IMAGES_LINES)   
          { 
            Serial.print("[frame]"); Serial.println((micros()-lastFrameShow));
            Current_imageLine = 0;
            lastFrameShow=micros(); 
            Start_new_round=false; 
            FILe.seek(0, SeekSet);

           } 

      }

}
Clemens Kirchgatterer
@everslick
can I assume GPIO2 to be unused by default or is the core sending something over that TX1 ?
Me No Dev
@me-no-dev
it's always Serial TX on boot
so while the bootloader is running, it's sending the same data as on serial 0
Clemens Kirchgatterer
@everslick
ok, thats killing my RTC that is connected there :-(
Me No Dev
@me-no-dev
are you using it for SCL?
Clemens Kirchgatterer
@everslick
lemme check
no, it's SDA
Me No Dev
@me-no-dev
should not be an issue then...
Clemens Kirchgatterer
@everslick
SCL is GPIO4
Me No Dev
@me-no-dev
what is the RTC?
Clemens Kirchgatterer
@everslick
DS3231
Me No Dev
@me-no-dev
always worked fine for me