LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Format Data

Hello,

 

I am a complete LabView beginner so please bear with me. I am changing from a string to a floating point in the attached vi. I would like to preserve all of the data as it appears in the string. How do I format the data (ie the %f) in the example shown.

 

Regards,

 

Nevica

 

 

0 Kudos
Message 1 of 9
(3,686 Views)

In what format do the channel string come? In what format do you want them? Have you tried using either the decimal string to number or the fract/hex string to number?

 

Give either of them a try and see if your number is truncated in any way.

0 Kudos
Message 2 of 9
(3,678 Views)

I suspect your indicators are hidding the extra decimal places. Right-click the indicator and check the number of decimal places.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 3 of 9
(3,668 Views)

Hello,

 

When I run the I/O routine (see attachment) it creates a variable of type string. For some reason this is creating an error at the next step (see attachment). How can I solve this?

 

Also, in the first attachment, when I parse the string I am concerned that it is not picking up the whole of the string as the data length changes from one to the next. Does pressing 'To end of data' underneath 'character count' change every time it parses or does it stay constant and that character length?

 

Nevica

 

 

Message Edited by nevica on 07-31-2009 10:35 AM
Download All
0 Kudos
Message 4 of 9
(3,650 Views)

Hello,

 

Additionally, I am creating an array with three columns from 1 second streamed data on three data channels. I want to create a file something like this:

 

Time Stamp      channel 1     channel 2     channel 3

      0                       x                y                  z

      1s                     x                 y                 z

      2s                     x                 y                 z

 

and so on.

 

I have a vi created thus (see attachment). Is this the best way off doing this?

 

Nevica

0 Kudos
Message 5 of 9
(3,631 Views)

You should build an 1D array for each channel's data in a shift register.

Then pass each of these 1D arrays into a 'build array' so you have all the columns.

 

Also, since you have a time delay of 1000 ms (= 1 second), you can just wire the iteration number as your time column.

To handle column headers, you can write a 1D array of strings to the file before you write the data.

 

write to file.PNG

Cory K
0 Kudos
Message 6 of 9
(3,608 Views)

Cory's example has several errors:

  • The shift registers are not initialized, meaning the next time you run it you would get the previous data appended to the run.
  • The 2D array wired to the Write to Spreadsheet file needs to be transposed. 
  • It appears that you have the True wired to the "append to file?" input rather than the "transpose?" input. In this case, since you are building arrays you will get essentially performing a double add. In other words, if you run the loop 3 times, and the random numbers are 0.662, 0.595, and 0.506you would get:

    0.000    0.662    0.662    0.662
    0.000    0.662    0.662    0.662
    1.000    0.595    0.595    0.595
    0.000    0.662    0.662    0.662
    1.000    0.595    0.595    0.595
    2.000    0.506    0.506    0.506
  • You are coercing the index, which means that you are performing larger and larger coercions in order to convert an I32 array to a DBL array. The index should be coerced before it's added to the array.
  • You are using Build Array in a loop, which means that you keep growing the array.
 
With all of that covered, the Build Arrays for the individual values and the shift registers are completely unnecessary. The following is what the example should be (note that in this case the "transpose" input is not needed):
Message Edited by smercurio_fc on 07-31-2009 05:03 PM
0 Kudos
Message 7 of 9
(3,593 Views)

Hello,

 

I am a complete VI beginner and I don't understand why the "capture10.jpg" will not work. I get the error "capture9.jpg". What am I doing incorrectly? I am taking the three outputs channel1, 2 and 3, changing them from strings to floating points and then creating a matrix from these three outputs. But I get the error as shown.

 

Nevica

Message Edited by nevica on 08-03-2009 03:47 AM
Download All
0 Kudos
Message 8 of 9
(3,560 Views)

Hello,

 

I am a complete LabView beginner so please bear with me. When I run the I/O routine (capture7.jpg) it creates a variable of type string. For some reason this is creating an error at the next step (capture9.jpg). How can I solve this?

 

Also, in the first attachment, when I parse the string I am concerned that it is not picking up the whole of the string as the data length changes from one to the next. Does pressing 'To end of data' underneath 'character count' change every time it parses or does it stay constant and that character length? Also the data output may have a "square" at the end of it and I am concerened that this is the problem. What does this square mean and could it mean the problem in my data reading? At the next step where the string is changed into a DBL do I need to format the data at this stage. If so, how do I do that and in what form does the data have to be? Any help would be very much appreciated.

 

Nevica

Message Edited by nevica on 08-03-2009 04:33 AM
Download All
0 Kudos
Message 9 of 9
(3,551 Views)