Real-Time Windows Target |
 |
Encoder Input Block
This Real -Time Windows Target I/O blocks allow you to select and connect specific encoder input channels to your Simulink model.
After you have added an Encoder Input block to your Simulink model, you can enter the parameters for this I/O driver. This procedure uses Humusoft's MF604 I/O board as an example:
- Double-click the Encoder Input block.
- The Block Parameters: Encoder Input dialog box opens.
- In the Sample time box, enter the same value you entered in the Fixed step size box from the Simulation Parameters dialog box. For example, enter
- In the Input channels box, 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 all 4 encoder input channels on the MF604 board, enter
- Encoders typically use two sets of stripes, shifted in phase, to optically detect the amplitude and direction of movement. The Quadrature mode parameter specifies which encoder stripe edges should be counted.
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 4 times more pulses per revolution than the single mode. Therefore, quadruple is more precise and is recommended 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 may not be used at all. The Reset input function specifies the function of this pin.
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 lowpass filter that attempts to filter out any high frequencies which are interpreted as noise. The Input filter clock frequency 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 all of 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
.
- Do one of the following:
- Click Apply to apply the changes to your model and leave the dialog box open.
- Click OK to apply the changes to your model and close the Block Parameters: Digital Input dialog box.
| Counter Input Block | | Output Signals from an I/O Block |  |