Select and connect encoder input channels
The Encoder Input block allows you to select and connect specific encoder input channels to your Simulink® model. After you have added an Encoder Input block to your model, you can enter the parameters for its I/O driver. The following procedure uses the HUMUSOFT® MF604 I/O board as an example.
Enter a value representing how frequently you want the block to execute and interact with the I/O hardware. The block will also synchronize your model with the real-time clock at this sample rate.
Enter the number of timer ticks that your model can lag behind the real-time kernel. When the model lags by more than this number, the block reports an error and simulation stops. Otherwise, simulation continues even if some ticks are missed.
Select this check box to display the current number of missed ticks as a block output.
Select this check box to grant other programs more CPU time while the kernel waits for a response from the hardware.
Enter a channel vector that selects the encoder input channels you are using on this board. The vector can be any valid MATLAB® vector form. For example, to select the four encoder input channels on the MF604 board, enter
[1,2,3,4] or [1:4]
Encoders typically use two sets of stripes, shifted in phase, to optically detect the amplitude and direction of movement. This parameter specifies which encoder stripe edges should be counted. From the list, select
double — Counts the rising edges from both stripe sets
single — Counts the rising edges from one stripe set
quadruple — Counts rising and falling edges from both stripe sets
Quadruple mode yields four times more pulses per revolution than the single mode. Therefore, quadruple is more accurate and should be used unless other parameters dictate otherwise.
The encoder interface chip has a reset pin in addition to encoder inputs. This pin is usually connected to the index output of the encoder. However, it can be connected to any signal or not be used at all. This parameter specifies the function of this pin. From the list, select
gate — Enables encoder counting
reset — Level reset of the encoder count
rising edge index — Resets the encoder count on the rising edge
falling edge index — Resets the encoder count on the falling edge
The encoder interface chip has a built-in low-pass filter that attempts to filter out high frequencies, which are interpreted as noise. This parameter is the cutoff frequency (Hz) of this filter. The cutoff frequency you specify is rounded to the nearest frequency supported by the chip.
If the encoder is moving slowly and high-frequency noise is present, employ the filter to eliminate the noise. This keeps the noise from being counted as encoder pulses. If the encoder is moving quickly, the filter can filter out the high-frequency pulses, including those you want to count. In this case, consider leaving the filter disabled by setting the cutoff frequency to Inf.
From the list, select the type of data that the block will output to the model.