Shop OBEX P1 Docs P2 Docs Learn Events
Making a RPM meter using a old computer mouse and a BS2 — Parallax Forums

Making a RPM meter using a old computer mouse and a BS2

theruss007theruss007 Posts: 7
edited 2010-06-02 15:38 in BASIC Stamp
Hi. I bought a Basic Stamp 2 about a year ago to build a robot and never used it·since. Now I am planning on using it to measure rpm. My plan is to use the geared disk on an·old computer·mouses to produce pulses from a IR LED to a Phototransistor·that the BS2 can count and tell me the pulses per minute.The gear·would make aprox.·40 pulses per revolution. I know theres a way to do it using the pulsin command, but how do I get it to be a rate of how many pulses per minute. Can the BS2 do math because I would use·that ability to·tell me how many revolutions per minute instead of pulses.I would I start the programming. I plan on using this from a sterling engine to a common 12v motor.

Comments

  • FranklinFranklin Posts: 4,747
    edited 2010-06-02 02:57
    The mouse parts should do for the input. The stamp can do integer math (whole numbers) and you can probably count the pulses in one second multiply by 60 and devide by the pulses per revolution.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • ercoerco Posts: 20,256
    edited 2010-06-02 04:33
    A similar problem at· http://forums.parallax.com/showthread.php?p=910582

    I posted my reply there.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·"If you build it, they will come."
  • theruss007theruss007 Posts: 7
    edited 2010-06-02 10:21
    The forum link you have there I have already seen. In fact you must have posted a comment on it only a few hours after I did.

    "The mouse parts should do for the input. The stamp can do integer math (whole numbers) and you can probably count the pulses in one second multiply by 60 and devide by the pulses per revolution."

    My only problem is I don't know how to do all of that. The only programing I did with the BS2 is try, and build a robot that failed to work(it spun in circles).
    So how do you do it. The simple math stuff I am sure I can look up, but the count the pulses per second I have looked up, and have had no luck on.
  • theruss007theruss007 Posts: 7
    edited 2010-06-02 10:31
    COUNT 0,1000,x Would that do the trick, just for the count the pulses per sec part. If so, how do you get a variable to be divided and multiplied. I am slowly but steadily learning how to this.
  • theruss007theruss007 Posts: 7
    edited 2010-06-02 11:40
    After learning a little bit more, would this be close to the programing I need?
    Name var word
    Name2 var word
    Name3 var word

    top:
    Count 5,1000,Name
    Name*60= Name2
    Name2/(number of pulses per revolution)=Name3
    debug Name3
    goto top

    WOuld that be anything near what I want it to do?
  • ercoerco Posts: 20,256
    edited 2010-06-02 15:38
    Nice to see your progress. Yes, you are off to a great start. But you have you redefine your equations to:

    Name2=Name*60

    and

    Name3= Name2/PPR

    Remember that the stamp truncates and does integer math only, so always multiply first and divide last for best accuracy, just as you have done.

    FYI, you could also do it all with the one variable in one step:

    count 5,1000,Name
    Name=Name*60/PPR

    It's OK to use a variable in equation to redefine itself, like:

    X=X+1 or Y=(Y*7)/(Y+7)

    A mindblower, huh? Just remember it's like

    (new Z value)=(old Z value)*(math manipulation)

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·"If you build it, they will come."
Sign In or Register to comment.