6
\$\begingroup\$

I'm not a guy from electrical engineering and I'm having a little trouble with a small garage project that I'm working on.

I want to use a photoelectric sensor to measure distances. I'll probably stick my sensor - an O1D105 - in a little board with a microcontroller to do some early processing and communication with a server. I'm used to dealing with components that already provide me some pre-processing of the data and communicates through SPI or serial RS232, but this is my first project with something of such a low level.

I don't know how to project a circuit to this DC PNP output that the datasheet is talking about. Also, I can't understand the pin diagram that was shown to me: what is L+ and L-? VCC and GND? And where is the output? Could it be pin 2, where the guy placed an amperemeter? It looks from the datasheet that I should measure the current to get an analog output for this device, but I could be wrong. And how do I connect this output to a microcontroller? Is it the usual workflow to find information about my microcontroller's input ports so that I can make sure that the output is in an acceptable range (I haven't chosen a microcontroller yet)?

Also, what should I start studying to figure this stuff out for myself? It looks to me that this is something really obvious to someone that works with the standards referenced by this component, but that I don't have a clue about.

UPDATE

About the distance between the controller and the sensor: there might me some meters of distance between them (probably no more than 5 meters) and it could be attached to a lamppost, so I guess I'll follow the tips to avoid noise.

Thanks for all the really detailed answers. I'm gonna try to work this out so that I can decide which answer was the most helpful, but I guess all of them could be the right answer. Thanks again!

\$\endgroup\$
4
\$\begingroup\$

L+ and L- are the power supply connections for the sensor. The datasheet shows this as being in the range 18 to 30V DC, so you'll have to provide that to the device.

From a brief skim through the user manual, I'd suggest the easiest way to interface this device to a microcontroller would be to configure it to provide a 0-10v voltage output rather than a 4-20mA current output (see the user manual section on configuring OUT2). The 4-20mA current output is a common instrumentation standard, but I don't think it would provide any advantage in your application (unless, for some reason, you need to detect the sensor being disconnected - with the current based interface, if you don't get at least 4mA of current being drawn, then you can assume the sensor is disconnected.)

A typical 8 bit microcontroller with analog to digital conversion will accept a voltage range somewhere between 0v and the controller's supply voltage (typically called Vcc or Vdd depending on the manufacturer's terminology.) If you're using a device with a Vcc of 5V then you just have to use a voltage divider (2 resistors in series - center tap to your controller analog input) to reduce the sensor's 0-10V output to the 0-5V required by the microcontroller.

As to what you should study to figure this stuff out, I can only suggest an electrical or electronic enngineering course, or start ploughing through some books in that area. Some of the books I've seen on Arduino controllers provide quite good introductory level stuff, but I'm not familiar enough to name any specific titles.

\$\endgroup\$
  • \$\begingroup\$ Another reason to use the 4-20mA signaling system is it has excellent noise immunity. However, that may not be needed either. \$\endgroup\$ – Connor Wolf Jun 25 '12 at 10:15
  • \$\begingroup\$ Yes "Fake Name" makes a good point. I had assumed that the controller would be connected close to the sensor so induced noise wouldn't be an issue. However, if the controller is located some distance from the sensor, the greater the risk of noise (e.g. from any nearby electrical equipment such as motors, car ignition systems etc.) being coupled into the analog signal. Without knowing the application, it's difficult to say whether that's likely to be an issue here - I haven't checked whether the source impedence of the voltage output is defined in the User manual. \$\endgroup\$ – Eddie Jun 25 '12 at 13:16
3
\$\begingroup\$

The O1D105 is a LASER based distance measuring system.

Output is

  • On / off DC from output 1 with a user programmable trigger point

    • Output one uses a PNP high side transistor switch to V+ which is turned either from on to off or from off to on (user selectable) as target distance increases through a user preset limit.

or

  • Analog output on output 2 corresponding to the distance of the target.

    • Output two is EITHER an industry standard 4 to 20 mA output that provides a current proportional to distance OR a 0-10V DC signal. Output range that is covered can be user selected to either cover the full possible measurement range or can be selected to be a fraction of the full range. See diagram below. This is from the "Operating Instructions" document mentioned below.

