question

Patrick Cloutier avatar image
0 Likes"
Patrick Cloutier asked Patrick Cloutier commented

How to change speed of an entire conveyor system using code

I have a conveyor system loop made of 132 conveyors of the same type. I have a motor connected to all of them to sync power and free dog positions. That works fine.

Now I need to change the speed of the entire system when certain products enter the line.

I tried the following code in my triggering object but in doesn't do anything:

treenode motor= model().find("Motor1");

motor.targetSpeed = 4;

Maybe I can't reference the motor to do this. But how would I reference the conveyor type instead of all the 132 sections ?

Thanks,

FlexSim 17.1.4
conveyor speed
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Arun Kr avatar image
0 Likes"
Arun Kr answered Arun Kr commented

Hi @Patrick Cloutier,

You can try the following code. One thing to note is, the motor doesn't have a speed property. So the expression " motor.targetSpeed" is invalid.

And conveyor references are taken from the motor via conveyors node in the variables.

Object Motor = model().find("Motor1");
double SpeedValue = 100;
treenode VarNode = getvarnode(Motor,"conveyors");
for(int k=1;k<=VarNode.subnodes.length;k++)
{
treenode ChildNodes = VarNode.subnodes[k];
Conveyor ConveyorRef = ownerobject(tonode(ChildNodes.value));
ConveyorRef.targetSpeed = SpeedValue;
}

Regards,

Arun KR

· 7
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Jeff Nordgren avatar image Jeff Nordgren commented ·

@Patrick Cloutier

@Arun KR

You can easily change the speed variable of a Conveyor Type by using this code:

model().find("ConveyorSystem>variables/conveyorTypes/ConveyorType1/speed").value = 5;

This changes the variable just like it would if you entered into the Properties Window of the Conveyor Type. But just changing that variable won't change the speed of that type of conveyor in a running model. Not sure there is a way to change the speed of conveyors in a running model. One problem, is that is would have to change conveyor "events" that were created when a flowitem entered a conveyor. That would be "ugly" to figure out for each potential flowitem that could be on a conveyor at any given point in a model.

But if you used the above code and then did a model reset, it would change the speed of all conveyors of that type in the model. But not sure that is helpful in your case Patrick.

0 Likes 0 ·
Arun Kr avatar image Arun Kr Jeff Nordgren commented ·

Hi @Jeff Nordgren,

Pls see the attached model. I was able to change the conveyor speed dynamically based on the type of flow items entering the conveyor. The code is inside the decision point.

If the model logic is useful or not Patrick can confirm.

Regards,

Arun KR

2 Likes 2 ·
patrick-support.fsm (19.6 KiB)
Patrick Cloutier avatar image Patrick Cloutier Arun Kr commented ·

Thanks a lot Arun. That seems to be working fine. But I'd like to understand how it works. Correct my understanding:

It loops through all the conveyors linked to the Motor and changes their speed individually. Is that correct?

1 Like 1 ·
Show more comments
Show more comments
Patrick Cloutier avatar image Patrick Cloutier Jeff Nordgren commented ·

I'm very surprised that this is not a standard option either in decisions points or motors as this is a very common situation in paint lines and other types of chain conveyors.

2 Likes 2 ·
Jeff Nordgren avatar image
1 Like"
Jeff Nordgren answered Patrick Cloutier commented

@Patrick Cloutier

Using basically the code that @Arun KR used in his reply, I changed the model a little. Because the goal is to change the speed of all conveyors connected to a Motor, it seemed more logical to have that code on the Motor and not on a DP.

I changed it so that you can send a message to the Motor with the first parameter being the speed you want to change the conveyors to. I added a "Speed" label to the flowitems and in the DP I send a message with the first parameter being the item.Speed label.

Would something like this work for you? And yes, it does loop through all the conveyors connected to the Motor.

change-conveyorspeed-sample1-v1714.fsm


· 2
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Patrick Cloutier avatar image Patrick Cloutier commented ·

Yes that works well. Thanks a lot guys.

0 Likes 0 ·
Patrick Cloutier avatar image Patrick Cloutier commented ·

Is it normal that, even if it works, the speed indicated in the conveyor type parameters always remains the same as I put in the beginning? No matter how many times I change it with the code you supplied. That is not a problem but I just wanted to know if its normal behavior.

Thanks,

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.