Question about mathmatical operations in the basic stamp
electroman
Posts: 4
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
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
You can also connect to a pc using bluetooth as a serial interface between the two.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
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
Post Edited (electroman) : 8/20/2009 8:11:54 PM GMT
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.