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-08-23
Package Version: 1.0.0.0
mikroSDK Library: 1.0.0.0
Category: Optical
Downloaded: 3342 times
Not followed.
License: MIT license
Opto Encoder 3 Click is a linear incremental optical sensor/encoder click, which can be used for the movement or rotation encoding.
Do you want to subscribe in order to receive notifications regarding "Opto Encoder 3 click" changes.
Do you want to unsubscribe in order to stop receiving notifications regarding "Opto Encoder 3 click" changes.
Do you want to report abuse regarding "Opto Encoder 3 click".
Library Description
The library includes functions to enable or disable reading pins, reading every single pin or reading all at once. The user has a function to count number of swipes, counter for direction swipes and function for reseting these counters.
Key functions:
void optoencoder3_Enabler(uint8_t active)
- Enables or disables readingvoid optoencoder3_readAllPins(T_OPTOENCODER3_PINS *pins)
- Reads state of all pinsuint8_t optoencoder3_Counter()
- Counts number of swipesint8_t optoencoder3_DirectionCounter()
- Counts number of swipe directionvoid optoencoder3_ResetCounters()
- Resets all countersExamples description
The application is composed of three sections :
void applicationTask()
{
uint8_t dataReady_;
char receivedData_;
dataReady_ = UART_Rdy_Ptr( );
if (dataReady_ != 0)
{
receivedData_ = UART_Rd_Ptr( );
switch (receivedData_)
{
case '1' :
{
taskNum = 1;
break;
}
case '2' :
{
taskNum = 2;
break;
}
case 'r' :
{
optoencoder3_ResetCounters();
taskNum = 0;
break;
}
}
}
if (taskNum == 1)
{
_drawPinsStatus();
}
else if (taskNum == 2)
{
_viewCounters();
}
else if (taskNum == 0)
{
_infoWrite();
}
}
Additional Functions :
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.