# Data Normalization

Hi All,

I just want to ask, is there any inbuilt function that arduino can use for the normalization of the collected data in between 0 and 1.

Which is the easy way of normalizing the data in between 0 and 1 with Arduino.

Thanks,

Harsh

Hi harsh,

what do you mean with "collected data"? Are you filling an array?

If you know the min and the max values, you can use map(...): http://arduino.cc/en/Reference/Map

Because map does not use float but long, you can use it to map between 0 and 10.000 for example. Devide that value with 10.000 just before using it to get a value between 0 and 1. Care about the types float and long if you do a type cast!

(You can find out min and max easily on your own by using min() http://arduino.cc/en/Reference/Min and max().)

What are you trying to do? May be there is an easyer way...

best regards, marleaux

Hi Marleaux,

Thank you very much for the reply.

Actually i am working with a sand compaction sensor. It is a capacitive sensor. I have a circuit that converts the capacitance into the voltage.I am using the ADC to sample the current readings in the mV. But i have 3 sensors with the different lengths of connecting cables. So, as the length of the cable changes the read values changes.

I mean with sensor 1, i get the sand compaction readings in between 450 to 1400 with the other one i get the readings between 600 to 1600 and with the other one i get the readings between 1000 to 2100 mV.

All these readings are for the same sand with same set up but the only thing is the length of the cable is different so it adds its own capacitance and that changes the readings.

Thus to nullify the effect of length of cable i have to normalise the data between 0 and 1.

So ideally the normalised values should be identical for all lengths of cable.

I think your suggestion is a good way but sometimes the max and min values can change so is there any function which will automatically adjust the max and min values when sampled value is more than previously defined max value or less than previously defined min value.

Thanks a lot for your help.

Regards,

Harsh