LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

fract/exp string to number, only getting zeros

Solved!
Go to solution

Your concatenating new string information to the end of the old.  So of course you are going to get whatever information you first received since it is at the beginning of the string.

 

(PS:  Use block diagram cleanup to get rid of overlapping wires and straighten them out.)

0 Kudos
Message 11 of 25
(1,333 Views)

If I don't concatenate then labview doesn't read output from the external instrument.

0 Kudos
Message 12 of 25
(1,331 Views)

What are you using for the Read Count?  Does your instrument end the message with a termination character (typically a Carriage Return and/or Line Feed)?

 

Since you are getting an ASCII message, it is pretty safe to assume it is using a termination character.  Therefore, just tell the VISA Read to read more bytes than you ever expect in a message (somewhere around 100 should do it).  Then you should be getting a full message each iteration of your loop.


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 13 of 25
(1,323 Views)

That picture doesn't show us what the message is that you did get.  Why wouldn't you be getting the entire message?

 

You can also get rid of the Build Array and To DDT express VI at the bottom of the picture and just wire the orange wire directly into the chart terminal.

0 Kudos
Message 14 of 25
(1,319 Views)

I don't get a message when I run the program without concatenating. I've changed the read count to over 100 and that didn't change anything. I've checked in NI-MAX for the correct read count and used that in my program, but didn't give me anything.

0 Kudos
Message 15 of 25
(1,314 Views)

That doesn't make any sense.  If you get nothing if you do a single read, but your proceed to concatenate multiple reads together you do get something?

 

What does NI-MAX say is the correct read count?  And are you saying that NI-MAX can read it correctly?

 

And your earlier example has 154 characters in it.  You should read more than 100.  Try reading 1000 bytes.  Are you sure you are getting a termination character?

 

Run you VI with a single read and 1000 bytes.  Then when done, set the string indicator to save the value as default, save the VI, and attach it to your message.  That way we can see exactly what your message looks like in LabVIEW.

0 Kudos
Message 16 of 25
(1,316 Views)

I set the read bytes to 1024 and NI-Max reads it correctly. When I run a single read in my program with read bytes set to 1024 I get nothing. I've attached the VI, NI-Max output and a screen shot of my program.

0 Kudos
Message 17 of 25
(1,295 Views)

Sending the actual data helps a lot to see what is actually going on!

 

Your device seems to be returning a line feed followed by a carriage return as the termination characters.  It also seems to be doing it twice since you have blank lines between each set of data.  Do you know why it is doing that?  Can you set the termination character in the device?

 

Try setting the termination character in LabVIEW to be a carriage return rather than line feed.  (x0D).

To deal with the extra blank lines, after doing a VISA Read, if you detect there is no data in it.  (just the line feed/carriage return) discard that data and do another VISA Read..

0 Kudos
Message 18 of 25
(1,289 Views)

Hi Augspurger,

 

When I run a single read in my program with read bytes set to 1024 I get nothing.

According to your NI-MAX list you should atleast receive a "\n". Do you?

 

Why don't you implement the very scheme you use in NI-MAX in your VI?

Well, I don't understand why you need to request the IDN twice - but when that scheme works for you, then you should follow exactly those steps!

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 19 of 25
(1,288 Views)

I've been working on this all day. I finally got the program to read the data with concatenating, however I'm still not getting live data. I will get a number (not quite the same number as the external meter); the next write/read loop gives me NaN; then I get the same number I got the first write/read loop.  The meter does change output rather continuously and I need labview to keep up.

0 Kudos
Message 20 of 25
(1,274 Views)