LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Newbie doubt: two loops, one file, one graph

Solved!
Go to solution

@gracabrotas wrote:

Hello! Thank you  for your quick notes! For some of them I still have questions, if you don't mind helping

 

  • "actual state" string should also go into a shift register.

well... In the beginning I had a lot more shift registers, but I thougth they made the code look messier with all the wires going around, so I replaced some of the with local variables. My mistake I guess, although I don't quite understand why local variables are that bad.... However, for the "Actual state", my problem was I needed it to be one of the triggers to end the program, and with the shift register It wasn't working as I needed.

 

  • You don't need the inner while loop in the "check deltatT" case. Use the outer loop to repeat the state and only go to the next state if the condition is met. (you can make the outer wait state-dependent if this should occur faster)

I see what you mean here, but wouldn't that mean that this state needs to access two states? and I only have one "blue" shift register.... How do I use the outer case as a loop without a looping condition and a stop?

 

  • You don't need the sequence structure in the "end" case. The case does not output anything until everything in it has completed.

This one I really get. I deleted it already!! 

 

  • If you would place your controls before the case structure, you can eliminate many locals.

Yep, I get this, I was just trying to minimize the amount of wires going around. I didn't know it was such a bad option.

 

  • Similarly, if you would place the Actual T" indicator on the orange wire before the case structure, it would never contain stale data (initialize the SR with NaN, same for the output in the first state). Similar arguments for MinK.

Ok, I'll try to do this.

 

  • Focus on more consistent error handling.

Honestly, this is a first version, and I was just trying to make it work, so we could use it in the lab.... afterwards I will continue to work on it to improve it, but I really need it to work for now! 😉

 

  • Your enum should be a typedef. Right now you have diagram constants of it scattered everywhere and if you ever need to e.g. add a new state later, it would be like herding cats to update every instance.

Yeah, I saw this in many videos, but I couldn't find it.... I'm working on LV7.1, so I think I don't have that feature.... 🤔

 

Anyway, the only thing I really need now to use the program, is to write the file, as I explained I the previous message, do you have any suggestion on how to do that?

 

Thank you very much for all your help!! 


If you really have too many shift registers (and you really don't) you can use Bundle to only have 1 wire and use Bundle and Unbundle to extract/write when needed. 🙂

 

I'm pretty sure you have Type def in LV 7.1, but you don't have the r-click meny to just do a simple "make type def". You'll probably need to Create Control manually and place the Enum there.

 

Also, to to handle decimal comma/point, I usually to a Search and replace to replace , with . and then use a False connected to the "use local decimal sign" on the String to number. Also, make that a SubVI since you use that on a couple of places.

 

It's looking much better already!

 

Edit

Regarding choice of state, you usually make a comparison (e.g. x>2), connected to Select which selects which case to send as 'next state'

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

Qestit Systems
Certified-LabVIEW-Developer
Message 11 of 12
(306 Views)

@gracabrotas wrote:

 

  • "actual state" string should also go into a shift register.

well... In the beginning I had a lot more shift registers, but I thougth they made the code look messier with all the wires going around, so I replaced some of the with local variables.


Well, all you really need is one single shift register containing a cluster of all desired elements. Give all elements intuitive names and you can "unbundle by name" to get any particular elements, "bundle by name" to rewrite one, and the IPE structure to modify one.

Message 12 of 12
(291 Views)