Shop OBEX P1 Docs P2 Docs Learn Events
Question about mathmatical operations in the basic stamp — Parallax Forums

Question about mathmatical operations in the basic stamp

electromanelectroman Posts: 4
edited 2009-08-20 20:29 in BASIC Stamp
Hi,

I am using the basic stamp 2, and I'm facing a problem,
is it·possible to deal with decimal numbers in the basic stamp?
and if not, is there away to link the basic stamp with pc with a bluetooth
connection such that i can use anothor pragram (MATLAB)·to do the complicated caculations
and then send the instructions to the basic stamp???


I hope that some one can help me


thanks

Post Edited (electroman) : 8/20/2009 5:48:49 PM GMT

Comments

  • FranklinFranklin Posts: 4,747
    edited 2009-08-20 19:15
    yes, if you want two digits decimal multiply the number by 100 and do the math.
    You can also connect to a pc using bluetooth as a serial interface between the two.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • electromanelectroman Posts: 4
    edited 2009-08-20 19:36
    I can't, because the final answer will be a decimal number,
    Example calculation : H = 0.5 * 3.14 + 0.15 which equals 1.72
    then i will substitute the result in : PAUSE H
    so if the basic stamp could not read that number as a decimal number, everything will go wrong




    thanks
  • GeorgeLGeorgeL Posts: 131
    edited 2009-08-20 19:56
    Isnt there a math co-proccesor or something like that on Parallax's website?
  • electromanelectroman Posts: 4
    edited 2009-08-20 20:01
    I'm not sure about that

    Post Edited (electroman) : 8/20/2009 8:11:54 PM GMT
  • Mike GreenMike Green Posts: 23,101
    edited 2009-08-20 20:16
    H = 0.5 * 3.14 + 0.15

    This is equivalent to

    H = 3.14 / 2 + 0.15

    If you scale this to two decimal places, you'd have

    H = 314 / 2 + 015

    You do need to make this an integer to use in a PAUSE, so you'd do

    PAUSE H / 100 if you want it rounded, you'd do PAUSE (H + 050) / 100

    Note that the pause is in whole milliseconds only. There are ways to use
    PULSOUT to produce smaller pauses, but the BS2 still takes a couple of
    hundred microseconds to execute its statements and you'd have to work
    that into your delays to get something at all accurate.
  • electromanelectroman Posts: 4
    edited 2009-08-20 20:29
    thanks for your help, I'll try it
Sign In or Register to comment.