TOP Contributors

  1. MIKROE (2762 codes)
  2. Alcides Ramos (374 codes)
  3. Shawon Shahryiar (307 codes)
  4. jm_palomino (118 codes)
  5. Bugz Bensce (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 (139247 times)
  2. FAT32 Library (71743 times)
  3. Network Ethernet Library (57115 times)
  4. USB Device Library (47428 times)
  5. Network WiFi Library (43082 times)
  6. FT800 Library (42403 times)
  7. GSM click (29835 times)
  8. mikroSDK (28073 times)
  9. PID Library (26885 times)
  10. microSD click (26198 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: 4788 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

DAC 5 Click

0

DAC 5 Click carries Texas Instruments DAC53608 IC, a low-power, eight-channel, 10-bit buffered Digital-to-Analog Converter.

[Learn More]

Stepper 6 click

5

Stepper 6 click is the complete integrated bipolar step motor driver solution. It comes with the abundance of features that allow silent operation and optimal working conditions for the connected motor. A specialized integrated driver chip on this Click board far exceeds the capabilities of similar, commonly used step motor drivers.

[Learn More]

AlphaNum G click

5

AlphaNum G click is a simple solution for adding 14-segment alphanumeric displays to your device. The board carries two TLC5926 16-bit Constant-Current LED sink Drivers as well as a dual character LED 14-segment display. The board is designed to use either a 3.3V or 5V power supply.

[Learn More]