In order to measure the angle and calculate the angular velocity and acceleration of a large metal wheel with a rotational frequency \$f = 0.01 \ldots 1.00~Hz\$, I try to build a custom rotary encoder located on the axis of the wheel.
The basics to this task are described in this National Instruments Tutorial #7109. To be exact, I want to have three rotating metal discs (Data Channel A, Data Channel B, Reference Channel Z) with a radius of \$r_{Disc} = 114.592~mm\$, i.e. with a circumference of \$U_{Disc} = 720~mm\$.
For an 1° accuracy, I plan to cut \$4~mm\$ slits on the outside of the discs - 90 slits each for discs A and B and 4 slits on disc Z (0°, 89°, 182°, 271° references). The slits should then be detected with fork light barrier sensors.

I already have the following parts from National Instruments, which I would like to use for this task:

  • Controller NI cRIO-9074 or Compact Chassis NI cDAQ-9171
  • Bidirectional 5V/TTL Digital Input/Output Module NI 9401
    • Input Voltages
      \$2.00~V \leq V_{In,High} \leq 5.25~V\$
      \$0.00~V \leq V_{In,Low} \leq 0.80~V\$
    • Output Voltages
      • Output High
        Sourcing \$100~\mu A\$: \$V_{Out,High} \geq 4.7~V\$
        Sourcing \$2~mA\$: \$V_{Out,High} \geq 4.3~V\$
      • Output Low
        Sinking \$100~\mu A\$: \$V_{Out,Low} \leq 0.1~V\$
        Sinking \$2~mA\$: \$V_{Out,Low} \leq 0.4~V\$


Now the question is which light barrier sensors I can use. The first idea is a Panasonic PM-T54 (NPN Open-Collector Transistor, datasheets here and here) or a PM-T54P (PNP Open-Collector Transistor, datasheets here and here).
They each require a supply voltage of \$5~V~DC \ldots 24~V~DC \pm 10\%\$

  • Can I use both the NPN- and the PNP-Type or would one of those be more suited for the NI 9401?
    If I understand correctly, the PNP-Type does need a sinking input (i.e. sinking output on the NI 9401) with a grounded connection to the load, whereas the NPN-Type needs a sourcing input (i.e. sourcing output from the NI 9401) with a voltage source to the load.
  • Does the NI 9401 provide enough current?
    In the datasheets of the sensors, a maximal current consumption of \$50~mA\$ (circuit diagram in first datasheet or page 6 in second datasheet) or \$15~mA\$ (page 5 in second datasheet) is indicated.
    (Side Question: What is the difference between the maximal current consumption and the maximal sink/source current on page 5 in the second datasheet?)
    However, it seems that the NI 9401 is only capable of providing a maximum of \$2~mA\$. Is this correct? Does this mean that I need a different power source for the sensors, but that I can keep the NI 9401 as an input module?
  • 1
    \$\begingroup\$ First, your slot width and spacing should be 4 mm, not two. Note that you don't need to have 2 data channel disks. You only need one, with two detectors whose relative phase is offset by 90 degrees. Note, though, that however you do it you'll need to be very careful in machining your slots to avoid cumulative errors as you make successive slots. \$\endgroup\$ – WhatRoughBeast Jan 31 '17 at 14:10
  • \$\begingroup\$ With all the money that you are already spending on that fancy NI hardware why don't you just purchase a ready made rotary encoder unit. Reasonably priced units are available such as here: usdigital.com/products/encoders/incremental/rotary/shaft/H1. Just take the unit and couple it to the wheel similar to the thing you are trying to build. \$\endgroup\$ – Michael Karas Jan 31 '17 at 14:26
  • \$\begingroup\$ @MichaelKaras The NI hardware has already been bought and used for a couple of years now, so I only have to buy the sensors. Rotary encoder units will not fit due to some constraints, you have to just believe me on this one. Hence a simple, DIY encoder. \$\endgroup\$ – Discbrake Jan 31 '17 at 14:34
  • \$\begingroup\$ @user5564832 - If it is so simple then why the massive overload of questions here? \$\endgroup\$ – Michael Karas Jan 31 '17 at 14:38
  • 1
    \$\begingroup\$ VTC - This site is not a consulting service setup to do component selection and design work for you. \$\endgroup\$ – Michael Karas Jan 31 '17 at 14:40

