nanoFramework.Iot.Device.RotaryEncoder 1.2.128

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package nanoFramework.Iot.Device.RotaryEncoder --version 1.2.128
                    
NuGet\Install-Package nanoFramework.Iot.Device.RotaryEncoder -Version 1.2.128
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="nanoFramework.Iot.Device.RotaryEncoder" Version="1.2.128" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="nanoFramework.Iot.Device.RotaryEncoder" Version="1.2.128" />
                    
Directory.Packages.props
<PackageReference Include="nanoFramework.Iot.Device.RotaryEncoder" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add nanoFramework.Iot.Device.RotaryEncoder --version 1.2.128
                    
#r "nuget: nanoFramework.Iot.Device.RotaryEncoder, 1.2.128"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package nanoFramework.Iot.Device.RotaryEncoder@1.2.128
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=nanoFramework.Iot.Device.RotaryEncoder&version=1.2.128
                    
Install as a Cake Addin
#tool nuget:?package=nanoFramework.Iot.Device.RotaryEncoder&version=1.2.128
                    
Install as a Cake Tool

Quadrature Rotary Encoder

A Rotary encoder is a device that detects angular position. One use of this is similar to a volume control on an FM radio where the user turns a shaft and the loudness of the broadcast is changed. Incremental rotary encoders do not provide information on their exact position but supply information about how much they have moved and in which direction.

Board

image of rotary encoder

Typically a quadrature rotary encoder will have two outputs A and B, perhaps called clock and data. For each part of a rotation then the A pin will provide a clock signal and the B pin will provide a data signal that is out of phase with the clock. The sign of the phase difference between the pins indicates the direction of rotation.

encoder

From above if we look at Pin B (data) at the time of a falling edge on Pin A (clk) then the if the value of pin P is 1 then the direction is clockwise and if it is 0 then the rotation is counter clockwise.

Usage

This sample shows how to implement an FM radio tuner control using the ScaledQuadradureEncoder binding. It simply prints the tuner value to the console as the knob is turned.

rotary example

This binding implements scaled quadrature rotary encoder as ScaledQuadratureEncoder. The value is a double. You can for example set it up as a tuning dial for an FM radio with a range of 88.0 to 108.0 with a step of 0.1.

The code below shows an example of using the encoder as an FM tuner control.

// create a RotaryEncoder that represents an FM Radio tuning dial with a range of 88 -> 108 MHz
ScaledQuadratureEncoder encoder = new ScaledQuadratureEncoder(pinA: 5, pinB: 6, PinEventTypes.Falling, pulsesPerRotation: 20, pulseIncrement: 0.1, rangeMin: 88.0, rangeMax: 108.0) { Value = 88 };
// 2 milliseconds debonce time
encoder.Debounce = TimeSpan.FromMilliseconds(2);
// Register to Value change events
encoder.ValueChanged += (o, e) =>
{
    Debug.WriteLine($"Tuned to {e.Value}MHz");
};

This binding also features

  • Debounce functionality on the clock signal.
  • Acceleration so that rotating the encoder moves it further the faster the rotation.
  • Events when the value changes.

Also available is a QuadratureRotaryEncoder binding which has properties that represent the rotation of the encoder and the raw pulses.

Limitations

This binding is suitable for manual and small rotations where it is not a big deal if one or few rotations may be lost.

This binding is not suitable for motor control with a very high rate and very precise number of counts.

The precision really depends of the hardware you are using and it is not possible to give specific range of usage. You may have to try to understand if this is working for you or not.

Product Compatible and additional computed target framework versions.
.NET Framework net is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.2.864 203 4/2/2025
1.2.852 192 3/11/2025
1.2.822 143 2/26/2025
1.2.775 152 2/4/2025
1.2.772 136 2/4/2025
1.2.755 136 1/31/2025
1.2.737 121 1/13/2025
1.2.696 144 12/16/2024
1.2.673 151 10/23/2024
1.2.662 139 10/11/2024
1.2.631 146 8/28/2024
1.2.590 155 7/17/2024
1.2.570 154 6/14/2024
1.2.560 156 5/29/2024
1.2.548 138 5/15/2024
1.2.436 285 11/10/2023
1.2.416 157 11/8/2023
1.2.329 271 5/26/2023
1.2.313 252 5/12/2023
1.2.297 258 5/3/2023
1.2.208 429 1/3/2023
1.2.203 413 12/28/2022
1.2.159 495 11/14/2022
1.2.153 473 11/5/2022
1.2.141 514 10/25/2022
1.2.128 495 10/22/2022
1.2.125 522 10/12/2022
1.2.122 578 10/12/2022
1.2.114 533 10/8/2022
1.2.95 541 9/22/2022
1.2.87 588 9/15/2022
1.2.73 521 9/8/2022
1.1.116.8772 561 6/24/2022
1.1.113.2032 544 6/23/2022
1.1.58.10097 554 5/23/2022
1.1.3 570 4/15/2022
1.1.1 553 4/14/2022
1.0.277-preview.126 198 3/25/2022
1.0.277-preview.125 192 3/25/2022
1.0.277-preview.112 193 3/19/2022
1.0.277-preview.111 197 3/18/2022
1.0.277-preview.106 208 3/15/2022
1.0.277-preview.99 196 3/10/2022
1.0.277-preview.98 197 3/8/2022
1.0.277-preview.60 215 2/4/2022
1.0.277-preview.53 215 1/31/2022
1.0.277-preview.32 221 1/27/2022
1.0.277-preview.17 209 1/24/2022
1.0.277-preview.15 208 1/21/2022
1.0.277-preview.1 211 1/11/2022
1.0.259 438 12/9/2021
1.0.218 284 10/18/2021
1.0.155 474 8/31/2021
1.0.135 252 7/16/2021
1.0.134 252 7/15/2021
1.0.133 271 7/14/2021
1.0.125 282 7/5/2021
1.0.121 282 6/29/2021
1.0.119 311 6/28/2021
1.0.25 286 5/21/2021