Shop OBEX P1 Docs P2 Docs Learn Events
Non "OEN" optical shaft encoder HELP! — Parallax Forums

Non "OEN" optical shaft encoder HELP!

rybitskirybitski Posts: 7
edited 2007-12-09 05:00 in BASIC Stamp
So I am using the Boe board with non-parallax optical encoders and am having a software crisis. I tried modifying the parallax code that you can download for the Parallax "digital encoders" and because the parallax encoders only have 8 "ticks" per revolution the code is not compatible. The encoders I am trying to use have 90 "ticks" per rotation. I am not that familiar with PBasic, but what I am trying to do is have the 2 motors spin 90 ticks (1 revolution).

Right encoder pin1
Left encoder pin2
Right motor pin 12
Left motor pin 13

Could some body please help me with this code? It would be greatly appreciated, thank you.

-Chris Rybitski

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2007-12-06 17:17
    Just to clear up one misconception regarding the BOE-Bot Digital Encoder Kit: Although it does use the eight holes in the wheel, those holes provide 16 nearly equally-spaced edges, yielding a resolution of 0.5" (12mm) of travel. This is a very reasonable precision for the BOE-Bot, which the BASIC Stamp is able to track without missing any pulses. 90ppr, on the other hand, would give you 0.09" (2mm). Assuming the BASIC Stamp was even capable of tracking that many pulses at a reasonable rate of travel while pulsing the servos too, and notwithstanding the difficulty of getting a pulse-controlled continuous servo motor to stop with 4-degree precision, do you really need that kind of accuracy? If "yes", you might consider the ServoPAL as a way, at least, to offload the servo pulsing. But even then, since the BASIC Stamp is a single-task processor, any interaction with the ServoPAL may cause you to miss a pulse or two from your encoders.

    -Phil
  • rybitskirybitski Posts: 7
    edited 2007-12-06 17:24
    The reason I went with these encoders is because you cannot use the parallax encoders except with the Boe Bot wheels.

    So are you saying that the BS2 is unable to handle these encoders?
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2007-12-06 17:33
    The advantage of a coarser resolution is that there's time between encoder pulses to do other things, like controlling the motors. At 90ppr, your window of opportunity for performing these other tasks closes down rather severely and, unless you're moving very slowly, you're going to miss encoder pulses while you're attending to these other tasks.

    If using the standard BOE-Bot wheels is out of the question, perhaps you could replace the code wheel accompanying your encoder with one that has fewer stripes. A laser- or inkjet printer could easily print such a pattern.

    -Phil
  • rybitskirybitski Posts: 7
    edited 2007-12-07 04:42
    The thing is it is a too late to change the design... Any help with this code would be greatly appreciated.
  • metron9metron9 Posts: 1,100
    edited 2007-12-07 05:10
    Well then you will just have to use an external chip inline with the encoders that will convert the 90 pulses to 8. So every 11 ticks you toggle the output pulse that goes to the stamp. After 44 ticks you will need to increment by 1 to adjust for the .25 tick as 90 / 8 = 11.25 when you get to 89 you add another 1 to make it 90. That would be if the 8 ticks resolution is ok. If you need the resolution of the 90 ticks for other than a full revolution then you will need to drive the motors with a faster processor as well.

    You could use a , help me out here Phil, one of those counter chips , decade counter or something like that flip flops, shift registers, lots of ways to skin the cat.



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Think Inside the box first and if that doesn't work..
    Re-arrange what's inside the box then...
    Think outside the BOX!
  • rybitskirybitski Posts: 7
    edited 2007-12-07 05:22
    I thank you for the suggestion, but the thing is the deadline for this project is very soon (too soon to order any parts)...
    Poor planning on my part..
    Is there any way someone could assist me with the code (I understand that it will be flawed)?
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2007-12-07 05:32
    A simple divider will get confused when you reverse direction. Without a quadrature decoder, the best option would be a count-up/-down IC with the up/down input controlled by the BASIC Stamp. A 75HC191 might be a good place to start. Even that will gain or lose counts over time, though, since it always counts on a rising edge from the encoder. There's probably no need to have an integer number of counts per revolution, since the overground distance traveled is of greater interest.

    -Phil
  • rybitskirybitski Posts: 7
    edited 2007-12-07 05:38
    I don't have time to order any IC's. What if I covered up every other slot on the encoder so it was only 45 ticks per rotation? Would anyone help me then?
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2007-12-07 05:42
    rybitski,

    I understand and sympathize with the pickle you're in, but I'm not optimistic that there's a way out without some additional hardware to reduce the pulse frequency.

    -Phil
  • metron9metron9 Posts: 1,100
    edited 2007-12-07 05:51
    Depends on the speed of the wheel. You could cover up 8 of every 9 to get a total of 10 ticks.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Think Inside the box first and if that doesn't work..
    Re-arrange what's inside the box then...
    Think outside the BOX!
  • rybitskirybitski Posts: 7
    edited 2007-12-09 05:00
    Luckily one of the other teams had a QTI sensor pack they traded us for some other parts. Thank you for all the help, I hope this works...
Sign In or Register to comment.