LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

reading a text file and using data to plot a graph

Dear Friends,

I have the following problem...

I have a text data looking like this;



100000000
1003ff001
1010013ff
1000003ff
1023fe001
102000000
1023ff3ff
1010013fd
0ff0033fc
0ff002001
0fe3fd3ff
0ff000002
100000000
1003ff001
1010013ff
1000003ff
1023fe001
102000000
1023ff3ff
1010013fd
0ff0033fc
0ff002001
0fe3fd3ff
0ff000002
...............


My Code should have a button , when you click that button it should ask you to choose a txt file to open this file from a specific place. The Indicators of the front panel should show me the ID , Name and Date. The data;
100000000
1003ff001
1010013ff
1000003ff
1023fe001
102000000
1023ff3ff
1010013fd

the first 3 bits belong to X axis, the next 3 bits belong to Y and the rest 3 belongs to Z axis.  I have to convert those values to Decimal system, and plot them in a graph, 10 times a second , which means after converting and plotting 10 values , one second is over.
I would aprriciate it very much if you could help me in this case....

Thanks in advance.





Message Edited by Support on 11-13-2007 01:03 PM

Message Edited by Support on 11-13-2007 01:04 PM
0 Kudos
Message 1 of 13
(4,363 Views)


@C.E wrote:
the first 3 bits belong to X axis, the next 3 bits belong to Y and the rest 3 belongs to Z axis.  I have to convert those values to Decimal system, and plot them in a graph, 10 times a second , which means after converting and plotting 10 values , one second is over.

Your lines look like they consist of 9 hexadecimal digits. I would expect that three nibbles (=12 bits) belong to x, y, z resp. I guess you just want to convert them to numeric, so "decimal" is quite meaningless, because it is just a display property and has no meaning for the underlying data.

Do you want to plot the data in 3D or as three traces of a graph?

Message Edited by altenbach on 10-29-2007 01:00 AM

Message 2 of 13
(4,356 Views)
Hello,

the given acceleration values are hexadecimal. With decimal , I mean that hex with base 16 will be converted to base 10 , for instance 100 will be converted to 256.
My graph should be 2 dimensional.  Time domain should be horizontal, and the others  -each different color- in vertical domain.

best regards
0 Kudos
Message 3 of 13
(4,336 Views)
Read file with file I/O function, spreadsheet string to 1D array. Split the array after the header info. Parse the header info and place into the indicators.
Split the graph value strings in a for loop into three strings each 3 characters long and convert to number (hex str to number) and output each number as an auto-indexing array of the for loop.

Regards,
André (CLA, CLED)
0 Kudos
Message 4 of 13
(4,320 Views)
OK, here's a quick example (LabVIEW 8.0)  just using the raw data as string. You can read the file as a string and just modify the code accordingly. To react to a button press, use an event structure. Let me know if you need help with that too.
 
 
 
 
Message 5 of 13
(4,312 Views)


altenbach a écrit:
OK, here's a quick example (LabVIEW 8.0)  just using the raw data as string. You can read the file as a string and just modify the code accordingly. To react to a button press, use an event structure. Let me know if you need help with that too.


Cool ! Homework done !!! :D:D:D
Chilly Charly    (aka CC)
0 Kudos
Message 6 of 13
(4,308 Views)
LOL,
 
I am not sure if this was homework, but anyone who would simply submit my VI as homework better undestand every little detail of the code to be able to answer the teachers question about it. 😄
 
0 Kudos
Message 7 of 13
(4,300 Views)
Yes, altenbach, but your VIs and examples are always so clear, so that's not really all that hard... Smiley Wink
Message 8 of 13
(4,292 Views)

Yes I agree sm, Altenbach always helps you out with his example VI's and even modifies them for you.

Hats off Altenbach!!Smiley Happy

Ravi

Message Edited by Dravi99 on 10-29-2007 01:09 PM

0 Kudos
Message 9 of 13
(4,288 Views)

Some questions a teacher might ask:

  1. What's the display setting for the "\n" string diagram constant? Why?
  2. Is it better to read the file one line at a time or all at once?
  3. What would you do to be able to stop the chart display before it runs out of data?
  4. What would be different if we combine the two FOR loops into one?
  5. How would you display the header as a multiline string instead of an array of strings?
  6. Why is the scan format %03x instead of %3x? Would it make a difference?
  7. What is the purpose of the two items of the property node?
  8. What would you need to change to plot the data every 50ms? (change in two places!)
  9. Why is the error output of the property node wired to the first FOR loop? (After all, the error value is not really used anywhere there!)
  10. Instead of the two "array subset" operations, we could do it with one icon. Which one? (two possibilities!)
  11. ...

So... be prepared! 😄

Message Edited by altenbach on 10-29-2007 11:31 AM

Message 10 of 13
(4,288 Views)