You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/hardware/06.nicla/boards/nicla-voice/tutorials/user-manual/content.md
+282-2Lines changed: 282 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -50,7 +50,7 @@ Here is an overview of the board's architecture's main components shown in the i
50
50
51
51
-**Microcontroller**: at the heart of the Nicla Voice is the nRF52832, a powerful and versatile System-on-Chip (SoC) from Nordic® Semiconductor. The nRF52832 is built around a 32-bit Arm® Cortex®-M4 processor running at 64 MHz.
52
52
-**Speech and sensor-fusion processor**: the board features the NDP120 Neural Decision ProcessorTM, an ultra-low power always-on audio and sensor-fusion processor from Syntiant®, which enables several applications, including echo-cancellation, beamforming, noise suppression, speech enhancement, speaker identification, keyword spotting, acoustic event and scene classification, and multi-sensor fusion.
53
-
-**Onboard advanced motion sensors**: the board features the BMI270, a high-precision IMU by Bosch® Sensortec, which combines a 3-axis accelerometer and a 3-axis gyroscope for precise motion tracking and orientation detection. The board also features the BMM150, a compact geomagnetic sensor from Bosch® Sensortec with a 3-axis magnetometer.
53
+
-**Onboard advanced motion sensors**: the board features the BMI270, a high-precision Inertial Measurement Unit (IMU) from Bosch® Sensortec, which combines a 3-axis accelerometer and a 3-axis gyroscope for precise motion tracking and orientation detection. The board also features the BMM150, a compact geomagnetic sensor from Bosch® Sensortec with a 3-axis magnetometer.
54
54
-**Onboard high-performance microphone**: the Nicla Voice is equipped with the IM69D130, a high-quality MEMS microphone by Infineon® Technologies. The IM69D130 offers excellent audio quality and low noise performance, ensuring accurate and distortion-free audio capturing.
55
55
-**Onboard connector for external PDM microphone**: an external PDM microphone can be connected to the board via an onboard connector.
56
56
-**Wireless connectivity**: the board supports Bluetooth® Low Energy connectivity, provided by the ANNA-B112 module developed by u-blox®. This compact, high-performance Bluetooth® Low Energy module allows the Nicla Voice to communicate wirelessly with other devices and systems.
@@ -439,7 +439,287 @@ The onboard magnetometer of the Nicla Voice can be used to determine the board's
The example code below demonstrates using the Nicla Voice board to perform Machine Learning inference on IMU (Inertial Measurement Unit) data. The code sets up event indicators using the onboard RGB LED and sends IMU data to the NDP processor for inference. The example can be found in the board's built-in examples by navigating to **File -> Examples -> NDP -> IMUDemo**.
442
+
#### Accelerometer and Gyroscope Data
443
+
444
+
The example code below shows how to get acceleration (m/s<sup>2</sup>) and angular velocity (in °/s) data from the onboard IMU and streams it to the Arduino IDE Serial Monitor.
445
+
446
+
```arduino
447
+
/**
448
+
Nicla Voice accelerometer and gyroscope test sketch
449
+
Name: nv_acc_gyro_test.ino
450
+
Purpose: Sketch tests onboard accelerometer and gyroscope (BMI270)
451
+
452
+
@author Arduino PRO Content Team
453
+
@version 1.0 22/05/23
454
+
*/
455
+
456
+
#include "NDP.h"
457
+
#include "BMI270_Init.h"
458
+
459
+
// Named constants
460
+
#define READ_START_ADDRESS 0x0C
461
+
#define READ_BYTE_COUNT 16
462
+
#define SENSOR_DATA_LENGTH 16
463
+
464
+
// Accelerometer range is set to +/-2g
465
+
// Raw accelerometer data is represented as a signed 16-bit integer
466
+
// Raw accelerometer data can be converted to acceleration in m/s^2 units using the following scale factor:
// Convert raw accelerometer data to acceleration expressed in m/s^2.
625
+
x_acc = x_acc_raw * ACCEL_SCALE_FACTOR;
626
+
y_acc = y_acc_raw * ACCEL_SCALE_FACTOR;
627
+
z_acc = z_acc_raw * ACCEL_SCALE_FACTOR;
628
+
629
+
// Convert raw gyroscope data to angular velocity expressed in °/s.
630
+
x_gyr = x_gyr_raw * GYRO_SCALE_FACTOR;
631
+
y_gyr = y_gyr_raw * GYRO_SCALE_FACTOR;
632
+
z_gyr = z_gyr_raw * GYRO_SCALE_FACTOR;
633
+
634
+
// Print accelerometer data (expressed in m/s^2).
635
+
Serial.print("x_acc:");
636
+
Serial.print(x_acc);
637
+
Serial.print(",");
638
+
Serial.print("y_acc:");
639
+
Serial.print(y_acc);
640
+
Serial.print(",");
641
+
Serial.print("z_acc:");
642
+
Serial.println(z_acc);
643
+
644
+
// Print gyroscope data (expressed in °/s).
645
+
Serial.print("x_gyr:");
646
+
Serial.print(x_gyr);
647
+
Serial.print(",");
648
+
Serial.print("y_gyr:");
649
+
Serial.print(y_gyr);
650
+
Serial.print(",");
651
+
Serial.print("z_gyr:");
652
+
Serial.println(z_gyr);
653
+
654
+
delay(1000);
655
+
}
656
+
```
657
+
658
+
Here you can find a step-by-step explanation of the code:
659
+
660
+
First, the necessary libraries are included:
661
+
662
+
-`NDP.h` and `BMI270_Init.h` for the Nicla Voice board's basic functions and the IMU control.
663
+
- Macros are defined for checking the status of the IMU; these macros allow the sketch to detect and handle sensor errors.
664
+
665
+
Next, user functions `ledBlueOn()`, `ledGreenOn()`, and `ledRedBlink()` definition:
666
+
667
+
- These functions allow the onboard LEDs to flash specific colors to indicate different states: blue for a successful match, green for an event, and red to indicate an error.
668
+
669
+
Next, in the `setup()` function:
670
+
671
+
- The serial communication is initialized at a baud rate of 115200.
672
+
- The Nicla Voice board is initialized, and the LDO regulator (used for putting the board into power-saving modes) is disabled to avoid communication problems with the IMU.
673
+
- Error and event handlers are initialized.
674
+
- NDP processor is initialized; this process includes populating the external Flash memory of the board with the NDP processor internal microcontroller firmware (`mcu_fw_120_v91.synpkg`), the NDP processor internal DSP firmware (`dsp_firmware_v91.synpkg`), and the ML model (`ei_model.synpkg`).
675
+
- The BMI270 sensor is initialized; this includes a software reset, loading the sensor configuration, and setting it into normal power mode with the accelerometer and gyroscope operational.
676
+
677
+
Finally, in the `loop()` function:
678
+
679
+
- Memory is allocated for the sensor data; data is then read from the sensor and stored in this allocated space.
680
+
- Raw sensor data is then parsed and extracted into raw accelerometer and gyroscope data. This data is represented as 16-bit signed integers ranging from -32 768 to 32 767.
681
+
- Raw sensor data is converted into understandable and standard unit measurements; for the accelerometer, data is converted to meters per second squared, and for the gyroscope, data is converted to degrees per second.
682
+
- Converted accelerometer and gyroscope data are printed on the Serial Monitor, allowing the user to observe sensor data in real-time.
683
+
684
+
After uploading the example code, you should see accelerometer and gyroscope data on the IDE's Serial Monitor as shown below:
685
+
686
+

