LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Max and Minimum values incorrect for serial communication - VISA - MLX90621

Solved!
Go to solution

Hello All,

I have a temperature sensor of resolution of (4*16)  and am reading the values through a serial port using VISA - (The values keep refreshing very quickly). The output array values are correct but when i try to see the max and min values from the same array they are incorrect. 

Could some one please help me, i have just started learning labvew. 

And please excuse me if this is a dum question. 

Download All
0 Kudos
Message 1 of 16
(3,331 Views)
Solution
Accepted by topic author Aaatif

I see 3 problems with your code.

 

1.  Move the VISA Conguration subVI outside of your while loop.  it should be only done once at the beginning of your VI.

2.  You are doing an array Max and Min on a array of strings.  You need to be converting those strings to doubles.  Comparisons of doubles will give you the largest and smallest.  Comparison of strings will give you what is alphabetically first and alphabetically last.

3.  Finally, your not accounting for the space that is coming right after the comma.  Everything that is after the 1st column in your data has a space in front of it, and that is messing up the alphabetically comparison of your string versions of the numbers.  A space charcter comes alphabetically before a digit character.  So "{space}34.11" comes alphabetically before "33.04" and thus makes 33.04 look like the largest number.  In effect, your method is really only giving your the largest number in the first column, and the smallest number in the remaining columns.  Fix point #2 and this problem goes away.

 

Your parsing of the string into individual string elements could be handled a lot easier than that while loop you have in there now.  Use Spreadsheet String to Array in the  String pallet using comma as a delimiter and you'll be able turn that entire while loop of code into a single node.

Message 2 of 16
(3,304 Views)

thank you so much, will try it out like your advise/direction and keep you updated.

0 Kudos
Message 3 of 16
(3,257 Views)

Hello 

Download All
0 Kudos
Message 4 of 16
(3,229 Views)

That looks good.  It looks like it is working like you want now.

 

There is one change I would make that relates to LabVIEW style.  Your boolean control, the stop button, that stops the loop doesn't have  any label.  All terminals on a block diagram should have their label shown.  If you don't want the label on the front panel, that is fine, just change visibility of the label on the front panel, but don't do it on the block diagram because that is the primary way for someone looking at your code to know what that terminal is for.   Hide the front panel, label, but don't hide the diagram label, and don't do something like delete the characters out of the label.

Message 5 of 16
(3,217 Views)

Hello 

 

 

0 Kudos
Message 6 of 16
(3,194 Views)

Hello 

 

 

0 Kudos
Message 7 of 16
(3,194 Views)

I'm glad to hear it is working for you.

 

If I may offer 2 more tips.

1.  Use block diagram cleanup.  Several wires run "backwards" making them harder to follow.

2.  Check your spelling of the word "temperature" on the  front panel.  You left out an "e".

Message 8 of 16
(3,172 Views)

WOW, did not know all this functionality. I think i like LabView even more.

Thank you again RavensFan for your patience and advise.

Attached is the corrected .vi.

Regards 

Atif

0 Kudos
Message 9 of 16
(3,149 Views)

Hello Again,

One last question im unable to output sound from the laptop if the max temp or min temperature is reached. Im using the beep function .. any advise ? 

 

Atif

0 Kudos
Message 10 of 16
(3,118 Views)