File Exchange

image thumbnail

Raspberry Pi Quadrature Encoder SFunction

version (17.3 KB) by Joshua Hurst
Quadrature encoder route implemented with interrupts with WiringPi


Updated 21 Aug 2014

View Version History

View License

This code is port of Giampy's encoder SFunction from Arduino using the WiringPi library.
It has support for multiple encoders.

Other device driver block, and the hardware it was run on is available at our website:

A complete library for Arduino and curriculum is available here:

coming soon:
- MPU6050 gyro accelerometer
- HMC5883L magnetometer
- FreeIMU driver

and others!

This work is part of the Mechatronics curriculum at Rensselaer Polytechnic Institute.

Cite As

Joshua Hurst (2021). Raspberry Pi Quadrature Encoder SFunction (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (5)

Nimra Zeeshan

Nimra Zeeshan

can anybody help me in implementing this encoder on my DC Motor with incremental encoder?? cause its showing no results .

Klaus Webers

Alright I got it working by doing this:
- open the model configuration paramters
- go to code generation
- change build configuration to: "Specify"
- at the Linker pane add: "-lwiringpi" (without the "" symbols)
- press apply

Klaus Webers

I get the following error:
STDERR: Quad_Encoder_sfn_wrapper.c.o: In function `pinMode':
Quad_Encoder_sfn_wrapper.c:(.text+0x2948): undefined reference to `softToneStop'
Quad_Encoder_sfn_wrapper.c:(.text+0x2af4): undefined reference to `softToneCreate'

Due to the command "xmakefilesetup" no longer being available there is no current workaround.
Has this problem occured before and do you happen to have an idea on how to fix this?

Paul Kassebaum

MATLAB Release Compatibility
Created with R2013a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Inspired by: Device Drivers

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!