View previous topic :: View next topic |
Author |
Message |
logicchild
Joined: 16 Nov 2013 Posts: 14
|
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9237 Location: Greensville,Ontario
|
|
Posted: Sat Nov 16, 2013 6:24 am |
|
|
I downloaded the datasheet and it's a 'common' reflective sensor.
Typically you supply power to the LED section and connect the optotransistor to the PIC as an input. When the IR light is 'broken', the sensor changes the output state.This is similar to what happens in PC 'mice'.
How you connect and use it depends on your application.The LED could be supplied with a constant power level( check the specs). A simple current limiting resistor in series to drop the 5V supplying the PIC to a nominal 1.7V for the LED, at whatever current you want( usually 5ma to a MAX of 40ma).I'd try 10ma and put a regular LED in series as an 'on' indicator.
Depending on your application you could power thre LED from the PIC using one or more of the I/O pins to supply power.You can either have the PIC 'source' or 'sink' the LED.Again a series red LED will show whether it's on or off.This configuration allows the PIC to control the LED.In low power(battery) applications this is very useful.
With respect to the transistor output, there are two options.You can put a load resistor(say 10Kr, again check the specs!) in the collector with the emitter grounded.Breaking the IR beam should give good ones and zeros for off and on. You can also put the resistor in the emitter to ground leg with the collector tied to 5V. This would give good zeros and ones for off and on.
For a starting point, I'd use a 330r to limit current in the LED,fed from the 5V for the PIC, a 10Kr in the collector of the transistor,emitter grounded.
Use a voltmeter to monitor the collectore voltage while blocking and unblocking the sensor's view area(maybe 1/4" in front).
Again, check the specs! The more you read and get familiar with them, the more you'll understand what's going on!!
hth
jay |
|
|
logicchild
Joined: 16 Nov 2013 Posts: 14
|
Nice |
Posted: Sat Nov 16, 2013 6:36 am |
|
|
Thanks, that really helps.
But, can you draw a schema showing the PIC and the sensor, I want to read the distance (not actual distance, just to know if there is an obstacle or not) from the sensor, depending on that, the PIC will take a decision, for example turning a LED ON or OFF.
And I want to source the sensor from the same battery that sourcing the PIC.
Thanks again. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9237 Location: Greensville,Ontario
|
|
Posted: Sat Nov 16, 2013 7:27 am |
|
|
Wiring....
+5(same as what powers PIC) to one side of 330r.
other side of 330r to ANODE of sensor.
ground CATHODE of sensor.
+5(again..PIC power)to one side of 10Kr.
other side of resistor to COLLECTOR of sensor AND to PIC input pin.
ground EMITTER of sensor.
NOTE: put meter(or scope) on COLLECTOR to test sensor operation.You should get 0v and 4.5 for 'object' ,'no object' conditions.
anything <.5 V would be a 'zero', anything >4.0 is a 'one'.These are 'nominal' readings.
from the datasheet...
The phototransistor responds to illumination from the emitter when a reflective object passes within the field of view
centered typically at 0.15” (3.8 mm)....
That means the object must be about <4mm from the sensor. This sensor is not used for distance measuring and not really suitable for a 'collision' sensor. 1/10th of an inch is the pin spacing for a DIP type PIC!
Test by using your finger! Placing your finger on the sensor(top of the 'A') will block the light giving you a '0'.No finger should be a '1'.
hth
jay |
|
|
logicchild
Joined: 16 Nov 2013 Posts: 14
|
|
Posted: Sat Nov 16, 2013 7:45 am |
|
|
Thank you so much, you are good, man.
Just to ensure, is that correct regarding the collector connection?
PIC
[.......]
[.......]5v------^^^(10kr)^^^-------+------[[[[[[ Collector
[.......]...........................................|
[.......]...........................................|
[.......]IN----------------------------<<|
[.......]............................................
[.......]............................................
[.......]............................................
[.......]............................................
So if there is an object, the PIN input will read digital 0, otherwise 1?
Thanks again. |
|
|
logicchild
Joined: 16 Nov 2013 Posts: 14
|
|
Posted: Sat Nov 16, 2013 12:33 pm |
|
|
Hi, again
I connected what you've said, but it didn't work, it always return 1, I've used 300 ohm in the diode, and 10k in the collector.
is there any wrong?
I'm using OPB705,
please help :( |
|
|
dyeatman
Joined: 06 Sep 2003 Posts: 1934 Location: Norman, OK
|
|
Posted: Sat Nov 16, 2013 2:44 pm |
|
|
Try it without the PIC connected.
If the PIC is connected and programmed wrong you may
have the pin set for high output. If you have the pullup
wired as you show it has to work unless the LED is wired wrong.
If it works without the PIC connected then show us your code
before we go any further, something is likely wrong in your code.
Do you have a limiting resistor in series with the LED? _________________ Google and Forum Search are some of your best tools!!!! |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9237 Location: Greensville,Ontario
|
|
Posted: Sat Nov 16, 2013 3:18 pm |
|
|
300r is fine, should allow 11 ma to flow.You could insert a red LED in series, replace the 300r with say 150r and it'll work AND give to a 'status' LED at the same time.
yes, do NOT have PIC connected to sensor ! Unless it's properly programmed it will affect the operation.
you might need a 4k7 instead of the 10k, but you should get some response even with the 10k.
hth
jay |
|
|
logicchild
Joined: 16 Nov 2013 Posts: 14
|
|
Posted: Sun Nov 17, 2013 11:49 am |
|
|
Hi again,
Sorry guys, I cannot start this sensor :(, the connection can be shown in the link below, any advice??
As seen in the schema, the Voltage from the first node of 300ohm resistor node is 3v, and 1.23v from the other side.
any help :(
https://drive.google.com/file/d/0B4SOWTLLmD7hTDczMkRoVWlBbXc |
|
|
dyeatman
Joined: 06 Sep 2003 Posts: 1934 Location: Norman, OK
|
|
Posted: Sun Nov 17, 2013 12:14 pm |
|
|
Are you doing this with real hardware or in Proteus/ISIS?
The device you are using to emulate is not the same current draw.
By my estimation 300 ohms should drop around 6V or so at 20ma, so
something isn't right.
OK, I edited this a bit based on your feedback
If you keep the diode try 150 ohms to see if that works better _________________ Google and Forum Search are some of your best tools!!!!
Last edited by dyeatman on Sun Nov 17, 2013 12:39 pm; edited 2 times in total |
|
|
logicchild
Joined: 16 Nov 2013 Posts: 14
|
|
Posted: Sun Nov 17, 2013 12:35 pm |
|
|
Hi,
No, I am doing this in real, ignore the name of the components, I've used that device because it has a diode and a transistor, same as my sensor, just to show my sensor's component.
Thanks |
|
|
logicchild
Joined: 16 Nov 2013 Posts: 14
|
|
Posted: Sun Nov 17, 2013 12:51 pm |
|
|
Hi,
Thanks, but here what I have:
1. Sensor OPB705, consists of Diode, a Transistor (Emitter, Collector)
2. A 100ohm connected to 5v, and from this resistor to the anode of the LED, and the cathode is grounded.
3. A 5v with 4.7kohm connected to the collector, and the Emitter is grounded.
the voltage from the node (between the 4.7 and the Collector) to ground is always 5 even when putting my finger :(
I don't have 150ohm, I have 10, 100, 220, 300, 10k |
|
|
logicchild
Joined: 16 Nov 2013 Posts: 14
|
|
Posted: Sun Nov 17, 2013 1:23 pm |
|
|
Hi,
I've removed the LED and putting 220ohm, so 5v to 220ohm to the anode.
And measured the V between Anode to the ground which is 1.27v
is that correct? |
|
|
logicchild
Joined: 16 Nov 2013 Posts: 14
|
|
Posted: Sun Nov 17, 2013 2:26 pm |
|
|
guys,
i found a solution that works for me:
but output is analog, how can I convert it to digital without using the ADC in the PIC, I want the PIC read it as a digital input,
BTW, the output voltage is 0~1.8 or something like that.
|
|
|
dyeatman
Joined: 06 Sep 2003 Posts: 1934 Location: Norman, OK
|
|
Posted: Sun Nov 17, 2013 2:40 pm |
|
|
Why are you putting the 10k in the ground side of the receiver? To get a
positive going voltage? You will get a getter voltage swing if you put
it in the supply side. You can then invert the signal in software.
Also, the harder you drive the IR LED current wise the more range
you will get (relatively speaking). The max is 25ma so figure on at least
20ma and calculate the resistor needed (not 470 ohms)
For the input use port C which are Schmitt Trigger inputs. They will either
be high or low, no in between. _________________ Google and Forum Search are some of your best tools!!!! |
|
|
|