LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem using Case Statments in LabVIEW for myRIO FPGA

Solved!
Go to solution

Hi. I am using LabVIEW to program my myRIO FPGA. I am running a complex case structure where I am assigning different states to specific (16) outputs. Based on the problem statement, the cases that I am running are 279 in number. As soon as I save my complete program and build it, the LabVIEW goes to not responding state and the LabVIEW crashes and I have to force stop it. The screen-shot of one state of case structure and the error message is as below:

 

Block DiagramBlock DiagramError MessageError Message

I have spent too much time on this issue but have failed to find any solution.

 

Please help! Thanks in Anticipation.

0 Kudos
Message 1 of 10
(3,837 Views)

Hi Ahmad,

 

having 279 cases isn't considered "structured programming"…

 

- Do you output those booleans in each state? Why not use an array of 279 rows to define your boolean values?

- Can you "merge" those IO node outputs to DIO0-7 and use an U8 value (like you can with NI9403 module on cRIO)? Then your array would shrink to an array of 279 U8 values!

- Can't you join those states in a useful ("senseful") way? Are those 279 states so different that you need to assign a case for each of them?

- Do you need to use local variables in each state?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 10
(3,825 Views)

Not sure if you are hitting some limit.

 

Do all states write something to all these local variables? If so, why aren't the local variables after the case structure?

Why not just index into a 2d array of booleans using the enum instead? Do you even need the locals? Couldn't you just place the DIO after the case structure and eliminate the loop on the right?

 

I don't understand the uppermost shift register at all. Why is it there? You never use the output!

Message 3 of 10
(3,822 Views)

Hi GerdW, thanks for the reply. 
Yes, we are taking the boolean outputs in each state. And yes, those 279 states are different and we have to assign 279 different cases to them. We have made the local variables for 16 DIO pins and we are using their instances in each case to write the particular sequence to those DIO pins. 
Can you describe me a little more, how can I use arrays for this purpose?

0 Kudos
Message 4 of 10
(3,819 Views)

AhmadHassan wrote: 

Can you describe me a little more, how can I use arrays for this purpose?


Here is a simple example. You create a 2D array diagram constant with the desired pattern for each row.

 

LEDs.png

Message 5 of 10
(3,806 Views)

@AhmadHassan wrote:

Can you describe me a little more, how can I use arrays for this purpose?


You can just have an array of 279 booleans and use Index Array to get the value you need.

 

And you do not need the local variables nor the second loop.  Just move the IO nodes into your first loop after the case structure.


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
Message 6 of 10
(3,805 Views)
Solution
Accepted by topic author AhmadHassan

Just messed around with a project just to make sure, but GerdW had a great suggestion of using the ports instead of the lines.  This way, you can manage 8 lines at a time with a single value.  You can even change the view of the U8 to be in a binary format so you can see the individual bits.


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
Message 7 of 10
(3,801 Views)

Hi altenbach, thanks for the suggestion.
Yes, all the states write something to those local variables. Now, I will try doing this by eliminating local variables. Thanks for the suggestions. I really appreciate your time! 

0 Kudos
Message 8 of 10
(3,798 Views)

Thanks altenbach for this example. 
Best Regards,
Ahmad

0 Kudos
Message 9 of 10
(3,791 Views)

You are writing to local variables nearly 300 times in parallel.  While a SCTL won't actually allow this, running in a normal while loop will, and will use an arbitration model to choose who has access.  It might be that this arbitration for each of your locals is causing the program some headaches.

 

I suggest getting rid of the locals altogether as others have said.

Message 10 of 10
(3,781 Views)