LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

verification of my software code for best practice

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

0 Kudos
Message 21 of 34
(1,196 Views)

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

0 Kudos
Message 22 of 34
(1,185 Views)

@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).

 

altenbach_0-1584989742464.png

 


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.  😉

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 23 of 34
(1,171 Views)

@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.

 

  • show caption
  • move caption to right or left side (text justify right if on caption is on left side)
  • enter all lines at once
  • Select caption and do ctrl+/- to change font size until things line up.

 

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!! 🙂

Message 24 of 34
(1,168 Views)

@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.


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
0 Kudos
Message 25 of 34
(1,155 Views)

@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 ...

USB speed.png

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 26 of 34
(1,140 Views)

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.

 

main VI_VISA Read-Write loop.png

 

0 Kudos
Message 27 of 34
(1,132 Views)

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

0 Kudos
Message 28 of 34
(1,131 Views)

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

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 29 of 34
(1,125 Views)

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).

Certified LabVIEW Architect
Message 30 of 34
(1,124 Views)