Create a cycle time of Assembler atom that depends on product

All topics on coding 4Dscript in Enterprise Dynamics.
ASV
Posts: 8
Joined: Tuesday 31 March, 2020 - 19:43

Create a cycle time of Assembler atom that depends on product

Post by ASV »

Hi :)

I am using Enterprise Dynamics for my project at the University, and have a problem. I am fairly new to Enterprise Dynamics, so hopefully, someone can help me out.

I want to put two different products in a container with the use of an Assembler atom. All though, I would like to make the cycle time of the Assembler depending on the product that enters the Assembler atom. At the moment I am using the following "Trigger on exit" for the two products respectively:

Product 1: Label([Element], i) := 1
Product 2: Label([Element], i) := 2

At the same time, I am using the following code on the cycle time of the Assembler atom, which in my belief would state that if the product/element is labelled with number 1, then the cycle time would be the first Bernoulli distribution. And if not, the cycle time is the second Bernoulli distribution.

If(Label([Element], First(c)) = 1, Bernoulli(75, 8, 16), Bernoulli(75, 3, 6)).

The B.O.M list in the Assembler atom is set out to assemble one Container, one of Product 1 and one of Product 2 before it can move on.

My problem is that when I do this, it always follows the last argument (Bernoulli distribution no.2: Bernoulli(75, 3, 6)), even though the highest cycle time comes from the first Bernoulli distribution. I have tried with true numbers instead of Bernoulli, but the same thing happens.
ED_model.JPG
ED_model.JPG (67.43 KiB) Viewed 13519 times
User avatar
HarryBunnik
Posts: 362
Joined: Monday 07 February, 2011 - 11:22

Re: Create a cycle time of Assembler atom that depends on product

Post by HarryBunnik »

Ha ASV,

Welcome to the community!

There are a few things to take into account here:
  • You're referring to the product with first(c). However, that is the first atom in the current atom (the assembler itself). This is most likely the container, and not the product you try to influence. That has no label, therefore returns a 0, which makes it end up at the second Bernoulli statement.
  • You have to place the code, which looks good, on the "Trigger on entry channel 2...n".
  • In this entry trigger you can use "i" (involved atom, so the atom the triggered the atom by entering the assembled). That way you don't need to know what the position of the atom is in the assembler, but can directly refer to it. Note that "i" is not always possible to use, but when checking the predefined code, you can quickly see what to use where.
I hope this helps you further!

Cheers, Harry

P.S.

If you get more than just 2 products, you should take a look at the case-statement in 4Dscript. This makes the code a bit more clean :-) And you can check if a label is not existent (returns a 0).
ASV
Posts: 8
Joined: Tuesday 31 March, 2020 - 19:43

Re: Create a cycle time of Assembler atom that depends on product

Post by ASV »

Thank You Harry!

I now understand why I should not use First(c) in the cycle time code and have tried to implement the changes into my simulation model. All though, it does not work. Therefore, just to make sure I have understood your response correctly:

What should be written in the following:
  • "Trigger on exit" in the Source atoms
  • "Cycletime" in the Assembler atom
  • "Trigger on entry channel 2..n" in the Assembler atom
Regards
User avatar
HarryBunnik
Posts: 362
Joined: Monday 07 February, 2011 - 11:22

Re: Create a cycle time of Assembler atom that depends on product

Post by HarryBunnik »

Sorry, here I was a bit to quick and only went through half of your question.
  • In the OnExit of the source, you indeed create the labels identifying the products.
  • I would write the code on the "Trigger on entry channel 2..n" in the Assembler atom and write the outcome away in a label called "ProdCycleTime" on the product (that way you are also directly logging what the CycleTime of each product is). Then I would write this value in a label on the assembler itself as well and use that for the CycleTime.

    Code: Select all

    Do(
      If(
        Label([Element], i) = 1, 
        Label([ProdCycleTime], i) := Bernoulli(75, 8, 16), 
        Label([ProdCycleTime], i) := Bernoulli(75, 3, 6)
      ),
      Label([CurAssemblerCycleTime], c) := Label([ProdCycleTime], i)
    )
  • Then on the CycleTime on the GUI of the assember, I would read out that CycleTime from this label.

    Code: Select all

    Label([CurAssemblerCycleTime], c)

I hope this helps you further!

