Shop OBEX P1 Docs P2 Docs Learn Events
Tachometer, help me plz! — Parallax Forums

Tachometer, help me plz!

ManuelManuel Posts: 105
edited 2005-07-28 05:38 in General Discussion
Hello im a highschool stundent yet and want to make a tachometer with my bs2sx, i was thinking of using an optical switch to count the turns but yet im having trouble to use it with my Basic stamp, if anyone has an idea, suggetion or anything to say, i would really apreciate it.
Best Regards
Manuel C. Reinhard
·

Comments

  • MacGeek117MacGeek117 Posts: 747
    edited 2005-07-26 22:40
    COUNT should work quite nicely.
    bugg

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Boe-bot: $229


    Toddler: $249

    Learning Google is your friend: priceless
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-07-26 22:57
    Manuel,

    ·· It might be a bit easier to help you if we knew the problem.· We know what you're trying to do, but not what problems you're having.· What do you have, what's it connected to, and what's happening?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • ManuelManuel Posts: 105
    edited 2005-07-27 03:28
    I have a opto switch( thats what they call it), but i realized it doesnt work, so i will change to the hall efect sensor to make my tachometer, thanks for the help. By the way, does anyone know how to use decimals in a BS2SX?
    Thanks
    Best Regards
    Manuel C. Reinahrd
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-07-27 14:46
    You can't use decimals directly, but you can specify a value in any units. If, for example, you did you math in hundredths, 123 would actually represent the value 1.23.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • ManuelManuel Posts: 105
    edited 2005-07-27 20:32
    I am trying with that, but as i am using big numbers i lose too many numbers, what happens is that the division ends up with decimal numbers, although im using numbers up to 60000. I just want to get my division of 400/ .1885 right.
    What im doing is (incomplete only to show my problem)

    q var word
    meters ver word (this variable is comonly 400)

    q = ((meters*100)/1885) * 100

    the results comonly are two digits and two zeros, result of the arrival to the decimal place.

    Is it posible to have variables bigger than a word so i could make my operation q = ((meters*10000)/1885) ?
    Because in that way i would not loose my last two numbers
    Thanks for the help.
    Best Regards
    Manuel C. Reinhard
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-07-27 21:08
    If your fractional value is a constant you can use the */ or ** opeators.· For example, ** multiplies in units of 1/65536.· So what you can do is this:

    · q = meters ** 12353

    How did I get 12353?· Multiply 0.1885 * 65536.· See Dr. Tracy Allen's web site (www.emesystems.com) for excellent examples of using */ and **.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • ManuelManuel Posts: 105
    edited 2005-07-27 21:15
    Hey, after a while of doing some math to solve my decimals problem and now i loose aprox.· 1 unit at the end, so its fine.
    Thx for all the help.
    But now i got another problem confused.gif, i want to be meassuring a hall efect sensor so when it reaches the same value of my variable q something happens.
    my idea is the use of the lookdown and in some other way to increase a variable each time the sensor senses the magnet.
    My idea is this:
    ' {$Stamp BS2sx}
    part_two:
    button 1, 1, 10, 20 , enter, 1, continue
    pause 20 (2.5 times as on the BS2)
    Lookdown counting, [noparse][[/noparse]q], go_on
    goto part_two
    continue:
    counting = counting+1
    goto part_two
    go_on:
    more actions...

    Any corrections or improvements will be appreaciated
    Best Regards
    Manuel C. Reinhard
    ·
  • Paul BakerPaul Baker Posts: 6,351
    edited 2005-07-27 21:28
    Yeah there is a work around to your problem, the modulus operator. If you in addition to the q = ((meters*100)/1885) * 100, do qmod = (((meters*100)//1885)*100)/1885 then q = q + qmod, you'll regain those two digits of precision. The first expression takes the fractional part of the division in the equation for q, expands it out beyond the fraction by multiplying 100 then re-dividing the value. Your expression for q given meters is 400 returns 2100, when 2122 is the correct value. The second equation evaluates (meters*100)//1885 to be 415, multiplied by 100 then divided by 1885 returns 22, the missing two digits of your first equation.

    Ah, Im late to post, the ** and */ should provide a quicker result.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·1+1=10
  • ManuelManuel Posts: 105
    edited 2005-07-27 21:36
    thx for the help,
    i tried the ** and */, but the number goes around 65536, i will try your qmod operations.
    Thanks a lot
    Best Regards
    Manuel C. Reinhard
  • ManuelManuel Posts: 105
    edited 2005-07-28 04:45
    Do the hall efect sensors work like buttons?
    Like if i put a magnet in front of it i get a 1 and if not i get a 0?
    Best Regards
    Manuel C. Reinhard
  • ManuelManuel Posts: 105
    edited 2005-07-28 05:38
    Hey im having new trouble with my project, i have been using some buttons in downstate=1 circuitry, as shown on the basic stamp manual, except for the 220 ohm resistance. Im using a 1kohm resistance because i read in one of the nuts and volts that it would protect better my bs2. I dont think thats my problem.
    I changed my circuitry from downstate=1 to downstate=0 and i also changed my code from
    ex.
    button 3 , 1, 10 , 20, enter, 1, prepare
    to
    button 3 , 0, 10 , 20, enter, 1, prepare
    and it will go on as if the buttons were pressed.
    anyone has any idea?
    Best Regards
    Manuel C. Reinhard
Sign In or Register to comment.