Problem with 4Dscript

All topics on coding 4Dscript in Enterprise Dynamics.
vincent1989
Posts: 15
Joined: Friday 19 October, 2012 - 15:18

Re: Problem with 4Dscript

Post by vincent1989 »

Hello David,

To achieve what I said you can do the following:

In your model, open the Atom Editor (shift + F5). Go to your source atom under O Model. There you can add an attribute, under "Attributes". Let's call this new attribute "counter".

"counter" needs to be set at 0 each time the model is reset. Go to "Events", and under "Reset" add the line:
'att([counter], c) := 0'.

Now you can, in your source in the model, add the following exit trigger;

do(
Label([productnr],i) := Att([counter],c),
Inc(Att([counter],c))
)

So now for each product that is generated via the source the 'counter' increases 1. This 'counter' is stored in each product under the label [productnr]. Using this label, you can separate the first product from the rest.

In the scara robot, you can for example under the 'pick selection rule' place a condition on this ([productnr]) label.

Let me know if this helps.

Regards,

Vincent.
dawikra405
Posts: 18
Joined: Tuesday 20 March, 2012 - 19:10

Re: Problem with 4Dscript

Post by dawikra405 »

Hi Vincent,

I used your instructions and I've new attribute and then I've put code to source according your advices. When the product leaves source it has label [productnr] but robot has code using label [where] and model works correct, why ? Could you explain me ?

Regards,
David
vincent1989
Posts: 15
Joined: Friday 19 October, 2012 - 15:18

Re: Problem with 4Dscript

Post by vincent1989 »

Hello Dawrika,

The code using [where] tells the robot where to put the current product next (in the server / turntable or on the conveyor). This code is used to perform all the movements you want, but is separate from the routines. The [productnr] tells us the number of the product. The first product has [productnr] = 0 etc. You can use this to separate the first product from the rest.

Regards,

Vincent.
dawikra405
Posts: 18
Joined: Tuesday 20 March, 2012 - 19:10

Re: Problem with 4Dscript

Post by dawikra405 »

Obviously, i know bit I wonder about it:

Source trigger on exit:
do(
Label([productnr],i) := Att([counter],c),
Inc(Att([counter],c))
)

Robot Sen to:
if(Label([Where],i)=0,
Do(Min(NrOC(c), NrOC(c) + 1 - IndexMatch(NrOC(c), 1, OCReady(NrOC(c) + 1 - Count, c)))),
If(|(Label([Where],i)=1,Label([Where],i)=4),3,
if(|(Label([Where],i)=3,Label([Where],i)=6),4,
if(Label([Where],i)=2,1,
if(Label([Where],i)=5,2)
)
)
)
)

So atom source adds label [productnr] but Robot refers to label [where]. Model works correct but it mysterious for me :)
I attached this model.

Regards
Attachments
parallel increasing value of products.mod
(28.02 KiB) Downloaded 275 times
vincent1989
Posts: 15
Joined: Friday 19 October, 2012 - 15:18

Re: Problem with 4Dscript

Post by vincent1989 »

Hello,


if(Label([Where],i)=0,
Do(Min(NrOC(c), NrOC(c) + 1 - IndexMatch(NrOC(c), 1, OCReady(NrOC(c) + 1 - Count, c)))),
If(|(Label([Where],i)=1,Label([Where],i)=4),3,
if(|(Label([Where],i)=3,Label([Where],i)=6),4,
if(Label([Where],i)=2,1,
if(Label([Where],i)=5,2)
)
)
)
)

is basically your routines, but in 4D script, instead of actual routines.


do(
Label([productnr],i) := Att([counter],c),
Inc(Att([counter],c))
)

is used to differentiate products (i.e. give them a number).


Regards,

Vincent.
dawikra405
Posts: 18
Joined: Tuesday 20 March, 2012 - 19:10

Re: Problem with 4Dscript

Post by dawikra405 »

Thanks Vincent. Could you look at my problem in topic Advanced problem, especially third question

Regards

David
Post Reply