Hi all,
I’m working on a device made by a portenta h7 that can be controlled remotely via wifi. I am able to record more data buffers at a frequency of 0.5kHz more or less. I am using mbed library but cannot store those buffers in the sd at an idle speed. Let’s say that if I record 30 sec at 500Hz, then I need about 300 seconds to save them.
My template is like this:
#include "SDMMCBlockDevice.h"
#include "FATFileSystem.h"
SDMMCBlockDevice block_device;
mbed::FATFileSystem fs("fs");
#include <SDRAM.h>
SDRAMClass mySDRAM;
unsigned long j = 1; unsigned long k = 0;
float *Data;
char output[10];
void setup() {
/**** SETUP SD ****/
_UART_USB_.println("Mounting SDCARD...");
int err = fs.mount(&block_device);
if (err) {
_UART_USB_.println("No SD Card filesystem found, please check SD Card on computer and manually format if needed.");
//int err = fs.reformat(&block_device); // seriously don't want to format your good data
}
else {
_UART_USB_.println(" SDCARD ready");
}
mySDRAM.begin(SDRAM_START_ADDRESS);
Data = (float*)SDRAM.malloc(0.5 * 512 * 1024);
}
void loop() {
//Phase of recording: fulfill Data at 500Hz
//save it
for (k = 1; k <= j - 1; k++)
{
_UART_USB_ .print("J: "); _UART_USB_ .print(k); _UART_USB_ .print(" , ");
_UART_USB_ .print("Space: "); _UART_USB_ .print(Data[k]); _UART_USB_ .print(" \n ");
sprintf(posiz, "%.2f", Data[k]); strcat(posiz, "\n ");
const char* nomeid = myFileName.c_str();
FILE *myFile = fopen(nomeid , "a");
// fwrite(&Data[k], 10, len, myFile);
fprintf(myFile, posiz);
fclose(myFile);
_UART_USB_.println(j);
}
_UART_USB_.println("Saved");
}
Can someone give me some tips to improve the storage method? Thanks to all