enter image description here

The critical document to have is
Operating instructions - Optical distance sensor O1D105.

To interface to a microcontroller and to measure distance with the sensor see section 9.2.11 on page 19.

To interface to a microcontroller you would probably be best to use the analog 0-10V output on output-2.

Divide this output with two resistors so that Vout = ADC_Vmax when Vin = 10V.
In the diagram below Vout = Vin x R2/(R1+R2)
or rearranging R2 = V0 x R1 / (Vin - Vout)

Set R1 to say 10k and select R2 to suit. Use next standard LOWER value of R2 so that Vsdc_max_in is < Vallowed.
Example 1: Vin = 10V, V_ADC = 5V max, R1 = 10k.
R2 = 5V x 10k / (10V-5V) = 10k. So R1 = R2 = 10k.

Example 2: Vin = 10V, V_ADC = 3V max, R1 = 10k.
R2 = 3V x 10k / (10V-3V) = 30/7k = ~4.3k. -> Use say R1 = 3k9
So R1 = 10k. R2 = 10k.
V0 = Vin x 3k9/(10k+3k9)
For Vin = 10V, Vout = 2.806V.

enter image description here

\$\endgroup\$
3
\$\begingroup\$

I also find the documentation for this difficult to understand.

I am still mystified at what "Electrical design: DC PNP" is supposed to mean.

I'm assuming you're putting the microcontroller right next to this sensor. If you're running 10 meters of cable between them, you'll need something more complex.

Like many websites, there's a brief summary with a photo of the device, with a link to a more detailed datasheet.

Skimming through what the "operating instructions for the O1D105", it appears to me that

  • pin 3: L- is GND
  • pin 1: L+ is +power, where they expect you to connect a power supply anywhere in the range 18 VDC to 30 VDC
  • pin 2: out2 : set with [OU2]
  • pin 4: out1 : set with [OU1]

The KISS principle recommends keeping things simple, if possible -- setting the sensor to give a binary on/off output seems to be simpler than setting the sensor to give an analog output.

simple binary on/off output

The out1 output is a relay connected to GND; it's either open or closed. These are extremely easy to connect to a microcontroller:

  • You connect a 10 kOhm resistor (exact resistance is not critical) from the microcontroller's digital input pin to the microcontroller's VCC pin. (The microcontroller's VCC pin is often 3V or 5V). (Keep that resistor far away from the sensor's +power +24 VDC pin).
  • You connect the GND pin on the microcontroller to the GND pin 3 of the sensor.
  • You connect out1 pin 4 on the sensor to the digital input pin of the microcontroller.

For many applications, this open/closed switch works great.

analog output

When out2 is set to voltage mode mode "[U]", The out2 pin 2 outputs an analog voltage from 0 to 10 V. This is slightly more complex to hook up.

pin 2 ---R1---+---+--- analog input pin of microcontroller
(0..10V)      |   |    (0..VCC)
             R2   C1
              |   |
             GND  GND

The resistors R1 and R2 form a resistor divider to linearly translate every analog voltage in the range 0..10V into some other analog voltage in the range 0..VCC.

You set R1 = R2 * ( Vin - Vout) / Vout. Use the next standard higher value for R1 to keep things in range. (While I'm typing this, I see RM gives more or less the same advice, except he re-arranges the equations to start from R1 and then calculate R2).

  • If your microcontroller runs on 5V, then you want R1 = ((10-5)/5) R2 = R2.
  • If your microcontroller runs on 3V, then you want R1 = ((10-3)/3) R2 = 2.3*R2.
  • Connect the GND pin on the microcontroller to the GND pin 3 of the sensor.

The capacitor C1 provides some noise filtering and also helps hold the voltage steady when the ADC inside the microcontroller does its thing. Alas, many microcontrollers have an internal ADC that pulls so much current that this simple circuit isn't adequate -- they require an external op-amp to drive the ADC. (Feel free to ask another question about "Does my ADC require an op-amp buffer?").

The question " How can I interface with these 24 V signals? " has some tips in the answers that would apply to this system.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.