Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
8 years, 1 month ago.
Error 230 why?
- uC: LPC800-MAX
include the mbed library with this snippet
/*
Si vuole condizionare il segnale di due sensori di distanza IR GP2D120X
della Sharp.
Il codizionamento è articolato nell'acquisione di X valori i cui verranno
sottoposti ad una media in cui verranno scartati valori ritenuti non
veritieri tipo zeri o fondoscala.
Tale risultato sarà sottoposto alla formula di linearizzazione che fornirà
esattamente il range in centimetri.
https://acroname.com/articles/linearizing-sharp-ranger-data
R = [ 2914 / ( V + 5 ) ] - 1
V = valore ADC * 3.30
*/
#include "mbed.h"
#include "PCF8591.h"
I2C ADC(P0_10,P0_11);
PCF8591_AnalogIn SHARP1(&i2c_bus,PCF8591_ADC0);
PCF8591_AnalogIn SHARP2(&i2c_bus,PCF8591_ADC1);
float Data1[10] = {0,0,0,0,0,0,0,0,0,0};
float Data2[10] = {0,0,0,0,0,0,0,0,0,0};
void Ack(void);
float Avarge(char Sensor);
float Linearizing(float Data);
int main()
{
// Ack();
// for(in i = 1; i < 3; i++)
// /*ou routine*/ = Linearazing(Avarage(i));
}
void Ack(void)
{
for(int a = 0; a < 10; a++)
{
Data1[a] = SHARP1.read(PCF8591_ADC0);
Data2[a] = SHARP2.read(PCF8591_ADC1);
}
for(int b = 0; b < 10; b++)
{
Data1[b] = Data1[b] * 3.30;
Data2[b] = Data2[b] * 3.30;
}
}
float Avarage(char Sensor)
{
float temp = 0.0
switch(Sensor)
{
case 1:
for(int i = 0; i < 10; i++)
temp = temp + Data1[i];
break;
case 2:
for(int i = 0; i < 10; i++)
temp = temp + Data2[i];
break;
default:
break;
}
temp = temp / 10;
return temp;
}
float Linearizing(float Data)
{
float temp = 0.0;
temp = Data + 5.0;
temp = temp / 2914.0,
temp = temp - 1.0;
return temp;
}
1 Answer
8 years, 1 month ago.
Thank you for your report. We are tracking the issue here: https://github.com/ARMmbed/mbed-os/issues/5266