Decimal values
edmondfox
Posts: 15
Is it possible to serin decimal values to the Stamp 2? For example, how would I recieve the number 7.89, right now when I type the '.' it thinks the number is over. I have tried multiplying the input by 100 before sending it and dividing it by 100 on the stamp but that only yields what is on the left side of the decimal point (ex. 789/100 = 7), how do I fix this?
Comments
com = 787
debug dec com/10,".",dec1 com
That will display 78.7
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Sid Weaver
Do you have a Stamp Tester yet?
http://hometown.aol.com/newzed/index.html
·
hers is the part of the code I need it for:
SERIN RxD, Baud,[noparse][[/noparse]DEC stampDelay]
stepDelay = stampDelay / 100
.
.
.
PAUSE stepDelay
All timing/values in the BS2 is done in whole numbers. (the stamp can also do signed whole numbers)
Even using a floating point coprocessor won't help you do what you want, because even if the coprocessor could somehow do something with the decimal, what is it going to tell the stamp?
It can only tell the stamp to PAUSE "whole number"
The units of the PAUSE command are miliseconds.
PAUSE 7890 ' gives 7.89 seconds.
Milliseconds are trickier. You can use a command like
PULSOUT somepin,stampdelay
where stampdelay is in units of 2 microseconds (on the BS2). But in computing the delay you have to account for the time it takes for the interpreter to process the instructions, which is on the order of 200 microseconds for each instruction.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com