Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Error 1 occurred at Scan From String (arg 1)

Solved!
Go to solution

Hi,

 

I made a code that sends serial data to labview through MATLAB.

After receiving all the data, the error 1 occurred at scan from string. But the data is saved well as a designated text file. 

I don't know why this error occurs. 

 

I attached my code and the error.

Thank you! 

Download All
0 Kudos
Message 1 of 11
(1,485 Views)

What is the data you are receiving?


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 2 of 11
(1,451 Views)
  • If this happens after you get all the data, it means that you get an empty string on the next iteration. Maybe you need to stop reading at this point and/or correctly handle exceptions and errors.
  • Leaving the "error out" terminal of "scan from string" unwired is NOT handling errors! (automatic error handing will create the popup you see because of that!)
  • What is your loop rate?
  • What is the value of "byte count"?
  • What is the value for "timeout"?
  • What's the purpose of the sequence structure? Does not really do anything useful.
  • Maybe you could replace your sequence frame with a case structure and skip formatting and file writing if the string is empty.
  • What is the purpose of your express VI. we cannot tell which inputs are wired. I am sure there are better way to log elapsed time.

Too many questions that cannot be answered from a code picture. Please attach a simplified version of your VI containing typical default values in the controls! 

0 Kudos
Message 3 of 11
(1,438 Views)

Thank you for your reply!!!

 

  • What is the value of "byte count"? 

          => 8

  • What is the value for "timeout"?

          => 10000

  • Maybe you could replace your sequence frame with a case structure and skip formatting and file writing if the string is empty. 

         => can you edit my code? 

  • What is the purpose of your express VI. we cannot tell which inputs are wired. I am sure there are better way to log elapsed time.

         => I wanna receive serial data from a moving instrument, so I'm practicing send serial data to LabVIEW

              using MATLAB. 

 

I attached my code file and saved data file. Thank you so much!!!! 🙂 

Download All
0 Kudos
Message 4 of 11
(1,412 Views)

I send continuous numbers from MATLAB for testing.

I attached a picture of saved data file.

 

Thank you!!

0 Kudos
Message 5 of 11
(1,410 Views)

@jw121 wrote:

After receiving all the data, the error 1 occurred at scan from string.


Ok, I think I missed this point before.  So I'm left to assume here that the Matlab code has a set number of points that it sends out.  So how does the LabVIEW code know when it got it all the data?  It appears you are getting a timeout at the VISA Read just because there is no data to read.  So you get an empty string out from that.  The Scan From String will therefore return an error because you cannot scan anything from an empty string.  And the only way you will see that error is if you have Automatic Error Handling turned on.

 

So the way I see it, you just need the Scan From String in the error chain.


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 6 of 11
(1,386 Views)

Thank you!

 

What is mean  "you just need the Scan From String in the error chain."??

0 Kudos
Message 7 of 11
(1,369 Views)
Solution
Accepted by topic author jw121

Wire the Error Out on the VISA Read to the Error In on the Scan From String.  Then the Error Out on the Scan From String goes to the Error In on the Write Text File.


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
Message 8 of 11
(1,359 Views)

Thank you so much. It worked!! 

 

I have another question. 

Can I set start time of elapsed time when the serial data starts to come in?

 

Thank you.

0 Kudos
Message 9 of 11
(1,345 Views)

@jw121 wrote:

Can I set start time of elapsed time when the serial data starts to come in?


Use the Iteration Terminal of your loop.  If i = 0, reset.


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 10 of 11
(1,333 Views)