Reading opto interrupters

Discussion in 'General Electronics Chat' started by camerart, Aug 19, 2014.

  1. camerart

    Thread Starter Active Member

    Feb 25, 2013
    517
    30
    Hi,

    I have been adding photo interrupters to motor/gearboxes: http://forum.allaboutcircuits.com/showpost.php?p=750615&postcount=421 The interrupters are 180 degrees on a 9light 9dark film disk.

    It's not as straight forward as it might seem!

    First I tried one to get the best on/off balance by choosing resistors. Then built 4x of them (Perhaps a mistake, but it's done)

    Trying to read on/off times on an oscilloscope is giving me odd readings. Should it be set for 1 or 2 triggers? ac/dc? It give best result with 1x trigger, but my logic say it need 2xtriggers.

    Any tips welcome.

    Cheers, Camerart.
     
  2. ericgibbs

    AAC Fanatic!

    Jan 29, 2010
    2,503
    380
    hi C,
    I assume that the amplified signal output from the opto is a TTL square wave.?

    Its usual to trigger/count on a rising or falling edge of the square wave.

    E

    EDIT:
    Are you using two opto-inter on your optical disc set at quadrature positions relative to each other.??
     
    Last edited: Aug 19, 2014
  3. camerart

    Thread Starter Active Member

    Feb 25, 2013
    517
    30
    Hi Eric,

    I am pretty sure it is TTL.

    EDIT: Yes two opposite to each other on odd numbered disk, with slight adjustment.

    See: http://youtu.be/holB_T5xF-0 Oscilloscope set to 2v/square.

    The first part of the video is set to 1 channel, the last part set to 2 channels.

    Camerart
     
  4. ericgibbs

    AAC Fanatic!

    Jan 29, 2010
    2,503
    380
    hi C,
    Your uTube is blocked as Private.
    Cannot log in.?

    E
     
  5. camerart

    Thread Starter Active Member

    Feb 25, 2013
    517
    30
    Hi E,

    Sorry, try now.

    C
     
  6. ericgibbs

    AAC Fanatic!

    Jan 29, 2010
    2,503
    380
    Hi,
    If the scope display is set to Alternate, try Chopped and trigger Normal on the high going edge of the the upper channel.

    E
     
  7. camerart

    Thread Starter Active Member

    Feb 25, 2013
    517
    30
    Hi E,

    I changed the setting, but there's not much difference.

    I think the problem is lots of errors from me adding up.

    On the motor (as video), I noticed that the disk is running eccentrically, I can re-fit it.

    I doubt with my skills I can get much better results.

    This set-up should give 10X better resolution to what is needed. Do you think that as long as the channels don't switch too near to each other, this will be acceptable?

    Camerart.
     
  8. ericgibbs

    AAC Fanatic!

    Jan 29, 2010
    2,503
    380
    hi,
    As long as you get distinct over lapping and non overlapping pulses on the A and B optos you should be able to count the rev's and also the direction of rotation.

    Which method are you using to convert the pulses into 'directional' commands for the motors.?
    E
    EDIT:
    As your clip shows, its OK.
     
  9. camerart

    Thread Starter Active Member

    Feb 25, 2013
    517
    30
    Hi Eric,

    Ok, that's good.

    I'm not sure how to convert the pulses, but I'll finish the mechanics, then come back to the tracker thred. (I think Roman know how to do it)

    Camerart
     
  10. THE_RB

    AAC Fanatic!

    Feb 11, 2008
    5,435
    1,305
    That scope shot looks perfectly fine.

    Each sq wave is close to 50:50 duty, and they are very close to perfect phasing.

    The PIC you are using has schmidt trigger inputs which will clean up the waves nicely.

    Just make sure the waves are as close to 5v in amplitude as you can get, while still being 50:50 duty cycle.

    I showed you a technique in the other thread where you can use two trimpots for the opto receiver bias resistors. That helps a lot to adjust the waveform amplitude and 50:50 bias.
     
  11. camerart

    Thread Starter Active Member

    Feb 25, 2013
    517
    30
    Hi Roman,

    True the pic looks 50/50. Did you see the earlier video I posted? It shows wavering about. I don't know what causing it, but as Eric says, as long as the edges don't cross over, it will still work, not quite as accurately as perfect. (The problem cold be caused by my ancient oscilloscope and its trigger)

    Camerart.
     
  12. THE_RB

    AAC Fanatic!

    Feb 11, 2008
    5,435
    1,305
    The wavering is caused by your opto disc having imperfect spacing. The scope triggers on different edges, which are imperfectly spaced and so you get screen artifacts due to the phase errors.

    Those small edge errors won't make any significant difference in your application, provided the edges occur in the correct quadrature sequence.

    If we worked out before that one quadrature count is 0.1 degree movement of your machine, those edge errors are probably less than a 5th of a quadrature count so in use will only give an error of maybe 0.02 degrees. Your gearbox slop will be more than that. Probably a lot more. :)
     
  13. camerart

    Thread Starter Active Member

    Feb 25, 2013
    517
    30
    Hi Roman,

    The disk were laser printed from a pie chart, which was probably pretty accurate but darks were not dark enough (A find did it and told me he hadn't used the best setting:confused:) I made negatives of the print from Lith film which is developed by eye and kind of spreads to black. This is perhaps were the errors lie?

    Thanks to your suggestion of using the faster end of the motor/gearbox we have the 0.1degree resolution giving some error room, thanks.

    Camerart.
     
  14. Sensacell

    Well-Known Member

    Jun 19, 2012
    1,131
    267
    It's also possible that your edge speeds are too slow and perhaps generating multiple transitions, which are hard to catch, especially when the signals go right into a microcontroller input.

    Try buffering the signals with a schmitt trigger gate, 74LS14 for example.
    Check the output of the '14 for clean edges, with no extra transitions.
     
  15. camerart

    Thread Starter Active Member

    Feb 25, 2013
    517
    30
    Hi,

    I should have spent more time planning how to fit the interrupters. These ones are approx 5mm x 5mm and glued to arms that move in/outwards to allow fitting the disk. Gluing them accurately, is difficult and aligning the slot parallel to the disk lines also. Hence the errors.

    The signals will connect to motor control PICs that have trigger gates.

    C
     
Loading...