Shop OBEX P1 Docs P2 Docs Learn Events
Trouble getting values into PLX-DAQ — Parallax Forums

Trouble getting values into PLX-DAQ

ElectricAyeElectricAye Posts: 4,561
edited 2008-08-20 16:50 in Propeller 1
Hi all,

I'm trying to get my Excel spreadsheet to record data through the PLX-DAQ routine.· I've had good luck getting the data to display on a TV but when I send it to Excel via PLX-DAQ, strange and mysterious things happen to it and I can't understand why.·

For example, I'm using this code to show the data nicely on a TV:

degC := FloatMath.FDiv(FloatMath.FFloat(temp), 16.0)
degF := FloatMath.FAdd(FloatMath.FMul(degC, 1.8), 32.0)
result := degF

...The result then gets read into a variable named Temperature1 and gets displayed to TV using:

··· FloatString.SetPrecision(7)
··· tv_text.str(string(13))
··· tv_text.str(string("Temperature1· "))
··· tv_text.str(FloatString.FloatToString(Temperature1))
··· tv_text.str(string("°F··· "))

The above code works fine.· But when I take Temperature1 and try to pass it to PLX-DAQ like this:

PLX-DAQ.Data(Temperature1)

then Excel displays the following·in the appropriate cell· 1117108634
·and that's for a temperature of about 78 degrees F.

Also, for a value of 17.0, PLX-DAQ.Data(value) yields an Excel value of
1099431936

Martian math?· Blackhole booleans?

Lawrd knows I've tried to work my way back through all the method calls, etc. and reverse engineer this, but the usual lack of comments leaves me lost in the wilderness.· I had hoped working with Excel would be plug and chug, but like everything else it's been "a great learning experience."

Anybody know how to make Excel turn 1117108634 into something that looks more like 77.82 ???· I'm guessing it has something to do with strings vs. floats and binary representations, but... I've gone blind staring at this thing.

thanks,
Mark







▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
It might be the Information Age but the Eon of Ignorance has yet to end.

Comments

  • ElectricAyeElectricAye Posts: 4,561
    edited 2008-08-20 05:13
    It seems totally asinine to me but I found this works.


    PLX-DAQ.DataText(FloatString.FloatToString(Temperature1))

    Why asinine? you ask?
    Because, to me, this doesn't work like the example. And the example wouldn't work for my value of Temperature1.
    I'm sure there's some better way to do this. And I'm sure I'm missing something... somewhere...

    In any case, in the event this is the only solution documented for the next month or so, I hope this helps somebody... somewhere...

    I need some aspirin.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    It might be the Information Age but the Eon of Ignorance has yet to end.
  • evanhevanh Posts: 15,438
    edited 2008-08-20 11:28
    PLX-DAQ.Data() prolly takes an integer? That would certainly screw you over putting a float in if it needed an int. The second method using FloatToString() makes perfect sense since PLX-DAQ.DataText() would be expecting a string.

    I tried to find PLX in the object exchange but came up blank.


    Evan
  • ElectricAyeElectricAye Posts: 4,561
    edited 2008-08-20 12:02
    evanh,
    You can find the download for the PLX-DAQ here:

    http://www.parallax.com/tabid/393/Default.aspx

    Yes, it makes sense that it should go into the Object Exchange. I'm not sure why it isn't.
    Also baffling is why it doesn't have some kind of PDF file to download and browse. Instead you have to use its help file, which requires the program up and running.

    Mark
  • evanhevanh Posts: 15,438
    edited 2008-08-20 12:58
    Thanks. Yup, looking at PLX-DAQ.spin in the examples I find the Data function and it says it is for integers. So your second method is definitely the way to go for floats.


    Evan
  • ElectricAyeElectricAye Posts: 4,561
    edited 2008-08-20 16:50
    Thanks evanh,
    now I'm beginning to see what they did in the example for PLX-DAQ.
    First of all, I got thrown off by their description: that PDAQ.Data sends an "integer decimal". To me, that sounded like an oxymoron, so I assumed they meant decimal. Secondly, the way they passed the sine value was to first multiply it by a thousand, pass it as an integer, then divide it by 1000 downstream for Excel. At least I think that's what they did. Gooo thing there aren't very many comments on these programs. I wouldn't know what to do with all my free time if I didn't have to slog through each and every operation.

    cheers,
    Mark

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    It might be the Information Age but the Eon of Ignorance has yet to end.
Sign In or Register to comment.