Achieve unparalleled levels of precision and accuracy in your motion tracking and control systems
A
A
Hardware Overview
How does it work?
Opto encoder Click is based on the TCUT1600X01, a tall dome dual channel transmissive optical sensor with phototransistor outputs from Vishay. This sensor is equipped with one infrared LED with the wavelength of 950nm, and two phototransistors. These phototransistors are positioned behind two small slits on the sensor, on the opposite side of the LED. They form two separate channels. When the transistors get illuminated by the LED, they become conductive. The collectors of these transistors are connected to the same pin, while their emitters are routed to two separate output pins of the TCUT1600X01 - E1 and E2. This allows the activity on both channels to be detected by the host MCU. Since the signals of these two output channels are not enough to drive pins
on a host MCU, the Click board™ features two additional MOSFETs. These MOSFETs are also used to drive two additional LEDs, which indicate activity of each channel. E1 and E2 pins are routed to the MOSFET gate pins, while the MOSFET drains are routed to the mikroBUS™ PWM and INT pins. These pins are pulled to a LOW logic level by the pull-down resistors, to avoid floating. Signal encoding itself is done by the host MCU. Having two optical sensing channels, Opto Encoder click has the ability of both speed and direction encoding. The most common usage is encoding of the step motor position: a cylinder with slits is physically mounted above the sensor so that the LED can illuminate the phototransistors only through these slits. By rotating this cylinder,
the light beam will be blocked periodically. The single sensor output will be a pulse train, while the cylinder is rotating. Having two photo sensors physically distanced by a small amount, allows the pulse signal of the first sensor to be either delayed or expedited with respect to the pulse on the second sensor, depending on the rotational direction. This Click board™ can operate with either 3.3V or 5V logic voltage levels selected via the VCC SEL jumper. This way, both 3.3V and 5V capable MCUs can use the communication lines properly. Also, this Click board™ comes equipped with a library containing easy-to-use functions and an example code that can be used as a reference for further development.
Features overview
Development board
EasyPIC v8 is a development board specially designed for the needs of rapid development of embedded applications. It supports many high pin count 8-bit PIC microcontrollers from Microchip, regardless of their number of pins, and a broad set of unique functions, such as the first-ever embedded debugger/programmer. The development board is well organized and designed so that the end-user has all the necessary elements, such as switches, buttons, indicators, connectors, and others, in one place. Thanks to innovative manufacturing technology, EasyPIC v8 provides a fluid and immersive working experience, allowing access anywhere and under any
circumstances at any time. Each part of the EasyPIC v8 development board contains the components necessary for the most efficient operation of the same board. In addition to the advanced integrated CODEGRIP programmer/debugger module, which offers many valuable programming/debugging options and seamless integration with the Mikroe software environment, the board also includes a clean and regulated power supply module for the development board. It can use a wide range of external power sources, including a battery, an external 12V power supply, and a power source via the USB Type-C (USB-C) connector.
Communication options such as USB-UART, USB DEVICE, and CAN are also included, including the well-established mikroBUS™ standard, two display options (graphical and character-based LCD), and several different DIP sockets. These sockets cover a wide range of 8-bit PIC MCUs, from the smallest PIC MCU devices with only eight up to forty pins. EasyPIC v8 is an integral part of the Mikroe ecosystem for rapid development. Natively supported by Mikroe software tools, it covers many aspects of prototyping and development thanks to a considerable number of different Click boards™ (over a thousand boards), the number of which is growing every day.
Microcontroller Overview
MCU Card / MCU

Architecture
PIC
MCU Memory (KB)
128
Silicon Vendor
Microchip
Pin count
40
RAM (Bytes)
3728
Used MCU Pins
mikroBUS™ mapper
Take a closer look
Click board™ Schematic

Step by step
Project assembly
Track your results in real time
Application Output
1. Application Output - In Debug mode, the 'Application Output' window enables real-time data monitoring, offering direct insight into execution results. Ensure proper data display by configuring the environment correctly using the provided tutorial.

2. UART Terminal - Use the UART Terminal to monitor data transmission via a USB to UART converter, allowing direct communication between the Click board™ and your development system. Configure the baud rate and other serial settings according to your project's requirements to ensure proper functionality. For step-by-step setup instructions, refer to the provided tutorial.

3. Plot Output - The Plot feature offers a powerful way to visualize real-time sensor data, enabling trend analysis, debugging, and comparison of multiple data points. To set it up correctly, follow the provided tutorial, which includes a step-by-step example of using the Plot feature to display Click board™ readings. To use the Plot feature in your code, use the function: plot(*insert_graph_name*, variable_name);. This is a general format, and it is up to the user to replace 'insert_graph_name' with the actual graph name and 'variable_name' with the parameter to be displayed.

Software Support
Library Description
This library contains API for Opto encoder Click driver.
Key functions:
optoencoder_getO1
- Function for reading O1 stateoptoencoder_init_dev
- Initialization functionoptoencoder_get_position
- Function for reading the position of the encoder
Open Source
Code example
The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.
/*!
* \file
* \brief Opto Encoder Click example
*
* # Description
* This application is used to encode motion or rotation.
*
* The demo application is composed of two sections :
*
* ## Application Init
* Initializes driver and opto encoder.
*
* ## Application Task
* Depending on the direction of the movement it increments/decrements the step counter.
*
* \author MikroE Team
*
*/
// ------------------------------------------------------------------- INCLUDES
#include "board.h"
#include "log.h"
#include "optoencoder.h"
// ------------------------------------------------------------------ VARIABLES
static optoencoder_t optoencoder;
static log_t logger;
static int16_t old_step = 0;
// ------------------------------------------------------ APPLICATION FUNCTIONS
void application_init ( void )
{
log_cfg_t log_cfg;
optoencoder_cfg_t cfg;
/**
* Logger initialization.
* Default baud rate: 115200
* Default log level: LOG_LEVEL_DEBUG
* @note If USB_UART_RX and USB_UART_TX
* are defined as HAL_PIN_NC, you will
* need to define them manually for log to work.
* See @b LOG_MAP_USB_UART macro definition for detailed explanation.
*/
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info(&logger, "---- Application Init ----");
// Click initialization.
optoencoder_cfg_setup( &cfg );
OPTOENCODER_MAP_MIKROBUS( cfg, MIKROBUS_1 );
optoencoder_init( &optoencoder, &cfg );
optoencoder_init_dev( &optoencoder );
}
void application_task ( )
{
int16_t new_step;
new_step = optoencoder_get_position( &optoencoder );
if ( old_step != new_step)
{
log_printf( &logger, "Step: %d \r\n", new_step );
old_step = new_step;
}
}
void main ( void )
{
application_init( );
for ( ; ; )
{
application_task( );
}
}
// ------------------------------------------------------------------------ END