LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Extracting a value from a 1D array

This is probably really simple but I've been at it for a day and a half and I still haven't gotten anywhere. Basically, I'm reading signals from a CAN bus and one of VIs reads one of the signals and outputs it as a 1D array. How do I search and extract a value from this 1D array automatically and, depending on the value, output a string? The values and strings output are as follows.

1-Forward
2-Neutral
3-Reverse

Any help would be greatly appreciated.  Thanks in advance!

Regards,
Adrian
0 Kudos
Message 1 of 10
(5,672 Views)
Well, to get any desired array element from an array given its position, use "index array".
 
If you want to "search" for a certain element, you have to be a bit more clear. You can use "search array" to find a specific value or you could use "array Min&Max" to find the values and locations highest and smallest value in the array. etc.
 
To translate the found array element into a string, you could use a case structure with 3 cases, each case containing one of the strings. You could also have an diagram string array constant with your 3 elements, then calculate which index to use to get the right string as a function of your data.
 
It might help if you could attach a simplified version of your code so we can get a better picture of what you are trying to do.. 🙂
0 Kudos
Message 2 of 10
(5,665 Views)
If the value you are looking at is at the same index every (ie is at the same element in the array every time) then you can just use index array to get you to the element and then compare that and output the neccessary string



Joe.
"NOTHING IS EVER EASY"
Message 3 of 10
(5,665 Views)
Thank you both for replying! I'll try both ways sometime today.  I just got the third edition of LabVIEW for everyone so I'm going to put my reading glasses for a little bit.  Smiley Wink

I'll reply again as soon as put both your ways to work!!  Once again, muchas gracias!

Regards,
Adrian
0 Kudos
Message 4 of 10
(5,636 Views)
Jhoskins, I have LV 8.0.  I couldn't open your VI.  Smiley Sad
0 Kudos
Message 5 of 10
(5,626 Views)
My VI does pretty much what the wizard Smiley Happydescribed.



Joe.
"NOTHING IS EVER EASY"
0 Kudos
Message 6 of 10
(5,622 Views)

Adrian,

You have received great answers so far. I converted the Pick.VI example to LV8.0 so that you can open it and added one more example that does the same thing, but uses a slightly different approach.

Kalin T
Applications Engineer
National Instruments

Kalin T.
Download All
Message 7 of 10
(5,601 Views)
at first i was really worried about posting what is probably an elementary question for you guys. which pretty much kept me to just search the boards and try to learn by myself. that didn't get far. now i don't mind being wet behind the ears still.  YOU GUYS ARE GREAT! between using the wizard's (jeff travis?) book as reference and bugging you guys with my questions it should make for easier learning of LV (granted it doesn't take the place of experience).  and i promise not to abuse it.

i posted modified versions of both Joe's and Kalin's VIs with some questions on there.  you don't need to respond but these were just questions to clear it up with myself.

again, thanks guys for your help.
Download All
0 Kudos
Message 8 of 10
(5,586 Views)
errr...i just read my reply over and it sounded a little dramatic.  Smiley Indifferent sorry about that...i'm going to go change the oil in my truck now....Smiley Tongue

regards,
adrian
0 Kudos
Message 9 of 10
(5,585 Views)

I made some comments to the pick mod vi. Never be afraid of asking a question here on the forum. I (WE) love to help people learn labview so that they can use this great language to it's fullest potential. However we do have a rule here on the forum.

IF YOU LIKE THE ANSWER AND IT SUITS YOUR NEEDS THEN RATE IT:  Will work for stars.Smiley Wink

and  you can abuse the forums as much as you like that is what we are here for. Even some of the veterans have asked (DUH) questions before.

Have fun with LV, you will learn to love it.Smiley Happy

Cheers,  

Message Edited by Jhoskins on 09-06-2006 07:11 PM




Joe.
"NOTHING IS EVER EASY"
Message 10 of 10
(5,575 Views)