LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

VISA read buffer acting differently

Solved!
Go to solution

Hello,

 

I have a force gauge (MARK-10) which I want to read the force and display it in LabVIEW.

 

I found a code which I added some extra code in it, and it works perfectly. But when I wanted write my own code, because I wanted to include motion control as well then it didn't work. So I tried to read only from the force gauge once again but I wrote another code from scratch exactly the same as the first one, but it still doesn't work. And I really can't see what the difference is, do you know what the problem could be?

 

file, forceGauge (the one that is working): reads very smoothly. the indicator shows the value all the time.

file, test stepper and force gauge (not working): displays *51 in the read buffer, and it flashes in the indicator.

 

Grateful if you could help me.

Download All
0 Kudos
Message 1 of 8
(4,129 Views)

I cannot download and view VIs.  Any chance you could also take screenshots and post those?

0 Kudos
Message 2 of 8
(4,122 Views)
Solution
Accepted by topic author 50616d656c61

In your force\stepper VI, you are sending ?\r,  as in a literal question, backslash, r because your constant is in normal display mode.  In your force gauge VI, your control is in \code mode so you are sending ?  carriage return.  I'm sure that is error #1 in the force/stepper VI.

 

In both VI's, I see a problem,  You are writing a command, then immediately doing a "bytes at port".  Since you haven't given any time for the device to respond, you probably have 0 bytes at port and read nothing that iteration.  Bytes at port is the wrong thing to use about 95% of the time.  If the response has a termination character (you set up the serial port with a line feed as the termination character), then use it.  Read a large number of bytes and the response will come back and terminate with the linefeed character.  You won't need the bytes at port and you'll have a complete response.

Message 3 of 8
(4,116 Views)

Here are some screenshots.

Download All
0 Kudos
Message 4 of 8
(4,111 Views)

Hi pamy,

 

when you use string constants with \-codes you should ALWAYS make the display style item visible!

 

Set your string constant to \-code displaymode, then correct your string content…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 5 of 8
(4,110 Views)

Of course, I totally missed that. Thank you so much.

 

And thank you for the feedback, I'll try it out.

0 Kudos
Message 6 of 8
(4,106 Views)

@GerdW wrote:

Hi pamy,

 

when you use string constants with \-codes you should ALWAYS make the display style item visible!

 

Set your string constant to \-code displaymode, then correct your string content…


This practice should be a subset of "if you are displaying any control, indicator or constant in a non-default fashion, always indicate it in the appropriate manner".  e.g., display style for a string, radix for a number, etc... imagine mistaking 100 decimal for 100 hex.

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 7 of 8
(4,068 Views)

billko wrote:  imagine mistaking 100 decimal for 100 hex.

I inherited a project where that happened at least 10 times a day (hardware guy was in hex while the test guy was in decimal).  No wonder the project took WAAAAAAAAAAAAY longer to do than it should have...


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 8
(4,058 Views)