Trying to convert ultrasonic sensors distance reading into coordinates

Hey all I am making a project where I am using 4 ultrasonic sensors and a stepper motor. I am using the ultrasonic sensors to measure distance and am trying to convert that distance into polar coordinates. From there I will try to make the stepper motor move to an angle and hopefully at the right x and y coordinates. So far I have gotten the sensors to all display distance reading but I have no idea how to convert their readings into coordinates. If anyone could offer help that would be amazing.

Thanks, Lomax

A coordinate system has an origin and well defined axial directions. What would those be, in your project? How would those relate to the distances you are measuring?

Have a look at the "How to get the best out of this forum" post, linked at the head of very forum topic, which gives suggestions on what sorts of information you need to provide in order to get well-informed help.

Study the sensor documentation. Usually there is an entry describing the "cone of response", which means the width of the beam in degrees. Your distance can be ANYWHERE in that beam of response. Not very helpful in determining coordinates. Ultrasonics is NOT useful in your project!

My origin would be my stepper motor. The stepper motor will most likely be in the middle of a 20 by 20cm square.

That is a start!

Hi, @lomax09

Should you wish to continue in this line of thought.

Use two ultrasonic sensors.
One on each corner along one side.

PING one sensor, get the distance to target.
PING the other sensor, get the distance to target.

You have a baseline, the distance between the sensors, one side of triangle.
The distance from each sensor to the target, the other two sides.

Do some maths to find the X-Y position on the floor.
Regard the problem as two right angle triangles.

Convert to polar co-ords.

I think in principle that's feasable.

Tom... :grinning: :+1: :coffee: :australia:
PS. if you want a diagram, I'm at work at the moment, when I get home in 4 hours I'll draw one.

Hi Mr. Tom, I figured out how to code the Stepper and the Sensors together but I do appreciate the help.

Thanks, Lomax

If the stepper is in the middle of the field how will you avoid it being detected by the ultrasonics?

Do you see in my idea you only need two ultrasonic units to get an X - Y coord.
Do you understand the maths involved in getting the X - Y co-ords.?

OR
You use he stepper to sweep one ultrasonic like sonar, and get polar co-ords direct.

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

The r is the distance and the theta is the angle the sensor makes with your base plane.

Instead of doing that I have 2 ultrasonic sensors on 1 breadboard and having them on opposite ends. I can show you a picture of it in an hour or 2 if it helps.

This picture doesn’t have the stepper motor in it but the motor would go in between all the sensors so the sensors wouldn’t detect it. I have already tested this and they don’t detect it.

Hi,
Thanks for the pictures.
You will have to note and fix the positions of the ultrasonics, I see you have two side by side to give you "beam" width.

Have you got them all working and returning valid distance data?
I hope you have a delay between each ping to let the ping dissipate and not cause a miss trigger of the next sensor to ping.

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

Do the geometry - or at least describe the geometrical setup to us in detail in order to figure it out.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.