Component: Encoder Rotary (Inputs: General)

From Flowcode Help
Jump to navigationJump to search


Author Matrix TSL
Version 1.3 (Release)
Category Inputs: General


Image 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.

EncoderCircuit.jpg

Examples

Polling

Example program showing how to use a quadrature encoder component using a polling method. FC6 Icon.png 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. FC6 Icon.png 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). FC6 Icon.png 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

BYTE


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

INT


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