03-23-2020 02:01 PM
So if i hide the front panel of my VI in which i am communicating with my device through USB communication and stop the communication without closing the VISA resource to open another sub VI inside it. Will i be able to communicate with the same VISA resource as per my protocol and on closing that Sub VI, again able to communicate with my device in the Main VI as earlier
03-23-2020 03:07 PM
My Main purpose of putting the code here for verification was to fine tune my USB communication part where i am communicating with external device through USB based on my protocol of sending command and receiving data against it. Below are the points on which i wanted expert advice
1. Am i opening the VISA resource as per the standard practice
2. Is my producer loop proper
3. Am i using the Queue correctly
4. How can i assure that my data bytes does not get missed and i will get same data each time (if i consider my hardware device is perfectly fine)
5. Am i opening my sub VIs properly so that they will properly communicate with external device through USB with same VISA resource
6. Am i opening the Sub VIs properly after using them
7. My device is sending data (39 Bytes) at 115200 Baud Rate. I want to run the loop at 50 milliseconds. Right now it is running at 130 ms. It means at every 130 ms, i am sending a command of 7 bytes and in return the device is sending 39 bytes.
I am thankful to all the useful comments so far and few of them i have already implemented and working on the other useful suggestions as well.
I am looking forward to receive expert suggestions on the above questions
Thanks in advance
Dushyant
03-23-2020 05:32 PM
@altenbach wrote:
@billko wrote:
@altenbach wrote:
If the LEDs are not arranged in a row or column, convert to a cluster with arbitrarily arranged LEDs.I find it convenient to convert the array of Booleans to a cluster so you can label them individually. It makes any wires self-documenting.
Yes, but converting to a cluster is a bit more work, especially if you want the labels to be "in the wire" to later (un-)bundle by name, etc. If you just wire to an indicator with the correct labels, it's of course easier.
Here's how I typically use the "caption" for a plain vertical boolean array (play with LED size and font size to match things up).
I bet that in the amount of time it took you to line up the text with the LEDs, you could've made a cluster. 😉
03-23-2020 05:48 PM
@billko wrote:
I bet that in the amount of time it took you to line up the text with the LEDs, you could've made a cluster. 😉
Don't underestimate my speed.
With a cluster, you need to individually enter text into N separate labels, select that arrangement, etc.
... but yes, I also often use clusters, e.g if each LED should be a different color.... 😄 Of course I might also use an array of color LEDs, now each array element can be a different color. Fancy!! 🙂
03-23-2020 09:32 PM
@Dushy_11 wrote:
My Main purpose of putting the code here for verification was to fine tune my USB communication part where i am communicating with external device through USB based on my protocol of sending command and receiving data against it. Below are the points on which i wanted expert advice
What VI should I even be looking at? Your project is completely disorganized. I suggest having your main VI be directly under you "MyComputer" and then have folders organizing your VIs into logical groups. And "sub VIs" is not a logical group.
03-24-2020 04:34 AM
@Dushy_11 wrote:
My Main purpose of putting the code here for verification was to fine tune my USB communication part where i am communicating with external device through USB based on my protocol of sending command and receiving data against it. Below are the points on which i wanted expert advice
[snip]
7. My device is sending data (39 Bytes) at 115200 Baud Rate. I want to run the loop at 50 milliseconds. Right now it is running at 130 ms. It means at every 130 ms, i am sending a command of 7 bytes and in return the device is sending 39 bytes.
Well, according to your Subject: 'verification of my software code for best practice'
As to #7, this might be a factor ...
/Y
03-24-2020 06:25 AM
Thank you, Sure i am restructuring my project as per your valuable suggestions
And the VI i majorly wanted to go under scrutiny here is "WSP Offline GUI Main.vi" under my project and that too the part/loop where i am communicating with VISA in reading and writing data. I am attaching the screenshot for reference.
03-24-2020 06:29 AM
when i am changing the loop to 50 ms, then i am not getting complete packet of 39 bytes every time or i would say most of the time. So i wanted to make sure at my end first before questioning the external device that the device is not able to provide me the data at this sampling rate
03-24-2020 06:41 AM
No, that's because you're using "Bytes at port", which you shouldn't do. I see you have an unused constant 39 which is what should be used (this might cause problems if the system is ending messages with e.g. \n, in which case you should set a termination character and read 100 chars (which'll break early if a \n appears))
Also, you're reading and writing in parallell which is bad. Better would be to read in the 'don't write'-case
Also, don't use Front panel controls as constants, use constants.
/Y
03-24-2020 06:44 AM
I can't open the code now, but, Is it a "bytes at port" I see in that huge diagram? And it looks like you are writing and reading in parallel but have some waits that control the flow. Am I correct? Usually you only need Write and then Read with no waits, instead you enable a termination character (or a known number of bytes).