Shop OBEX P1 Docs P2 Docs Learn Events
Taking in a byte turning it into a value 4096-0 and dividing it — Parallax Forums

Taking in a byte turning it into a value 4096-0 and dividing it

AcquaLifeAcquaLife Posts: 19
edited 2012-05-10 10:07 in Propeller 1
The title says it all. I'm trying to figure out how to take in bytes from a sensor(which I've done) and then divide and multiply them. I'm using this working code
pst.Str(string("adcVal["))
pst.Dec(channel)
pst.Str(string("] = "))
adcVal[channel] := adc.In(channel)
pst.Position(12, channel)
pst.dec(adcVal[channel]) <---- here is where i print it out as a decimal 0-4096
pst.str(string(" ",pst#NL))
pst.ClearEnd

I tried using the FloatMath library. and the command PUB FFloat(integer)

what i did was
math.FFloat(adcVal[channel]) <
this might be wrong not sure if this is the proper way to use the command
then im kind of confused i dont see a pst.float or anything.

Any help would be appreciated

Comments

  • BeanBean Posts: 8,129
    edited 2012-05-10 10:07
    You use the FloatString object to print floating point values.

    If you used adcVal[channel] := math.FFloat(adcVal[channel]) that would convert the values to floating point. From that point on any math MUST be done using the floating point routines.

    OBJ fs : "FloatString"

    pst.str(fs.FloatToString(xxx))

    Bean
Sign In or Register to comment.