The RY series integrated encoder module is the latest integrated encoder module launched by Leadshine Intelligent. It has the advantages of small size, powerful functions (including counting, probe, one-dimensional comparison, two-dimensional comparison, PWM output, etc.) and simple use, which can meet the needs of different customers in the market.
The following is a selection table for RY series encoders:
01. Preparations before use
1. Install the encoder module library "LS_Driver_ETC_V10018.compiled-library"
①The installation can be completed by going to "Tools" > "Libraries" > "Install" > "Select the required library".
2. Import the encoder module library “LS_Driver_ETC_V10018.compiled-library”.
① After installation, you need to import the library "LS_Driver_ETC_V10018.compiled-library".
② Add Library > Advanced > Select LS_Driver_ETC_V10018 > OK
02. PDO and Functional Description
03. Counting and Resetting Functions
1. Add the PDOs required for counting and resetting (all are selected in this example for ease of use in subsequent examples, but it is recommended to uncheck PDOs that are not used to improve bus transmission efficiency).
① Double-click “RYEC-E0200-D(RYEC-E0200-D)” with the left mouse button.
② Left-click "Process Data (PDO)" to enter the PDO interface.
③ Select the PDOs to use (all PDOs are selected in this example).
2. Set encoder counting parameters
① Double-click “LS_Encoder_CH0” with the left mouse button, and then click “Basic Settings” with the left mouse button to enter the basic settings page. This example uses the default parameters.
② Left-click "CH0 Parameter Settings" to enter the CH0 settings page. This example uses the default parameters.
3. Call the counting function block and the clearing function block (please refer to the "RY Series Module User Manual" for function block descriptions).
① Create the following variables
② Call and enable the RYEC_Counter counting function block. This function block can perform counting, frequency measurement, and counting direction functions.
③ Call the RYEC_CounterClear function block to set the clearing mode (0: software clearing is selected in this example), and then trigger the clearing enable to complete the count clearing.
04. Probe Function
01. Single latch function
1. The PDO required to add the probe function will not be described here.
Note: If using the probe function block RYEC_ToughProbe encapsulated in Leadshine's LS_Drive_ETC library, you need to check the CH0 Latch Mapping NEW-16#1A06 and CH1 Latch Mapping NEW16#1A07 objects.
2. Set the parameters of the probe port.
① Double-click “LS_Encoder_CH0” with the left mouse button, then left-click “CH0 Parameter Settings” and set the relevant parameters in “Input Port Settings”.
② Select ports X00 and X01 (i.e., IN00 and IN01) for latching function, and set the filtering time, level logic, etc. Note: Ports X00 and X01 (i.e., IN00 and IN01) can latch the encoder 0 count port value and time, and ports X10 and X11 (i.e., IN04 and IN05) can latch the encoder 1 count port value and time.
3. Call the probe and probe zeroing function blocks (for a description of the function blocks, please refer to the "RY Series Module User Manual").
① Create relevant variables
② Call and enable the RYEC_ToughProbe probe function block. If IN00 and IN01 receive signals, the value and time of encoder 0 can be latched. eTriggerType is TP_POS rising edge, and eTriggerMode is TP_Singled single trigger. (For triggering methods and modes, please refer to the function block description above.)
If it is necessary to trigger the latching encoder value and time again, the RYEC_ToughProbeClear probe clearing function block needs to be called to re-trigger the RYEC_ToughProbe probe function block. Only if the corresponding input port IN00 or IN01 receives a signal again can the encoder value and time be latched again. Note: Latch clearing only clears the latch completion status, not the latch position and time. The previous value is overwritten only by the next latch position and time.
02. Continuous latching function
1. The PDO required to add the probe function will not be described here.
2. Set the parameters of the probe port, which is the same as the single latch function, so it will not be described here.
3. Description of the probe function block and probe clearing function block: The single latch function has been introduced and will not be repeated here.
4. Call the probe and probe zeroing function block, and set the probe function block to continuous latching function. (For function block descriptions, please refer to the "RY Series Module User Manual")
① Create relevant variables
② Set the probe function block to continuous latching, and set eTriggerMode to 1.
③ Trigger probe function block enable. If IN00 receives a rising edge signal, it can latch the value of encoder 0. In this example, 10 encoder 0 values are latched. As shown in the figure below, IN00 receives 10 signals. The array afIN00ToughProbePosPostion stores the latched value, and uiCycleCount is the number of latches.
④ To clear the latch value cache fPosPosition and restart continuous latching, you need to call the RYEC_ToughProbeClear probe clearing function block to clear the latch cache fPosPosition. If uiCycleCount is 0 latch counts, the continuous latching clearing function is successful.
05. One-dimensional comparison function
01. Single Comparison Function
1. The PDO required to add the comparison function will not be introduced here.
2. Set the parameters of the comparison port.
① Double-click “LS_Encoder_CH0” with the left mouse button, then left-click “CH0 Parameter Settings” and set the relevant parameters in “Output Port Settings”.
② Select ports Y00 and Y01 (i.e., OUT00 and OUT01) as comparator outputs and set the logic levels, etc. Note: Ports Y00 and Y01 (i.e., OUT00 and OUT01) are the comparator output ports of encoder 0 (CH0), and Y10 and Y11 (i.e., OUT04 and OUT05) are the comparator output ports of encoder 1 (CH1).
3. Call the one-dimensional comparison function block (for a description of the function block, please refer to the "RY Series Module User Manual").
① Create relevant variables
② Call the one-dimensional comparison function block (call two function blocks to associate with output ports Out0 and Out1 respectively), set the eOutType comparator working mode to 3 (single comparison greater than mode), set the comparison point position lrCmp1DPos to 500, set the output port xOutEnable to TRUE, and then trigger the function block to enable.
As shown in the figure below, after the one-dimensional comparison function block is triggered, if the encoder count value is greater than 500 (600 in the example), the output state is 3, and both the Out0 and Out1 output ports will have output.
02. Continuous Comparison Function (FIFO Time Output)
1. The PDO required to add the comparison function will not be introduced here.
2. Set the parameters of the comparison port.
① Double-click “LS_Encoder_CH0” with the left mouse button, then left-click “CH0 Parameter Settings” and set the relevant parameters in “Output Port Settings”.
② Select ports Y00 and Y01 (i.e., OUT00 and OUT01) as comparator outputs and set the logic levels, etc. Note: Ports Y00 and Y01 (i.e., OUT00 and OUT01) are the comparator output ports of encoder 0 (CH0), and Y10 and Y11 (i.e., OUT04 and OUT05) are the comparator output ports of encoder 1 (CH1).
3. Call the one-dimensional comparison function block (for a description of the function block, please refer to the "RY Series Module User Manual").
① Create relevant variables
② Call the one-dimensional comparison function block, set the eOutType comparator working mode to 4 (FIFO time output), set the output port time udiOutpara to 5000us, write the comparison point position afCmpPos (array type, write the comparison points to the corresponding numerical variable afCmpPosPostion, quantity 10), set the comparison point quantity uiCmpNum to 10, set the output port xOutEnable to TRUE, and finally trigger the function block to enable.
As shown in the figure below, as the encoder's 0 value increases, the output port outputs 10 times at the corresponding comparison point position.
-END-