Shop OBEX P1 Docs P2 Docs Learn Events
Need encoder help! — Parallax Forums

Need encoder help!

lardomlardom Posts: 1,659
edited 2014-08-04 12:58 in Robotics
I'm having trouble getting a clean high/low response from my IR emitter-reciever module. I'm using an LED in series with the detector to show when it conducts and it only goes from dim to bright.
I scavenged several RPR-220 reflective modules from a discarded document feeder and found the datasheets online. My encoder disks are 'about' 3mm from the detectors. The disk resolution is 44. (I guess that means 44 pairs of stripes.) I put a 15-turn trimmer in series with the emitter to help find the sweet spot.
How do I get a clean high-low signal? Comparator? Schmitt trigger?

Comments

  • Duane DegnDuane Degn Posts: 10,588
    edited 2020-08-29 22:49
    I would think the LED in series would cause trouble. The signal isn't meant to provide much current. If you used it with a QuickStart's I/O pin P16 to P23, then you could have your LED and signal too. (That was supposed to sound like "have your cake and eat it too.")

    Also 3mm seems kind of far to me. Here's a picture of encoders I added to a Roboni-I robot.

    94288


    As you can see, the sensor is awfully close to the gear with the stripes. The gear was transparent to IR so I added a layer of Al foil so the IR would reflect back to the sensor.

    The P5587 encoders include a Schmitt trigger and works really well. You still need good light and dark areas. Some black material isn't so black when the light is IR. I originally used Gorilla tape for my black area in this experiment but switching to black masking tape made a big difference.

    It's also a good idea to have a pair of encoders (quadrature) so you can detect which way the motor is turning. The quadrature encoders will also make sure you don't count transitions across the same boundary (going forward then back) as real movement.
  • lardomlardom Posts: 1,659
    edited 2014-07-20 10:08
    Duane, so the P5587 is a breakout board that includes a Schmitt trigger? I'll order at least four on Monday. How can I get a gear like the one in the picture? A gear on the inner motor shaft would eliminate the slight wobble I see from my wheel mounted reflective disk.
    Thanks.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2014-07-20 10:26
    lardom wrote: »
    Duane, so the P5587 is a breakout board that includes a Schmitt trigger?

    The P5587 includes a Schmitt trigger internally. Make sure and look through the P5587 thread to see how it mounts. It's not really breadboard friendly.

    I think I offered to post gerber files to PCBs for the P5587. Just let me know which PCB design you're interested in.
    lardom wrote: »
    How can I get a gear like the one in the picture? A gear on the inner motor shaft would eliminate the slight wobble I see from my wheel mounted reflective disk.

    The gear was part of the robot's drive mechanism.

    If you post photos of your motor (from several views) someone might have an idea on a good way to mount an encoder disk. Sometimes it's easier to mount one on a gear than directly to the motor's shaft.
  • lardomlardom Posts: 1,659
    edited 2014-07-21 08:17
    Duane Degn, I'm learning. After reading your post then researching 'Schmitt trigger' and comparators I realized I had to digitize the signal. The bright-to-dim response I saw was analog. I placed the IR detector about 6mm from the encoder disk based on what I thought was a recommendation from the datasheet. I'll move the detector as close as I can to the disk.
    1024 x 768 - 69K
    1024 x 768 - 89K
  • Duane DegnDuane Degn Posts: 10,588
    edited 2014-07-21 09:00
    I know I had to experiment with what material the stripes were made from and I also had to experiment with the distance of the sensor to the stripes to find the best combination.

    One concern I have is if the sensor can distinguish the individual stripes at that distance. Is it "seeing" more than one stripe at a time?

    I don't know how you have your setup wired but you want to protect the Propeller I/O pins from too much current through the clamping diodes. With the I/O pin set as an input, the current through the clamping diodes should not be more than 500uA (0.5mA). A 3.3K resistor will keep the pin safe from a 5V signal.
  • lardomlardom Posts: 1,659
    edited 2014-07-21 09:51
    It's not connected to the Propeller yet. I'm testing with a 6V battery pack, a multimeter and a 'point and shoot' camera. I used a trimmer to control current to the emitter. It's clear I have to get the detector closer. I'll redesign the circuit.
  • GordonMcCombGordonMcComb Posts: 3,366
    edited 2014-07-21 17:37
    lardom wrote: »
    IMy encoder disks are 'about' 3mm from the detectors. The disk resolution is 44. (I guess that means 44 pairs of stripes.)

    That's your problem. A Schmitt trigger or comparator can certainly be useful, but your sensor is seeing more than one stripe at a time, and no additional electronics will make this work reliably. You either need to get the sensor right up against the encoder, use a different sensor with a smaller aperture, or use a code wheel with (far) fewer stripes. Start with 6 or 8, and work your way up from there.
  • ercoerco Posts: 20,255
    edited 2014-07-21 19:41
    You could add an aperture (blinders) to limit your sensor's field of vision. And measure the output (scope) from the IR PTX before filtering or Schmitt trigger. Here's an interesting old read on troubleshooting a homebrew encoder sensor: http://list.dprg.org/archive/1998-July/005620.html

    And another fun read about the merits of encoder-based dead reckoning: http://www.seattlerobotics.org/encoder/200108/using_a_pid.html
  • lardomlardom Posts: 1,659
    edited 2014-07-21 23:39
    Gordon, I had grey hair before I discovered my passion for programming. During my college years I believed it was unbearably tedious. Solving 'problems' excites me. The charge I get from solving things fades quickly so I'm constantly seeking new challenges. I'm already thinking about leaning to control my bot with an rc controller.
    erco, great links. Thanks.
  • ercoerco Posts: 20,255
    edited 2014-07-22 07:37
    That's your problem.

    IOW, in technical parlance, that's a "YP", not an "MP".



    Obscure "Boogie Nights" reference.

    Larry: You can try moving your sensors closer to the disk. Per Gordon, the sensors' view of the disk is critical.
  • GordonMcCombGordonMcComb Posts: 3,366
    edited 2014-07-22 07:55
    The mechanical construction of your plywood (yea, plywood!) bot ought to make it real easy to adjust the distance between the sensor and code wheel. A slot in either the base or sensor mount can allow you to test various distances. You ought to be able to adjust it so the sensor is just a hair width away from the wheel. Of course, all wheels will have run-out (wobble), so be sure the servo screw is all the way tight, and adjust the sensor for its closest distance.

    Folks often over-complicate encoders. The Big Trak toy of the 80s, which people could program for fairly accurate moves, had a wheel encoder with maybe 10 or 12 holes in it. (And at that it only had one of them. The two wheels were kept synced by using a novel magnetic differential clutch.) If you can get your 44 stripe encoder to work, that's great, but an 8 or 12 stripe wheel works very well, too. Beyond that the frustration quotient increases exponentially.
  • lardomlardom Posts: 1,659
    edited 2014-07-22 09:49
    Quote by erco;
    ...Per Gordon, the sensors' view of the disk is critical.
    I owned "Troubleshooting and Repairing VCRs" by Gordon McComb at a time when I thought I was smart because 'I knew' that a Basic Stamp had nothing to do with postage. Shortly after I bought "What's a Microcontroller" I bought "Robot Builder's Bonanza".
    I'm getting an education from some of the best people in the business. If people spend time for my benefit, I learn the lessons. The important thing is I enjoy the heck out of the learning process.
    Gordon, I'm listening. Thanks.
  • ercoerco Posts: 20,255
    edited 2014-07-22 14:55
    Gordon's quite knowledgeable, he knows about everything. Micros (even them Ardweeny things), robots, VCRs, jukeboxes, PCs, Macs, web commerce, software, even a bit about Corvairs.

    https://www.google.com/search?tbo=p&tbm=bks&q=%22Gordon+McComb%22&gws_rd=ssl#q=%22Gordon+McComb%22&start=10&tbm=bks

    He's the man. Listen to him. Learn from him.
  • GordonMcCombGordonMcComb Posts: 3,366
    edited 2014-07-22 16:23
    Well, here's what I know about Corvairs.

    I was almost in a deadly wreck in one. I'm sure the inexperienced driver invented "drifting" racing that day. I never knew a car could actually travel sideways.

    In same Corvair I put my foot through the rusted out floorboards in the back seat, and actually scraped it against the pavement rolling underneath!

    (Incidentally, this was in the early 70s, so the car wasn't more than 10 years old at the time.)

    My favorite comedian of all time, Ernie Kovacs, was killed in a first generation Corvair stationwagon, when he took a modestly high speed turn on Santa Monica Blvd over wet pavement -- bad combination for a Corvair.

    On the other hand, my favorite auto writer and famed sexist curmudgeon Tom McCahill liked it.
  • ercoerco Posts: 20,255
    edited 2014-07-24 16:42
    On the other hand, my favorite auto writer and famed sexist curmudgeon Tom McCahill liked it.

    Not to mention that racer Dan Gurney drove one for his personal car: http://corvaircenter.com/phorum/read.php?1,92023

    And Don Yenko made the Stinger: http://www.yenkostinger.com/

    And John Fitch made the Sprint: http://www.corvaircorsa.com/fitch01.html
Sign In or Register to comment.