11-21-2017 08:13 AM
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:
I have spent too much time on this issue but have failed to find any solution.
Please help! Thanks in Anticipation.
Solved! Go to Solution.
11-21-2017 08:51 AM
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?
11-21-2017 08:58 AM - edited 11-21-2017 09:00 AM
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!
11-21-2017 09:02 AM
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?
11-21-2017 09:21 AM
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.
11-21-2017 09:24 AM
@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.
11-21-2017 09:31 AM - edited 11-21-2017 09:31 AM
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.
11-21-2017 09:33 AM
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!
11-21-2017 09:37 AM
Thanks altenbach for this example.
Best Regards,
Ahmad
11-21-2017 10:17 AM
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.