Search code examples
embeddedsensorsadc

How to calculate distance using voltage from Q4X Analog Laser Sensor


I have a Q4X Stainless Steel Analog Laser Sensor to calculate the distance with analog output voltage. It does display distance on Laser Sensor display and I am trying to do the same thing in my code using scale factor but its not matches with Laser Sensor display value.

here is my scaling factor.

#define A2D_SCL_LASER  ( 11.81f / ( 10.0f - 0.0f  ) ) // inches per volt

Devices specs:

Supply Voltage (Vcc)
12 to 30 V dc
Sensing Range—Threaded Barrel Models
500 mm models: 25 mm to 500 mm (0.98 in to 19.68 in)
300 mm models: 25 mm to 300 mm (0.98 in to 11.81 in)
100 mm models: 25 mm to 100 mm (0.98 in to 3.94 in)

Comparison of distance calculation in my code and sensor display

          My values(mm)    sensor display value(mm)
1V        29.9974          52               
2V        59.944           80              
3V        89.916           107             
4V        119.888          134             
5V        150.114          162             
6V        179.832          190             
7V        209.804          217             
8V        240.03           245            
9V        270.002          272             
10V       300              300 

Ref: http://info.bannerengineering.com/cs/groups/public/documents/literature/185623.pdf


Solution

  • distance VS voltage fit

    I simply fitted the sensor displayed value with the voltage you give in your question. The R²=1 means that the fit is perfect (or near perfect) and this is a good sign.

    The equation you are searching for is

    Distance(mm) = 27.533 x Volt + 24.467