LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

stuck with comparison!!

Hi I'm attaching my vi. I'm doing serial Visa read to get the data. My algo goes like this:
I compare my serial port visa read string with  char "x". If x is received than I increament the index in the structure. There is another control(steps) which tells me when to run my other structure for other processing.  I wanna compare both my Desired number and index and if they are equal, my vi should run the desired structure.
Now problem is as soon as index increaments my desired number also increaments, which is very logical. 😞
I wish to compare my index with the last desired number for eg.
In current position if Index is 5 and steps control says 2 means my next processing in structure has to run when index becomes 7.
0 Kudos
Message 1 of 4
(2,731 Views)
You probably need to clarify the problem a bit better. Your VI is designed with an uninitialized shift register, but you don't have any connectors hooked up, so it seems to be the toplevel program. This means that your counter will start at a high value for subsequent runs of the same program.
 
What should happen after the processing has occured? Should it again happen after a desired number of steps or never again?
 
I think what you need is a second shift register to keep the last action index (and have both initialized to zero). Place the action case into the X case, because it can only happen if another x is encountered, right?
If an action occurs, place the index into the action index. If no action occurs, don't. 🙂
 
Here's a quick draft. You probably need to tweak it for the exact requirements. (I added a chart to record the various events)
 
You should also make sure to use a "larger or equal" comparison. If you do an "equal" comparison and you would switch the steps from 4 to 1 in a case where the comparison is already e.g. 3, the "equal" will never happen again, ever!
 
(Since I don't have your VISA, I substituted some code that generates x with about 25% probability. I also placed a beep in the action case)

Message Edited by altenbach on 06-30-2007 10:48 AM

0 Kudos
Message 2 of 4
(2,721 Views)
Ok I explain my problem once again.
I get data from the serial port from the microcontroller, everytime it moves a millimeter it sends a char x as a ready signal for measurements inside labview.
So I increament the index everytime I read X on Visa. Now I need to have an option whether I wanna take measurements every 1 mm or 2 mm or 3 mm etc. This vaule I pass though the steps control, as you can see in my sample vi attached above. For eg, suppose I pass 2mm to steps control and my present index says 7 this means I need to run my desired code for measuremetns when Index becomes 9,11,13 like that. Now when all measurements are done and labview sits idle in while loop and I change my steps control to say 1 mm now and if my present index is 34 than I wanna run my desirerd code when index becomes 35,36,37,38 etc...I hope I'm clear enough now...
Please can you help me out..
0 Kudos
Message 3 of 4
(2,706 Views)
Maybe you can use a simple quotient&remainder calculation to get close. This, and the above example, should get you going, just mix&match. 😄
Message 4 of 4
(2,701 Views)