ultrasonic5 2.1.0.0
Main Page

Ultrasonic 5 click

‍Ultrasonic 5 Click is a compact add-on board that contains circuits for processing the ultrasonic sensor's output. This board features the TUSS4470, a transformer-drive ultrasonic sensor IC with a logarithmic amplifier from Texas Instruments. In addition to the high selectability of the power supply of the IC itself, this board also allows you to choose between 40kHz and 1MHz operating frequency, with a signal zero crossing comparator as an option. The ultrasonic sensor, the UTR-1440K from PUI Audio, also comes in the same package with this Click boardâ„¢.

click Product page


Click library

  • Author : Stefan Filipovic
  • Date : Jun 2023.
  • Type : SPI type

Software Support

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

Standard key functions :

Example key functions :

Example Description

‍This example demonstrates the use of Ultrasonic 5 click board by reading the measurements from the connected ultrasonic sensor and displaying it on a Serial Plot.

The demo application is composed of two sections :

Application Init

‍Initializes the driver and performs the click default configuration.

void application_init ( void )
{
log_cfg_t log_cfg;
ultrasonic5_cfg_t ultrasonic5_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
ultrasonic5_cfg_setup( &ultrasonic5_cfg );
ULTRASONIC5_MAP_MIKROBUS( ultrasonic5_cfg, MIKROBUS_1 );
if ( ULTRASONIC5_OK != ultrasonic5_init( &ultrasonic5, &ultrasonic5_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
if ( ULTRASONIC5_OK != ultrasonic5_default_cfg ( &ultrasonic5 ) )
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
}
#define ULTRASONIC5_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition ultrasonic5.h:262
void application_init(void)
Definition main.c:36
@ ULTRASONIC5_OK
Definition ultrasonic5.h:333

Application Task

‍Performs a burst generation which starts the measurement and then reads the next 200 ADC samples and displays the results on the USB UART (SerialPlot).

void application_task ( void )
{
float voltage = 0;
// Burst generation / Start measurement
ultrasonic5_pwm_start( &ultrasonic5 );
ultrasonic5_clear_io1_pin ( &ultrasonic5 );
Delay_500us ( );
ultrasonic5_set_io1_pin ( &ultrasonic5 );
ultrasonic5_pwm_stop( &ultrasonic5 );
// Read and log the next 200 ADC samples which we will plot on a Serial Plotter
for ( uint16_t cnt = 0; cnt < 200; cnt++ )
{
if ( ULTRASONIC5_OK == ultrasonic5_read_an_pin_voltage ( &ultrasonic5, &voltage ) )
{
log_printf( &logger, "%.3f\r\n", voltage );
}
}
}
#define ULTRASONIC5_DEF_DYTY
Definition ultrasonic5.h:221
err_t ultrasonic5_set_duty_cycle(ultrasonic5_t *ctx, float duty_cycle)
Ultrasonic 5 sets PWM duty cycle.
void ultrasonic5_set_io1_pin(ultrasonic5_t *ctx)
Ultrasonic 5 set io1 pin function.
err_t ultrasonic5_pwm_stop(ultrasonic5_t *ctx)
Ultrasonic 5 stop PWM module.
void application_task(void)
Definition main.c:72

Note

‍In order to get valid measuremets a proper ultrasonic sensor must be connected to OUTA and OUTB.

We have used an UTR-1440K-TT-R sensor for the test. We recommend using the SerialPlot tool for data visualizing. Refer to the datasheet "Application Curves" section in order to check and compare the results from the plotter.

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

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.