LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Minimizing code complexity

Hi,

 

I'm trying to build a code for automating one of my processes. This involves sending a query to my equipment (serial communication), obtaining the query result and proceeding depending on the result. For eg, if my query result is "RNU" , I perform a check to see if the first letter is "R" and the third is "N". If it is"R" and "N", I proceed, if it is "R" and "U", I need to repeat my previous steps. I tried putting it in a case structure for True and Flase cases. True seems fine, if it is Flase, I need to repeat whatever I had done earlier until it becomes True. I am having a hard time putting it all in a case structure. If I dont use any loops or structures, the block diagram is going to look messy and bulky. The enire code is full of comparisons that give a boolean output. Does anyone have any suggestions?

 

Thanks,

Sukanya

0 Kudos
Message 1 of 3
(2,406 Views)

Sukanya,

 

The last lines of your posting give the clues you need.  You need a loop.  You need a case structure.  And you need a shift register.  When you have these three components, it suggests that a State Machine architecture is a good starting place.

 

Look at the examples which come with LabVIEW and the many postings here about state machines. 

 

But before you start wiring your LV code, please take some time to carefully plan and design your program. That time will be well spent when compared to the time it will take to debug an unplanned program.

 

Lynn 

0 Kudos
Message 2 of 3
(2,388 Views)

Hi,

 

The above explanation is very useful.

 

If you want then you can post your code for review and optimization.

 

 

Regards,

 

Shrek

0 Kudos
Message 3 of 3
(2,354 Views)