LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

select only even

i have this simply code,
i am trying to select only the odd elements.
i been stuck on this simple code for a while now. can someone give me a pointer on where i can fix this?
i want 1,3,5,7,9
Best regards,
Krispiekream
0 Kudos
Message 1 of 47
(4,751 Views)
i created this.
but i think there is easy, better ways.

Best regards,
Krispiekream
0 Kudos
Message 2 of 47
(4,737 Views)
Try using the code below.  You should try to avoid using so many local variables as they slow the code down dramatically.

Cheers!





Message Edited by jmcbee on 05-06-2008 02:47 PM
Message 3 of 47
(4,737 Views)
You really need to learn to program without using local variables and without sequence frames. Your code can be written completely without either one:



As for selecting the odd elements you need to use the other output of the Decimate 1D Array function. Or, are you trying to do this inside the loop, as in replacing the odd elements with TRUE? In that case, use the Quotient & Remainder function.




Message Edited by smercurio_fc on 05-06-2008 03:49 PM
Message 4 of 47
(4,734 Views)
both methods is better than mine..
yeah..i have alot to learn. i want to setup something




Message Edited by krispiekream on 05-06-2008 04:09 PM
Best regards,
Krispiekream
0 Kudos
Message 5 of 47
(4,722 Views)
i have created this second version.
everytime i click on "advance" the button system will look for the device found and move to that position.

right now, my code have too many local variables/sequences, what can i do to clean them up?

Best regards,
Krispiekream
0 Kudos
Message 6 of 47
(4,688 Views)


krispiekream wrote:
right now, my code have too many local variables/sequences, what can i do to clean them up?

Delete them all!

Part of the problem is that you use controls as indicators and then you need local variables in order to write to them. You also break all dataflow, forcing you to sequence the code artificially.
 
You are also running your UI loop at full speed doing nothing but waiting for a button press. How fast can you possibly press it? Place a wait inside the loop!
 
Better yet, use an event structure. Here's a quick draft.
 
 
Message 7 of 47
(4,671 Views)

I totally agree with Altenbach.

Delete ALL locals.  My LabVIEW world is one without Local Variables and void of Stacked Sequence Structures.

Experiment with the Event Structure.  It is actually easier to use than it first seems.

RayR

Message 8 of 47
(4,687 Views)
wow, that looks nice..
but one of the problem i was having is, i always have to click "adv" everytime in order to go to the next module
for instant.
when i am at currentposition 1, i have to click advance twice to get to position 3.
i want to go from 1, 3, 5, 7, 9
i dont know what to do with my index because incrementing it by 1 everytime causes my problem.


another thing...
i use my controls as indicators because i want to setup my case...
i want to be able to control my advance button...


ideally, i want the program to find all modules in the system..
then if there is a device on a board, it will list all of the devices found..
the first position i will look at is the position that makes 1D search true.
for instant..i have devices on position 1,3,5,7,9 on a board
the first position i will look at is 1.
but my question is..can i click on CONTROL my current possition to 7, then click on ADVANCE..
the next position it will work with is at position 7.
thats why i created my controls

i still have alot to learn..




Message Edited by krispiekream on 05-06-2008 08:42 PM
Best regards,
Krispiekream
0 Kudos
Message 9 of 47
(4,680 Views)

I don't have Labview installed on this PC, so I can't look at your code.

Why do you not set the case to add 2 instead of 1 if you select that button?  So instead of incrementing by 1, increment by 2.  If the increment value can be set by a control, then read the increment value from the control.

Maybe I need to look at the code to understand your constraint.

Message 10 of 47
(4,675 Views)