Sinking 2 mA 0.4 V maximum means the source resistance is 0.4V/2mA = 200 Ohms which can deliver 15mA with a small series current limiting Resistor. If using IR LED's with 1.2V drop from 5V then a total series resistance of 3.8V/15mA= 250 Ohms. If the driver is 200 Ohms and LED is about 10 Ohms then a series R of about 40 Ohms is needed. If a RED LED is used with 2V drop and about 15 Ohms internal resistance and you want Iol = 15mA then 5V-2V=3V then 3V/15mA=200 ohms same as the CMOS drive in the "0" state and the CMOS driver would pull down the cathode directly causing Vol to rise to 3V with the Anode on 5V. Note that it is no longer TTL logic levels but since we are not interfacing the LED driver to other logic this is ok.

The current levels, slot width, Emitter efficacy and detector sensitivity all affect the received photo voltage so that the blocked condition must attenuate the light sufficiently to create a valid logic level with equal margin to the transmitted signal saturating the detector. This is a subtle design characteristic of on off light detection using hysteresis in the detector. The optical path of the emitter must be carefully blocked to reduce the angle to allow light to be blocked between slots when aligned and with a gap about the same as the width of the block. This is where care in the optical signal to noise ratio is critical. Signal being transmitted light and Noise being stray light that leaks past adjacent slots. So both the emitter and detector need apertures about the same as the slot dimensions. ( fine tuning or calculations are necessary to determine optimum aperture size to match the channel or slot and blocked gap between.)

This becomes the critical test of your electro-optical design is how much margin you have in detecting pass/block encoder wheel levels to allow for 30% aging of the emitter and all other sources of aging (dust blockage , supply variation, etc) This is about the limit of using the CMOS as a current driver. There are other methods using transistors as well.

The position of the 2 detectors then gives the quadrature alignment of 90 degrees and the edges of detection controlled by optical path, sensitivity , %hysteresis and "any sources of stray light" . Normally IR is best with daylight blocking filters in the detector or in enclosed encoders, RED is used as it is a few pennies "cheaper" but not better, but perhaps easier to see stray light the first time.

You can create any aperture size by a controlled hole size and the depth of LED emitter surface relative to the hole. It is best to use high optical gain small angle emitters and moderate angle detectors but not too small that alignment becomes critical. A 15 degree LED is ok or maybe 30 deg but signal is lost with beamwidth and 8 degree "may be" too little and sensitive to alignment. So consider the path loss in emitter, aperture, slot, detector aperture and detector to choose the balanced highest margin on/off levels. Consider all the factors of alignment before careful position of emitter and detector for optimal performance. ( See how the pros do it and take measurements)

Obviously a laser emitter gives the best precision but also has the highest aging rate for intensity so some method of regulating the emission levels with an internal reflective PD sensor and lowest temperature rise on the laser Diode in order to achieve longest possible life at , even though at a greater cost for ultra high resolution or long gap encoder applications. This is how I expect some commercial "fork" detector encoders to work, obviously costing much more than a mouse wheel, but then expected to be much better.

This reminds of an article I wrote on how to design a better reliable "flop flop" in a toilet water flap valve or "how to design a better mouse-trap" with the same attention to Murphy's Law.

| improve this answer | |
  • \$\begingroup\$ p.s. 200 Ohm CMOS is characteristic of high voltage CMOS logic that can operate > 5V Low voltage limited CMOS logic has output reistance of 50 and 25 ohms respectively for 5V max and 3.3V max types. ( typical verify with Vol/Iol) It is also possible to use IRDA2 IR emitter detectors up to 1 meter gap with 5mm holes and parts recessed to give a 5mm path for fork blocking applications. I have done this and been able to detect a resistor wire attenuating IR path in a 1 meter span using pulsed light patterns as data and detecting data errors \$\endgroup\$ – Tony Stewart Sunnyskyguy EE75 Jan 31 '17 at 15:47

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