News:

SMF - Just Installed!

Main Menu

Custom Workpart

Started by pablo.martinez garcia, January 17, 2023, 07:50:12 PM

Previous topic - Next topic

pablo.martinez garcia

Hi!
I have been programming with the default workparts for several days, I would be very interested in being able to create my own objects to move them.
I created a cage but it doesn't interact with conveyors.

Regards! ;D

EasyPLC_Master

#1
You can customize the WorkParts in several ways:
-Modify the scale, shape, texture and model

or you can create a User Defined Component with complex shapes and use it as a WorkPart in the WorkPartCreator. In this case you must use Dynamic Components in order to be affected by the gravity and physics forces.

pablo.martinez garcia

So, then i can create a custom model and import as a model of workpart? have u any tutorial how to use dynamic components? Thanks!

EasyPLC_Master

Yes, of course! all the components that have the model property can be assigned to a custom model imported in .obj format and copied on the (Installation folder) \Machines Simulator 3\ms3bin_Data\StreamingAssets\ path.

This is explained in the Machines Simulator Instruction Guide.pdf (Appendix section).

Here you can see an example: https://youtu.be/05byHkSB8M8

The dynamic components are very easy to use, they are like a Static Component but it is affected for the gravity and forces.

pablo.martinez garcia

Alright, I might have expressed myself poorly. I have read the manual and I have several questions since I am new to this.
Regarding the WorkParts, for example, I have created a UCD of a cage, and that is what I would like to be a Workpart, not so much importing a 3D model. Basically, I would like it to move on conveyors.

The second question has to do with the movement from a PLC signal properly in a UCD. I am creating a magnetic plate from zero with the components that brings Machines simulator. (when I finish it, I will upload it for others to enjoy) and I need to move it right/left or up/down until I see for example a detector, not so much with axis absolute positions. I have tried to do it with the Graph code but I only move it to one position.

If I update the position,  I must turn off and turn on the bool signal that gives it the action movement. My question is, how could I send movement in the X axis for example continuously while a PLC signal is active? My intention is to program it in TIA Portal so maybe the Graph is not the most convenient.

Greetings and thanks for your time ;)

pablo.martinez garcia

I don't know why it wouldn't let me upload images, but here is the plate.


EasyPLC_Master

#6
If you want to move up/down or left/right ot forward/backward one component (static, model) you can do it using the Movemet node in graph code or the AnimationMove function in sctip code.
For instance using this graph code the Static Component will mobe to the left while the PLC Ouput 0 will be on and will stop when off (until reach the maximun postion X = 10)
Also if you want you can send me your udc file and I will try to help you better.

pablo.martinez garcia

Sure I am sending it to you now. Thanks!

pablo.martinez garcia

I have a couple of questions, one regarding the hook system and the other about the graph. In regards to the hook, I would like to know if I have to make 1 hook for each item I want to hook or if I can make a wide area that catches multiple items at once.

And regarding the graph, the plate stops when I'm going up according to the up detector condition, and down when I'm going down. But when it's detecting security up, it doesn't go down, and the signal to go down should only take into account the bottom detector.

I can't seem to see the problem. Greetings.

EasyPLC_Master

Hi Pablo!

The hook component can only grab one WorkPart at a time, if there is more than one that collides with it, it will grab the last one that has collided. So, effectively you need a hook for each item you want to grab.

Regarding the graph code, take into account that the BreakMovement node prevails over the Movement node, then if is activated, the Movement node has not effect.
You may need to insert a trigger type node (at BreakMovement Action port) so that the component stops only on the rising edge of the signal instead of continuously.

pablo.martinez garcia

I understand. What I need is that whenever I see the top detector , I cannot go up, and vice versa for down. But if it is top, I should be able to go down.
In my Graph (which I am not sure is correct) what I am trying to do is that if it is going up, it makes a break with the top detector . But it  should ignore the break to go down. The other break is that it cuts off movement if I am not going up or down.
I have tried with the trigger but it doesn't work well for me either. I will continue investigating. ;)

EasyPLC_Master

OK, perhaps could be better to use the script code, due for complex movements or operations is powerfull.
Here I attach you an example how to make it what you pretend:

-> PLC Output 0 moves the component up until it detects Inductive sensor 1
-> PLC Output 1 moves the component down until it detects Inductive sensor 2

Here is the script and machine example file attached , hope it helps!

bool flag1 = false;
bool flag2 = false;

public void Init()
{
   IOManager.SetOutputDesc(0, "Mover Arriba");
   IOManager.SetOutputDesc(1, "Mover Abajo");
}

public void Main()
{
   if(IOManager.GetOutput(0))
   {      
      if(!flag1 && !IOManager.GetInput(0))
      {
         S0.AnimationMove("Y", 1, 3);
         flag1 = true;
      }
      
      if(IOManager.GetInput(0))
      {
         S0.BreakMovement();
      }      
   }   
   else if(IOManager.GetOutput(1))
   {
      if(!flag2 && !IOManager.GetInput(1))
      {
         S0.AnimationMove("Y", 1, 0);
         flag2 = true;
      }
      
      if(IOManager.GetInput(1))
      {
         S0.BreakMovement();
      }
   }
   else
   {
      S0.BreakMovement();
      flag1 = flag2 = false;
   }
   
   
}

public void Physics()
{

}

public void Finish()
{

}

pablo.martinez garcia

Indeed, it was the next thing I was going to try.
Surely with code it would be simpler. I have adapted a bit of what you sent me and it works perfectly.
Now that we have removed the Graph, I have not tested the Acceleration in the movement function. I will also try to do it in code. Greetings! :D

pablo.martinez garcia

Hey! Its possible to set a speed less than 1? Thanks!

EasyPLC_Master

of course! you can set any value < 1
For instance: 0.1f, 0.5f, 0.02f,...