How does it work?
Opto Encoder 4 Click is based on the EE-SX4330, a transmissive photo-microsensor from OMRON. The sensor uses a two-tower design. The emitter consists of an LED with a peak emission wavelength of 855nm and a 1.4×1.4mm window. The detector has a peak spectral sensitivity wavelength of 870nm and a narrower window than the emitter (1×0.3mm). This, and a fast response delay time, ensures more precise readings of a spinning encoder disk. By calculating the number of readings in a given time, you can determine the spinning speed. However, you can’t detect the rotation.
Opto Encoder 4 Click uses a general-purpose IO to notify the host MCU of interrupts the EE-SX4330 provides over the OUR pin. For visual presentation, there is the OUT LED. The OUT pin is the opto encoder output. There is a 4-pin header that allows you to use those outputs for an external device (relay, LED, and more).
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.
Specifications
Type
Optical
Applications
Can be used for the development of optical sensors in automotive applications, motion, speed, and direction sensors, precise motor shaft positioning applications, knob encoder applications, and more
On-board modules
EE-SX4330 – transmissive photo-microsensor from OMRON
Key Features
In combination with an encoder disk or similar object, it can detect movement, and the spinning speed, fast response delay time, precise readings, minimal response frequency of 3KHz, two-tower design, low power consumption, and more
Interface
Analog,GPIO
Feature
ClickID
Compatibility
mikroBUS™
Click board size
M (42.9 x 25.4 mm)
Input Voltage
3.3V or 5V
Pinout diagram
This table shows how the pinout on Opto Encoder 4 Click corresponds to the pinout on the mikroBUS™ socket (the latter shown in the two middle columns).
Onboard settings and indicators
Label | Name | Default | Description |
---|---|---|---|
LD1 | PWR | – | Power LED Indicator |
LD2 | OUT | – | Output Detection LED Indicator |
JP1 | VCC SEL | Left | Logic Level Voltage Selection 3V3/5V: Left position 3V3, Right position 5V |
Opto Encoder 4 Click electrical specifications
Description | Min | Typ | Max | Unit |
---|---|---|---|---|
Supply Voltage | 3.3 | – | 5 | V |
Emitter Peak Wavelength | – | 855 | – | nm |
Detector Peak Sensitivity Wavelength | – | 870 | – | nm |
Software Support
We provide a library for the Opto Encoder 4 Click as well as a demo application (example), developed using MikroElektronika compilers. The demo can run on all the main MikroElektronika development boards.
Package can be downloaded/installed directly from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on Mikroe github account.
Library Description
This library contains API for Opto Encoder 4 Click driver.
Key functions
-
optoencoder4_get_out_pin
This function returns the output pin logic state. -
optoencoder4_get_our_pin
This function returns the output pin reversed logic state.
Example Description
This example demonstrates the use of Opto Encoder 4 Click board™ by processing the encoder output pin state and incrementing the step counter on falling edge.
void application_task ( void )
{
static uint32_t step_cnt = 0;
log_printf( &logger, " Step counter : %lurn", step_cnt );
// Increment counter on falling edge of output pin
while ( !optoencoder4_get_out_pin ( &optoencoder4 ) );
while ( optoencoder4_get_out_pin ( &optoencoder4 ) );
step_cnt++;
}
The full application code, and ready to use projects can be installed directly from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on Mikroe github account.
Other Mikroe Libraries used in the example:
- MikroSDK.Board
- MikroSDK.Log
- Click.OptoEncoder4
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. UART terminal is available in all MikroElektronika compilers.
mikroSDK
This 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.
For more information about mikroSDK, visit the official page.