Highly versatile color recognizer
A
A
Hardware Overview
How does it work?
Color 16 Click is based on the AS7343, a 14-channel multi-purpose spectral sensor from ams AG, providing fast and accurate spectral measurements. It is optimized for reflective (thanks to an onboard LDC red LED controlled through AN pin of the mikroBUS™ socket), transmissive, and emissive light applications, including color matching, fluid or reagent analysis, lateral flow test applications, and spectral identification in the visible range. The AS7343 has a built-in aperture that controls the light entering the sensor array to increase accuracy. The spectral response is defined by individual channels covering approximately 380nm to 1000nm with 11 channels centered in the visible spectrum, one near-infrared, and a clear channel. The AS7343 features a 5x5 photodiode array. Above and below the array, there are two photodiodes with
dedicated functions such as flicker detection and near-infrared response, while in each corner, the array has a photodiode without a filter that is responsive in the visible spectral range. The AS7343 can detect 14 channels - 12 wavelengths, plus a clear and flicker output channel - making this Click board™ great for LED color calibration, miniature optical spectrometers, and more. This sensor does not need a specific Power-Up sequence but requires a voltage of 1.8V for its interface and logic part to work correctly. Therefore, a small regulating LDO, the TLV700, provides a 1.8V out of 3.3V mikroBUS power rail. Color 16 Click communicates with MCU using the standard I2C 2-Wire interface with a maximum clock frequency of 400kHz, fully adjustable through software registers. Since the sensor for operation requires a power supply
of 1.8V, this Click board™ also features the PCA9306 and SN74LVC1T45 voltage-level translators. The I2C interface bus lines are routed to the voltage-level translators allowing this Click board to work with 3.3V MCU properly. Also, it uses an interrupt pin, the INT pin of the mikroBUS™ socket, used when an interrupt occurs to alert the system when the color result crosses upper or lower threshold settings. This Click board™ can only be operated with a 3.3V logic voltage level. The board must perform appropriate logic voltage level conversion before using MCUs with different logic levels. However, the Click board™ comes equipped with a library containing functions and an example code that can be used as a reference for further development.
Features overview
Development board
PIC32MZ Clicker is a compact starter development board that brings the flexibility of add-on Click boards™ to your favorite microcontroller, making it a perfect starter kit for implementing your ideas. It comes with an onboard 32-bit PIC32MZ microcontroller with FPU from Microchip, a USB connector, LED indicators, buttons, a mikroProg connector, and a header for interfacing with external electronics. Thanks to its compact design with clear and easy-recognizable silkscreen markings, it provides a fluid and immersive working experience, allowing access anywhere and under
any circumstances. Each part of the PIC32MZ Clicker development kit contains the components necessary for the most efficient operation of the same board. In addition to the possibility of choosing the PIC32MZ Clicker programming method, using USB HID mikroBootloader, or through an external mikroProg connector for PIC, dsPIC, or PIC32 programmer, the Clicker board also includes a clean and regulated power supply module for the development kit. The USB Micro-B connection can provide up to 500mA of current, which is more than enough to operate all onboard
and additional modules. All communication methods that mikroBUS™ itself supports are on this board, including the well-established mikroBUS™ socket, reset button, and several buttons and LED indicators. PIC32MZ Clicker is an integral part of the Mikroe ecosystem, allowing you to create a new application in minutes. Natively supported by Mikroe software tools, it covers many aspects of prototyping 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
PIC32
MCU Memory (KB)
1024
Silicon Vendor
Microchip
Pin count
64
RAM (Bytes)
524288
Used MCU Pins
mikroBUS™ mapper
Take a closer look
Schematic
Step by step
Project assembly
Track your results in real time
Application Output via Debug Mode
1. Once the code example is loaded, pressing the "DEBUG" button initiates the build process, programs it on the created setup, and enters Debug mode.
2. After the programming is completed, a header with buttons for various actions within the IDE becomes visible. Clicking the green "PLAY" button starts reading the results achieved with the Click board™. The achieved results are displayed in the Application Output tab.
Software Support
Library Description
This library contains API for Color 16 Click driver.
Key functions:
color16_read_data
This function checks if the spectral measurement data is ready and then reads data from all channels along with the STATUS and ASTATUS bytes.color16_set_wait_time_ms
This function sets the wait time in milliseconds by setting the WTIME register.color16_set_integration_time_ms
This function sets the integration time in milliseconds by setting the ATIME and ASTEP registers.
Open Source
Code example
This example can be found in NECTO Studio. Feel free to download the code, or you can copy the code below.
/*!
* @file main.c
* @brief Color 16 Click example
*
* # Description
* This example demonstrates the use of Color 16 click by reading and displaying
* the values from all 14 channels.
*
* The demo application is composed of two sections :
*
* ## Application Init
* Initializes the driver and performs the click default configuration.
*
* ## Application Task
* Waits for the spectral measurement complete flag and then reads data from all 14 channels
* in 3 cycles, and displays the results on the USB UART every 300ms approximately.
*
* @author Stefan Filipovic
*
*/
#include "board.h"
#include "log.h"
#include "color16.h"
static color16_t color16;
static log_t logger;
void application_init ( void )
{
log_cfg_t log_cfg; /**< Logger config object. */
color16_cfg_t color16_cfg; /**< Click config object. */
/**
* 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.
color16_cfg_setup( &color16_cfg );
COLOR16_MAP_MIKROBUS( color16_cfg, MIKROBUS_1 );
if ( I2C_MASTER_ERROR == color16_init( &color16, &color16_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
if ( COLOR16_ERROR == color16_default_cfg ( &color16 ) )
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
}
void application_task ( void )
{
color16_data_t color_data;
if ( COLOR16_OK == color16_read_data ( &color16, &color_data ) )
{
log_printf ( &logger, " STATUS: 0x%.2X\r\n", ( uint16_t ) color_data.status );
log_printf ( &logger, " ASTATUS: 0x%.2X\r\n", ( uint16_t ) color_data.astatus );
log_printf ( &logger, " ------- Cycle 1 -------\r\n" );
log_printf ( &logger, " Channel FZ: %u\r\n", color_data.ch_fz );
log_printf ( &logger, " Channel FY: %u\r\n", color_data.ch_fy );
log_printf ( &logger, " Channel FXL: %u\r\n", color_data.ch_fxl );
log_printf ( &logger, " Channel NIR: %u\r\n", color_data.ch_nir );
log_printf ( &logger, " Channel 2xVIS_1: %u\r\n", color_data.ch_2x_vis_1 );
log_printf ( &logger, " Channel FD_1: %u\r\n", color_data.ch_fd_1 );
log_printf ( &logger, " ------- Cycle 2 -------\r\n" );
log_printf ( &logger, " Channel F2: %u\r\n", color_data.ch_f2 );
log_printf ( &logger, " Channel F3: %u\r\n", color_data.ch_f3 );
log_printf ( &logger, " Channel F4: %u\r\n", color_data.ch_f4 );
log_printf ( &logger, " Channel F6: %u\r\n", color_data.ch_f6 );
log_printf ( &logger, " Channel 2xVIS_2: %u\r\n", color_data.ch_2x_vis_2 );
log_printf ( &logger, " Channel FD_2: %u\r\n", color_data.ch_fd_2 );
log_printf ( &logger, " ------- Cycle 3 -------\r\n" );
log_printf ( &logger, " Channel F1: %u\r\n", color_data.ch_f1 );
log_printf ( &logger, " Channel F5: %u\r\n", color_data.ch_f5 );
log_printf ( &logger, " Channel F7: %u\r\n", color_data.ch_f7 );
log_printf ( &logger, " Channel F8: %u\r\n", color_data.ch_f8 );
log_printf ( &logger, " Channel 2xVIS_3: %u\r\n", color_data.ch_2x_vis_3 );
log_printf ( &logger, " Channel FD_3: %u\r\n", color_data.ch_fd_3 );
log_printf ( &logger, " -----------------------\r\n\n" );
Delay_ms ( 300 );
}
}
void main ( void )
{
application_init( );
for ( ; ; )
{
application_task( );
}
}
// ------------------------------------------------------------------------ END