LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Bytes at Port are random

Hello,

 

I have a problem with my VI.  I use a Bytes at Port element before a VISA read which gives me random bytes which seems to correlate with strange outcomes. 

When the Bytes at Port reads 0 bytes, of course the outcome is 0.

When the Bytes at Port reads 9 bytes (which is the correct amount), the outcome is correct unless the read buffer reads (0,0,3,0) which also makes the outcome equal to 0.

When the Bytes at Port reads 4 bytes, the outcome then multiplies by 10,000.

 

I have no idea what is wrong.  I have tried many fixes which I have found on forums and discussions, nothing seems to be working.  I am using a Lock-In Amplifier in the COM1 port for this VI.  I have configured this instrument and port into MAX.

I cannot unfortunately display my VI because I am working for a professor at a University, so therefore this isn't really my work to display.

I am relatively new to LabVIEW, only been working on it for a little over a month.

 

Any help would be appreciated.

0 Kudos
Message 1 of 13
(2,943 Views)

@Larryr11 wrote:

When the Bytes at Port reads 9 bytes (which is the correct amount), the outcome is correct unless the read buffer reads (0,0,3,0) which also makes the outcome equal to 0.

When the Bytes at Port reads 4 bytes, the outcome then multiplies by 10,000.


Please define what you mean by "outcome". How are you processing the raw string from the read operation?

0 Kudos
Message 2 of 13
(2,942 Views)

Describe the "many fixes" that you've tried so we don't duplicate your effort.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 3 of 13
(2,940 Views)

It is also in general a bad idea to use VISA Bytes at Serial Port. The best thing is to use the termination character and just set the number of bytes to read to some arbitrary number.

 

The reason you get is different byte count is probably simply a small difference in time between when the instrument sends data and when you check the byte count. Obviously the timing is windows is going to pretty random and the resolution is only about 15 msec. That is just one of the reasons to avoid the VISA Bytes at Serial Port. There are ways  around this, of course.

 

Please provide the instrument make and model that you are using. Have you searched to see if there is an existing instrument driver for it?

0 Kudos
Message 4 of 13
(2,922 Views)

By outcome I mean the voltage read by the Lock-In Amplifier which is hooked up to my computer.  I am using it with a Double Integrating Sphere System.  I am using the RS232 port for my data.  The display on the Lock-In Amplifier is very steady and there seems to be no strange noise there.

I am using 2 "NXT String to Number" elements to process the string.  The first is String to Float, the second is Float to String.  And then a "Scan from String" element.  This VI was created before I started working here, so please don't be too harsh on me.

 

As for fixes I have tried substituting the "Term Char" element in the property node.  I have turned the "Enable Term Char" on the VISA configure serial port to true, false, and unwired it.  I have tried adding a buffer after my property node.

 

I need this data to be stable so I can export it to an excel spreadsheet which I already have set up. 

 

Thanks for the quick responses.

0 Kudos
Message 5 of 13
(2,921 Views)

The Lock-In Amplifier model:

 

Signal Recovery 7265 DSP Lock-In Amplifier

0 Kudos
Message 6 of 13
(2,915 Views)

@Larryr11 wrote:

I am using 2 "NXT String to Number" elements to process the string.  The first is String to Float, the second is Float to String.  And then a "Scan from String" element.


This is all gibberish. You need to provide more detail! Can you at least show that code?

0 Kudos
Message 7 of 13
(2,904 Views)

There is a driver (Help>Find Instrument Drivers). Had a look and while it is not very well writtten, I can confirm that the instrument does send a termination character with each response and there is absolutely no reason to use VISA Bytes at Serial Port.

Message 8 of 13
(2,896 Views)

@Larryr11 wrote:

By outcome I mean the voltage read by the Lock-In Amplifier which is hooked up to my computer.  I am using it with a Double Integrating Sphere System.  I am using the RS232 port for my data.  The display on the Lock-In Amplifier is very steady and there seems to be no strange noise there.

I am using 2 "NXT String to Number" elements to process the string.  The first is String to Float, the second is Float to String.  And then a "Scan from String" element.  This VI was created before I started working here, so please don't be too harsh on me.

 

As for fixes I have tried substituting the "Term Char" element in the property node.  I have turned the "Enable Term Char" on the VISA configure serial port to true, false, and unwired it.  I have tried adding a buffer after my property node.

 

I need this data to be stable so I can export it to an excel spreadsheet which I already have set up. 

 

Thanks for the quick responses.


Trying random fixes isn't going to help you.  Do you even know if the response contains a termination character?  Do you have the manual or programmer's guide?

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 9 of 13
(2,893 Views)

Ok thanks guys.

I will be downloading the drivers.  Sorry this is not very well written, and that I cannot show the code.  This is not my decision.

I will respond as soon as I can with an update.

 

Any chance of telling me how to correctly set up a "term char" element on the property node?  Maybe I was not doing it correctly. 

 

Thanks all for helping a beginner.

0 Kudos
Message 10 of 13
(2,891 Views)