zassx
Posts: 20
Joined: Mon Jan 15, 2018 4:37 pm

Measuring speed using IR LED Phototransistor

Thu Feb 15, 2018 11:01 am

Hey there guys.

I am relatively new to Raspberry PI scene. Well I have some experience in software development but none when it comes to electrical circuits.
Me and my mates came up with an idea of building a speed sensor to measure speeds of some objects passing through. We are talking about small difference between sensors, around 15-20cm max!

I have one Raspberry PI v2 at disposal so I figured out I should come up with a prototype, but actually don't know how to begin with making a circuit.
I found few sensors that could actually be good for our case: PT334-6B/IR333C-A Phototransistor.

So the idea is of creating some kind of lightgate, so when the object passed through and IR changes that, we know that there was an interrupt. When this happens we will save the entry time and then again save the time when the object is through. Calculating that time and knowing the width of the object we can figure out the speed.

The problem is that if we have that sensors, we don't know how to create a circuit. This is where I would need help from you.
Do we need additional elements to make things work or will putting those leds and receivers in breadboard work? If anyone is so kind to help us out creating a scheme, we would be very grateful. Thank you in advance!

pcmanbob
Posts: 3856
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Measuring speed using IR LED Phototransistor

Thu Feb 15, 2018 2:09 pm

May be this example I found on the web will give you a starting point.

http://deddieslab.blogspot.co.uk/2014/0 ... ry-pi.html
Please only ask questions in the forum I will not answer questions sent to me directly via PM
Remember we want information.......................no information no help
The use of crystal balls & mind reading is not supported

zassx
Posts: 20
Joined: Mon Jan 15, 2018 4:37 pm

Re: Measuring speed using IR LED Phototransistor

Thu Feb 15, 2018 2:31 pm

Thanks, I already came across this project and already got all the useful info.
But the problem is that since the elements I will be using are not the same, will creating same scheme work on my end? Maybe I could fry my Raspberry or something, that is why I would like few guidelines on how to implement this.

pcmanbob
Posts: 3856
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Measuring speed using IR LED Phototransistor

Thu Feb 15, 2018 2:58 pm

Seeing as the transistor in question is an NPN device you could connect it like this depending on which way round you want the input to read.

normally high goes low on activation or normally low goes high on activation

Image

The LED side can just be threaded like any other LED power it from 5v using a suitable current limiting resistor if you intend to leave it powered all the time.
Please only ask questions in the forum I will not answer questions sent to me directly via PM
Remember we want information.......................no information no help
The use of crystal balls & mind reading is not supported

zassx
Posts: 20
Joined: Mon Jan 15, 2018 4:37 pm

Re: Measuring speed using IR LED Phototransistor

Thu Feb 15, 2018 3:17 pm

Oh nice, that is what I was looking for! Thank you very much, will definitely drop by again as soon as I test this out.

boyoh
Posts: 1130
Joined: Fri Nov 23, 2012 3:30 pm
Location: Selby. North Yorkshire .UK

Re: Measuring speed using IR LED Phototransistor

Fri Feb 16, 2018 2:58 pm

The speed of a object passing the sensors, could this be don by ,two sensors spaced apart
The first sensor will start a timer when the leading edge of the object passes the sensor.
When the leading edge of the object passes the second sensor ,this will stop the timer.
Calibrate timer to suit
BoyOh ( Selby, North Yorkshire.UK)
Some Times Right Some Times Wrong

zassx
Posts: 20
Joined: Mon Jan 15, 2018 4:37 pm

Re: Measuring speed using IR LED Phototransistor

Fri Feb 16, 2018 3:04 pm

boyoh wrote:
Fri Feb 16, 2018 2:58 pm
The speed of a object passing the sensors, could this be don by ,two sensors spaced apart
The first sensor will start a timer when the leading edge of the object passes the sensor.
When the leading edge of the object passes the second sensor ,this will stop the timer.
Calibrate timer to suit
Thanks but I am already doing that, but only with one sensor. No need to have two. So the logic and the software is not a problem, the problem is my lack of knowledge in creating circuit. :)

boyoh
Posts: 1130
Joined: Fri Nov 23, 2012 3:30 pm
Location: Selby. North Yorkshire .UK

Re: Measuring speed using IR LED Phototransistor

Fri Feb 16, 2018 6:02 pm

zassx wrote:
Fri Feb 16, 2018 3:04 pm
boyoh wrote:
Fri Feb 16, 2018 2:58 pm
The speed of a object passing the sensors, could this be don by ,two sensors spaced apart
The first sensor will start a timer when the leading edge of the object passes the sensor.
When the leading edge of the object passes the second sensor ,this will stop the timer.
Calibrate timer to suit
Thanks but I am already doing that, but only with one sensor. No need to have two. So the logic and the software is not a problem, the problem is my lack of knowledge in creating circuit. :)

Saying you already have the circuit working using only one sensor , so what is your problem
It would be a good Idea to draw your circuit, to save going over ground already covered
You must have built a circuit to get it working,,

Regards BoyOh
BoyOh ( Selby, North Yorkshire.UK)
Some Times Right Some Times Wrong

