LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading from CO2 sensor connected to the PC

Solved!
Go to solution

@DP123 wrote:

Hi Raven

 

The command IDN was already in the example in labview and that is why I just left it there. I actually did not know what it did until you just explained it. So what should I replace it with? 

 

 


I don't know.  This where the point where you have to take the time to Read The Manual.

 

The reason you are getting a zero is that your response has a space in front of it.  Do you remember reading message 20?

0 Kudos
Message 41 of 63
(1,332 Views)

Hi Raven

 

Yes, I remember message 20. I just thought that adding a space in my seach string would be a mistake as you told me in message 22?

 

It is now working properly and the data is being plotted on the chart. Thanks alot to you, crossrulz and the others! 

 

I am still dealing with a problem though. Sometimes when I start reading I get an error message. I tried solving this by increasing the VISA buffer size but I do not think it is helping or I might have done it in a wrong way.  

 

I attached the error message and the VI aswell. Thanks again!

 

Greetings 

DP

 

 

Download All
0 Kudos
Message 42 of 63
(1,296 Views)

Hi DP,

 

which function gives you this error message? There are atleast 2 VISARead functions…

 

Next mistake: NEVER use "default if unwired" tunnels in structures for references like your VISA reference!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 43 of 63
(1,294 Views)

Hi Gerd!

 

How would I know which one give me the error. I guess I could take one of them out and see if I am still getting the error?

 

How do I fix that? I do not see any other options then using "use default if unwired". 

 

Greetings

DP

0 Kudos
Message 44 of 63
(1,288 Views)
Solution
Accepted by topic author DP123

@DP123 wrote:

I am still dealing with a problem though. Sometimes when I start reading I get an error message. I tried solving this by increasing the VISA buffer size but I do not think it is helping or I might have done it in a wrong way.


My guess is because you have the Boolean set to FALSE.  Get rid of that button and the case structure around your VISA Read.  So what is happening is the instrument is constantly sending data and it is filling up your buffer while you are not read it.  If you do not read the data in order to clear out some of the buffer, the buffer will get full.  So the next time you do a read, you will get that error.  So the solution is simply to always read the data.


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 45 of 63
(1,285 Views)

Hi Crossrulz

 

It makes perfect sense what you are telling me. There is an LED on the usb that shows if the device is reading data and if I stop the VI from running for a minute it stops flashing. Then when I run the VI again it gives me the error and I guess it is like you said the buffer got filled up. 

 

Greetings

DP

0 Kudos
Message 46 of 63
(1,285 Views)

Hi DP,

 

How would I know which one give me the error.

Well, using indicators or probes for DEBUGGING would be a good start - you should have read/heard about this in the beginner tutorials you can get for free on NI's website!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 47 of 63
(1,281 Views)

@DP123 wrote:

Hi Raven

 

Yes, I remember message 20. I just thought that adding a space in my seach string would be a mistake as you told me in message 22?

 


 

 I did say it was a mistake adding the space in the search string.  It seems that sometimes that space is there and sometimes it is not.  So adding the space in the search string means you are going to get errors the other times when the space does not exist in the incoming data.

 

Read what I said in message 22.

You need to figure out what is going wrong with that space being there or not.  And if you can't, then use trim white space on the incoming data to clean it up before you scan it.

0 Kudos
Message 48 of 63
(1,273 Views)

Hi Raven

 

It makes sense that I should get an error when the space is not there. The thing is I am not getting any error except the error I get when the buffer is full. How can that be? Like you said I would expect an error.

 

Greetings 

DP

0 Kudos
Message 49 of 63
(1,267 Views)

Let's reset.

 

Is it true that you are no longer having errors that are the result of problems with the data coming in and the format string used to scan the data from the string?

 

Now the problem left to solve is that you sometimes get buffer full error messages?

 

You said "Sometimes when I start reading I get an error message."  What do you define as "start reading"?  Is it when the VI starts?  Or are you toggling that boolean control while running.  If it is stopping and restarting the VI, you shouldn't have a problem because the VI closes the serial port and won't receive in any messages on the wire.  If it is leaving the serial port open and you just stop reading, then you will have a problem because the serial port buffer will fill up.

 

With a device you have no control over as to when and how much data it sends because it is just spewing data continuously, I recommend you close the serial port whenever you are not going to read from it, and reopen the port when you start up again.  Be prepared to deal with incomplete messages because you have a possibility of reopening the port in the middle of the transmission of a message.

 

Or just go ahead and continually read from the serial port and discard the data you don't care about.

0 Kudos
Message 50 of 63
(1,260 Views)