Cheers, Harry
ASV
Posts: 8
Joined: Tuesday 31 March, 2020 - 19:43

Re: Create a cycle time of Assembler atom that depends on product

Post by ASV »

Hi Harry. That's okay, I'm just glad you offer your service!

I have written the following in the "Trigger on exit" for the Soruce atom:

Product 1: Label([Element], i) := 1
Product 2: Label([Element], i) := 2

The following in the "Trigger on entry channel 2..n" in the Assembler atom:

Do(
If(
Label([Element], i) = 1,
Label([ProdCycleTime], i) := Bernoulli(75, 8, 16),
Label([ProdCycleTime], i) := Bernoulli(75, 3, 6)
),
Label([CurAssemblerCycleTime], c) := Label([ProdCycleTime], i)
)

And the following in Cycletime of the Assembler:
ASV
Posts: 8
Joined: Tuesday 31 March, 2020 - 19:43

Re: Create a cycle time of Assembler atom that depends on product

Post by ASV »

Sorry, the last repost was not finished, and I can't seem to delete it.. Here it is in full length.

Hi Harry. That's okay, I'm just glad you offer your service!

I have written the following in the "Trigger on exit" for the Soruce atom:

Product 1: Label([Element], i) := 1
Product 2: Label([Element], i) := 2

The following in the "Trigger on entry channel 2..n" in the Assembler atom:

Do(
If(
Label([Element], i) = 1,
Label([ProdCycleTime], i) := Bernoulli(75, 8, 16),
Label([ProdCycleTime], i) := Bernoulli(75, 3, 6)
),
Label([CurAssemblerCycleTime], c) := Label([ProdCycleTime], i)
)

And the following in Cycletime of the Assembler:

Label([CurAssemblerCycleTime], c)

It gives me the result seen in the picture.. Where it only can assemble the blue product, and none products are visible in the containers anymore.. What I am doing wrong? :(
ED_model.JPG
ED_model.JPG (46.83 KiB) Viewed 13492 times
User avatar
HarryBunnik
Posts: 362
Joined: Monday 07 February, 2011 - 11:22

Re: Create a cycle time of Assembler atom that depends on product

Post by HarryBunnik »

Can you add your model, so I can have a look?

It can be that the B.O.M is not correct and not accepting other products, or that the checkbox for the display contents is not set, or...
ASV
Posts: 8
Joined: Tuesday 31 March, 2020 - 19:43

Re: Create a cycle time of Assembler atom that depends on product

Post by ASV »

I saw that at had not checked the display contents in the Assembler atom. Sorry about that.

The file is attached. I have switched the location of the codes you provided, as I think I might misunderstood them. Let me know what you think is my problem.

Thanks
Attachments
Draft.mod
(31.7 KiB) Downloaded 328 times
User avatar
HarryBunnik
Posts: 362
Joined: Monday 07 February, 2011 - 11:22

Re: Create a cycle time of Assembler atom that depends on product

Post by HarryBunnik »

Ha ASV,

What I see is that you swapped the code for the Entry trigger and the cycle time. When the product is entering the assembler, we already want to calculate the cycle time and place it on the product and the assembler using labels.

First then the assembler its cycletime is set. This way the referencing to the correct product is easier.

However, I see that you have a B.O.M. where you need one container, one product 1 and one product 2. So you'll have 2 products on you container this way. If that is your goal, then it's all ok. But then you'll need to think how your cycletime is build up, because you now use 1 cycletime for 2 products (see the help) since the cycletime is for the complete assembly and not for placing a single product on a container. And it is also first starting when the B.O.M. is complete.

If you want 2 different assemblies, where each has a different product on a container, you'll need to add a second column to your B.O.M. and write some 4Dscript code to define product you want to place on the container in the field referring to the column reference.

Success!

Harry
ASV
Posts: 8
Joined: Tuesday 31 March, 2020 - 19:43

Re: Create a cycle time of Assembler atom that depends on product

Post by ASV »

Hi Harry.

Thanks! I now get why my model is no good, and that the cycle time is for the complete assembly and not for placing a single product on a container.

How would you recommend that I solve my problem then? My goal is to assemble two different products in one container, and that the products have different processing times, which follows a Bernoulli distribution.

Hope you can help!
ASV
Post Reply