Advanced non accumalating conveyor position

All topics on coding 4Dscript in Enterprise Dynamics.
Post Reply
JimH
Posts: 2
Joined: Thursday 11 February, 2016 - 16:30

Advanced non accumalating conveyor position

Post by JimH »

Hi guys,

It's been some time since I've worked with ED, so I'm still a little rusty with my 4d script.
I was wondering if it is possible to trigger an event to move one product from 1 non accumalating conveyor to another. I know it is possible to do this with a sensor and then open/close a channel, but I want to this based on the position of the conveyor. Why? Because my goal is to run the position/speed of the conveyor from a PLC and retrieve this data in ED so I can emulate my model.
There needs to be 15 positions on 1 conveyor from which a product can be transferred to a second conveyor. Any help would be much appreciated!

Thanks
User avatar
HarryBunnik
Posts: 362
Joined: Monday 07 February, 2011 - 11:22

Re: Advanced non accumalating conveyor position

Post by HarryBunnik »

Ha JimH,

This is a quite tricky thing (and I hope I can give you something to make a start with). First of all you'll need the function "Conveyors_PreliminaryExit". Hopefully you have the option to go into the atom editor and can check the code there (TRANSPORT\General Conveyor Functions). That makes it a bit easier to see what I tried to do. I've added a small example model so you can see:
ConveyorEarlyRelease.mod
(19.27 KiB) Downloaded 238 times

What I've made are 2 functions using a User Events atom (You most likely want to do this in your own UserEvent which makes it a bit more flexible) named Release1 and Release2 (using User events makes life a lot nicer here since you can catch all then in one event instead of separate ones... ) which will trigger the release code from the conveyor.

Code: Select all

Do(
  SetCS(i), {Needed in the SendTo statement of the conveyor since c no longer will refer to another atom by the time we want the product to be released}
  Conveyors_PreliminaryExit(i {Product], up(i) {Conveyor}, 1 {Exit channel, will be 2 in release 2}), 
  Error([Triggered release 1]) {A check if it is doing something.}
)
On the OnEntry trigger of the conveyor I've placed the following code, which is alternating between the 2 outgoing channels. It sets then a label on the product with its exit code and calls the related release function.

Code: Select all

Do(
  If(
    Mod(input(c), 2) + 1, 
    Do(
      Label([Exit], i) := 1,
      Release1
    ), 
    Do(
      Label([Exit], i) := 2,
      Release2
    )
  )
)
Then I set on the Send to statement of the conveyor that it must be send to the exit channle that is defined on the label on the product (which we now have to refer to as "cs"):

Code: Select all

Label([Exit], cs)  
If I now run the model, the products are going of at the requested points. However I guess that I will run in problems when there is no space for the product to go to... But I think that is for later concern. ;-)

I hope this helps you a bit further.

Cheers,

Harry
JimH
Posts: 2
Joined: Thursday 11 February, 2016 - 16:30

Re: Advanced non accumalating conveyor position

Post by JimH »

Hi Harry,

This is exactly what I needed to get me started. Thanks!
As this is a project outside of working hours, I don't have much time to spend on this. But I'll try and keep you posted.

Once again thanks,

Jim
Post Reply