Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Novice Programmer With Functional Code. Looking For Feedback on Organization/Improvements

Hi everyone. I'm a Test Engineer for a small company and have no coding experience prior to a few months of what I taught myself in a physics lab. I have no background with any coding software besides LabVIEW and am seeking feedback on my code and what looks good as well as what could also use some improvements. I hope to use 'PM100D Measure Power.vi' in the near future and it is working, but I would like to take the time to review my first project so I can limit my mistakes next time I build a project like this.

 

Currently, the file is in PM100D.llb because the driver would not function for me outside of the library of drivers. I modified the 'Measure Power' VI which is what I will be using to do measurements. Essentially, I can control a DC power supply while simultaneously using an optical power meter. I can save data and also have over voltage protection incorporated. 

 

I would like to be able to control more than 1 channel of the power supply at a time, but feedback is the main goal of this post. If you see a way in which I can improve my VI please let me know. Thank you in advance for those who respond!

 

P.S. I added a simpler version of the optical power meter that is able to function outside of the llb file and it is the same exact thing as the 'PM100D Measure Power.vi', however, no power supply is integrated in the while loop so it executes MUCH faster.

Download All
0 Kudos
Message 1 of 3
(2,600 Views)

Hey Malichi: 

    

    I was taking a look at your code and my first impression is kudos! For someone who is getting started, it looks very good. I have three recommendations though, that could improve it, they are based on what I see for the Power Meter (Passive): 

 

1) Change the controls and indicator so that they are not viewed as icons (right click them and unselect view as icons). This is a space saver!

 

2) I see that in the equal close to the stop condition you have a coercion dot (the red dot in the lower input of the equal), this dots are usually considered bad practice since they force a conversion between data types and increase memory usage.You can easily solve that by inserting a to double precision float function between the i and the equal. 

 

3) I would change the write to measurement file express VI. These usually are really slow and memory consuming so they are no that recommended.  We usually recommend lower level VIs. You can take a look at the options here http://www.ni.com/newsletter/51339/en/. 

 

PD. Great job with the VI documentation! That's always relevant.

 

Carlos Diaz 

Applications Engineer

 

0 Kudos
Message 2 of 3
(2,553 Views)

Hi Malichi,

 

I like the UI, but there are some issues with the code.  I have some questions for you, then some tips, and my stab at cleaning up your block diagram.

 

Was your "Error Checking" doing anything? Your while loop wouldn't stop if an error occurred in DLL and there was no Stop button. If you wanted 1000 samples that could be a problem.

 

How important is the time data of the measurement?  I don't think the Elapsed Time Express VI would give you what you want as it was being used.  As it was coded it executed at a random time in the while loop.  Maybe before, maybe after your measurement.  Make sure you review the principles of data flow!

 

Why 2 charts of the power? I've include a x-y plot of power vs time as an example in case that's what you really want.

 

Tips for coding..

0. Think data flow.  Control code execution order with data flow or allow parallel operations, but make sure you know which you want.

1. Make subVIs where possible, like W-->dBm conversion.

2. Read LabVIEW style checklist for tips
- Group indicators
- prgoram flows left-right, avoid wires going right-left and crossing randomly

- alignment and symmetry are your friends
- indicator labels on the right, control labels on the left
- many more good programming practices..http://zone.ni.com/reference/en-XX/help/371361P-01/lvdevconcepts/checklist/

3. Avoid Express VIs when possible...they take up a lot of space on BD

4. Initialize shift registers.

novice_tips.png

 

Best of luck with the project.

Craig

 

Edit to fix spelling and a poor sentence.

Download All
0 Kudos
Message 3 of 3
(2,547 Views)