get float ?
Tesla trooper
Posts: 4
Hi!
I have been trying to read values from a digital mutimeter. The values comes in scientific form, eg. 3,2E+3. Cant find any suitable way to do this...
Is there a "getfloat" command, or something similar?
Thanks in advance!
I have been trying to read values from a digital mutimeter. The values comes in scientific form, eg. 3,2E+3. Cant find any suitable way to do this...
Is there a "getfloat" command, or something similar?
agi.get[color=#990000] ???[/color](agiVal) agiVal := (flo.FloatToString(agiVal)) agiVal := (vfd.StrToDec(agiVal)) vfd.dec(agiVal)
Thanks in advance!
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.
However, I can't seem to find any command to collect this floating point number from the multimeter.
After the routine is performed you will have a floating point representation of the string
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.
Post Edited (Paul Baker (Parallax)) : 5/6/2008 6:20:58 PM GMT
Problem is, "tara" is supposed to be a "calibration-value". I am writing this program for someone, the idea is that he can tune the sufficient calibration and then turn the propeller off. And when he switches it on again the tara-value is still the same as it was when he turned the chip off, and hence he doesn't have to recalibrate it every time he starts up propeller chip. My spontaneous idea was to store this tara-value in the EEPROM, it's just that I can't seem to find any simple way to do that... Is there a way to achieve this?
you can use the Format object function bscanf
OBJ
· fmt: "Format"
k var long
buf var byte[noparse][[/noparse]10] 'assumed to hold received value string
i var long
f var long
e var long
k := fmt.bscanf(@buf,0,string("%d"),@i)· 'convert integer part, reads up to the decimal point (comma)
k := fmt.bscanf(@buf,k,string(",%d"),@f)· 'convert fractional part, skips the decimal point·(comma)
k := fmt.bscanf(@buf,k,string("E%d"),@e)· 'convert exponent, skips the E
Both i and e can be positive, zero or negative, f can be zero or positive.
Now you just need to combine i, f and e into a floating point number.
You will find the Format object in the object exchange under Tools.
regards peter