News:

SMF - Just Installed!

Main Menu

Component Programming in Machine Simulator Editor

Started by KCP-KIMUEL, May 28, 2015, 08:52:08 AM

Previous topic - Next topic

KCP-KIMUEL

Hi All,

I'm starting to learn programming in Machine Simulator Editor to control the movement of my component in X-Axis and Y-Axis.
I'm currently programmed some component (see attached), using C# and observed that my component is not stable if not press during run-time.
Can somebody have a look at my code and tell me whats wrong.

Thanks,

[attachment deleted by admin]

KCP-KIMUEL

Hi All,

I'm starting to learn programming in Machine Simulator Editor to control the movement of my component in X-Axis and Z-Axis.
I'm currently programmed some component (see attached), using C# and observed that my component is not stable if not press during run-time.
Can somebody have a look at my code and tell me whats wrong.

Thanks,

EasyPLC_Master

An important target to know is what your component must to do, or in other words, what should be the behaviour of your component.
You must to explain in order to adecuate the programming.
Other problem is if you use Models that are not in the default library, is hard to see nothing due the other users nothing see, and must imagine what should be the shape of the objects, then or you use standar models or you attach also the used.
Why you declare the 'Plane' component as not inmovable?, if the code must move it could be not a good idea to set as 'affected by gravity'.
Please explain.

KCP-KIMUEL

I'm sorry for my not so good programming skill. :( :( :(
What I want to do is to move the Plane and the Box Unit together meaning they are join in X-axis movement.
But during Z-axis I only want to move the plane.
Example is Position 1,2,3,4,5 Plane and Box Unit is moving together in x-axis, but if I press the Advance or Reverse Button the Plane will only move.
Is it possible?
Can you please help me fix the code even if you use the available components in your library not the component that I send.
I will really appreciate it and will learn a lot after that fix.

Thank you.

KCP-KIMUEL

I thought that if I set Plane component as not immovable the code works in Z-axis and yes it happened.
But now I know that its not a good idea.


EasyPLC_Master

OK, understood!

Then I think the code you need is very similar to this example used in this forum thread:
http://nirtec.com/forum/index.php?topic=329.0

KCP-KIMUEL

Hi,
Just a quick question base on the exampe you gave at this thread: http://nirtec.com/forum/index.php?topic=329.0
How you set the position of your Pusher_Virtual and Pusher_phys. Is it depends on the code or in the Position Setting in Machine Simulator Editor?

Thank you!

EasyPLC_Master

if you see the help about the available functions for the Translate method, is explained:

void Translate(int id, Vector3 value);   

   Description: Translate the box element with index 'id' to the 'value' position. The translation is relative to the component coordinates.
   Example: Editor.Translate(2, new Vector3(0.6f, 1.5f, -3.6f));

Pay attention to the explanation: The translation is relative to the component coordinates.
This means that the final movement will be transformed to the final component position. This is very important, otherwise you can have a undesired effect, viewing that your component have a correct behavior if you place it in the World Zero coordinate (0,0,0) but if you place in another position the movements are not correct.
Then, the translate method automatically applies the necessary transformations in order to move the box correctly no matter where the component is placed by the user in the Editor.
Hope my explanation helps you!

KCP-KIMUEL

Wow very well explained!!
Thank you so much, I'm learning a lot from you. ;D ;D ;D

KCP-KIMUEL

Hi Again,

I'm currently studying how to rotate the models like conveyor did.
When I try the object like  Conveyor Roller there is no problem my code works.
But when I try to change the object to Tube_O. It rotates in a way that I never expect. The rotation is like a windmill.( I'm using the code, I used in Conveyor Roller that I created.)
I thought there is no problem If I change the objects it that way.
Can you help me look at my code and tell me whats wrong.

Thanks!!

[attachment deleted by admin]

KCP-KIMUEL

Hi Sorry I already created the correct one. I just change Editor.RotateX(1,rot); to Editor.RotateZ(1,rot);.

EasyPLC_Master


KCP-KIMUEL

Hi  EasyPLC_Master,

Can I ask for a copy of cmp file for elevator, because it's not available in my Components file.
I want to study how things works for it, also the code how it fits together.

Thank You!

KCP-KIMUEL

I make a simple code it it goes like this (see attached)
Do you have any idea of making it more simpler.

[attachment deleted by admin]

EasyPLC_Master

The Elevator is not a UserDefinedComponent (belongs to the default system library), then not cmp file is available.
About your elevator (in general) seems me correct, but if you are not using orientation, better is to use the Translate function to move the elevator up & down.
void Translate(int id, Vector3 value);
Also some performance corrections can be done, see the attached file. Is better not to create always new Vector3 objects, and work directly with the Y component of the Vector.



[attachment deleted by admin]