LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Readings from visa read to excel

Hi guys, I carried on with the work and documented myself. In this way I was able to carry on with the work.
Everything works, I can request the measurements from the comparators and they respond with the measurement. Now I have a problem that I can't solve, I would like to take the 4 string data and connect them to an excel file and place them on 4 columns. Furthermore, on the first two columns of the excel file I would like to have the date and time of the moment in which I press the request button for the first measure.
In reality, the ideal would be to make everything automatic, ie I press a single button and read the date and time and the 4 readings at slightly different times as they work on the same wireless frequency.

0 Kudos
Message 1 of 13
(1,791 Views)

Hi Valery,

 


@Valeryhill4 wrote:

Everything works, I can request the measurements from the comparators and they respond with the measurement.


I doubt that sentence!

You are opening one (1) serial connection, but you read/write to your device 4 times in parallel!

And then you try to close that one (1) VISA reference four (4) times!?

 


@Valeryhill4 wrote:

I would like to take the 4 string data and connect them to an excel file and place them on 4 columns. Furthermore, on the first two columns of the excel file I would like to have the date and time of the moment in which I press the request button for the first measure.
In reality, the ideal would be to make everything automatic, ie I press a single button and read the date and time and the 4 readings at slightly different times as they work on the same wireless frequency.


Suggestions:

  • To repeat a process you should user a loop! (Open the VISA reference once before the loop and close it once after the loop!)
  • Instead of doing parallel IO operations on your VISA reference you should use a small state machine to handle those IO one after the other.
  • Then create an array of your 4 strings.
  • Use string formatting functions to format the current time to your required timestamp strings, prepend those strings to your measurement result array.
  • Save that array to a CSV (!) file using WriteDelimitedSpreadsheetFile…
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 13
(1,763 Views)

@GerdW wrote:

Suggestions:

  • Save that array to a CSV (!) file using WriteDelimitedSpreadsheetFile…

Due to the international folks, I find using a tab delimited text file (txt) to work better than a comma separated values file (csv).  Either can be easily imported into Excel.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 3 of 13
(1,732 Views)

mine worked there but only by requesting single measurements one at a time and without reporting them in excel
now I did as you indicated, but the measurements are mixed. maybe I need to use a stacked sequence instead of the flat one.
Is this right as I did in the VI?7

 

 

0 Kudos
Message 4 of 13
(1,708 Views)

Hi Valery,

 


@Valeryhill4 wrote:

now I did as you indicated, but the measurements are mixed.


No, you did not…

 

A statemachine is something different than a large flat sequence structure!

Do you really need to compare the received strings with some constants when you send the commands one after the other?

Why do you use InsertIntoArray when you want to build an array? Why not use BuildArray for simplicity???

Does your device responds with a full message within your 50ms timeout range?

What are "mixed messages"?

Do you really need to wait for 1s, 2s, 3s and 4s in those 4 frames? That's 10s in total per iteration! Why do you need to place an additional 1s wait in the loop?

 


@Valeryhill4 wrote:

maybe I need to use a stacked sequence instead of the flat one.


No. Sequences are almost always NEVER the solution to any (LabVIEW) problem!

 


@Valeryhill4 wrote:

mine worked there but only by requesting single measurements one at a time and without reporting them in excel


So the current VI is working - or are there any problems?

Why do you insist on "reporting in Excel" when you create a DelimitedTextFile now? (You know a CSV/TSV file is just text, which can be handled by Excel too?)

 

See these suggestions:

It should basically do the same as yours, but with much less code…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 13
(1,690 Views)

Hello, the comparison of strings with some constants is necessary because the instrument has a limit and that is that when the measurement always remains on the same value which can happen in practical tests, the request generates an error which is the one written as ST1 .......... which is different of course for each comparator. So I need to set the condition that when this happens I take the last result that the comparator device has read to prevent it from printing the error. Furthermore, the response from the instrument appears as DT100000+20.05M, I only need the datum with the sign so I'm going to skim it.

By mixed messages I mean that the comparators work at the same frequency so it occurred to me that the measurement data of one comparator was reported in the box of the other. As for the time, how do I figure out how to set it so that the receiver is able to make the request and the transmitter sends the response? it says that the transmitters work with 2.4 Ghz zigbee technology.  How do I determine the time ?

 

0 Kudos
Message 6 of 13
(1,655 Views)

Hi Valery,

 


@Valeryhill4 wrote:

As for the time, how do I figure out how to set it so that the receiver is able to make the request and the transmitter sends the response?


You already do that! You send a command and you read the response using VISAWrite+VISARead…

 


@Valeryhill4 wrote:

it says that the transmitters work with 2.4 Ghz zigbee technology.  How do I determine the time ?


Why do you need that time?

Anyway: get the timestamp before sending the command and the timestamp after receiving the response. Subtract one from the other…

 


@Valeryhill4 wrote:

the response from the instrument appears as DT100000+20.05M, I only need the datum with the sign so I'm going to skim it.


That could be so easy (when there always is a sign char):

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 7 of 13
(1,646 Views)

I built everything as you showed me, the only thing is that when the measurement is repeated I get the ST10002000000998305 error code, I would like to resume the last measurement I made for that comparator.
Furthermore, in the front panel it is possible to view the array for maybe 4 while loops and therefore see 4 measurements in the column for each comparator.
As for the wait, how do I figure out which constant to set to ensure that the requests of a cycle do not conflict with those of the following ones.
In excel I would like to find the time with the value for each comparator and so on for a certain number of repetition measurements

0 Kudos
Message 8 of 13
(1,626 Views)

Hi Valery,

 


@Valeryhill4 wrote:

I built everything as you showed me,


You forgot to attach your actual VI…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 9 of 13
(1,621 Views)

When the inequality is false that I have the ST error....... I would like to report the previous measurement respective to that comparator instead of the error. Is there a way?

0 Kudos
Message 10 of 13
(1,618 Views)