Opto Encoder Click Board
Opto Encoder Click Board
The Opto Encoder Click Board™ is a linear incremental optical sensor/encoder Click Board™, which can be used for the movement or rotation encoding. Encoders of this type are widely used for many applications which involve precise detection of the position, speed, or rotational angle of an object. Rotary encoders are often used for various types of controllers on many different devices.
Whether it be a rotary encoded knob controller or a rotation encoder on a motor shaft, the principle is the same - it includes an optical sensor, just like the one found on the Opto Encoder Click Board™.
Software Support
We provide a library for the Opto Encoder Click Board™ on our Libstock page, as well as a demo application (example), developed using MikroElektronika compilers and mikroSDK. The provided click library is mikroSDK standard compliant. The demo application can run on all the main MikroElektronika development boards.
Library Description
This library contains basic functions that will allow you to read the sensor.
Key Functions
void optoencoder_init();
- Initialization for the click board.
uint8_t optoencoder_getO1();
- Read the state of encoder channel 1.
uint8_t optoencoder_getO2();
- Read the state of the encoder channel 2.
int16_t optoencoder_getPosition();
- Return's the current position.
Example Description
- The application is composed of three sections:
- System Initialization - Initializes PWM pin and INT pin as INPUT.
- Application Initialization - Initializes Driver init and opto encoder init.
- Application Task - (code snippet) - Detects the change of step and logs to USB UART number of stepped steps.
void applicationTask() { newStep = optoencoder_getPosition(); if(oldStep != newStep) { IntToStr(newStep, text); mikrobus_logWrite(" Step: ", _LOG_TEXT); mikrobus_logWrite(text, _LOG_LINE); oldStep = newStep; } }
The full application code, and ready to use projects can be found on our LibStock page.
Other mikroE Libraries used in the example:
- UART Library
- Conversions Library
- C_String Library
Additional Notes and Information
Depending on the development board you are using, you may need a USB UART click, USB UART 2 click or RS232 click to connect to your PC, for development systems with no UART to USB interface available on the board. The terminal available in all MikroElektronika compilers, or any other terminal application of your choice, can be used to read the message.
MIKROSDK
The Opto Encoder Click Board™ is supported with mikroSDK - MikroElektronika Software Development Kit. To ensure proper operation of mikroSDK compliant click board demo applications, mikroSDK should be downloaded from the LibStock and installed for the compiler you are using.
Opto Encoder Click Board
Frequently Asked Questions
Have a Question?
Be the first to ask a question about this.