Skip to content

Derivation of SHARP IR sensor - GP2Y0A21YK0F output function via curve-fitting

License

Notifications You must be signed in to change notification settings

farhanfuadabir/Sharp-IR-sensor-Curve-Fitting

Repository files navigation

Sensor-Curve-Fitting

This project aimed for the derivation of an output function for SHARP IR sensor (GP2Y0A21YK0F) in order to convert the raw value to meaningful distance.

Issue

SHARP IR sensor (GP2Y0A21YK0F) outputs a raw value which is not linearly correlated with the distance. So, a non-linear function is needed to output the distance from raw value.

The distance measureing characteristics (output) of GP2Y0A21YK0F is shown below:

Source: Datasheet

Experiment

The experiment is designed with a fixed opaque obstacle, a ruler for distance measurement and the sharp IR sensor. Matlab Arduino Support Package and Curve Fitting Toolbox was used respectively for Arduino Nano-Matlab connectivity and curve fitting.

  • Total 25 distance data of the obstacle and the sensor was recorded from the physical scale to the Matlab input prompt.
  • The corresponding sensor raw ADC value was recorded simultaneously.
  • Curve Fitting Toolbox was used on the recorded ADC value and measured distance following the settings.
Fitting Characteristics= Rational
Numerator degree= 0
Denominator degree= -1

Result

General model Rat01:
     f(x) = (p1) / (x + q1)
Coefficients (with 95% confidence bounds):
       p1 =        4835  (4723, 4948)
       q1 =      -28.76  (-33.52, -24)

Goodness of fit:
  SSE: 1.701
  R-square: 0.9987
  Adjusted R-square: 0.9986
  RMSE: 0.272

Derived output function:

Comment

The output function resembles the output characteristics of the sensor within 10-80 cm distance.

About

Derivation of SHARP IR sensor - GP2Y0A21YK0F output function via curve-fitting

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published