This Click board™ features a very small optical encoder employing reflective technology for motion control purposes. The encoder houses an LED light source and a photo-detecting circuitry in a single package. It can be used as an optical sensor in automotive applications, motion, speed, and direction sensor, for precise motor shaft positioning applications, knob encoder applications, and similar applications, where dual channel optical sensing can be utilized.
How does it work?
The optical sensor used on the Opto Encoder 2 click is the AEDR-8300, reflective Surface Mount Optical Encoder from Avago Technologies. This sensor combines an emitter and a detector in a single surface mount leadless package. the AEDR-8300 consists of three major components: a light emitting diode (LED) light source, a detector IC consisting photodiodes and lens to focus light beam from the emitter as well as light falling on the detector. The operation of the encoder is based on the principle of optics where the detector photodiodes sense the absence and presence of light. In this case, the rotary/linear motion of an object being monitored is converted to equivalent light pattern via the use of codewheel/codestrip.
Opto Encoder 2 click offers options of either single channel or two-channel quadrature digital outputs. Being TTL compatible, the outputs of the AEDR-8300 series can be interfaced directly with MCU. Hence the Opto Encoder 2 click provides great design-in flexibility and easy integration into existing systems. A and B pins are routed to the routed to the mikroBUS™ PWM and INT pins, thus providing the quadrature digital signal.
Signal encoding itself is done by the host MCU. Having two optical sensing channels, Opto Encoder 2 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 photodiodes only when light hits the reflective surface of the codewheel. 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.
Since the sensors recomended operating voltage is 5V, the Opto Encoder 2 click uses the 5V rail for power supply. The other pins it utilizes are the, before mentioned, Interrupt and PWM pins on mikroBUS™ socket. This click also has a Power LED indicator.
This Click Board™ is designed to be operated only with 5V logic level. A proper logic voltage level conversion should be performed before the Click board™ is used with MCUs with logic levels of 3.3V.
Specifications
Type
Optical
Applications
Automotive optical sensors, accurate position sensor for encoder, sensor for motion, speed, and direction, etc.
On-board modules
Reflective Surface Mount Optical Encoder from Avago Technologies
Key Features
The Opto Encoder 2 click features a precise detection of the position, speed, or rotational angle of an object. It is able to detect the direction of the movement since it features two photo-sensing elements.
Interface
GPIO
Feature
No ClickID
Compatibility
mikroBUS™
Click board size
S (28.6 x 25.4 mm)
Input Voltage
5V
Pinout diagram
This table shows how the pinout on Opto Encoder 2 click corresponds to the pinout on the mikroBUS™ socket (the latter shown in the two middle columns).
Opto Encoder 2 click specifications
Description | Min | Typ | Max | Unit |
---|---|---|---|---|
Supply Voltage | 4.5 | 5 | 5.5 | V |
LED Current | 13 | 15 | 18 | µs |
Count Frequency | – | – | 30 | kHZ |
Resolution | – | 75 | – | LPI |
Onboard settings and indicators
Label | Name | Default | Description |
---|---|---|---|
LD1 | PWR | – | Power LED Indicator |
Software Support
We provide a library for the Opto Encoder 2 click on our LibStock page, as well as a demo application (example), developed using MikroElektronika compilers. The demo can run on all the main MikroElektronika development boards.
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 ); } }
The full application code, and ready to use projects can be found on our LibStock page.
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 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.
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.