postformac Posted April 12, 2009 Report Share Posted April 12, 2009 Hi, I'm reading a floating point number from an external source over serial (its a PIC giving a voltage reading as an ASCII string output) It works great but I am having difficulty finding a way to display the data to a set number of decimal places. I have tried changing my indicator to a number of different display formats, but they all have issues with certain values. For example, if my incoming string reads "1.123" and I set my display format to floating point with 3 digits of precision, don't hide trailing zeros, it works perfectly and shows "1.123" on my indicator. If the incoming string reads "1.023" it then displays "1.0230" on my indicator, I assume that it doesn't count the first zero as a digit. If I hide trailing zeros then it works with either of the above examples but if the string reads "1.100" then I just get "1.1" on my indicator. Either way the number of digits on my indicator changes according to the data coming in. I just want it to show 3 decimal places, so either "1.123", "1.023" or "1.100" depending on the input string. Is there any way to fix it like this? I don't want the display to keep changing the number of digits after the decimal point. Thanks Quote Link to comment
PA-Paul Posted April 12, 2009 Report Share Posted April 12, 2009 Hiya, Just had a play with this in lv 8.6.1, the following setting for the display format (right click on the indicator, then select "Display format") should do what you want: This does assume you're using a "numeric" indicator to display your data... Hope that helps Paul Quote Link to comment
postformac Posted April 12, 2009 Author Report Share Posted April 12, 2009 Thanks for the reply. I had tried it set like that, and was getting the data back as I described in the original post. However, I just tried with a new VI as a test and it works fine. I went back to the original VI and checked all the settings, which were the same, but that was still adding zeros on the end when there was a leading zero (ie. "1.023" would read "1.0230") I went into the advanced editing mode and found that on the new VI it had "%.3f" as the format string but on the original it had "%_3f". I changed it manually and it works perfectly now, not sure what caused that! Thanks anyway Quote Link to comment
Neville D Posted April 14, 2009 Report Share Posted April 14, 2009 QUOTE (postformac @ Apr 11 2009, 09:50 AM) I went back to the original VI and checked all the settings, which were the same, but that was still adding zeros on the end when there was a leading zero (ie. "1.023" would read "1.0230") Check "Hide Trailing zeros" in the menu shown above in another post. Neville. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.