### robotmaker

USA

Asked
— Edited

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

Skip to commentsUSA

Asked
— Edited

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

Skip to comments
#1The 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

#2This 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

#3The 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.

#4is 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)

#5Fred,

six inches, etc.

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

#7If 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...

#8Ok 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

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

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

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

#10OK thanks DJ ,last question i need in inches

#11Hi @robotmaker From what you posted re: the specs on the LV-MaxSonar-EZ1T, (1 inch resolution and 0-254 inch range)... since that matches the ADC range of 0-255 then I would think that you could use the Analog Output of your sensor and an ADC port on the EZ-B.

The

ADC Valuecontrol does have the option to type in your unit of measurement (for our visual purposes only) and a multiplier feature, which if set to 0shouldrepresent 1 inch for each displayed number.You may not need a scaler (multiplier) but if you do then the math is the same, just do the calibration steps @DJ mentioned using inches, and enter the scaler number in the multiplier field (i.e. 0.5 using @DJ's example).

Hope this helps.

#12they say that the analog ouput is not very stable,this sonar has the best accuracy of all the sonars pwm is very stable