TOP Contributors

  1. MIKROE (2650 codes)
  2. Alcides Ramos (350 codes)
  3. Shawon Shahryiar (307 codes)
  4. jm_palomino (112 codes)
  5. Chisanga Mumba (90 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 (136545 times)
  2. FAT32 Library (69739 times)
  3. Network Ethernet Library (55845 times)
  4. USB Device Library (46180 times)
  5. Network WiFi Library (41803 times)
  6. FT800 Library (40990 times)
  7. GSM click (28924 times)
  8. PID Library (26385 times)
  9. mikroSDK (26286 times)
  10. microSD click (25300 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: 4215 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

PWM click

0

PWM click is a simple solution for controlling 16 PWM outputs through a single I2C interface. You can use it to control anything from a simple LED strip to a complex robot with a multitude of moving parts.

[Learn More]

Index Counter click

0

Index Counter Click is a simple prototyping high precision Hall-Effect switch solution with direction detection.

[Learn More]

Bargraph 2 click

0

BarGraph 2 click is a 10-segment bar graph display click, which uses a high-quality, multicolor bar graph LED display. The bar graph display is a very popular device for displaying various properties, whether it be an audio level, current/voltage level, position of the encoder, and generally any property that can be displayed in a form of a bar graph.

[Learn More]