How to tell robot what kind of product triggered the sensor

I have several different trays moving on conveyor and when they reach sensor that stops the conveyor a robot has to place product that matches the tray type. I have made different routines for each tray type but how I can tell the robot what kind of tray is at the sensor so that right subroutine can be called?

You can use some of informations contained in this video:
on sensor use componentssignal and in script read what type of component it is(componentsignal.Name(or Value, i am not sure)), then use if/else to compare names of signals with components that you want to identify and in the end set different bools to True for sending this signals to robot input. In robot program just make if/else loop where you check which type of component it was and then let robot decide which path will he go.

Yeah I was trying to do something like that but just didn’t get it to work. Here is the script I’m using:
from vcScript import *
from vcHelpers.Robot2 import *
def OnRun():
robot = getRobot()
comp = app.findComponent(“Sensor Conveyor”)
sensor_signal = comp.findBehaviour(“SensorSignal”)
while robot.SignalMapIn.input(0) != True:

tray = sensor_signal.Value
ID = tray.getProperty(“Name”)
print ID
if ID == “t1”:
elif ID == “t2”:
elif ID == “t3”:

The problem with this is that I don’t get name property of the trays and I’m not sure why that is. I tried to print the ID variable to see what it holds but it gives me this: <vcProperty object at 0x000002844CE0C748> so I have no idea what it actually contains. I also tried to read what that memory place holds with ctypes.cast but it only gave me blank space so either it didn’t work or it actually just has blank space in it?

getProperty returns a vcProperty object. To get the value of the property called “Name” just do like this:

tray = sensor_signal.Value
ID = tray.getProperty(“Name”)
print ID.Value

or an easier way to get the value of property called “Name” directly is:

tray = sensor_signal.Value
print tray.Name

Yes it works now. Thank you for all the answers.

1 Like