11-10-2016 03:15 PM
Hello all
I'm using Labview 2009, and have a String from Match Pattern, Match SubString that contains 5 digits. Example: 03926 Since the zero is a place holder to denote the 10,000's position, I can not lose it. I need to get that number into a Double Percision format in order to feed it back to an input that is also Double Percision. I have been trying this using Scan from String but can't seem to come up with the right format condition to keep my leading zero, or zeroes. Can Someone help me get past this knot?
Solved! Go to Solution.
11-10-2016 03:37 PM
For the control / indicator, Right-Click -> Properties -> Display Format -> Use Minimum Field width. Note that this is just display, the actual number is still just 3926, to convert it back to string the format is %06f
11-14-2016 02:20 PM
Thanks for the reply, yeah on the note I'll have to play with that part later also. What I would like to do is strip the return string from the sig. gen. down to just the 5 numbers. Exclude numbers like 010, or 001, 100 etc. those would be mode requests (or sends?) on the same line. All the 5 digit numbers are telling me that the sig. gen. is responding to my "u" by incrementing to frequency xxxxx, or "d", decrementing to frequency xxxxx. This 5 digit number I want to convert it to dbl percision, and feed it back to the knob/indicator programmatically keeping that display current with where the sig gen thinks it is. Right now the 001, 010, or 100 gets through as a match. It also skips displaying a match every other time even though the sig. gen. has received my command, stepped the frequency, and sent the 5 digit code. Instead of displaying a match, it says offset past match is -1. The next increament is off by 1, the next mis is off by 2, the next mis puts it off by 3 and so on. Hopefully my attachment took, but the "Manual Stepping Down" case structure is what I am experimenting with. the delays, and some of the stuff in there are experimental or obsoleted themselves after I learned more about Labview. I'm sure there is tons of stuff that is shotty programming in here FYI.
Thanks
11-14-2016 04:29 PM
To match exactly five digits using the Match Pattern function, you'll want to use this syntax:
If you use [0-9]+, it'll match any sequence of digits in the string. String to Number will convert it to a double no matter how many leading zeros there are.
11-15-2016 07:53 AM
THAT, is the ah ha I needed! Thanks pangvady! I noticed something with my other problem where I don't get a match every other read. I was looking at the IO Trace, and in my attempt to just write the switch once, i had the case flip to a blank false side as soon as the switch unpressed. It looks as though that happens so fast that the case flips to false before it even gets to the read command so I can receive the sig. gen. 5 digits. I am guessing I should replace it with maybe a FOR Loop? Because they are both in a While loop, and I want them only used once every time their specific switch is closed. That is the only fix left that I am aware of. I can't wait to see how fixing my format string runs. NOW we are having fun. 🙂
11-15-2016 09:12 AM
I know that some would disagree with me, but I might consider parsing out the whole message, depending on how complicated the message is, because you never know when you're going to need the other stuff. It's usually quite trivial to do this, and you end up looking like the hero down the road if they ever need the info. It's so nice to say, "already done". 😉
Other than that, I don't see a single subVI in the picture you posted. That's like dumping all your text code into main(). It's probably going to be kind of tough to troublshoot.
11-15-2016 09:22 AM
I think what you're trying to do is to read from the instrument if there are any bytes available to read and only write when a button is pushed. In this case, you'll want to put the write and read functions in their own case structures. This way, reading is decoupled from any button state.
This code will work but, normally, event structures should be used for handling any user interface actions in order to get the best performance/readability/use of resources from your software.
http://zone.ni.com/reference/en-XX/help/371361N-01/glang/event_structure/
11-15-2016 09:40 AM
Hey Billko
I like the idea of having it all done and parsed out. As for subvi's, I've only made one once before, and I use it to pull this VI up from a splash screen, (Im not very good at it since buy the time I finish imagineering what I want to do by feel, I have this huge thing. I will work on it. This is the first program I ever really did while I was teaching myself, so alot of the ground work was done before I ever learned about subvi's, or lots of other stuff. Thanks for the guidence.
Dan
11-15-2016 09:47 AM
You do get what I am trying to do pangvady. Thanks, too much compartmental thinking on my part, I never thought to look at it as smaller tasks. That should do It for me. I really want to go back and redo everything but I bet we all think like that. I will just document, document, document. 🙂
Thanks for your help, ideas, and time.
Dan