Conveyor sensor

All topics on coding 4Dscript in Enterprise Dynamics.
Post Reply
PeutLeVoir
Posts: 2
Joined: Thursday 01 January, 2015 - 22:46

Conveyor sensor

Post by PeutLeVoir »

I have following problem.

I have one main conveyor (which consist of a few sections) and some perpendicular side conveyors connecting to the main conveyor. There are manipulators which carry product from side conveyor to the main conveyor. When product apeears at the end of side conveyor, sensor check if product on main conveyor (it has higher priority) is closer than 1 meter. If not – manipulator take product and carry it to next section of the main conveyor. If distance is shorter than 1 meter, manipulator waits.

I use advanced conveyor which has sensors I put sensor one meter befor its outskirts with code:

Code: Select all

do(
if(Status(AtomByName([manipulator1], Model))=2,closeoutput(c)),
closeinput(atombyname([manipulator1],Model))
)
and release sensor trigger:

Code: Select all

closeinput(atombyname([manipulator1],Model))
but further there is problem with opening outputs/inputs if they are closed, so i added condition control:
with expression:

Code: Select all

status(atombyname([robot1],Model))=1
and action on true

Code: Select all

openoutput(atombyname([mainconveyor1],Model))

I am not sure if it's good solution. Can you give me some advice, another solution how to solve my problem?
User avatar
HarryBunnik
Posts: 362
Joined: Monday 07 February, 2011 - 11:22

Re: Conveyor sensor

Post by HarryBunnik »

Hello,

Without a small model showing the behavior, its a bit difficult to suggest improvements, but it sounds to me as a workable method.

The only point I have is the repeated usage of the commando "AtomByName", which is a slow way of finding an atom. Especially when you have larger models, it will kill your performance. So I would suggest to refer to these atoms using channel references (out, in, next, last etc), or in cases you really need an atom all through your model, creating a global variable for it "Dim([refGlobalReference], vbAtom, AtomByName([....], model))" in a Initialize atom. That way you use the "AtomByName" only once on initializing, instead of constantly and you can refer to your desired atom using "refGlobalReference".

I hope this helps you a bit,

Cheers,

Harry
Post Reply