Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

How do I get the position of something using PIC microcontroller?

Status
Not open for further replies.

Mtze

New Member
Hello everyone
My name is Mauricio, I'm new in this forum.
I am student of the first semester , so I do not know that much about electronics, I got really interested in this kind of topics and I am trying to make some little projects for the microcontrollers PIC using assembler coding.
I have been thinking in to making a device that could know me where I am respect of this device (An spacial position in the 2d plane).Of course 2 PICS would be required one for me and the second one in the device itself
But I find it hard because I do not find out how to make it after all. I think about using an specific frequency generator (pasive buzzer) with power enough in order to send this signals (This ones must not be listened by anyone) and to have a sound receptor for this specific frequency/sound-signal 3 or 4 meter away (Does it exist?) what is its name?.
I figure out that the far I go , the less the sound-frequency signal power is received and the PIC would know that I am getting away.
Is it really possible? Or Am I really wrong? Do you know any sound/signal receiver that I could use ?
Do you know other way to find my position and possibly the distance in a 2d plane? If you could give me the name of sensors of something would be grate, I do not know much of them.
Thanks for your advise and have a nice Sunday.
Mauricio M.
 
First...don't use signal power if you need accurate distance. I mean, it could work but it would be very inaccurate and unreliable because would be affected by what's in the room due...echoes, materials damping the sound, stuff between the transmitter and receiver damping/blocking the sound, or maybe just the speaker getting stronger or weaker over time. Here are more accurate ways:

1. GPS

2. Make your own GPS-like system: You need at least THREE beacons at known locations so you can triangulate your position relative to the beacons. A few ways to do it:

(a) Synchronize the beacons in time and have them all send out a sound pulse at the same time. The receiver measures how long it takes for the pulse to arrive. Then you can calculate your distance to each beacon and triangulate your position. The problem here is it is really tough to synchronize clocks. GPS does this with atomic clocks. Not recommended.

(b) Have each beacon send out two pulses that travel at different speeds. Probably light and sound. The receiver measures the difference in time of arrival between the light and the sound and uses that to calculate the distance from each beacon. With three beacons, you can triangulate your position. The receiver must be able to identify which sound and light signal came from which beacon so you will need 3 different sound frequencies and 3 different light frequencies.

Since your distances are small, and light travels so much faster than sound you can assume that the signals were sent when the light pules was received. This lets you simplify calculations more like (a) which are easier. But if you are making that assumption you can simplify things even farther with method (c).

(c) Have the 3 beacons send out sound pulses of a unique frequency (so you can tell which beacon sent which sound pulse). But the 3 beacons don't send out a light pulse. Instead, your receiver sends out a light pulse which triggers the beacons to send their sound pulse. Since you assume that the light reaches the beacons instantly, the light basically acts as a global clock that synchronizes everything similar to (a). Simpler than (b) since you need less light transmitters and receivers, but not as accurate as each beacon sending out its own light pulse since the the light needs to travel to the beacon before the sound pulse is sent but you probably won't notice since distances are small, light travels so fast, and sound travels so much slower than light.

3. A variation on (2) is to to just have ONE beacon transmit a sound pulse have an array of 3 microphones on the receiver. The receiver can measure difference in the time of arrival of the sound pulse between all the microphones and from that determine the direction and distance of the beacon. This is similar to how you use your ears to tell where a sound is coming from. This method is inherently less accurate than (2) because the distances between the microphones is smaller than the distance between three beacons. This makes measuring differences in time of arrival more difficult. It is also more difficult because one PIC has to accurately measure the time of arrival for three different signals at the same time.

But the advantage is you need less beacons and it's really simple to just plop the one beacon down and have your result be "the receiver is X meters away in the heading of Y degrees from the beacon in the direction of 30 degrees, whereas with 3 beacons you need to measure the distance and headings of the beacons relative to each other. I would choose this method personally because I don't feel like measuring the absolute position of every beacon. It's trickier though.

(a) You can have the beacon send a light signal so that the receiver knows when the signal was sent (if you assume light reaches the receiver instantly).

(b) You can have the reciever send a light signal to to the beacon to trigger the sound pulse to be sent to synchronize things. Not as accurate as (a) since the light needs to travel to the beacon before the sound pulse is sent but you probably won't notice since distances are small, light travels so fast, and sound travels so much slower than light. No point doing this when there is only one beacon since there's no need to synchronize multiple beacons with each other.
 
Last edited:
The answer is that PICs can know nothing about your position without knowing something about the physics of the situation first. The PIC needs to have a transducer (external to itself) before it knows anything...
 
First...don't use signal power if you need accurate distance. I mean, it could work but it would be very inaccurate and unreliable because would be affected by what's in the room due...echoes, materials damping the sound, stuff between the transmitter and receiver damping/blocking the sound, or maybe just the speaker getting stronger or weaker over time. Here are more accurate ways:

1. GPS

2. Make your own GPS-like system: You need at least THREE beacons at known locations so you can triangulate your position relative to the beacons. A few ways to do it:

