From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

-1073807339 VISA Read in Serial.vi->GAUSSMETER VI.vi

If you have 0 bytes available, you shouldn't do a read. You are getting that error because the return string is empty and the scan fails. Looking at your top level VI, you still seem to having trouble understanding how to send control characters. You've got a \r in the string and then you append a carriage return. You are sending the text "\" and "\r" because you don't have '\' Codes Display turned on. Try the attached. I added the line feed constant but you may not need that. I also fixed the serial VI to get rid of the worthless sequence structure and set it to only read if there are bytes available.
0 Kudos
Message 11 of 21
(1,205 Views)
Thanx for fixing the program. now the problem is that it gives a value 0f -9999 since the case structure is false always i.e i m not getting any read string. do i need to do anything else.
nostra
0 Kudos
Message 12 of 21
(1,200 Views)
Nostra--
 
      Error 85 in Scan from String VI happens when you have given this particular VI an input that it doesn't understand (i.e a number when it expects a string) First, you'll need to find which instance is causing the problem.  (If you are having trouble find it..you can try Highlight Execution or set a breakpoint between multiple instances to see which causes the error) 
 
    There is a really good document on our website regarding why this happens and how to fix it.  Usually, with specific errors, the quickest way to get information is to simply search our website (or the support section of the website) See the link below for more detailed information about error 85:
 
 
   This error is a LabVIEW error and is fairly common, so I am glad that I am able to give you some information right away... rather than routing you around.  Keep in mind that you did post it in the GPIB forum on an old thread, if it had been a serious or complicated problem you could always post on the LabVIEW forum so that your issue gets to the appropriate engineer.
 
  Hope that document is helpful.  Best Regards...
 
John H.
Applications Engineer
National Instruments
0 Kudos
Message 13 of 21
(1,196 Views)
Dear John
Thanx for ur input. I appreciate it. But my biggest prob is that i cannot read data continuosly. I understand that scan frm a string error is generated b/c there is no read string at the output of the Serial vi. Can u plz help me how to have the read string generated continuosly on each iteration. As i told before in this post that Serial vi runs fine when executed once where the serial vi prg is taken frm examples code of lv 7.0
regards
nostra

Message Edited by nostra on 06-23-2006 02:35 PM

0 Kudos
Message 14 of 21
(1,195 Views)
Adding
Dennis' code works fine but the problem is no read string is generated. thats why the case structure is always false and i always get a value of -9999. .........nostra
0 Kudos
Message 15 of 21
(1,191 Views)

Nostra-

       In looking at the serial VI that case structure is false when you are not getting a positive value from the bytes at port...you said it was ALWAYS false giving -99999.  Are you just never getting data?  I don't know if continuously reading would help if you are not getting any data at the port.  You should check to make sure you know what data is supposed to be acquired. 

     Right now your program will go through the outer while loop and enter the serial Vi and write to the port (which i am assuming will trigger the device to generate data) then it waits the timeout and tries to read.  If no data then it returns the -99999 Then repeats the whole process....so if you missed that data then it will loop around again and write and then miss it again.  Try making your timout bigger to make sure you catch the data or change your program so that it reads longer before it closes the resource.  Basically right now it is reading that one time and if the data is not there then it starts over again.  You could put a for loop around the read, or around the bytes at port so that it has more than one opportunity to get the data.

    Hope that helps.

John Harvey

Applications Engineer

National Instruments

 

0 Kudos
Message 16 of 21
(1,184 Views)
Dear John
I changed the time out to 20 secs and this time i read only -99999. there should be correcton to my earlier post. when the time out was 10 secs then on 1st iteration the meter returns a value of zero and error code of 85*as should be expected) on the 2nd iteration it gives a value -99999. i havnt tried the for loop that u have suggested. but i dont understand that why a serial port should give so much trouble when everything is so well defined ( thats my feeling u could say..still!!!!). I would try that for loop and let u know.In the meantime if u can suggest anything else. Again I checked with serial vi for single run and meter responds well, so as to say there is nothing wrong with the meter or the cable..
0 Kudos
Message 17 of 21
(1,183 Views)

Nostra--

   I spent a little time playing with your VI with an instrument we have here.  The only time I was getting the constant 99999's was when the timeout in the serial VI was too slow.  Which is what I was trying to get at....so I just wanted to be sure the wait in the main VI is not the same as the timeout in the serial VI.  I am sure you are already aware but I wanted to be sure.  So, just let me know and we'll see if we need to look at something else.

Regards,

John H.

Applications Engineer

National Instruments

 

0 Kudos
Message 18 of 21
(1,175 Views)
Dear John
I m using at present the vi provided by Dennis. Do u think that the time out matches with delay time? I m just asking u b/c that the time out I tried is 20 secs where as the max time delay was 50 msec. I dont have much experience(actually i m a novice). last time I played with serial port was a motor and the prog went well after doing some searches in this forum. Is the prg work ok with ur serial port device. If u can play with the prg a little more and let me what might be wrong. Its imp to tell u that no string is generated when i run the program. I checked with the manual n they have some example prg written in Basic. Its the same thing with some error handling.
Regards
nostra

Message Edited by nostra on 06-23-2006 11:50 PM

0 Kudos
Message 19 of 21
(1,175 Views)

Nostra--

     There are two possible places to change the time in the VI that Dennis put up.  In the top level VI there is a wait in the while loop.  This makes the program wait this amount of time between every acquisition.  The second place is the wait IN the serial VI (if you double click on that one) and is located right before the bytes at port.  This controls the amount of time to wait between issueing the command (write) and getting the data (read) If this is too small then the instrument hasn't completed and there is nothing to read and you will get the 99999's. 

     With the instrument I have here, the only time that I was getting 99999's was when the wait between the write and read wasn't long enough to let the instrument finish.  Try making that wait longer and let me know.

John

0 Kudos
Message 20 of 21
(1,165 Views)