User avatar
bensimmo
Posts: 2712
Joined: Sun Dec 28, 2014 3:02 pm
Location: East Yorkshire

Re: Measuring speed using IR LED Phototransistor

Fri Feb 16, 2018 8:14 pm

I've done this many times as it's used for lightgates in science/physics.

It's a simple switch at its basic level.

Either a led or a laser if you need a more directional beam of light.
That and a LDR works fine (or a photodiode too)


- Laser/LED just powered off the Pi pins (5V or 3.3V as needed, with an inline resistor.)

- LDR placed in a potential divider circuit.
An everyday LDR that has no light has a lower resistance compared to the high resistance with the laser/LED shining on it.

So look up GCSE potential dividers and work out which way around the circuit needs to be so the voltage at the divider will drop from >> ~1.7V to <<~1.7V
One side is 3V3 the other GND and the middle is the GPIO pin.

You can then easily use python and gpiozero module in button mode.
It works a bit nicer if you switch to the pigpio pin factory (as they call it now,but only once you works).


So basically just a common LDR and a resistor a common 'laser diode pen', either pull the module out the front or just power it from batteries.


Arduino's also work well for this as do Micro:bit and others.

boyoh
Posts: 1130
Joined: Fri Nov 23, 2012 3:30 pm
Location: Selby. North Yorkshire .UK

Re: Measuring speed using IR LED Phototransistor

Sat Feb 17, 2018 9:51 am

Photoresistor
A photoresistor is a light-controlled variable resistor. The resistance of a photoresistor decreases with increasing incident light intensity; in other words, it exhibits photoconductivity. A photoresistor can be applied in light-sensitive detector circuits, and light-activated and dark-activated switching circuits.
BoyOh ( Selby, North Yorkshire.UK)
Some Times Right Some Times Wrong

User avatar
bensimmo
Posts: 2712
Joined: Sun Dec 28, 2014 3:02 pm
Location: East Yorkshire

Re: Measuring speed using IR LED Phototransistor

Sat Feb 17, 2018 11:48 am

Yep, they are slower to respond too (at least the ones I use too, so not to be used for microsecond timing if using leading/trailing edge). But you get the advantage of, cheap, can use visible light, and good for proof of concept before a wavelength is needed. Visible light is much easier to see than IR for this :-)

zassx
Posts: 20
Joined: Mon Jan 15, 2018 4:37 pm

Re: Measuring speed using IR LED Phototransistor

Mon Feb 19, 2018 9:33 am

boyoh wrote:
Fri Feb 16, 2018 6:02 pm
zassx wrote:
Fri Feb 16, 2018 3:04 pm
boyoh wrote:
Fri Feb 16, 2018 2:58 pm
The speed of a object passing the sensors, could this be don by ,two sensors spaced apart
The first sensor will start a timer when the leading edge of the object passes the sensor.
When the leading edge of the object passes the second sensor ,this will stop the timer.
Calibrate timer to suit
Thanks but I am already doing that, but only with one sensor. No need to have two. So the logic and the software is not a problem, the problem is my lack of knowledge in creating circuit. :)

Saying you already have the circuit working using only one sensor , so what is your problem
It would be a good Idea to draw your circuit, to save going over ground already covered
You must have built a circuit to get it working,,

Regards BoyOh
I don't have a circuit, but like I said I have software already written and working (only simulated since I have no circuit yet). My point quoting your comment was to tell you that you don't need two sensors to make this work but you can measure speed with only one sensor (ofc you got to know the object width in order to do this).
bensimmo wrote: I've done this many times as it's used for lightgates in science/physics.

It's a simple switch at its basic level.

Either a led or a laser if you need a more directional beam of light.
That and a LDR works fine (or a photodiode too)


- Laser/LED just powered off the Pi pins (5V or 3.3V as needed, with an inline resistor.)

- LDR placed in a potential divider circuit.
An everyday LDR that has no light has a lower resistance compared to the high resistance with the laser/LED shining on it.

So look up GCSE potential dividers and work out which way around the circuit needs to be so the voltage at the divider will drop from >> ~1.7V to <<~1.7V
One side is 3V3 the other GND and the middle is the GPIO pin.

You can then easily use python and gpiozero module in button mode.
It works a bit nicer if you switch to the pigpio pin factory (as they call it now,but only once you works).


So basically just a common LDR and a resistor a common 'laser diode pen', either pull the module out the front or just power it from batteries.


Arduino's also work well for this as do Micro:bit and others.
Thanks for this, will check it out!

boyoh
Posts: 1130
Joined: Fri Nov 23, 2012 3:30 pm
Location: Selby. North Yorkshire .UK

Re: Measuring speed using IR LED Phototransistor

Sat Feb 24, 2018 6:54 pm

Hoping now you have the circuit working using only one sensor.

As a mater of interest I would like to see your circuit,? If you
have it working,

Regards BoyOh
BoyOh ( Selby, North Yorkshire.UK)
Some Times Right Some Times Wrong

Return to “Beginners”

Who is online

Users browsing this forum: Baidu [Spider], Bing [Bot], Steffenwolt, zbarna and 34 guests