General Category > Machines Simulator

2 Phase encoder integration?

(1/1)

chengo89:
Hi,

For example (in the real world with Mitsubishi FX-series PLC), when I use this kind of encoders on my machines conveyor, it's connected to pair of inputs, let's say X0 (Phase A) and X1 (Phase B).
When the conveyor moves forward it's count up on High-speed counter (C252) and also count down when the opposite occurs.

Any idea how to create / integrate 2 Phase encoder in Machines Simulator?

Thanks

EasyPLC_Master:
I think you want make a conveyor where the tray motor is connected to an encoder in order to control the position.

Usually in MS3 the conveyors are made using the Plane Element, that can move objects placed over them.
You can read the amount of movement of the Plane Element using this code:


--- Code: ---float v=0;

public void Init()
{
 
}

public void Main()
{

if(IOManager.GetOutput(0))
{
Plane.Reverse(false);
Plane.Advance(true);
v += Plane.Speed * Time.deltaTime;
}
else if(IOManager.GetOutput(1))
{
Plane.Advance(false);
Plane.Reverse(true);
v -= Plane.Speed * Time.deltaTime;
}
else
{
Plane.Advance(false);
Plane.Reverse(false);
}

EditorUtils.ShowText(v.ToString());


}

public void Finish()
{
 
}
--- End code ---

Then in the float variable 'v' you have the current position the Plane is moving, then you can use as if was an absolute encoder or, if you want to set digital PLC inputs for two phase encoder, create an algorith that counts the v increments to activate/deactivate a digital PLC input.

It could help you?

Navigation

[0] Message Index

Go to full version