LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to compare 1D array

Solved!
Go to solution

I am reading data from inport in hex form and save it in array to compare data with 0100800000D0..  how can i make hex constant array to store 010080000D0... and then compare it with the array that store data from inport.. (Actually it works as check)

Or there is any other good option

timmy
0 Kudos
Message 1 of 18
(5,595 Views)

You don't need to make array to compare. You can directly compare data array with hex reference number it will give comparison answer in form of Boolean array.

PBP
Labview 6.1 - 2019
0 Kudos
Message 2 of 18
(5,591 Views)

Thanks parashant for your reply

timmy
0 Kudos
Message 3 of 18
(5,561 Views)

I am receving data in single byte like 00, 01 or 08.... But my check is 5byte thats why first i store my data in array and than want it to compare. On comparing if its true than i have to send data..

timmy
0 Kudos
Message 4 of 18
(5,557 Views)

Can you send me your VI with comment so that I can understand the code functionality.

PBP
Labview 6.1 - 2019
0 Kudos
Message 5 of 18
(5,550 Views)

To create a hex constant array:

1. drop an array constant onto the block diagram

2. Add a numeric constant to the block diagram and drag it into the empty array constant

3. right click on the numric in the array and select representation. Select U8

4. right click on the numric in the array and select display format->hexadecimal

5. click on the edge of the array and drag it to expand it to the required size

 

you can then put the values you want to compare in it, and use the equals sign to compare. Right click the equals sign and select comparison mode-> 'compare aggregates' 

 

Hope that helps,

 

Chris

Regards,
Chris Vann
Certified LabVIEW Architect
0 Kudos
Message 6 of 18
(5,518 Views)

@InDo asia wrote:

I am receving data in single byte like 00, 01 or 08.... But my check is 5byte thats why first i store my data in array and than want it to compare. On comparing if its true than i have to send data..


  • The string diagram constant on your diagram is 10 bytes, not five. Try hex display instead before entering.
  • Do you (1) stream until five consecutive bytes match the desired pattern, or do you (2) read exactly five bytes, then compare with the constant? In case (2), the outer while loop should probably be a FOR loop. Autoindex at the output tunnel and you get an array with five elements.
  • What is the purpose of the inner while loop. Should it have a small wait?
  • You get an I8 value, so doing a logical AND with xFF in the inner loop does not do anything useful. Right?
  • What's up with all these sequence structures? None are needed. Use the error wire to enforce execution order instead.
  • You can use "stop if true" so you don't need to invert the boolean.
  • You forgot to include the subVI. Please attach it.
  • ...

Here's a quick draft (case 2 above) to get you some ideas. More code is needed to make a complete program, e.g. the inner loop will run forever if there is a problem. Not good.

 

 

0 Kudos
Message 7 of 18
(5,497 Views)

Thanks Parashant, Chris and specially Altenbach

Sorry for late reply.. After my last mail I went on site.

 

I want to stream the data until 5 consective bytes match the pattern and the inner while loop is used to ensure data reading... So that what ever is send it must be read. The code is under work so thats why its like that and I am a new user.

I will reattach the subvi as soon as I reach back to office.. The missing vi is used to send data.. The string is converted to bytes=n and send by outport by n-1 formula using while loop i...

While(Bytes=n, i=0, i<=n-1)

{

outport data

}

The data is send on receving consecutive 5 same bytes.

timmy
0 Kudos
Message 8 of 18
(5,460 Views)

Kindly download the attached files.....kindly suggest me a possible check for continous reading and then continous comparing with constant 5byte data

Thanks

timmy
Download All
0 Kudos
Message 9 of 18
(5,430 Views)

Hi Timmy,

 

Check attached VI and give me feedback.

 

 

Prashant Patel

PBP
Labview 6.1 - 2019
0 Kudos
Message 10 of 18
(5,421 Views)