Difference between revisions of "Component: Quadrature Encoder (General Input)"
| Line 82: | Line 82: | ||
Example program showing how to use a quadrature encoder component using a interrupt on pin state change interrupt (IOC).  | Example program showing how to use a quadrature encoder component using a interrupt on pin state change interrupt (IOC).  | ||
{{Fcfile|Quad_Encoder_IOC.fcfx|Quad_Encoder_IOC}}  | {{Fcfile|Quad_Encoder_IOC.fcfx|Quad_Encoder_IOC}}  | ||
| + | |||
| + | |||
| Line 87: | Line 89: | ||
==Macro reference==  | ==Macro reference==  | ||
| + | ===CheckForChanges===  | ||
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"  | {| class="wikitable" style="width:60%; background-color:#FFFFFF;"  | ||
|-  | |-  | ||
| Line 100: | Line 103: | ||
| + | ===Disable===  | ||
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"  | {| class="wikitable" style="width:60%; background-color:#FFFFFF;"  | ||
|-  | |-  | ||
| Line 113: | Line 117: | ||
| + | ===WriteCounter32===  | ||
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"  | {| class="wikitable" style="width:60%; background-color:#FFFFFF;"  | ||
|-  | |-  | ||
| Line 131: | Line 136: | ||
| + | ===Enable===  | ||
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"  | {| class="wikitable" style="width:60%; background-color:#FFFFFF;"  | ||
|-  | |-  | ||
| Line 144: | Line 150: | ||
| + | ===Rotate===  | ||
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"  | {| class="wikitable" style="width:60%; background-color:#FFFFFF;"  | ||
|-  | |-  | ||
| Line 162: | Line 169: | ||
| + | ===ReadCounter===  | ||
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"  | {| class="wikitable" style="width:60%; background-color:#FFFFFF;"  | ||
|-  | |-  | ||
| Line 175: | Line 183: | ||
| + | ===WriteCounter===  | ||
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"  | {| class="wikitable" style="width:60%; background-color:#FFFFFF;"  | ||
|-  | |-  | ||
| Line 193: | Line 202: | ||
| + | ===ResetCounter===  | ||
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"  | {| class="wikitable" style="width:60%; background-color:#FFFFFF;"  | ||
|-  | |-  | ||
| Line 206: | Line 216: | ||
| + | ===ReadCounter32===  | ||
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"  | {| class="wikitable" style="width:60%; background-color:#FFFFFF;"  | ||
|-  | |-  | ||
Revision as of 11:49, 3 February 2023
| Author | Matrix TSL | 
| Version | 1.5 | 
| Category | General Input | 
Contents
Quadrature Encoder component
Quadrature Encoder component implements a rotary encoder connected to two pins. Quadrature Encoders provides incremental positioning rather than absolute positioning.
Component Source Code
Please click here to download the component source project: FC_Comp_Source_Encoder_Quadrature.fcfx
Please click here to view the component source code (Beta): FC_Comp_Source_Encoder_Quadrature.fcfx
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
Macro reference
CheckForChanges
| CheckForChanges | |
| Polling function to check changes Returns 1 for chaged, 0 for no change, 255 for error | |
| Return | |
Disable
| Disable | |
| Disables the use of the quad encoder Once this ist called, the read functions will return zeros until the next Enable() call | |
| Return | |
WriteCounter32
| WriteCounter32 | |
| Sets the value of the internal count variable. Range: -2147483648 to 2147483647 | |
| Value | |
| Range: -2147483648 to 2147483647 | |
| Return | |
Enable
| Enable | |
| Enables the use of the quad encoder If this is not called, the read functions will return zeros | |
| Return | |
Rotate
ReadCounter
| ReadCounter | |
| Reads the current dial counter This is a counter from -32768 to 32767 | |
| Return | |
WriteCounter
| WriteCounter | |
| Sets the value of the internal count variable. Range: -32768 to 32767 | |
| Value | |
| Range: -32768 to 32767 | |
| Return | |
ResetCounter
| ResetCounter | |
| Resets the current dial counter to zero | |
| Return | |
ReadCounter32
| ReadCounter32 | |
| Reads the current dial counter as a 32-bit value This is a counter from -2147483648 to 2147483647 | |
| Return | |
