LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Logic Sanity Check

Solved!
Go to solution

Hello everyone,

 

I am working on some code to automate Resonant Ultrasound Spectrometer measurements at varying temperature and field via taking the measurements within a Quantum Design PPMS. Attached is my code, input file, as top level subVIs. Can anyone just verify my logic here and tell me if this code will do what I am wanting it to do? I cannot test the code directly, as the PPMS is in another lab which is across campus; however, I have lab time with it tomorrow. 

 

What I want the code to do:

  • Take and strip all the data from the input file (I know this works)
  • Set the temperature and field (I know this works for temp, haven't tested field but if it doesn't work it is the subVI)
  • In the while loop run the subVIs until BOTH the temp and magnet subVIs return the status of OK
  • Once BOTH the temp and magnet status are OK run the "RUS Code" subVI 
  • After the RUS Code subVI is finished (boolean signals when RUS Code is finished) check to see if the "wait" is 0 in the input file
    • If wait != 0 then wait the defined time, if wait = 0 stop the while loop and move to next iteration

 

Just want to make sure I'm not crazy, but I have a feeling I may have screwed something up. Would be nice to have it working as soon as we start operating tomorrow, as time with the PPMS is valuable. Appreciate any feedback and criticism, and thanks in advance! 

 

*RUS_PPMS_File_Control.vi is the main VI

0 Kudos
Message 1 of 9
(2,686 Views)

Hi etvg,

 

Appreciate any feedback and criticism, and thanks in advance! 

Why is there an additional While loop in the FOR loop?

Why is there no project file?

Why do we have to search for your "main" VI?

How do you know "set magnet" and "set temp" have been executed? How do you know they executed successful? (No real error handling! Comparing floats for equality!)

Is there a reason to use those old GPIB function instead of "modern" VISA?

 

Why is "LIdA3_1" so huge? (With bad coding style in general.)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 9
(2,672 Views)

@GerdW wrote:

Hi etvg,

 

Appreciate any feedback and criticism, and thanks in advance! 

Why is there an additional While loop in the FOR loop?

Why is there no project file?

Why do we have to search for your "main" VI?

How do you know "set magnet" and "set temp" have been executed? How do you know they executed successful? (No error handling!)

Is there a reason to use those old GPIB function instead of "modern" VISA?

 

Why is "LIdA3_1" so huge? (With bad coding style in general.)


Hey GerdW,

 

Thanks for the input, hopefully this clears some things up:

 

  • The for loop is so the while loop will execute the number of measurements listed in the input file, can I do away with that somehow?
  • You're right, this should be a project, my apologies. 
  • I can add indicators to verify the set magnet and temp have been executed; however, in the past has been verified via visual confirmation of the PPMS setting new temperatures on its screen
  • The PPMS has to be connected via GPIB, so I do not not believe I can convert it to "modern" VISA. On the other hand, I admit I am not familiar with the subject
  • LIdA3_1 is a legacy code, which is in this code because it is known to work. I have reworked the legacy code a bit, creating many subVIs and fitting the top level of that onto one computer screen; however, I wrote this code using an older computer and the reworked LIdA3 code is on a laptop which is currently taking measurements in the lab. I will be replacing the legacy code before working with the PPMS tomorrow.

 EDIT: Added zip w/ project to this post

0 Kudos
Message 3 of 9
(2,663 Views)

Added error handling, which you pointed out was absent. Attached is updated main VI. 

0 Kudos
Message 4 of 9
(2,637 Views)
Solution
Accepted by topic author etvg

Hi etvg,

 

some changes to the VI:

check.png

- Still no need for that outer WHILE loop: it was finished just after the first iteration, so it was pure Rube-Goldberg!

- No need to IndexArray 5 times when you can resize that function to give the 5 outputs at once…

- No need to get the ArraySize when you already use autoindexing at the FOR loop border…

- Why did you create one more error cluster (without a label in the block diagram)? One error wire is enough!

- use the error wire to set the DATAFLOW and so command the execution order! (I still would use a state machine here: first set new parameters, then wait for reaching new setpoints, then read new measurement values. And an additional error handling state…)

- Keep parameters, which are constant in the loop, outside the loop. See your GPIB address as example…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 5 of 9
(2,622 Views)

GerdW,

 

While working with the PPMS today I couldn't seem to get the magnet controls working properly, so temporarily I made a temperature only version of this code which works flawlessly. There is no reason, dataflow wise, the "magnet status" subVI and "temp status" subVI cannot operate simultaneously is there? I think it may have just been a bug due to having the field set to "0" and the PPMS reading -3.3Oe as the field, so maybe for some reason it did not understand what it was being told to do (but looking at the data flow the all the subVIs were running besides the "magnet status" one, despite the fact they all should be running).. I would look into it myself but I'm back in my office and am running measurements with the laptop, time is limited on the PPMS so I was in more of a "get something working to collect data" mindset rather than troubleshooting the field issue, because these samples are being tested at zero field anyways.

 

Best regards,

Erich

0 Kudos
Message 6 of 9
(2,574 Views)

Hi Erich,

 

I guess the problem is the simultaneous access to the very same device. Your device gets two commands in parallel and tries to answer both. Which answer is received by which sender routine?

 

You cannot send multiple commands in parallel to the same device, you need to send them one after the other!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 7 of 9
(2,567 Views)

The set temp subVI is verified by the temp status subVI, and the set magnet subVI is verified by the magnet status subVI. So how do you suggest I change the layout of this top level VI to be able to manipulate the temp and field? Doing temperature first, once boolean signals temp is stable then set field, and once that is stable run the RUS code, maybe?

 

Cheers

0 Kudos
Message 8 of 9
(2,563 Views)

Hi etvg,

 

use DATAFLOW to order the commands!

Set temp first, then set magnet. Use the error wire to set execution order...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 9 of 9
(2,561 Views)