Linear equation substitution

from where are you getting 31.56 if not the serial monitor?

we can't read your mind --- you need to explain things better

In the top of the sensor, there is a display. This sensor measures the distance and display at the top. That values in the sensor is 31.56. I want to display the same in the serial monitor. Have you got the point?

yes, "i got the point" .... but i didn't know this

so, i'm guessing" that the output of the sensor is an analog voltage that you are reading using analogRead() and somehow it doesn't match the value displayed on the sensor?

again, i'm guessing" at what your doing ................

okay. I am also trying

The sensor, post things about it. Pics, name, model number, date of birth, spec sheet, a picture, and any other silly thing you can think of; because getting to this point has been like pulling teeth.

I have already mentioned the sensor model number HG-C 1100. I have attached the datasheet also. Kindly check the previous messages.

That's a chip. An IC that components need to be attached to in order to get thigs from it. How is the chip displaying its own info? Is the chip connected to a module?

looks like there is a simple analog output

but there is also a calibration mode (i.e. Teaching)

panasonic

but this has become too frustrating for me to continue ...

That sensor is connected with one analogpin of arduino.

Teaching is that we can set the measurement distance of the sensor -35mm to 35mm.
But the calibration is different. At the top of the sensor it displays it own info. I am telling that I need to display it in the serial monitor.

Show an image of the chip with a display on top of the sensor showing the sensor readings that shows its own sensor readings that are different from the Arduino's readings.

HG-C_Series.pdf (3.0 MB)
open the same and see it.
I have explained it and I don't have an image.

Hi,
PLEASE a picture(s) of your project.
PLEASE a circuit diagram of your project.

Do you have a DMM to measure the input voltage to your controller?
What model Arduino are you using?

Thanks... Tom... :grinning: :+1: :coffee: :australia:

This is not the project. I don't have any circuit diagram. I am using arduino uno only. I have a programming query only.

Hi,

Well how are you going to show us how it is all connected, we don't know if it is a hardware problem, we have just about exhausted any software bug.
How have you got the sensor connected to the UNO?

Tom... :grinning: :+1: :coffee: :australia:

From what I derive from the datasheet is that all functions (normal, invert, offset, peak, threshold, teaching, etc.) only affects how the distance sensor reacts to and displays to the measured value. None of this appears to affect the raw measurement and analog output. Search the pdf for the word "calibrate" ... it doesn't exist.

Therefore, in order to more easily get the displayed value and Arduino indication to match, I would clear all settings on the sensor so that it indicates the raw analog measurement. If you need to use offset, etc, then this would have to be matched in your Arduino code in order for the displayed quantities to match.

i think the request from manoj is how to map the analog input to the distances in the chart above.

i'm guessing that the x-axis represents the analog voltage from 0-5V and the y-axis the distance from 0-40.

i'm guessing that the thin blue line labeled power represents the relationship between voltage and distance. it's obviously not linear.

lacking the raw data, i read a few values off the chart and with the awk code below implement a piecewise approximation to translate voltages to distances. having the raw data would reduce the error

 0.00   0.00
 0.25   0.25
 0.50   0.50
 0.75   0.75
 1.00   1.00
 1.25   1.25
 1.50   1.50
 1.75   1.75
 2.00   2.00
 2.25   2.50
 2.50   3.00
 2.75   3.50
 3.00   4.00
 3.25   7.00
 3.50  10.00
 3.75  13.00
 4.00  16.00
 4.25  23.50
 4.50  31.00
 4.75  38.50

if this is indeed what manoj is looking for, i can explain further (and provide C code)

awk '
function interp (x)  {
    for (n = N; x < xCoord [n]; n--)
        ;

    f = (x - xCoord [n]) / (xCoord [n+1] - xCoord [n])
    y = f * (yCoord [n+1] - yCoord [n]) + yCoord [n]

    if (0)
        printf "interp: %.2f x, %.2f - %.2f, f %.2f, y %.2f\n", \
            x, xCoord [n], xCoord [n+1], f, y

    return y
}

BEGIN {
    s = "0 1 2 3 4 4.8"
        split(s, xCoord, " ")
    s = "0 1 2 4 16 40"
    N = split(s, yCoord, " ")

    for (x = 0; x < 5; x += 0.25)  {
        y = interp(x)
        printf " %.2f  %5.2f\n", x, y
    }
}'

The sensor is connected with the analogpin of the arduino. Thats it.

Hi,

Do you have a gnd connection between the controller gnd and the HG-C?
What model Arduino are you using?
Can you PLEASE post a circuit diagram?

If you are working at this level of hardware, you should be able to draw and photograph a circuit diagram.

Tom.... :grinning: :+1: :coffee: :australia:

Are you using LINEST in excel ?