спасибо, что помогли мне с моей предыдущей проблемой. Теперь я могу получить данные с ардуино на ПК с помощью шпатлевки с прикрепленным к подошве FSR и обнаружением давления.Arduino nano data points отсутствует
Единственная проблема, я столкнулся в настоящее время является то, что он, кажется, отсутствуют случаи удара пятку и носок Off каждый сейчас и потом. (Прикрепленное изображение) Plot of data
Синяя линия представляет данные от пятки FSR и красной линии для Toe FSR Из рисунка видно, что у ардуино отсутствует удар пятки на пике пик № 3 голубого цвета и мгновенный выход на красный пик 5 с конца.
Может ли один скажите мне, почему это происходит регулярно .. я использую Arduino Nano с скоростью передачи данных 9600 и 2 FSR в ..On увеличивая скорость передачи данных выше 38400 потери, кажется, происходит чаще
/** Код находит примеры пят выключения и пятки, используя данные из FSR в */
void setup()
{
/*************************************************SERIAL**************************************************/
Serial.begin(9600);
}
/*Variables for FSRS*/
//A0= Toe,A1=Heel
int sum_toe_max = 0,sum_toe_min = 0, sum_heel_max = 0, sum_heel_min = 0 ,toe, heel, temp,diff_toe,diff_heel,data_heel=0, data_toe=0, data_toe2, data_heel2 ;
int heel_max[5] = {0, 0, 0, 0, 0}, toe_max[5] = {0, 0, 0, 0, 0}; /*These arrays holds the top 5 maximas upto the time of calibration*/
int heel_min[5]= {100,100,100,100,100}, toe_min[5]={100,100,100,100,100};/*These arrays holds the top 5 maximas upto the time of calibration*/
float avg_heel_max,avg_heel_min,avg_toe_max,avg_toe_min;/*variables to hold the averages of the valus of max and min arrays*/
float UL=0.80,LL=0.05;/* Setting the Limiters*/
int counter_toe_max = 0, counter_heel_max = 0,counter_toe_min = 0, counter_heel_min = 0;//counter for the number of H and T occured
int cal_limit = 10;/*time for which calibration should go on*/
int timer = 0;/*stores the time elapsed*/
void loop()
{
read_FSR();//Call The FSR function
//read_acc();
}
/*********************************************FSR_TOE***********************************************/
/*Function to read the FSR_TOE data and save to SD*/
void read_FSR()
{
data_toe = analogRead(A0);
data_heel = analogRead(A1);
timer = millis()/1000;
Serial.print(millis());
Serial.print(" ");
Serial.print(data_toe);
Serial.print(" ");
Serial.println(data_heel);
/*Calibration and finding the maxima uptil cal_limit seconds.*/
if (timer < cal_limit)
{
/*TOE calibration*/
/*To find the top 5 max pressures*/
if (data_toe > toe_max[counter_toe_max])
{
toe_max[counter_toe_max] =data_toe;
counter_toe_max = counter_toe_max + 1;
}
if (counter_toe_max >= 5)
{
counter_toe_max = 0;
}
/*To find the top 5 min pressures*/
if (data_toe < toe_max[counter_toe_min])
{
toe_min[counter_toe_min] = data_toe;
counter_toe_min = counter_toe_min + 1;
}
if (counter_toe_min >= 5)
{
counter_toe_min = 0;
}
/*HEEL FSR calibration*/
/*To find the top 5 max pressures*/
if (data_heel > heel_max[counter_heel_max])
{
heel_max[counter_heel_max] =data_heel;
counter_heel_max = counter_heel_max + 1;
}
if (counter_heel_max >= 5)
{
counter_heel_max = 0;
}
/*To find the top 5 min pressures*/
if (data_heel < heel_min[counter_heel_min])
{
heel_min[counter_heel_min]=data_heel; =
counter_heel_min = counter_heel_min + 1;
}
if (counter_heel_min >= 5)
{
counter_heel_min = 0;
}
}
/*Displaying the maximum and minimum valus array and finding the averages for both the FSR's*/
if (timer == cal_limit && temp == 0)
{
/*Finding sum of the array elements*/
for (int i = 0; i < 5; i++)
{
sum_toe_max = sum_toe_max + toe_max[i];
sum_toe_min = sum_toe_min + toe_min[i];
}
for (int i = 0; i < 5; i++)
{
sum_heel_max = sum_heel_max + heel_max[i];
sum_heel_min = sum_heel_min + heel_min[i];
}
avg_toe_max = sum_toe_max/5;/*dividing by 5 to get the avg of the 5 values*/
avg_toe_min = sum_toe_min/5;
avg_heel_max = sum_heel_max/5;
avg_heel_min = sum_heel_min/5;
diff_toe = avg_toe_max-avg_toe_min;/*difference between maximas and minimas*/
diff_heel = avg_heel_max-avg_heel_min ;
Serial.println();
Serial.print(F("Avg ToePress max "));
Serial.println(avg_toe_max);
Serial.print(F("Avg ToePress min "));
Serial.println(avg_toe_min);
Serial.print(F("Avg HeelPress max "));
Serial.println(avg_heel_max);
Serial.print(F("Avg HeelPress min "));
Serial.println(avg_heel_min);
Serial.print(F("Diff in avg toe press:"));
Serial.println(diff_toe);
Serial.print(F("Diff in avg heel press:"));
Serial.println(diff_heel);
Serial.print(F("Target HeelPress "));
Serial.println(UL*(avg_heel_max-avg_heel_min));
Serial.print(F("Target ToePress "));
Serial.println(LL*(avg_toe_max-avg_toe_min));
temp = temp + 1;
}
/*Done with calibration(when timer =10s)*/
/*Checking the oncoming data for a condition of Toe Off
Consider it as a toe off if the normalised value of data_toe i.e (data_toe-avg_toe_min)/diff_toe
at the previous instant is greater than LL(Lower Limit) i.e 0.2 times the differnce between the averages of max and min of toe FSR
and the normalised value of data_toe2 at the current instant is lesser than the same*/
if (timer > cal_limit && (data_toe-avg_toe_min)/diff_toe > LL)
{
data_toe2 = analogRead(A0);/*Data toe at the current instant*/
if ((data_toe2-avg_toe_min)/diff_toe < LL)
{
//
Serial.print(timer*1000);
Serial.print(" ");
Serial.print(("f t T "));
Serial.print(data_toe);
Serial.print("Avg min ");
Serial.print(avg_toe_min);
Serial.print("Diff ");
Serial.print(diff_toe);
Serial.println(" TOE");
}
}
/*Checking the oncoming data for a condition of Heel Stike
Consider it as a Heel Strike if the normalised value of data_heel i.e (data_heel2-avg_heel_max)/diff_heel
at the previous instant is lesser than UL(Lower Limit) i.e 0.8 times the differnce between the averages of max and min of heel FSR
and the normalised value of data_heel2 at the current instant is greater than the same*/
if(timer>cal_limit && (data_heel-avg_heel_min)/diff_heel<=UL)
{
data_heel2=analogRead(A1);/*Data heel at the current instant*/
if((data_heel2-avg_heel_min)/diff_heel>=UL)
{
Serial.print(timer*1000);
Serial.print(" ");
Serial.print(("f t H "));
Serial.print(data_heel);
Serial.print(" HEEL");
Serial.println(UL);
Serial.flush();
}
}
}
Отбрасывание 100 строк строк вряд ли даст вам ответ. Пожалуйста, приложите усилия, чтобы предоставить [mcve] – Julien