01-05-2017 02:01 PM
Hi all,
I have connected an NI USB to RS485 cable connected and working.
Since it's a working project I did use abort button to stop the VI. Which is the reference of the RS485 is not closed. Will that cause the device to unregister it's port reference completely?
I have went through some of the discussion forums already and the solution does'nt match mine scenario.
My NI Device Motoring is up and running from startup. Also all I need to bring it back to list in MAX is to unplug and plug it back again.
Any suggestion o comments?
Solved! Go to Solution.
01-06-2017 12:58 PM
Hello grimmy123,
I do not think I fully understanding the problem. What port reference are you referring to in your first question?
From what I understand, your device dissappears from MAX, but unplugging it and plugging it back in seems to fix the issue. Are you asking what is causing this behavior to happen and why?
I hope you are having a great day,
Weston S.
Applications Engineering
National Instruments
01-09-2017 07:04 AM
Hi Weston,
Appreciate your response!!
The port reference I'm refering to is VISA read/write reference out to VISA close.
Exactly I'm not sure exactly what's causing my device to dissappear from MAX?
-Grimmy123
01-10-2017 06:02 PM
Hello @grimmy123,
If you could post a screenshot of your code and/or what your configuration is in MAX this will help me better understand what you are seeing as we try to find what might be causing your device to disappear in MAX.
Thanks!
Weston S.
Applications Engineering
National Instruments
01-11-2017 03:29 PM
Hi Weston,
Please find the images as follows,
1. This is what I get in NI MAX, Initially I was getting seperate Device and Interfaces as NI-RS485 and showing the ports.
2. This is my sample code. Very basic, sometimes I abort it as a part of development.
3. This is from my main application where I use Objects, Parent Class is Communication, Child 1 is CAN & Child 2 is RS485.
FYI, I just found that the reference out of "VISA read" not bundled back to the object references (I corrected the code as shown above). But I close the reference in of "VISA Flush" when the task is completed.
Will this be causing me the problem?
01-12-2017 04:19 PM
Hi @grimmy123,
Thank you for adding those screenshots. I do not see any red flags in your code at first glance that could be causing what you are seeing. But just so that we are both on the same page, are you saying that from what you understand, aborting your program in LabVIEW is causing your NI-RS485 device to dissappear in MAX? I am going to try to replicate what you are seeing on my end and want to make sure I am trying trying to replicate the same behavior you are seeing.
Regards,
Weston S.
Applications Engineering
National Instruments
01-13-2017 07:20 AM
Hi Weston,
Yeah, that's what i'm guessing. I'm not sure what exactly is happening. FYI, I tried some solutions which are already in the forums but didn't work out.
01-16-2017 03:42 PM
Good Afternoon @grimmy123,
http://www.ni.com/documentation/en/labview-comms/2.0/debug/abort-execution/
With reference to the document above: "Aborting a program that uses external resources, such as external hardware or file I/O operations, might leave the resources in an unknown state and cause the program to return errors the next time you access the resources. An alternative to using the Abort button is to enclose code that uses external resources in a While Loop with a Stop button. Using the Stop button instead of the Abort button cleans up external resources before stopping execution."
I recommend that you do not press the abort button to exit your program. It can cause unexpected behavior such as the behavior you are seeing. It seems like you have found a good work around. I cannot say one way or the other whether it will cause the device to unregister its port completely. I tried replicating this issue and the device did not unregister its port completely. However, that does not guarantee that this is what will occur for you as leaving resources in an unknown state by pressing the abort button results in unpredictable behavior. I would recommend not using the abort button and implementing a stop button in your code that will close out the reference as it appears you already have in screenshot number 2.
I hope this helps!
All the best,
Weston S.
Applications Engineering
National Instruments
01-17-2017 07:24 AM
Hi Weston,
Appreciate your extended support.
I also have another question which I am not clear. Is it mandatory to create a COM port in MAX for the USB to RS485 cable or the PXI system will detect them automatically?
01-18-2017 05:02 PM
Hello @grimmy123,
The PXI system will automatically detect the COM port.
I hope this helps!
All the best,
Weston S.
Applications Engineering
National Instruments