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.

PIC16f690, initialisation of ports, LEDS,reading from a pin

Status
Not open for further replies.
Ok, so what should be my next move?

Measuring distances using a simple beam of light reflected back is VERY, VERY difficult due to the fact the light acts at the same speed as the electronics does, and MUCH faster than a processor.

As Bill says, consult your teacher - it's not really the sort of project you would be given without a lot of information and help been provided.
 
:)actually, we are given zero information. the only ting we given is the topic and specifications. We can consult with our supervisors.
 
i want to determine the distance from the time interval between pulses.
Just imagine you dropping a stone into a deep hole and waiting for the sound of the stone hitting the floor.
The shorter the time between the point of release of the stone and the sound of it hitting the floor, the shorter
the distance the stone travelled.

The is how i want to program the circuit to operate.



Basically the sequence for programming should be as follows:

Set timer to ZERO!
Send signal to transmitting IR diode
Start timer
If your receiving IR diode(active low) - indicating it received the signal the STOP timer.

Work out the distance from halving the time and using that speed formula : distance = speed * time.


if i cant get the timer to work properly maybe i try this approach... its a little crude
but should give me some results in any case...

using an arbitrary variable say T (being an integer)

Set T = ZERO.
Send signal to transmitting diode.

If your receiving IR Diode is still low (meaning no signal received as yet)
increase T by 1

The above loop will continue to run until the receiving IR Diode goes HIGH.

Now you will have an unknown positive value in T which is not associated in any equation.
But if you plot out the value of T versus the distance you set the diodes at, then you can work out the equation
for distance - straight line equation

y = mx + c

m = (y2-y1)/(x2-x1)
(x1,y1) and (x2,y2) being co-ordinates with x representing distance and y representing the various values of T.

^
| /
T| /
| /
| /
| / this is a straight line
| /
|/
|----------------------------- >
0

your two co-ordinates (x1,y1) and (x2,y2) are for the shortest and furthest distance of measurement.
So when setting the shortest distance - use a ruler and obstruct the IR diodes approximately 5cm away.
Your distance is known cos you measured it right But you will get a T value for this distance.

Now set the furthest distance (50cm) - use the ruler, obstruct again at 50cm away and get that T value.
Plot a graph and work out the equation of T versus distance.

But this is if i cannot get the timer function to work but the procedure is the same in any case.

yes i will consult with my lecturer and respond to you all.
 
Last edited:
hi,
Work out how short a time the IR pulse width will have to be to ensure its off before you get an echo back.:)
 
As we've been saying all along - light is FAR, FAR, too fast - when you drop the stone the sound travels at a nice slow 1000 feet per second (very roughly), this is simple to do using electronics and processors. It's why ultrasonic sound is used for measuring levels in tanks, and not IR.

For each loop of your processor using light, the beam will have travelled 100's of meters.

The hardware you've using is for simple proximity detection, NOT measuring distance - and as I mentioned earlier, you can do a crude and rough distance measurement by using different transmitter powers in a proximity detector.
 
The Toshiba TV factory in Plymouth closed today, the last UK plant.:(

Was that the one that used to be the joint Bush/Toshiba factory way back when Bush still existed?.

If it is, back in the late 70's or so Toshiba pulled out and made Bush go bankrupt, then bought the factory cheap for themselves :mad:
 
thanks for the help, im just getting worried, dont wana fail.
 
thanks for the help, im just getting worried, dont wana fail.

hi,
Have just read the 'set specification'.
Whom ever set you that task as a project, has no idea of the complexity of a IR measuring system for measuring from 2cm to 50cm with 1cm accuracy off the surface of water.:)
 
I don't no if any one here has read 123 pic microcotroller experiments for the Evil genius but it shows how to do what you want to do that where I got the idea. Myke Predko write some killer code.

You can't change how fast light moves. But you can set how long the led is on how long it is off and get how far the water is in the tank

I don't think you'll get in 1cm
 
Last edited:
In my humble opinion I don't no if it will work on water and I'm not the best coder in the world. I used it to keep from hitting the walls. You can set a range like turn at 3 inches.
 
Last edited:
On another forum, the same question has been raised. Some assume that IR will bounce off the surface of water like it does from a wall. That is, when perpendicular, it bounces straight back so you can get a TOF distance measurement.

I have a Stanley FatMax which uses IR at 630 to 690 nm and TOF to measure distance, surprisingly to fairly high precision. So, I did an experiment from a fixed height of about 4' aimed at a basin of fresh water (empty and full). It did not measure the water level surface. In fact, the measured distance when the basin was full was increased, presumably due to the higher refractive index of water compared to air and reflection from the bottom in both cases.

That was a quick and dirty experiment, but it was enough to suggest that the fundamental assumption needs to be confirmed before doing a lot of work on the project.

John
 
Ahh I remember the 123 project, it's proximity not distance measurement device. It uses the reflection to see if it's close to a wall. It cannot resolve distance. The book also has a Sharp IR Rangefinder project, they work on triangulation.
**broken link removed**
 
Last edited:
any1 knows of an infrared receiver IC with an analogue output,
its output voltage should vary with the intensity of the reflected light?

plan to do some ADC with a lookup table
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top