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.

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

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
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.