01-20-2012 08:53 PM
Hello, I am hopelessly new to Labview, currently taking my first course now.
Question:
I am reading in CHAR from a TCP connection and using a shift register to concatenate them. I need to search this concatenated strings for KEYWORDS, lets say "ON" or "OFF" and then, when these key words are found control boolean outputs, such as turning on an LED or subsiquently turn OFF an LED display on the front pannel.
I am attempting to use the search / split string function with limited success. ATM I can inisially send "ON" and have an LED turn on using a (greater or euqal to 0) function attatched to the Search / split functions Index output. THen I can even get the "OFF" to turn the LED off using the same aforementioned method in conjunction with an XOR gate attached to the boolean LED.
The problem begins after this; After the first time runnng through, It becomes unresponsive and will nolonger "change states".
I will attach the VI i am working with.
01-20-2012 08:57 PM
I forgot to attach the VI i use to test this, it is the TCP communicator - Active in the labview examples
01-20-2012 10:41 PM
I haven't had a chance to really tear into it yet, but I think I've found your problem.
The shift register in the lower loop starts out with a blank string. Each time the loop iterates and there is data at TCP, it gets data appended to it from the TCP. The point here is that the string only gets longer and longer. No data is ever removed from it.
So once this string has one ON, that ON will always be there. Once it has one OFF, that off will also be there. That means that as soon as you have one ON and one OFF, your XOR will always come back false. Adding additional ON or OFF will have no effect. This makes it unresponsive after the first run through.
There are lots of ways to fix it, of course. Perhaps the easiest would be to simply reset your string whenever both ON and OFF are found. (See attached).
01-21-2012 04:03 AM
Oh, man... sorry, I just woke up (at 2:30 AM) and realized I gave you the wrong answer!
So here's the real answer: You're taking the 'offset' value and starting your next string search at the same point in the string where you found ON or OFF the previous time. This means that you keep finding the same ON and OFF in every iteration. Once you have one ON and one OFF, you're saturated and XOR will no longer change value.
You might think you could fix this by inserting a +1 into your offset shift register so that the next search starts after your previous match. However, this won't work because offset will then return to -1, then your next search will start at 0, resulting in the same match being found again.
The easy way to fix this is to only do the Search String on new data, not on the old data. I think this version will work better. (Also, I changed some of your logic. I don't think XOR gives you the functionality you want.)
01-21-2012 08:09 PM
Nice catch of your own mistake! Kudos Have a restful evening
01-23-2012 09:04 PM
Hello, and thanks for the replies. Unfortunately I run labview 9 and I an unable to look at the file you hosted. Is there anyway you could take a screenshot of the block diagram for me?
Thanks
01-23-2012 09:42 PM
LV9 Version attached.