The EQuote output of the SysGetEncoder function block cannot be reset or modified via a command. It can only be set to 0 by activating ZeroEn, which resets the encoder count upon detection of the encoder’s zero signal.
To manipulate the encoder count as required, the only approach is to handle it mathematically, as shown in the ST_EQuoteManage program example. Essentially, the program calculates the number of encoder pulses during each execution cycle and accumulates them into a count value. Since this count is a program variable, it can be adjusted as needed. Here is the core example.
Pulses:=TO_INT(EInp.EQuote-EMemo); //Encoder pulses
EMemo:=EInp.EQuote; //Encoder memo
Quote:=Quote+TO_DINT(Pulses); //Encoder quote
Pay attention that the Pulses variable must be signed, because the difference in the quote can be negative when the encoder rotates counterclockwise (CCW).
To use the two digital inputs on the MPS054 to acquire the encoder, a protection code must be applied. The SysGetEncoder function block must be configured as follows:
EInp.Address:=255; //Module address
EInp.Channel:=0; //Module channel