LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Count Occurence of Strings

Hello,

 

I am new to LabVIEW. I am communicating with LV via a robot. The robot is constantly sending updates of its position to LV via TCP/IP. The robot sends LV these positions as seperate messages as strings. In LV, I want to count how many messages (strings) it receives in 1 second. Anyone have any ideas on how to do that?


Thanks in advance for any help!

SM

0 Kudos
Message 1 of 23
(1,587 Views)

Use the Search Replace string function, telling it to replace all found instances, and the returned function will tell you how many it replaced.  You don't need to actually used the replaced string.

0 Kudos
Message 2 of 23
(1,581 Views)

I guess I also failed to mention I need to display the resulting number of strings per second as a DBL. How would I do that?


Thanks,

SM

0 Kudos
Message 3 of 23
(1,577 Views)

With either a feedback node, to track how much time has gone by over a period of time.  Or you use something like the Elapsed Timer VI, which will only trigger once every set amount of time.  So either calculate how much time has gone by, or set a known about of time to go by and use that in your calculation.

0 Kudos
Message 4 of 23
(1,564 Views)

Could you show me an example, I think I'm confused on what you are trying to say Hoovah.

 

Thanks,

SM

0 Kudos
Message 5 of 23
(1,557 Views)

No problem.  By the way this picture is executable code, no need trying to recreate it.

 

Example_VI.png

0 Kudos
Message 6 of 23
(1,551 Views)

I tried doing that with my incoming string as the input and it didn't really work. Any other suggestions?

 

Thanks,

SM

0 Kudos
Message 7 of 23
(1,538 Views)

What does "it didn't work" actually mean?  If you want suggestions, please post your latest VI so we can see what you've tried.  Post it with the incoming data saved as a constant or as default data in a control so we can see what the data looks like.

0 Kudos
Message 8 of 23
(1,534 Views)

Well I mean it doesn't count how many strings are received per second. I can't post it because it has too many things in it. The data is just an incoming string that starts with "10....", so I tried what Hoovah suggested, and searched "10" but all it is doing is saying "0.0001" and stays that way. Attached is a screenshot of my code.

 

Thanks,

SM

0 Kudos
Message 9 of 23
(1,531 Views)

How fast is your loop running?  If it is running once a millisecond, and you get 10 strings, then your calculations are going to be .0001.   (And don't you want to take the number of string and DIVIDE BY the time to get strings / second?  Right now you are seconds per string.)

0 Kudos
Message 10 of 23
(1,525 Views)