We strongly encourage users to use Package manager for sharing their code on Libstock website, because it boosts your efficiency and leaves the end user with no room for error. [more info]
Rating:
Author: MIKROE
Last Updated: 2019-06-25
Package Version: 1.0.0.0
mikroSDK Library: 1.0.0.0
Category: Optical
Downloaded: 3365 times
Not followed.
License: MIT license
Opto Encoder 2 click is a linear incremental optical sensor/encoder click 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.
Do you want to subscribe in order to receive notifications regarding "OptoEncoder 2 click" changes.
Do you want to unsubscribe in order to stop receiving notifications regarding "OptoEncoder 2 click" changes.
Do you want to report abuse regarding "OptoEncoder 2 click".
Library Description
Library contains functions for getting INT(Channel A) and PWM(Channel B) pin states Library contains function for incrementing/decrementing encoder position Library contains function for reseting encoder position counter to 0(zero) Library contains function for getting current encoder position
Key functions:
int32_t optoencoder2_getPosition(void)
- returns current encoder position.void optoencoder2_zeroCounter(void)
- resets encoder counter to 0(zero).uint8_t optoencoder2_isr( uint8_t n_cycles )
- checks for rising edge on Channel A (INT pin), within specified number of cycles (n_cycles), and increments or decrements encoder position.Examples Description
The application is composed of three sections :
void applicationTask( )
{
stop_flag = optoencoder2_isr(100);
encoderPosition = optoencoder2_getPosition( );
if (stop_flag == 0)
{
LongToStr( encoderPosition, text );
mikrobus_logWrite( "> pos : ", _LOG_TEXT );
mikrobus_logWrite( text, _LOG_LINE );
}
}
Other mikroE Libraries used in the example:
Additional notes and informations
Depending on the development board you are using, you may need 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.