HG-C 1100 sensor

Hi guys,
I am using two HG-C 1100 measurement sensor for measuring the width of the metal. In the top of the sensor I will be having the measurement value. The sensor is capable of measuring the dimensions from -35mm to 35mm.
So I am using the formula:

 int First_sample = analogRead(6);  
  int Second_sample = analogRead(7);
  float First_sensor = (map(First_sample, 1023, 0, -3500, 3500) / 100.0);     
  float Second_sensor = (map(Second_sample, 0, 1023, -3500, 3500) / 100.0); 
 Serial.print("First_sensor:");
  Serial.println(First_sensor, 3);
  Serial.print("Second_sensor:");
  Serial.println(Second_sensor, 3);
 Final_sensor = (First_sensor - Second_sensor);
Serial.println(Final_sensor, 4);

If I use this code, I will get the proper width of the metal. But when I place the metal in between the sensor, I am getting the exact width in the serial monitor. But at the top of the sensors the values are different.
I don't why the analog values are different on the serial monitor and the top of the sensors. But the output of the sensor is perfect in the serial monitor.
Can anyone help me with this?
HG-C_Series.pdf (3.0 MB)
Metal Width Detector.pdf (168.9 KB)

While teaching the sensor also, I get +35.00 and -34.98. But when I place the sensor, I get +35.70 and -35.70. Why is this error occurs in the sensor?
How can I rectify the errors?
Is this errors adding to my other values?
Kindly help me,.

@manoj_maniyan no-one here is familiar with this sensor. I have read parts of the document you attached. It is more like a sales brochure or a user instruction manual than a data sheet. The document focuses on the sensor's display and controls. There is no detailed description in the document about the analog output and how to interpret it's value.

You say that the output on serial monitor is different from the displayed value on the sensor but you give no examples of what those values are. Perhaps that would help us in some way

If my sensor value in the top is 16.45 means, The serial monitor displays 16.65. Why there is variation in the value. The exact sensor value from the sensor is not displaying in the serial monitor.

Uploading: hgcusermanual.pdf...file:///tmp/mozilla_dnk0340/hg-c_e_cata.pdf

Same document as before.

The sensor has a zero adjustment feature. Has this been used? Is it possible that the zero adjust feature affects the display but does not affect the analog output?

Another explanation for the difference could be that the 5V regulator in the Arduino is not very accurate, and does not exactly match the 5V signal used by the sensor.

It might be more accurate to use the Arduino's interval voltage reference, which is 1.1V for Uno. It will be necessary to use a voltage divider to reduce the signal from the sensor down to below 1.1V.

I am using arduino nano.

Hi @PaulRB

Oh quite a few of us are.

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

The theoritical and practical values should be the same right?
But why I am not getting the result.

(post withdrawn by author, will be automatically deleted in 24 hours unless flagged)

Hi, again

Can you draw a diagram of how you "Place the metal in between the sensor" please.
Or do you mean
"Place the metal in between the SENSORS"

A diagram please.

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

The top and bottom values which I have mentioned is at the top of the sensor.

But when I add the arduino code and see in the serial monitor, the values aren't as like the top of the sensor. if the first sensor is -17.5, it is taking as -17.78. if the second sensor is -21.5, it is taking as -21.12.
I have to know why there is a difference.
But the metal I place between the sensor gives me the proper output.

Have you got my point?

Hi,
Thanks for the diagram, I have added the scales for both sensors;

Defining your positive direction will help.
Tom... :grinning: :+1: :coffee: :australia:

I have inverted one of the sensor from positive to negative and vice versa.

:+1:

Could you please answer post 14
See the first sensor has inverted.

 float First_sensor = (map(First_sample, 1023, 0, -3500, 3500) / 100.0);     
 float Second_sensor = (map(Second_sample, 0, 1023, -3500, 3500) / 100.0); 

Could you please help me what software you have used for this?

Hi,
(21.5-21.12)/21.5 = 0.38/21.5 = 0.0176 == 1.7%

(17.78- 17.5)/17.5 = 0.28/17.5 = 0.016 == 1.6%

What percent accuracy are your potential divider resistors?
You may have to tune the potential divider values to get exact data.
Or adjust your software conversion equation.

Can you please post a circuit diagram?

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

Metal Width Detector.pdf (168.9 KB)

How can I adjust the software?
I have 10 BIT ADC and the my measurement is from -35mm to 35mm. So I am using the map function.
What else I can do with the software?

float First_sensor = (map(First_sample, 1023, 0, -3500, 3500) / 100.0);     
  float Second_sensor = (map(Second_sample, 0, 1023, -3500, 3500) / 100.0); 
 Serial.print("First_sensor:");
  Serial.println(First_sensor, 3);
  Serial.print("Second_sensor:");
  Serial.println(Second_sensor, 3);
 Final_sensor = (First_sensor - Second_sensor);
Serial.println(Final_sensor, 4);