Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

Select Inspection with TCP I/O

Hello,

 

I'm using Vision Builder 3.5. On the machine, I have one inspection per product. So, I need to be able to change the inspection very easily.

 

The vision system is installed on a dedicated computer. The picture aquisition is triggered by TCP I/O. When the vision system receive 1GO or 2GO or 3GO (the number 1, 2, 3 is an identification matching to recognize the answer but not important), I make an aquisition and the specific inspection. To receive this trigger, I'm using the TCP I/O and I'm waiting on 3 Bytes with a timeout of 1000ms. This part work perfectly.

 

I have a problem, with the Inspection Selection. The Inspection Selection is also waiting on a TCP information. To select the good inspection, at every start of the running mode of the machine, I send 4 bytes to Select the correct inspection (For example 4120 to load 4120.vbai). Now I have some problem. I need to send several times the 4120 from the machine to the Vision System to load the correct inspection. Sometimes after 30 retry, the good inspection is not loaded. The TCP I/O is waiting on 4 bytes with a timeout of 5000ms.

 

First, I would resolve this problem and second, I would work with a Termaison Charater to load the good inspection, because, I would not be fixe with 4 bytes.

 

Someone have encountered the same problem ????

I don't know if the waiting of the Picture aquisition erase the message to select the inspection ??? It work in sequence or in parrallele ????

 

Thank you for your help.

 

F.Michel

0 Kudos
Message 1 of 6
(4,006 Views)

Hi,

 

What is happening is that the TCP step you have in the inspection that waits for the trigger "steals" the bytes you send and were intended for the TCP step you have in the Product Selection state.

Is it possible for you to use Modbus/TCP instead of simple TCP frames on the device that currently sends the TCP commands to Vision Builder? Which language are you using to currently send the TCP commands? We have a Modbus library you can use if you're programming in LabVIEW.

If you're open to using the Modbus protocol, there is a clean solution, which is to use different Modbus Registers for triggering the acquisition and switching inspections.

If changing protocols is not an option for you, there is a solution, that is a little more complex:

In the inspection, store the TCP string received in a global variable, then use a calculator step to determine if you received a trigger string, or a product select string.

If you received a product select string, use the Modbus step to store the result in a Modbus register.

In the Product Selection state, read that register and switch to a new product based on the content of that register.

I've attached an example. Copy them in the Example folder of Vision Builder. You'll need to create the product selection state on your computer. Let me know if you have any question.

 

Hope this helps.

 

Best regards,

 

-Christophe

NI Vision R&D

0 Kudos
Message 2 of 6
(3,976 Views)

Hello,

 

Thank you for your very interessant answer.

 

I'm trying your solution and it is working fine. Thank you.

 

Now I'm trying to be able to use some "string" for the Select Inspection. When I set the Product Selection value to the ModBus register, I can't change the type of the output, only numeric.

It is possible to set as "string" ??

 

Thank you

 

Frédéric 

0 Kudos
Message 3 of 6
(3,961 Views)

Yes, it is possible. See attached example. I slightly modified the inspections I attached earlier to

1) Store a string in the modbus register.

2) Only update the Modbus register when we receive a Product Select string. This should make the inspection more robust.

 

The Analyse TCP String step now returns a string for the new product and a boolean to notify if we received a new product string. This way, we're not updating the Modbus register when we timeout or not receive a product string.

In the Product Select Register step, you can specify the type of data to store in the Modbus register. Choose ASCII to store a string.

Same thing when you read from the register in the Product Select state. Choose ASCII.

In both cases, when you select ASCII, you have to specify the number of registers to write. It needs to be at least half the size the string you're writing. Half the size, because the size of a modbus register is 2 bytes.

The only catch is the string you're reading from the Modbus register is always going to be the size you specified in the Modbus step. ie if you specified to read 5 bytes, the string returned will always be 10 characters. Keep that in mind when you perform the comparison in the Product select step. Even if you're sending a shorter string (say "125"). The string returned by the Modbus Step will be "125\0\0\0\0\0\0\0". This is the value you need to use in the Product Select step.

Hope it makes sense.

 

Best regards,

 

Christophe

0 Kudos
Message 4 of 6
(3,951 Views)
Not sure how the smiley got there...
0 Kudos
Message 5 of 6
(3,950 Views)

Hello,

 

Thank you for your very good support.

 

Now, I can use some "string" to select the inspection. And the select inspection is working very well.

 

Regards,

 

Frédéric M.

0 Kudos
Message 6 of 6
(3,935 Views)