element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Raspberry Pi
  • Products
  • More
Raspberry Pi
Raspberry Pi Forum Optek OPB732WZ  and the Raspberry Pi ?
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Raspberry Pi to participate - click to join for free!
Featured Articles
Announcing Pi
Technical Specifications
Raspberry Pi FAQs
Win a Pi
Raspberry Pi Wishlist
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Suggested Answer
  • Replies 10 replies
  • Answers 4 answers
  • Subscribers 664 subscribers
  • Views 1366 views
  • Users 0 members are here
  • raspberry_pi
Related

Optek OPB732WZ  and the Raspberry Pi ?

amasters
amasters over 6 years ago

I am hoping that I can use the  OPB732WZOPB732WZ Reflective Photo Interrupter https://uk.farnell.com/optek-technology/opb732wz/opto-switch-reflective/dp/1678639 with a Raspberry Pi which has both 5v and 3.3v supplies on the GPIO.

I have no great experience with electronics, but attaching optical sensors to a Raspberry Pi appears to be a simple matter according to articles I have read using similar devices.

 

Any advice on how to connect this device to the Raspberry Pi would be gratefully received.

 

Many thanks.

  • Sign in to reply
  • Cancel
  • shabaz
    0 shabaz over 6 years ago

    Hi Alan,

     

    You can use the circuit in the datasheet, there are four there, and the first one could be tried, although the third one can be better (and more energy efficient since it can be switched off). The third one needs a transistor, something like BC547 or any other generic NPN transistor is fine.

     

    But, the datasheet circuit is powering everything from one rail called VCC. Better in your case to split it, the receiver portion should be connected to the 3.3V supply (because the GPIO operate at that voltage), and the transmit portion can be connected to the 5V supply (because it will consume more current, and there is some limit on the 3.3V rail). The calculations for the resistors are in the datasheet, e.g. RD = (5V-1.8V)/20mA = 0.16k = 160 ohms, use the next highest easily available value, which is 180 ohms.

    For RL, something like 4.7kohm is fine or that ballpark, it is not very critical.

    If you use circuit#3, then the base of the transistor needs a resistor in series with the connection to the GPIO pin that drives it, although it is not shown. That can be a 1k resistor.

     

    I hope that helps, but if you need more help let me know.

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
  • amasters
    0 amasters over 6 years ago in reply to shabaz

    Thanks Shabaz for taking so much trouble to reply.

     

    I have re-visited the datasheet and with your explanation this seems to be much clearer.

     

    However, I am not clear about the purpose of the additional transistor in diagram 3, is this required to turn the infrared light off?   I am planning to run the Raspberry Pi using the mains adaptor plug and it will probably be in use for a maximum of two hours in any day, after which the Raspberry Pi will be turned off.

     

    My intended application is to record the time a piece of reflective tape passes by on a large wheel which has a rotation time of approximately two seconds, but could be a little faster or slower at various times.

     

    Have I interpreted circuit 2 correctly when I think that if the permanently on infrared LED shines on the reflective strip it will turn on the GPIO input pin. It appears to me that circuit 1 would keep the GPIO pin turned on when there is no light shining on it and turn off when there is ??

    • Cancel
    • Vote Up +3 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • shabaz
    0 shabaz over 6 years ago in reply to amasters

    Hi Alan,

    You're right, the extra transistor is for switching it off, or for pulsing it, for circuitry which isn't attached to the Pi, but can be used to pick up the signal amongst background light. It isn't used in your scenario if you're directly connecting to the Pi, and are running from the mains.

    Circuit 1 and 2 are similar, one provides an inverted output and the other doesn't. The software can usually be coded to accept either scenario. However electrically circuit 1 is better for this purpose usually, because the output can swing a bit more, and is more flexible in the way it can be wired for some use-cases, not that it matters for your application. Anyway, best to go with circuit 1 usually, unless there is a reason it cannot be handled in software. But either will work.

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
  • Former Member
    0 Former Member over 6 years ago in reply to shabaz

    Thanks again for your help Shabaz. I have more confidence now in proceeding with this project.

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • shabaz
    0 shabaz over 6 years ago in reply to Former Member

    Hi Alan,

     

    Excellent, good luck with the project! I don't think you'll need this link, but just in case it provides any ideas:

    Cyclops-1000: An Electronic Eye for Rotational Speed Measurement

    That link is to a microcontroller project however, not Pi based, but maybe bits of it are helpful.

    I find myself using it from time to time, to check things like small fan speeds end-on, i.e. directed at a fan blade with a white sticker stuck to it. The commercial tachometer tool I've got is actually less useful at such end-on applications and only really works side-on to rotating shafts/objects)

     

    If the time you're aiming to measure is of the order of 2 seconds as you mention, then the Pi should work fine for that to accuracy within a few msec hopefully (higher accuracy becomes harder because Linux could context-switch processes at any time).

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
  • Former Member
    0 Former Member over 6 years ago in reply to shabaz

    I have at last got round to build the circuit board, at the moment to accommodate two optical sensors, but while testing for shorts / connectivity I found that there is some form of connection between the two inverted outputs 1 and 2 . Unfortunately my test meter does not measure resistance accurately, so I have ordered one which should.  I am hoping that the connection is through the two resistors RL and the Vcc rail and not a short. I am using Circuit 1.

     

    Sorry for the silly question, but am I likely to get interference between the two inverted outputs 1 and 2 when one of them detects a reflection.  I am imagining that because the current is flowing from the Vcc rail to the ground rail when  the sensor detects a reflection that there will not be any interference, but I would like to be sure before connecting up to the Raspberry Pi and potentially causing damage.

     

    Many thanks,    Alan.

     

     

    image

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • shabaz
    0 shabaz over 6 years ago in reply to Former Member

    Hi Alan,

     

    What voltage are you intending to connect Vcc to, is it 3.3V or 5V? Ideally the LED (transmit) portion should be powered from 5V. The phototransistor (receiver) portion must be powered from 3.3V to be compatible with the Pi's inputs, The Pi's 3.3V can't supply much current, and the LEDs consume more power than the receivers, which is why they are preferred to be connected to 5V.

    If you're testing unpowered, then the resistance between the two outputs could be 2xRL or less. This path is through the two RL resistors so does not imply at all that there could be electrical or optical interaction when the top rail is set to a voltage. Since the rail is fixed at a voltage in operation, then the voltage at output 1 results from current passing through RL1 only, and the current through RL2 has no impact on it, and vice-versa.

     

    Before connecting to the Pi, confirm that the resistance between VCC and VEE is higher than a few hundred ohms. If it is very low (like 10 ohms or less) then you have a wiring fault and it must not be connected to the Pi.

    If the resistance is higher than a few hundred ohms then connect the VCC and VEE connections to the Pi. (VCC definitely being 3.3V for the receiver portions, and as mentioned 5V for the transmitter portions if possible).

     

    Next, with the meter set to Volts DC, confirm that output 1 and output 2 never go higher than 3.3V. If they go higher, then there is some wiring fault. If they don't go higher, then you're fine to make those connections too.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
  • Former Member
    0 Former Member over 6 years ago in reply to shabaz

    Thanks again for the comprehensive reply Shabaz.

     

    Yes, I have taken your advice and connected the LED part to the 5v and the phototransistor to the 3.3v but had not shown this in the diagram - sorry. You will recognise it as the diagram extracted from the fact sheet.

     

    I am waiting for a delivery of a test meter which is supposed to measure resistance accurately, so will resume testing when I receive it.

     

    Thanks too for the advice on connecting the 5v 3.3v and Ground only from the Pi to the board. I have some jumper leads which can be used for this. The final build will use a ribbon cable from the GPIO  to an Adafruit Pi T-Cobbler Kit Breakout for R Pi A+/B+ , so connecting that before your recommended test would be unwise.

     

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Problemchild
    0 Problemchild over 6 years ago in reply to shabaz

    Hi Shabaz, one thing for folk to note is that the output from  the phototransistor may not be as square as shown in the diagram afterall it is an analog device, we are assuming that for any reasonable amount of reflected light the gain of the transistor is such that it's more or less square and can easily be connected to a logic input. That said if you look at Shabaz's Cyclops Article you will see that he uses a part that already has a schmitt trigger inside and a further transistor to clean it all up.

     

    If you are getting intermittent or strange results you may well need to visit this part of the circuit!

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Problemchild
    0 Problemchild over 6 years ago in reply to shabaz

    Hey Shabaz, the other function of that transistor can be to modulate the output of the diode. That way you can have several emitters in fairly close proximity to each other but modulated at different frequencies or even just plain off when the other units are on this would make it easier to identify signals from each interrupter and also differentiate their signal from external ambient light sources

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube