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]
Rating:
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.
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".
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 chipvoid ultrasonic2_getUltrasonicMeasurement(uint8_t numObj, float *distOUT, uint16_t *widthOUT, uint8_t *ampOUT)
- Function for getting ultrasonic measurementvoid ultrasonic2_getDiagnostics(float *freqOUT, float *periodOUT, float *tempOUT, float *noiceOUT)
- Function for reading diagnosticsExamples description
The application is composed of the three sections :
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 );
}
void UART_RX_ISR()iv IVT_INT_USART3 ics ICS_AUTO
{
if( RXNE_USART3_SR_bit )
{
char tmp = USART3_DR;
ultrasonic2_getc(tmp);
}
}
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 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. The terminal available in all MikroElektronika compilers, or any other terminal application of your choice, can be used to read the message.