(a) Synchronize the beacons in time and have them all send out a sound pulse at the same time. The receiver measures how long it takes for the pulse to arrive. Then you can calculate your distance to each beacon and triangulate your position. The problem here is it is really tough to synchronize clocks. GPS does this with atomic clocks. Not recommended.

(b) Have each beacon send out two pulses that travel at different speeds. Probably light and sound. The receiver measures the difference in time of arrival between the light and the sound and uses that to calculate the distance from each beacon. With three beacons, you can triangulate your position. The receiver must be able to identify which sound and light signal came from which beacon so you will need 3 different sound frequencies and 3 different light frequencies.

Since your distances are small, and light travels so much faster than sound you can assume that the signals were sent when the light pules was received. This lets you simplify calculations more like (a) which are easier. But if you are making that assumption you can simplify things even farther with method (c).

(c) Have the 3 beacons send out sound pulses of a unique frequency (so you can tell which beacon sent which sound pulse). But the 3 beacons don't send out a light pulse. Instead, your receiver sends out a light pulse which triggers the beacons to send their sound pulse. Since you assume that the light reaches the beacons instantly, the light basically acts as a global clock that synchronizes everything similar to (a). Simpler than (b) since you need less light transmitters and receivers, but not as accurate as each beacon sending out its own light pulse since the the light needs to travel to the beacon before the sound pulse is sent but you probably won't notice since distances are small, light travels so fast, and sound travels so much slower than light.

3. A variation on (2) is to to just have ONE beacon transmit a sound pulse have an array of 3 microphones on the receiver. The receiver can measure difference in the time of arrival of the sound pulse between all the microphones and from that determine the direction and distance of the beacon. This is similar to how you use your ears to tell where a sound is coming from. This method is inherently less accurate than (2) because the distances between the microphones is smaller than the distance between three beacons. This makes measuring differences in time of arrival more difficult. It is also more difficult because one PIC has to accurately measure the time of arrival for three different signals at the same time.

But the advantage is you need less beacons and it's really simple to just plop the one beacon down and have your result be "the receiver is X meters away in the heading of Y degrees from the beacon in the direction of 30 degrees, whereas with 3 beacons you need to measure the distance and headings of the beacons relative to each other. I would choose this method personally because I don't feel like measuring the absolute position of every beacon. It's trickier though.

(a) You can have the beacon send a light signal so that the receiver knows when the signal was sent (if you assume light reaches the receiver instantly).

(b) You can have the reciever send a light signal to to the beacon to trigger the sound pulse to be sent to synchronize things. Not as accurate as (a) since the light needs to travel to the beacon before the sound pulse is sent but you probably won't notice since distances are small, light travels so fast, and sound travels so much slower than light. No point doing this when there is only one beacon since there's no need to synchronize multiple beacons with each other.

Do you think the only way is to use GPS? I want to make this project as cheaper as I could.
The description I gave was because as 2nd implementation of this I would like to put both PICS in movement, the control sistem to follow the one that is controlled. And this would make easier the process because I would only care about the direction of its movement and the distance between both pics(In this case, I would need 3 pics, 2 as the control sistem to figure out the position[that would be in movement] , and the 3rd as the one that I want to know its position).. Or may be this 2nd implementation its easier than the first one? The kind of process that I was talking about in the original description is really possible to use or the sensors?
Thanks !
 
How accurate do you need it? And how indoors
Do you think the only way is to use GPS? I want to make this project as cheaper as I could.
The description I gave was because as 2nd implementation of this I would like to put both PICS in movement, the control sistem to follow the one that is controlled. And this would make easier the process because I would only care about the direction of its movement and the distance between both pics(In this case, I would need 3 pics, 2 as the control sistem to figure out the position[that would be in movement] , and the 3rd as the one that I want to know its position).. Or may be this 2nd implementation its easier than the first one? The kind of process that I was talking about in the original description is really possible to use or the sensors?
Thanks !

Is this to know where something is in a space? Because that's how it sounded in your first post. But just now, you made it sound like this is for a following robot.

GPS won't be very good indoors or if you need accuracy less than a cm. GPS would make it easier, but whether it's cheaper depends on the cost of the GPS modules you can find. I feel it would make things more expensive. It would be faster and simpler though. But it won't work well for following because you need a GPS on the leader and the follower and a way to transmit the position of the follower to the leader. That's expensive. (2) has these problems too.

Option (3) is really good and accurate for following. But for following, and just for following you could just use a bright LED on the leader and an array of photo transistors on the follower (or put one photo transistor on a servo and have it pan around to find the bright LED). It won't be as accurate, but maybe you don't need that if all you're doing is following at low speed. You can use brightness to roughly keep the same distance when following but this would require you use something other than phototransistors since can't be used to measure brightness, but they are simpler to work with. Photodiodes would be better for that but more complicated to work with.
 
Last edited:
Welcome to ETO, mtze!

Here's some info that might be useful for your project (the Ultrasonic Sensor (HC-SR04) has a max range of about 13ft).

And other, cheaper processors can be used as well.

There is also plenty of examples of the code needed to make it all work.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top