In a previous article, we explained how to send commands to the robot. In this article, we will explain how to use the monitoring port to get information about the robot and display them on a LabVIEW front panel.
Meca500 Monitoring Port
As mentioned in the previous article, we can send commands to the robot through port 10000. To monitor the status of the robot however, the port 10001 is used. While only one connection to the control port can be created at any time, many connections to the monitoring ports can be created at the same time.
The robot sends information to the monitoring port at a fixed rate. The default delay is 15ms but can be changed using the command SetMonitoringInterval(n). The information sent to the port is:
[θ1, θ2, θ3, θ4, θ5, θ6]
[x, y, z, α, β, γ]
[as, has, sm, es, pm, eob, eom]
Again, every message sent by the robot ends with the ASCII null character \x00.
String Handling in LabVIEW
To get the status of the robot from the monitoring messages, some string handling is required. The big challenge here is that the messages are not of fixed length and the TCPRead doesn’t allow searching for a specific end of line character. The strategy to extract the messages and contents is:
Use the TCPRead function with a relatively small number of bytes to read. In our example we use 30.
Concatenate the new message with the previous one. This is because the message will not be complete after one read action and even when a message is complete, there is usually some left over data that is part of the next message.
Then we search for the character “\x00” in the string. Here two things can happen:
If we find the character, everything before it is passed along to be parsed. This is a complete message. Anything after the character is part of the next message and is then passed to be concatenated with the next message.
If no character is found, the string is passed on to be concatenated with the next one.
Select which string to parse:
If no new message is passed along to be parsed, the previous one is used
If a new message is passed, it is used instead of the previous one
Find the message code by checking the 4 characters that appear after the first bracket. This is fixed length so it is easy to do with LabVIEW’s string handling functions.
The message code is sent to a case structure as well as the whole message.
For every code, the data is extracted in the same way, only the quantity of data points changes.
Search for a “,” character in the string starting with an offset of 7. The offset is the brackets and code.
Everything after is fed to the next search function and step 8 is repeated with an offset of 1 instead of 7.
All the values extracted are displayed on the front panel.
The connection is created outside the while loop and the port 10001 is used. The default IP address is 192.168.0.100.
TCPRead and message extraction
This section might look a bit complicated but this is because some LabVIEW functions behave in a very specific way and we need to add some blocks to make it work the way we want.
This section corresponds to the steps 2-4 described earlier where we read the TCP port and extract the message.
The message parsing is fairly simple as it is a cascade of search functions and data conversion functions. For each code number, we parse the message the same way but with different outputs. We also add an empty "Default" case for the codes that we don't want to manage.
Monitoring the Meca500 robot on labview can be useful when creating most front panels. For instance if a jogging panel needs to be created, the monitoring is very useful to know if we approach the limits of the joints for instance. It can be a bit difficult to create since the string handling in LabVIEW is not the easiest thing to do, but as shown in this example, it is doable with a little bit of work.
Was this article helpful?
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
We appreciate your effort and will try to fix the article