## Ping Sensor Offset

how can i add offset to sonars or IR sensors ,some sensors dont read the distance correct ,like sonars its 6 inches

With ARC Pro, your robot is not just a machine; it's your creative partner in the journey of technological exploration.

#1

The value returned by the sonar is not a distance in inches or mm. There will be no offset setting. If you wish to convert your numbers to a unit, use math within EZ-Script #2

This is the info i got on maxsonar EZ1 model The LV-MaxSonar-EZ1T detects objects from 0-inches to 254-inches (6.45-meters) and provides sonar range information from 6-inches out to 254-inches with 1-inch resolution. Objects from 0- inches to 6-inches range as 6-inches how would i add that to your control under sonar distance like 1 inch from sonar is read as 1 inch and 2 inch is read as 2 inch and so on

#3

The value returned from the EZ-B is a number between 0 and 255. The returned value is relative to the distance resolution of the sensor. #4

is that analog voltage or ping value and do you have a example for the math and formula for the ping distance

lv-maxsonar-ez1 has both analog output and ping output

from the data sheet it says 147us/inch for pwm (ping)

#5

Fred,

``````Do it like we did for Leaf. Just measure the distance every foot or so.  and make the notes to what value from 0-255 you get. Then you can pretty well tell what is two feet, four feet, eight feet,
``````

six inches, etc.

#6

no,its not the same,it is C SHARP program,and not shore how ALEX did it plus some was done in lispworks too

#7

If you are working in C#, it is really easy. Or even EZ-Script it is easy. It's simple math, and here's how.

So let's say you take a tape measure and measure the distance between the sensor and a wall. Let's speculate the distance is 50 cm and the value is 100.

One would assume that a value of 200 would be the distance of 100 cm, and the value of 50 would be a distance of 25 cm.

So it's easy to see the multiplier (scalar) for the returned value would be 0.5 (50 divided by 100).

So you could make a C# function like this...

``````
public decimal GetDistanceInCM(EZ_B.Digital.DigitalPortEnum triggerPort, EZ_B.Digital.DigitalPortEnum echoPort) {

decimal scalar = 0.5m;
decimal value = GetValue(triggerPort, echoPort);

return value * scalar;
}

``````
#8

Ok thanks DJ, i thought it was much more in the EZ script. also thats in cm ,i forgot formula for inches

Coding is always hard for me and thinking for most of the rest of the guys in the forum ,thats one reason you made the EZB

#9

You mentioned the program you are working with is C#.

If it is EZ-Script, than you will do this...

``````
\$value = GetPing(d0, d5) * 0.5

``````

First you just need to figure out your scalar. And use the tape measure like my prevoius response #10

OK thanks DJ ,last question i need in inches