05-29-2017 01:42 AM
Hello to all LabVIEW users,
I am running a project in which I am trying to read values of some certain variables (temperature, current etc.) continuously according to the command send to the device. For this purpose I have written subVIs for each of the corresponding parameters. In this context, when I run them one by one it all works fine. But when I want to run all of the subVIs in the same project only one of them will give me the result. I guess the problem is with the communication hierarchy I am considering. But for the exact solution I will request your kind guidance.
05-29-2017 01:56 AM
I can't look at your code, but make sure you don't have any race conditions, use error wires between your read VI's so one will finish before the other starts. Another solution is to incorporate both function in a single VI and select what to read through an Enum input. Such a VI can only be run as singleton (normally) and thus prevents simultaneous read and writes to the com port.
/Y
05-29-2017 02:01 AM
Hello, thanks for reply. You can't look at the code due to LabVIEW version conflictions? If so I can save it for another version for you.
05-29-2017 04:48 AM
1. You reinitialize your port in each VI. That does not belong in your command VIs. You should initialize the port before you start your main loop and close it afterwards.
2. You should not be using the Bytes At Port, especially if the instrument is using a termination character. Just tell the VISA Read to read more bytes than you expect a message to be and it will stop when the termination character is read. This will also eliminate the need for those waits after sending the command.
05-29-2017 05:10 AM
Thanks for the reply @crossrulz. Yes, for the first remark you are fully right. I already fixed that issue after posting this. My question will be regarding second remark of you. When the program reads termination character it will stop that is true. But do you think it will effect the continuous data receiving? As I mentioned I should continuously measure my parameters.
05-29-2017 05:29 AM
@TITAN-x wrote:
When the program reads termination character it will stop that is true. But do you think it will effect the continuous data receiving? As I mentioned I should continuously measure my parameters.
Just to clarify, does the instrument only sends data back as a reply or does it constantly send data? Either way, the Termination Character will help you and reduce wasted time (due to the wait), which will help your continuous getting of data. But if your instrument is constantly sending data without a command, then we need to rethink architecture a little.
05-29-2017 06:44 AM
Actually I am sending command to the instrument so that it responds with the data I have requested. The problem is that, when I connect to subVI as attached in the first command, I sometimes get respond as expected and sometimes does not get a meaningful respond. Than I figured out that, when I connect the subVIs which run over same COM there is kind of crush happening between commands. How can I get rid of this complication?
05-29-2017 12:48 PM
Make the updates that I already told you to do. I gut feel is that the Bytes At Port was causing your issues (it becomes a very interesting race condition).