TOP Contributors

  1. MIKROE (2652 codes)
  2. Alcides Ramos (351 codes)
  3. Shawon Shahryiar (307 codes)
  4. jm_palomino (112 codes)
  5. Chisanga Mumba (90 codes)
  6. S P (73 codes)
  7. dany (71 codes)
  8. MikroBUS.NET Team (35 codes)
  9. NART SCHINACKOW (34 codes)
  10. Armstrong Subero (27 codes)

Most Downloaded

  1. Timer Calculator (136605 times)
  2. FAT32 Library (69810 times)
  3. Network Ethernet Library (55881 times)
  4. USB Device Library (46213 times)
  5. Network WiFi Library (41857 times)
  6. FT800 Library (41070 times)
  7. GSM click (28941 times)
  8. PID Library (26400 times)
  9. mikroSDK (26308 times)
  10. microSD click (25323 times)
Libstock prefers package manager

Package Manager

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]

< Back
mikroSDK Library

OptoEncoder 2 click

Rating:

5

Author: MIKROE

Last Updated: 2019-06-25

Package Version: 1.0.0.0

mikroSDK Library: 1.0.0.0

Category: Optical

Downloaded: 2856 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.

No Abuse Reported

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

  • mikroSDK Library 2.0.0.0
  • Comments (0)
DOWNLOAD LINK RELATED COMPILER CONTAINS
mikroBasic PRO for ARM
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroBasic PRO for AVR
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroBasic PRO for dsPIC30/33 & PIC24
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroBasic PRO for FT90x
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroBasic PRO for PIC
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroBasic PRO for PIC32
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroC PRO for ARM
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroC PRO for AVR
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroC PRO for dsPIC30/33 & PIC24
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroC PRO for FT90x
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroC PRO for PIC
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroC PRO for PIC32
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroPascal PRO for ARM
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroPascal PRO for AVR
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroPascal PRO for dsPIC30/33 & PIC24
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroPascal PRO for FT90x
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroPascal PRO for PIC
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroPascal PRO for PIC32
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc

mikroSDK Library Blog

Opto Encoder 2 click

Opto Encoder 2 click

Native view of the Opto Encoder 2 click board.

View full image
Opto Encoder 2 click

Opto Encoder 2 click

Front and back view of the Opto Encoder 2 click board.

View full image

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 :

  • System Initialization - Initializes LOG, initializes PWM and INT pins.
  • Application Initialization - Initializes GPIO driver and resets encoder counter to 0(zero) .
  • Application Task - If encoder is moving - increments or decrements encoder position on every rising edge on Channel A (INT pin) and logs encoder position .
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:

  • UART
  • Conversions

Additional notes and informations

Depending on the development board you are using, you may need USB UART clickUSB 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.

ALSO FROM THIS AUTHOR

RS232 Isolator click

0

RS232 Isolator click is a fully isolated dual transceiver click, used to provide secure and easy UART to RS232 conversion, with the galvanic isolation.

[Learn More]

3D Hall 3 click

5

3D Hall 3 click is a very accurate, magnetic field sensing Click board, used to measure the intensity of the magnetic field across three perpendicular axes.

[Learn More]

Temp-Log 6 click

5

Temp-Log 6 click is a temperature sensing Click board, which features the MAX6642, a specifically designed IC, capable of measuring its own die temperature, as well as a temperature at a remote PN junction.

[Learn More]