687
+
688
+
Let's use also the Arduino IDE Serial Plotter to test the example IMU sketch; let's start visualizing only accelerometer data. To do so, comment the gyroscope data output as shown below:
689
+
690
+
```arduino
691
+
// Print accelerometer data (expressed in meters per second squared).
692
+
Serial.print("x_acc:");
693
+
Serial.print(x_acc);
694
+
Serial.print(",");
695
+
Serial.print("y_acc:");
696
+
Serial.print(y_acc);
697
+
Serial.print(",");
698
+
Serial.print("z_acc:");
699
+
Serial.println(z_acc);
700
+
701
+
/* Print gyroscope data (expressed in degrees per second).
702
+
Serial.print("x_gyr:");
703
+
Serial.print(x_gyr);
704
+
Serial.print(",");
705
+
Serial.print("y_gyr:");
706
+
Serial.print(y_gyr);
707
+
Serial.print(",");
708
+
Serial.print("z_gyr:");
709
+
Serial.println(z_gyr); */
710
+
```
711
+
712
+
Upload the example sketch again and open the IDE's Serial Plotter by navigating to **Tools > Serial Plotter**. After a while, you should see a real-time graph showing data from the board's onboard accelerometer, as shown below (move the board):
713
+
714
+
715
+

716
+
717
+
When the board is not moving, you should see acceleration measurements close to zero on the x and y-axis, while the z-axis will be close to 1g (approximately 9.81 m/s<sup>2</sup>). If you want to visualize gyroscope readings, uncomment the gyroscope data output and comment on the accelerometer data output; when the board is not moving, you should see gyroscope measurements on the three-axis close to zero.
718
+
719
+
#### IMU and Machine Learning
720
+
721
+
The example code below demonstrates how to use the Nicla Voice board to perform Machine Learning inference on IMU data. The code sets up event indicators using the onboard RGB LED and sends IMU data to the NDP processor for inference. The example can be found in the board's built-in examples by navigating to **File > Examples > NDP > IMUDemo**.
0 commit comments