LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Change The Control Values Dynamically & Array Help

Hi everyone,

 

Please your help and thoughts on this.

 

I have a VI where I want to change the value of my initial control depending on the values obtained within. I know local variables might be a bad idea, which it actually is based on my run. Can someone please inspect my code and offer me suggestions/help on how to make this run perfectly.

 

 

I also know that when I run this program, most of my final values come out as 0 in the saved part and #NV for the integration part. What do I need to do right??

 

Code is attached. 

 

Here's a summary: First run goes with my defined Vmax, then subsequently changes based on the relationship between the last two power values (which I try to index from the array)

 

Thanks for your help!!

 

 

0 Kudos
Message 1 of 4
(2,988 Views)

Sorry, but this one is bleeding everywhere... The problem this is not only a spaghetti code, but there are many design mistakes too! I just cannot make a full list right now, I try to mention a few:

 

  1. You abuse the local variables in a strange way, involving a control and an indicator. Just use the Initial_Vmax Control ALONE, and do not use local variables. You do not need them. Inside your state machine you should alter the V_max as necessary. You can use an indicator INSIDE the while loop, after the case structure, to indicate the actual V_max_Current values (by connecting the wires to the Vmax_current located inside the state machine while loop, value can be stored in a shift register)...
  2. Testprogram_BDdfs.png
  3. You use two Queue lines, which is totally unnecessary. Use a single Queue from your bottom Producer loop with a cluster or array containing the 2 double values (Capacity and MFC values). This would simplify the design a little bit.
  4. The wiring is total crazy. The error wires, and also other parts are branched in a real chaotic way...I just do not get it.
  5. There are many repeated blocks which should be eliminated, like the part below. You could just use a single empty double array constant to initialise the arrays. By the way, as your code is written now, you will initialise some of these double array shift registers at EVERY iteration, you either "zero" them before the Case structure or since you set the borders of the Case structure as "Use default if unwired", those cases will empty the shift registers... This does NOT make any sense! That is why this program does not function as you want.
  6. Testprogram_BD.pngTestprogram_BD_fgd.png
  7. Please forget about these totally unnecessary Flat Sequence Structures (FSS)! You do not need to use them! Think of data flow, and use the wires, specially proper error wiring to determine execution order! These FSSs are like an evil epidemic, I just do not get why I see abusing LabVIEW code with these so often. Bad teachers at universities? Someone must teach these bad design techniques all around, i cannot explain otherwise the large popularity of these...
  8. Your code is huge, difficult to follow what happens and why. You should also learn about using Clusters, here they would be very helpful to reduce the number of wires.
  9. Learn how to properly program a state machine. Also you should understand better data flow and how shift registers work.
  10. I advice to go through the online courses, like Core 1 and 2. 

Good luck with the learning!

0 Kudos
Message 2 of 4
(2,960 Views)

I agree with you, the code is bleeding everywhere but I did make it right.

Thanks for your taking out time to look over the code. I was able to fix all my errors with your comments and the volume of the spaghetti is mostly reduced.

I believe we all get better with time.

 

Cheers.

0 Kudos
Message 3 of 4
(2,909 Views)

I am happy you managed to fix your code. If my post helped you to fix it, you can mark it as solution.

0 Kudos
Message 4 of 4
(2,891 Views)