Nirtec Studio Forum

General Category => Machines Simulator => Topic started by: chengo89 on February 21, 2019, 10:14:33 AM

Title: 2 Phase encoder integration?
Post by: chengo89 on February 21, 2019, 10:14:33 AM
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
Title: Re: 2 Phase encoder integration?
Post by: EasyPLC_Master on February 21, 2019, 06:56:41 PM
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:


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()
{

}


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?
Title: Re: 2 Phase encoder integration?
Post by: EasyPLC_Master on February 22, 2021, 08:00:16 AM
From Machines Simulator 3.8 version:

- Conveyor  belt includes a digital incremental encoder (two phases quadrature encoder) and PLC analog output speed management.