Skip to content

Commit b98519d

Browse files
authored
Merge pull request #16 from DrGFreeman/GP2Y0A41SK0F
Addition of GP2YA41SK0F sensor model (1.5.0)
2 parents 1e62eea + 766fa58 commit b98519d

File tree

5 files changed

+21
-7
lines changed

5 files changed

+21
-7
lines changed

README.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# SharpDistSensor
22
A library for the Arduino IDE that helps interface with Sharp analog distance sensors.
33

4-
Version 1.4.2
4+
Version 1.5.0
55
[![Build Status](https://travis-ci.org/DrGFreeman/SharpDistSensor.svg?branch=master)](https://travis-ci.org/DrGFreeman/SharpDistSensor)
6-
By Julien de la Bruère-Terreault (drgfreeman@tuta.io)
6+
By Julien de la Bruère-Terreault (drgfreeman@tuta.io)
77

88
## Summary
99
The analog value from the sensor is converted to distance using either a
@@ -59,31 +59,34 @@ Sets the range of analog values for which the polynomial or power fit is valid (
5959

6060
## Pre-defined sensor models
6161
* `GP2Y0A60SZLF_5V`: GP2Y0A60SZLF Analog Distance Sensor 10-150cm, 5V, polynomial fit.
62-
* `GP2Y0A710K0F_5V_DS`: GP2Y0A710K0F Analog Distance Sensor 100-500cm, 5V (data sheet), polynomial fit.
62+
* `GP2Y0A41SK0F_5V_DS`: GP2Y0A41SK0F Analog Distance Sensor 3-40cm, 5V (data sheet), polynomial fit.
6363
* `GP2Y0A51SK0F_5V_DS`: GP2Y0A51SK0F Analog Distance Sensor 2-15cm, 5V (data sheet), power fit.
64+
* `GP2Y0A710K0F_5V_DS`: GP2Y0A710K0F Analog Distance Sensor 100-500cm, 5V (data sheet), polynomial fit.
6465

6566
#### Polynomial / Power fit coefficients:
6667

6768
Model | Units | C0/C | C1/P | C2 | C3 | C4 | C5
6869
------|-------|----|----|----|----|----|----
6970
**GP2Y0A60SZLF_5V** | mm | 1734 | -9.005 | 2.032E-2 | -2.251E-5 | 1.167E-8 | -2.037E-12
70-
**GP2Y0A710K0F_5V_DS** | mm | 178506 | -1607.72 | 5.5239 | -8.47601E-3 | 4.87819E-6 |
71+
**GP2Y0A41SK0F_5V_DS** | mm | 761.9 | -8.13336 | 4.18857E-2 | -1.11338E-4 | 1.46237E-7 | -7.49656E-11
7172
**GP2Y0A51SK0F_5V_DS** | mm | 4.03576E+4 | -1.26093 | | | |
73+
**GP2Y0A710K0F_5V_DS** | mm | 178506 | -1607.72 | 5.5239 | -8.47601E-3 | 4.87819E-6 |
7274

7375
#### Analog values range:
7476

7577
Model | valMin | valMax
7678
------|--------|--------
7779
**GP2Y0A60SZLF_5V** | 30 | 875
78-
**GP2Y0A710K0F_5V_DS** | 284 | 507
80+
**GP2Y0A41SK0F_5V_DS** | 61 | 614
7981
**GP2Y0A51SK0F_5V_DS** | 70 | 500
80-
82+
**GP2Y0A710K0F_5V_DS** | 284 | 507
8183

8284
**Important Note:** The analog voltage returned by the sensor is largely dependent of the reflected object size and reflectivity. The distance returned by these pre-defined calibration functions can therefore vary significantly from the real distance depending on the object detected. Where accuracy is required by the application, it is recommended to perform calibration with the object to be detected and use custom calibration fit functions instead.
8385

8486
This library has been designed so that it is easy to add sensor models. Contributions are therefore welcome. Adding models to the library can be done by either submitting a pull request or providing me the proposed fit function and associated calibration data by email so I can add it myself. Thank you for contributing!
8587

8688
## Version history
89+
* 1.5.0 (2018-10-22): Added GP2Y0A41SK0F_5V_DS model.
8790
* 1.4.2 (2018-09-23): Improved comments in SharpDistSensorArray example.
8891
* 1.4.1 (2018-08-07): Updated MedianFilter to latest version from [daPhoosa/MedianFilter](https://github.com/daPhoosa/MedianFilter).
8992
* 1.4.0 (2018-05-21): Added GP2Y0A51SK0F_5V_DS model.

SharpDistSensor.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,13 @@ void SharpDistSensor::setModel(const models model)
9999
setPolyFitCoeffs(5, coeffs, 284, 507);
100100
break;
101101
}
102+
case GP2Y0A41SK0F_5V_DS:
103+
{
104+
// Set coefficients and range for Sharp GP2Y0A41SK0F 5V
105+
float coeffs[] = {761.913, -8.13336, 4.18857E-02, -1.11338E-04, 1.46237E-07, -7.49656E-11};
106+
setPolyFitCoeffs(6, coeffs, 61, 614);
107+
break;
108+
}
102109
case GP2Y0A51SK0F_5V_DS:
103110
{
104111
// Set coefficients and range for Sharp GP2Y0A51SK0F 5V

SharpDistSensor.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ class SharpDistSensor
7373
GP2Y0A710K0F_5V_DS,
7474
// Constant for GP2Y0A51SK0F 5V model
7575
GP2Y0A51SK0F_5V_DS,
76+
// Constant for GP2Y0A41SK0F 5V model
77+
GP2Y0A41SK0F_5V_DS
7678
};
7779

7880
/** Constructor

keywords.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,6 @@ setPolyFitCoeffs KEYWORD2
55
setPowerFitCoeffs KEYWORD2
66
setValMinMax KEYWORD2
77
GP2Y0A60SZLF_5V LITERAL1
8+
GP2Y0A41SK0F_5V_DS LITERAL1
9+
GP2Y0A51SK0F_5V_DS LITERAL1
810
GP2Y0A710K0F_5V_DS LITERAL1

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=SharpDistSensor
2-
version=1.4.2
2+
version=1.5.0
33
author=Julien de la Bruere-Terreault, drgfreeman@tuta.io
44
maintainer=Julien de la Bruere-Terreault, drgfreeman@tuta.io
55
sentence=Sharp analog distance sensor library

0 commit comments

Comments
 (0)