TOP Contributors

  1. MIKROE (2779 codes)
  2. Alcides Ramos (376 codes)
  3. Shawon Shahryiar (307 codes)
  4. jm_palomino (118 codes)
  5. Bugz Bensce (97 codes)
  6. S P (73 codes)
  7. dany (71 codes)
  8. MikroBUS.NET Team (35 codes)
  9. NART SCHINACKOW (34 codes)
  10. Armstrong Subero (27 codes)

Most Downloaded

  1. Timer Calculator (139559 times)
  2. FAT32 Library (72041 times)
  3. Network Ethernet Library (57254 times)
  4. USB Device Library (47607 times)
  5. Network WiFi Library (43219 times)
  6. FT800 Library (42551 times)
  7. GSM click (29930 times)
  8. mikroSDK (28292 times)
  9. PID Library (26930 times)
  10. microSD click (26309 times)
Libstock prefers package manager

Package Manager

We strongly encourage users to use Package manager for sharing their code on Libstock website, because it boosts your efficiency and leaves the end user with no room for error. [more info]

< Back
mikroSDK Library

Ultrasonic 2 click

Rating:

6

Author: MIKROE

Last Updated: 2019-01-04

Package Version: 1.0.0.0

mikroSDK Library: 1.0.0.0

Category: Miscellaneous

Downloaded: 4847 times

Not followed.

License: MIT license  

The Ultrasonic 2 click is an ultrasonic range detection Click board, capable of detecting both near-field and far-field objects. It is equipped with the PGA460, a highly-integrated system-on-chip (SoC), based on SONAR principle.

No Abuse Reported

Do you want to subscribe in order to receive notifications regarding "Ultrasonic 2 click" changes.

Do you want to unsubscribe in order to stop receiving notifications regarding "Ultrasonic 2 click" changes.

Do you want to report abuse regarding "Ultrasonic 2 click".

  • Information
  • Comments (0)
DOWNLOAD LINK RELATED COMPILER CONTAINS
mikroBasic PRO for ARM
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroBasic PRO for AVR
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroBasic PRO for dsPIC30/33 & PIC24
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroBasic PRO for FT90x
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroBasic PRO for PIC
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroBasic PRO for PIC32
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroC PRO for ARM
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroC PRO for AVR
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroC PRO for dsPIC30/33 & PIC24
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroC PRO for FT90x
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroC PRO for PIC
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroC PRO for PIC32
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroPascal PRO for ARM
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroPascal PRO for AVR
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroPascal PRO for dsPIC30/33 & PIC24
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroPascal PRO for FT90x
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroPascal PRO for PIC
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroPascal PRO for PIC32
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc

mikroSDK Library Blog

Ultrasonic 2 click

Ultrasonic 2 click

Native view of the Ultrasonic 2 click board.

View full image
Ultrasonic 2 click

Ultrasonic 2 click

Front and back view of the Ultrasonic 2 click board.

View full image

Library Description

The library initializes and defines the UART bus driver and drivers that offer a choice for writing data on UART. The library includes the function for initialization device, TVG, communication, and Thresholds, configuration chip and enabling device. The user also has the function for set Ambient temperature which depends on the speed of sound, the function for reading ultrasonic measurement and device diagnostics.

Key functions:

  • void ultrasonic2_enable(uint8_t state) - Function for enable chip
  • void ultrasonic2_getUltrasonicMeasurement(uint8_t numObj, float *distOUT, uint16_t *widthOUT, uint8_t *ampOUT) - Function for getting ultrasonic measurement
  • void ultrasonic2_getDiagnostics(float *freqOUT, float *periodOUT, float *tempOUT, float *noiceOUT) - Function for reading diagnostics

Examples description

The application is composed of the three sections :

  • System Initialization - Initializes UART module and sets CS and AN pins as OUTPUT
  • Application Initialization - Driver initialization for powering the Click board, chip configuration and reading the sensor diagnosis.
  • Application Task - (code snippet) - Starts measuring and measures the distance of an object every 500 ms.
void applicationTask()
{
    ultrasonic2_startUltrasonicMeasurement(_ULTRASONIC2_DETECT_OBJECT_1);

    for (cnt = 0; cnt < _ULTRASONIC2_DETECT_OBJECT_1; cnt++)
    {
        ultrasonic2_getUltrasonicMeasurement(cnt, &distance, &width, &peak);
        Delay_ms(10);

        distance = distance * 100;
        if(distance < 300)
        {
            FloatToStr(distance, demoText);
            demoText[ 6 ] = 0;
            mikrobus_logWrite(" Distance (cm): ",_LOG_TEXT);
            mikrobus_logWrite(demoText,_LOG_LINE);
        }
    }
    Delay_ms( 500 );
}
  • An additional function is used to store responses.
void UART_RX_ISR()iv IVT_INT_USART3 ics ICS_AUTO
{
    if( RXNE_USART3_SR_bit )
    {
        char tmp = USART3_DR;
        ultrasonic2_getc(tmp);
    }
}
  • Notes: Bear in mind that any change in device initialization drastically changes the workload of the device and its measurement pattern. This library has been made according to Texas Instruments PGA460 chip library.

Other mikroE Libraries used in the example:

  • UART

Additional notes and information

Depending on the development board you are using, you may need USB UART clickUSB 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.

ALSO FROM THIS AUTHOR

GSM-GPS Click

0

GSM-GPS Click is a mikroBUS add-on board with a SIM808 module that combines GSM/GPRS and GPS into a single device.

[Learn More]

PHT Click

0

PHT Click is a compact add-on board that contains a PHT combo sensor. This board features the MS8607, a digital combination sensor providing 3 environmental measurements all-in-one: pressure, humidity, and temperature from TE Connectivity. This sensor is based on leading MEMS technologies, provides factory-calibrated PHT data available over an I2C serial interface.

[Learn More]

Accel 8 click

5

Accel 8 click is an advanced 6-axis motion tracking Click boardâ„¢, which utilizes the MPU6050, a very popular motion sensor IC, equipped with a 3-axis gyroscope and 3-axis accelerometer.

[Learn More]