ERR:-1002 and the Arduino lib usage

A nano33 ble sense rev2 board is used for detecting the vibration style. I used accelerometer x,y,z, sample rate=100, window= stride=1000ms. A neural network is trained for classifying normal vibration and abnormal vibration. After I sampled and trained, then the ei binary FW is downloaded and burned into nan0 33 rev2. After running impulse in PowerShell for 2 minutes, error happens:
Starting inferencing in 2 seconds…
Sampling…
Timing: DSP 9 ms, inference 626 us, anomaly 0 ms, postprocessing 49 us
#Classification predictions:
abnormal: 0.003906
none: 0.996094
Starting inferencing in 2 seconds…
Sampling…
Can’t allocate new thread
Timing: DSP 5 ms, inference 602 us, anomaly 0 ms, postprocessing 49 us
#Classification predictions:
abnormal: 0.000000
none: 0.996094
Starting inferencing in 2 seconds…
Sampling…
Can’t allocate new thread
ERR: Failed to run DSP process (-1002)
Failed to run impulse (-5)

I am not sure, the bin FW is generated by EdgeImulse online studio, why errors?
Another question: I tried the Arduino library and the …\examples\nano_ble33_sense_rev2\nano_ble33_sense_rev2_accelerometer\nano_ble33_sense_rev2_accelerometer.ino, but the abnormal status could not be checked out,only normal checked will possibilities around >=0.98;meanwhile the same abnormal status is sampled and detected by “live classification” in Edge Impulse, abnormal is easily checked!!!
I wonder one thing: Do I need to modify MANUALLY the low level accelerometer driver(the BMI270 .c /.h) code to adapt to nano_ble33_sense_rev2_accelerometer.ino project? OR, is everything ready in the example nano_ble33_sense_rev2_accelerometer.ino?

Any response? Or do I miss something to get reply?

I did some tests to find the truth: the online studio’s sampling is different with that when use Arduino Library examples!!! The BMI270’s driver is not the same with that used in online studio.
With the same vibration operation(nano3 binded to a swinging fan), I sampled online and in the Arduino library example, and compare the waves of axes X,Y, Z data。 They are obviously different.
EdgeImpulse fellows, why don’t you tell me that point? And what configuration did you use when sampling online, the BMI270 sample rate, filter, continuous mode, opt mode? I tried many combinations but can not get the right wave style as the online sampling data.

1 Like

Thanks for sharing @john_swing and welcome to the Edge Impulse community!

Looks like that for Edge Impulse Studio you use 100 Hz but what’s the sampling rate of your Arduino? Maybe this is the missing point? Could you please confirm?

Thanks marcpous! I would like to know the following points:
(1)can I directly use the deployed Arduino Library project without any modification?just build it and then download to the nano 33 board?
(2)where did the preprocess steps performed? did the following code will do every thing like the online preprocess:
// Turn the raw buffer in a signal which we can the classify
signal_t signal;
int err = numpy::signal_from_buffer(buffer, EI_CLASSIFIER_DSP_INPUT_FRAME_SIZE, &signal);
if (err != 0) {
ei_printf(“Failed to create signal from buffer (%d)\n”, err);
return;
}
(3)do I have to modify anything manually to make the Arduino Library project performance aligned with online test?
With the online document: Run Arduino library, it seems that user can get a good model performance just by deploying the model project to board without any further effort.

I really nedd help. In firmware-arduino-nano-33-ble-sense/src/sensors/ei_bm270_bmm150.cpp at master · edgeimpulse/firmware-arduino-nano-33-ble-sense · GitHub I found the firmware code used for online sampling, the bmi270 set is : struct bmi2_sens_config sens_cfg[2];
sens_cfg[0].type = BMI2_ACCEL;
sens_cfg[0].cfg.acc.bwp = BMI2_ACC_OSR2_AVG2;
sens_cfg[0].cfg.acc.odr = BMI2_ACC_ODR_400HZ;
sens_cfg[0].cfg.acc.filter_perf = BMI2_PERF_OPT_MODE;
sens_cfg[0].cfg.acc.range = BMI2_ACC_RANGE_2G;,
And I copied the same setting to my native bmi270 library in arduino ide. But the strange thing happened: for the same vibration condition, I sample data at 100Hz, and online data and data fowarder data prested different FFT spectrum!!! Online data spectrum seems good:it has 47.5,12,3Hz component, bu data fowarder data presented only huge 50hz component。 I donot know why, they have the same driver setting ,why different?
My data forwarder code:
/*
Arduino BMI270 - Optimized for Edge Impulse Data Forwarder (200Hz)
适合 Arduino Nano 33 BLE Sense Rev2
*/

#include “Arduino_BMI270_BMM150.h”

#define CONVERT_G_TO_MS2 9.80665f
#define MAX_ACCEPTED_RANGE 2.0f
//

// 定义目标采样频率为 200Hz
#define TARGET_FREQUENCY_HZ 100

#define SAMPLE_INTERVAL_US (1000000 / TARGET_FREQUENCY_HZ)
//#define INTERVAL_MS (5)
static unsigned long last_interval_us = 0;

void setup() {

Serial.begin(1000000);
while (!Serial); // 等待串口助手或 Data Forwarder 连接

if (!IMU.begin()) {

while (1); 

}
IMU.setContinuousMode();
//Wire.begin();
// Wire.setClock(400000);

}
float ei_get_sign(float number) {
return (number >= 0.0) ? 1.0 : -1.0;
}
void loop() {
float x, y, z;
unsigned long t1,t2;
unsigned long dt,cur_us;
char buf[64];
float buffer[3] = { 0 };
dt = 5000;

if (micros() >= (last_interval_us + SAMPLE_INTERVAL_US)) {
last_interval_us = micros();

    //while (!IMU.accelerationAvailable());
    IMU.readAcceleration(buffer[0], buffer[1], buffer[2]);      
      for (int i = 0; i < 3; i++) {
        if (fabs(buffer[i]) > MAX_ACCEPTED_RANGE) {
            buffer[i] = ei_get_sign(buffer[i]) * MAX_ACCEPTED_RANGE;
        }
    }


    buffer[0] *= CONVERT_G_TO_MS2;
    buffer[1] *= CONVERT_G_TO_MS2;
    buffer[2] *= CONVERT_G_TO_MS2;  

    

    snprintf(buf, sizeof(buf), "%.2f,%.2f,%.2f\n", buffer[0], buffer[1], buffer[2]);
    //the print function costs a lot of time,makeing 200Hz to 167Hz/197Hz(if use snprintf)
    //so let's change to 100-150Hz
    Serial.print(buf);
  /**/
    #if 0
    Serial.print(x);
    Serial.print('\t');
    Serial.print(y);
    Serial.print('\t');
    Serial.print(z); 
    Serial.print('\t'); 
    Serial.println(dt); 
    #endif

}
}

The Arduino BMI270_BMM150 library v1.2.3 is installed. What to do to make online and offline sampling aligned?