Difference between revisions of "Component: Encoder Rotary (Inputs: General)"
(XML import) |
|||
Line 17: | Line 17: | ||
==[[File:Component Icon 3531a68d_7686_44b7_a3a5_67afda8467dc.png|Image]] Encoder Rotary component== | ==[[File:Component Icon 3531a68d_7686_44b7_a3a5_67afda8467dc.png|Image]] Encoder Rotary component== | ||
Encoder component implements a rotary encoder connected to two pins | Encoder component implements a rotary encoder connected to two pins | ||
+ | |||
+ | |||
+ | ==Detailed description== | ||
+ | |||
+ | Mechanical encoders can be a bit electrically noisy when switching and so to have reliable operation it is recommended to have a simple filter as shown here. | ||
+ | |||
+ | [[Image:EncoderCircuit.jpg]] | ||
Revision as of 13:46, 21 November 2022
Author | Matrix TSL |
Version | 1.3 (Release) |
Category | Inputs: General |
Contents
Encoder Rotary component
Encoder component implements a rotary encoder connected to two pins
Detailed description
Mechanical encoders can be a bit electrically noisy when switching and so to have reliable operation it is recommended to have a simple filter as shown here.
Examples
Polling
Example program showing how to use a quadrature encoder component using a polling method. Quad_Encoder_Test
Timer Interrupt Based Polling
Example program showing how to use a quadrature encoder component using a polling method via a timer interrupt. Quad_Encoder_Timer
Interrupt On Change
Example program showing how to use a quadrature encoder component using a interrupt on pin state change interrupt (IOC). Quad_Encoder_IOC
Downloadable macro reference
CheckForChanges
Polling function to check changes
Returns 1 for chaged, 0 for no change, 255 for error
Parameters
- This macro has no parameters
Return value
Disable
Disables the use of the quad encoder
Once this ist called, the read functions will return zeros until the next Enable() call
Parameters
- This macro has no parameters
Return value
- This call does not return a value
Enable
Enables the use of the quad encoder
If this is not called, the read functions will return zeros
Parameters
- This macro has no parameters
Return value
- This call does not return a value
ReadCounter
Reads the current dial counter
This is a counter from -32768 to 32767
Parameters
- This macro has no parameters
Return value
WriteCounter
Sets the value of the internal count variable.
Range: -32768 to 32767
Parameters
- INT Value
- Range: -32768 to 32767
Return value
- This call does not return a value
ResetCounter
Resets the current dial counter to zero
Parameters
- This macro has no parameters
Return value
- This call does not return a value
Simulation macro reference
This component does not contain any simulation macros
Property reference
Post Scaler
This property is of type Fixed list of ints and can be referenced with the variable name Divider.
Encoders with a mechanical click will often have 4 transitions per click.
1:1 would provide the maximum output resolution.
1:4 would provide the encoder click count.
A
This property is of type Single digital pin and can be referenced with the variable name pin_a.
Input pin A
B
This property is of type Single digital pin and can be referenced with the variable name pin_b.
Input Pin B
Repeat Rate
This property is of type Fixed list of ints and can be referenced with the variable name reprate.
Simulated repeat rate when clicking and rotating the encoder