analogmux5  2.0.0.0
Main Page

Analog MUX 5 click

Analog MUX 5 Click is a compact add-on board that switches one of many inputs to one output. This board features the MAX4634, a fast, low-voltage four-channel CMOS analog multiplexer from Analog Devices. This low-voltage multiplexer operates from both mikroBUS™ power rails and features 4Ω maximum ON-resistance (RON). CMOS switch construction allows the processing of analog signals within the supply voltage range. It is also characterized by an easy way of management, only through a couple of signals from the mikroBUS™ socket. This Click board™ is suitable for various applications, from industrial and instrumentation to medical, consumer, communications, and more.

click Product page


Click library

  • Author : Nikola Peric
  • Date : Apr 2022.
  • Type : ADC type

Software Support

We provide a library for the Analog MUX 5 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 Analog MUX 5 Click driver.

Standard key functions :

Example key functions :

Example Description

This example showcases how to initialize, configure and use the Analog MUX 5 click module.

The demo application is composed of two sections :

Application Init

Initializes the driver and enables the analog inputs.

void application_init ( void )
{
log_cfg_t log_cfg;
analogmux5_cfg_t analogmux5_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
analogmux5_cfg_setup( &analogmux5_cfg );
ANALOGMUX5_MAP_MIKROBUS( analogmux5_cfg, MIKROBUS_1 );
if ( ADC_ERROR == analogmux5_init( &analogmux5, &analogmux5_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
if ( ANALOGMUX5_ERROR == analogmux5_default_cfg ( &analogmux5 ) )
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
}

Application Task

This is an example that shows the use of a Analog MUX 5 click board In this example, we switch from channel AN1 to channel AN4, read and display the analog value and voltage on the active channel. Results are being sent to the Usart Terminal where you can track their changes.

void application_task ( void )
{
float analogmux5_an_voltage = 0;
Delay_ms( 100 );
if ( ADC_ERROR != analogmux5_read_an_pin_voltage ( &analogmux5, &analogmux5_an_voltage ) )
{
log_printf( &logger, " Channel [ 1 ] ---> AN Voltage : %.3f[V]\r\n\n", analogmux5_an_voltage );
}
Delay_ms( 100 );
if ( ADC_ERROR != analogmux5_read_an_pin_voltage ( &analogmux5, &analogmux5_an_voltage ) )
{
log_printf( &logger, " Channel [ 2 ] ---> AN Voltage : %.3f[V]\r\n\n", analogmux5_an_voltage );
}
Delay_ms( 100 );
if ( ADC_ERROR != analogmux5_read_an_pin_voltage ( &analogmux5, &analogmux5_an_voltage ) )
{
log_printf( &logger, " Channel [ 3 ] ---> AN Voltage : %.3f[V]\r\n\n", analogmux5_an_voltage );
}
Delay_ms( 100 );
if ( ADC_ERROR != analogmux5_read_an_pin_voltage ( &analogmux5, &analogmux5_an_voltage ) )
{
log_printf( &logger, " Channel [ 4 ] ---> AN Voltage : %.3f[V]\r\n\n", analogmux5_an_voltage );
}
Delay_ms( 1000 );
}

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.AnalogMUX5

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.


analogmux5_init
err_t analogmux5_init(analogmux5_t *ctx, analogmux5_cfg_t *cfg)
Analog MUX 5 initialization function.
analogmux5_cfg_setup
void analogmux5_cfg_setup(analogmux5_cfg_t *cfg)
Analog MUX 5 configuration object setup function.
ANALOGMUX5_SEL_CH_4
#define ANALOGMUX5_SEL_CH_4
Definition: analogmux5.h:56
application_task
void application_task(void)
Definition: main.c:67
analogmux5_select_ch
err_t analogmux5_select_ch(analogmux5_t *ctx, uint8_t ch_select)
Analog MUX 5 set channel function.
ANALOGMUX5_SEL_CH_3
#define ANALOGMUX5_SEL_CH_3
Definition: analogmux5.h:55
ANALOGMUX5_ERROR
@ ANALOGMUX5_ERROR
Definition: analogmux5.h:120
analogmux5_cfg_t
Analog MUX 5 Click configuration object.
Definition: analogmux5.h:102
analogmux5_t
Analog MUX 5 Click context object.
Definition: analogmux5.h:88
ANALOGMUX5_SEL_CH_2
#define ANALOGMUX5_SEL_CH_2
Definition: analogmux5.h:54
ANALOGMUX5_SEL_CH_1
#define ANALOGMUX5_SEL_CH_1
List of Muxs of Analog MUX 5 Click driver.
Definition: analogmux5.h:53
analogmux5_enable
void analogmux5_enable(analogmux5_t *ctx)
Analog MUX 5 enable function.
application_init
void application_init(void)
Definition: main.c:31
analogmux5_read_an_pin_voltage
err_t analogmux5_read_an_pin_voltage(analogmux5_t *ctx, float *data_out)
Analog MUX 5 read AN pin voltage level function.
analogmux5_default_cfg
err_t analogmux5_default_cfg(analogmux5_t *ctx)
Analog MUX 5 default configuration function.
ANALOGMUX5_MAP_MIKROBUS
#define ANALOGMUX5_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition: analogmux5.h:74