LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

RS 485 Communication Issue

I'm trying to get my flow meter to work. I send over 8 bytes of hex data in a text file. It's supposed to send me back some data over this port in bytes. The first 4 bytes are mass flow rate, the second four bytes are g/cc, the third four bytes are temperature of fluid, and the last four bytes are L/s. 

 

I'm using the VISA in my programming to access it. I've got it to work before on my RS 232 port too so I'm trying to use the same architecture for the 485 port. It keeps on getting a timeout, however. 

 

If someone knows how to fix the issue or even just some insight into what I'm trying to achieve that would be helpful.

0 Kudos
Message 1 of 8
(2,678 Views)

I can't tell exactly, but I do know that you are not handling errors properly.

 

With your code, if you get an error, you ignore it and try again.  The next loop iteration will forget about the error and try again.

I suggest you adapt your code to stop if an error occurs, or if the STOP button is clicked.

That way you can see ANY error that happens.

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 2 of 8
(2,639 Views)

Hello NickBI, first of all you haven't put a proper "wait function" to your system. You don't let your device to reply you properly after sending the write command. In order to clearly understand the problem you first need to put a wait (ms) function and let your device to write command first, than wait maybe for 500 or 1k ms and than get your reply. Since output of the VISA write is directly connected to the input of VISA read having no time delay, you may not get the answer you want. For that what you can do is that, you can put a flat sequence with wait (ms) function in between VISA write and VISA read.

P.s: Of course here assuming all the configuration settings are fully correct. If they are not correct, do not look for another problem.

Add 273 on whatever Celcius said.
-Kelvin
0 Kudos
Message 3 of 8
(2,609 Views)

Hi CoastalMaineBird, thanks. In my code now, why doesn't it stop if the stop button is pressed? I have a control wired to the stop condition currently. And for stopping if an error occurs anywhere in the code, is there a way where I can show the explanation of that error or does LabVIEW do that automatically when I wire an error status to the stop condition?

0 Kudos
Message 4 of 8
(2,583 Views)

Hi N. TESLA, thanks. Should it be the regular "wait function" or the "RT wait function"?

0 Kudos
Message 5 of 8
(2,582 Views)

Use a GENERAL ERROR HANDLER to display a dialog explaining the error, if there is one on the wire.

 

Remember that you must read the STOP button EVERY TIME THRU THE LOOP, meaning that the stop terminal must be INSIDE the loop boundaries.

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 6 of 8
(2,578 Views)

I've edited my code to add in the error handling at different points in the code as well as a flat sequence with a wait function. How does it look now?

0 Kudos
Message 7 of 8
(2,571 Views)

It looks like you don't quite understand how the ERROR chain works.

 

You're doing way to much work in that diagram.

 

The error chain works if every Vi which has an ERROR IN terminal checks for the existence of an error coming in and SKIPS doing it's work if there is.

The error then shut propagates from ERROR IN to ERROR OUT.

If you have a chain of such VIs and you wire the ERROR OUT of one to the ERROR IN of the next one, then you only need to check the error ONCE per loop. The ERROR cluster carries a code that tells you WHERE the error occurs.

 

If you wire from A.ERROR OUT to B.ERROR IN, and B.ERROR OUT to C.ERROR IN and C.ERROR OUT to the STOP terminal of a loop, then the loop will stop on any error.

Wire the C.ERROR OUT to a GENERAL ERROR HANDLER outside that loop and you get a dialog that says "Error 7 occurred at Open Text File in MyVI.vi - possible causes: File Not Found" or something like that.

 

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 8 of 8
(2,568 Views)