Turn raw motion data into valuable insights for your applications
A
A
Hardware Overview
How does it work?
Accel 28 Click is based on the LIS2HH12TR, an ultra-low-power, high-performance three-axis accelerometer from STMicroelectronics. The sensing element is made of a suspended silicone structure anchored in a few points and free to move toward the sensed acceleration. If there is an acceleration, the proof mass is displaced from its normal position and causes an imbalance in the capacitive half-bridge, which is measured. The whole measurements are on the values of internal capacitors. The values are outputted as 16-bit data. The sensor features extreme robustness with 10000g of high shock survivability. It also has an embedded temperature sensor for temperature compensation and a self-test. The self-test capability allows the user to check the functioning of the sensor in the final application. The sensor is
already factory-calibrated. The FIFO buffer of the LIS2HH12TR sensor works in several modes. Bypass mode bypasses the FIFO and is used to reset the FIFO when in FIFO mode. In FIFO mode, the sensor stores data from all three channels in the FIFO buffer. Stream mode provides continuous FIFO updates; the older data is discarded as new data arrives. There are additional modes: Stream-to-FIFO, Bypass-to-Stream, Bypass-to-FIFO, Retrieving data from FIFO, and Burst. The Burst mode allows multiple reads to be performed. Accel 28 Click allows the use of both I2C and SPI interfaces with a maximum frequency of 400KHz for I2C and 10MHz for SPI communication. The selection can be made by positioning SMD jumpers labeled as COMM SEL in an appropriate position. Note that all the jumpers' positions must
be on the same side, or the Click board™ may become unresponsive. While the I2C interface is selected, the LIS2DTW12 allows choosing the least significant bit (LSB) of its I2C slave address using the SMD jumper labeled ADDR SEL. The Accel 28 also possesses two interrupt pins, both routed to the INT pin on the mikroBUS™ socket over the INT SEL jumper (default INT1). These interrupt pins signal MCU that the user has sensed an event entirely through the I2C/SPI interface. This Click board™ can be operated only with a 3.3V logic voltage level. The board must perform appropriate logic voltage level conversion before using MCUs with different logic levels. Also, it comes equipped with a library containing functions and an example code that can be used as a reference for further development.
Features overview
Development board
EasyPIC v7 is the seventh generation of PIC development boards specially designed to develop embedded applications rapidly. It supports a wide range of 8-bit PIC microcontrollers from Microchip and has a broad set of unique functions, such as a powerful onboard mikroProg programmer and In-Circuit debugger over USB-B. The development board is well organized and designed so that the end-user has all the necessary elements in one place, such as switches, buttons, indicators, connectors, and others. With four different connectors for each port, EasyPIC v7 allows you to connect accessory boards, sensors, and custom electronics more efficiently than ever. Each part of
the EasyPIC v7 development board contains the components necessary for the most efficient operation of the same board. An integrated mikroProg, a fast USB 2.0 programmer with mikroICD hardware In-Circuit Debugger, offers many valuable programming/debugging options and seamless integration with the Mikroe software environment. Besides it also includes a clean and regulated power supply block for the development board. It can use various external power sources, including an external 12V power supply, 7-23V AC or 9-32V DC via DC connector/screw terminals, and a power source via the USB Type-B (USB-B) connector. Communication options such as
USB-UART and RS-232 are also included, alongside the well-established mikroBUS™ standard, three display options (7-segment, graphical, and character-based LCD), and several different DIP sockets. These sockets cover a wide range of 8-bit PIC MCUs, from PIC10F, PIC12F, PIC16F, PIC16Enh, PIC18F, PIC18FJ, and PIC18FK families. EasyPIC v7 is an integral part of the Mikroe ecosystem for rapid development. Natively supported by Mikroe software tools, it covers many aspects of prototyping and development thanks to a considerable number of different Click boards™ (over a thousand boards), the number of which is growing every day.
Microcontroller Overview
MCU Card / MCU
![default](https://dbp-cdn.mikroe.com/catalog/mcus/resources/PIC18F2455.jpg)
Architecture
PIC
MCU Memory (KB)
24
Silicon Vendor
Microchip
Pin count
28
RAM (Bytes)
2048
Used MCU Pins
mikroBUS™ mapper
Take a closer look
Schematic
![Accel 28 Click Schematic schematic](https://dbp-cdn.mikroe.com/catalog/click-boards/resources/1ee7fab7-32e0-6ec6-a638-0242ac120003/Accel-28-click-v100-Schematic-1.png)
Step by step
Project assembly
Track your results in real time
Application Output
After pressing the "FLASH" button on the left-side panel, it is necessary to open the UART terminal to display the achieved results. By clicking on the Tools icon in the right-hand panel, multiple different functions are displayed, among which is the UART Terminal. Click on the offered "UART Terminal" icon.
![UART Application Output Step 1](https://dbp-cdn.mikroe.com/cms/shared-resources/1eed703a-40a0-6b58-88de-02420a00029a/UART-AO-Step-1.jpg)
Once the UART terminal is opened, the window takes on a new form. At the top of the tab are two buttons, one for adjusting the parameters of the UART terminal and the other for connecting the UART terminal. The tab's lower part is reserved for displaying the achieved results. Before connecting, the terminal has a Disconnected status, indicating that the terminal is not yet active. Before connecting, it is necessary to check the set parameters of the UART terminal. Click on the "OPTIONS" button.
![UART Application Output Step 2](https://dbp-cdn.mikroe.com/cms/shared-resources/1eed703a-eb29-62fa-ba91-02420a00029a/UART-AO-Step-2.jpg)
In the newly opened UART Terminal Options field, we check if the terminal settings are correct, such as the set port and the Baud rate of UART communication. If the data is not displayed properly, it is possible that the Baud rate value is not set correctly and needs to be adjusted to 115200. If all the parameters are set correctly, click on "CONFIGURE".
![UART Application Output Step 3](https://dbp-cdn.mikroe.com/cms/shared-resources/1eed703b-7543-6fbc-9c69-0242ac120003/UART-AO-Step-3.jpg)
The next step is to click on the "CONNECT" button, after which the terminal status changes from Disconnected to Connected in green, and the data is displayed in the Received data field.
![UART Application Output Step 4](https://dbp-cdn.mikroe.com/cms/shared-resources/1eed703c-068c-66a4-a4fc-0242ac120003/UART-AO-Step-4.jpg)
Software Support
Library Description
This library contains API for Accel 28 Click driver.
Key functions:
accel28_get_data
- Accel 28 data reading function.accel28_write_reg
- Accel 28 register data writing function.accel28_sw_reset
- Accel 28 SW reset function.
Open Source
Code example
This example can be found in NECTO Studio. Feel free to download the code, or you can copy the code below.
/*!
* @file main.c
* @brief Accel 28 Click example
*
* # Description
* This example demonstrates the use of Accel 28 click board by reading and
* displaying the accelerometer data (X, Y, and Z axis).
*
* The demo application is composed of two sections :
*
* ## Application Init
* Initializes the driver, performs the click default configuration.
*
* ## Application Task
* Reads and displays on the USB UART the accelerometer data (X, Y, and Z axis)
* when it is available.
*
* @author Stefan Ilic
*
*/
#include "board.h"
#include "log.h"
#include "accel28.h"
static accel28_t accel28;
static log_t logger;
accel28_data_t accel_data;
void application_init ( void )
{
log_cfg_t log_cfg; /**< Logger config object. */
accel28_cfg_t accel28_cfg; /**< Click config object. */
/**
* Logger initialization.
* Default baud rate: 115200
* Default log level: LOG_LEVEL_DEBUG
* @note If USB_UART_RX and USB_UART_TX
* are defined as HAL_PIN_NC, you will
* need to define them manually for log to work.
* See @b LOG_MAP_USB_UART macro definition for detailed explanation.
*/
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
accel28_cfg_setup( &accel28_cfg );
ACCEL28_MAP_MIKROBUS( accel28_cfg, MIKROBUS_1 );
err_t init_flag = accel28_init( &accel28, &accel28_cfg );
if ( ( I2C_MASTER_ERROR == init_flag ) || ( SPI_MASTER_ERROR == init_flag ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
uint8_t id_data = 0;
accel28_generic_read( &accel28, ACCEL28_REG_WHO_AM_I, &id_data, 1 );
if ( ACCEL28_WHO_AM_I_VALUE != id_data )
{
log_error( &logger, " Communication error." );
for ( ; ; );
}
if ( ACCEL28_ERROR == accel28_default_cfg ( &accel28 ) )
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
}
void application_task ( void )
{
err_t error_flag = ACCEL28_OK;
if ( ACCEL28_PIN_STATE_HIGH == accel28_get_int_state( &accel28 ) )
{
uint8_t tmp_data;
error_flag = accel28_read_reg( &accel28, ACCEL28_REG_STATUS, &tmp_data );
if ( ( tmp_data & ACCEL28_STATUS_ZYX_DATA_AVL ) && ( ACCEL28_OK == error_flag ) )
{
error_flag = accel28_get_data( &accel28, &accel_data );
if ( ACCEL28_OK == error_flag )
{
log_printf( &logger, " X-axis %.2f mg\r\n", accel_data.x_data );
log_printf( &logger, " Y-axis %.2f mg\r\n", accel_data.y_data );
log_printf( &logger, " Z-axis %.2f mg\r\n", accel_data.z_data );
log_printf( &logger, " = = = = = = = = = = = = = =\r\n" );
}
}
}
}
void main ( void )
{
application_init( );
for ( ; ; )
{
application_task( );
}
}
// ------------------------------------------------------------------------ END