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
Fusion for PIC v8 is a development board specially designed for the needs of rapid development of embedded applications. It supports a wide range of microcontrollers, such as different PIC, dsPIC, PIC24, and PIC32 MCUs regardless of their number of pins, and a broad set of unique functions, such as the first-ever embedded debugger/programmer over WiFi. 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, Fusion for PIC v8 provides a fluid and immersive working experience, allowing access anywhere and under any
circumstances at any time. Each part of the Fusion for PIC 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
HOST/DEVICE, CAN (on the MCU card, if supported), and Ethernet are also included, including the well-established mikroBUS™ standard, a standardized socket for the MCU card (SiBRAIN standard), and two display options (graphical and character-based LCD). Fusion for PIC 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
Type
8th Generation
Architecture
PIC32
MCU Memory (KB)
128
Silicon Vendor
Microchip
Pin count
100
RAM (Bytes)
32768
Used MCU Pins
mikroBUS™ mapper
Take a closer look
Schematic
Step by step
Project assembly
Track your results in real time
Application Output via UART Mode
1. Once the code example is loaded, pressing the "FLASH" button initiates the build process, and programs it on the created setup.
2. After the programming is completed, click on the Tools icon in the upper-right panel, and select the UART Terminal.
3. After opening the UART Terminal tab, first check the baud rate setting in the Options menu (default is 115200). If this parameter is correct, activate the terminal by clicking the "CONNECT" button.
4. Now terminal status changes from Disconnected to Connected in green, and the data is displayed in the Received data field.
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