Description - Arrow Israel

INEMO-M1 Hands On
Part II
Petr STUKJUNGER
STMicroelectronics
AMS Application Team, EMEA Region
April 2014
Starting with INEMO-M1 Firmware package
• Content of INEMO-M1 Firmware package
• Using INEMO-M1 application examples in IAR
• Using Serial port to read application feedback
iNEMO-M1 Hands On
28/04/2014
2
Firmware folder structure
• FreeRTOS – real-time operating system
• Tilt compensated compass firmware
• Usage examples of sensors on INEMO-M1
• Device firmware upgrade
• Drivers of sensors on INEMO-M1
• M1 Discovery System – see next slide
• Sensor libraries
• USB library
• Virtual COM port library
• Standard peripheral library
Notes:
• All items are delivered in source codes
• Sensor fusion AHRS algorithm is not delivered with iNEMO
Suite, it is delivered separately on STEVAL-MKI121CD1
INEMO-M1 Hands On
28/04/2014
3
Connecting SWD flasher/debugger
• Connect your SWD flasher/debugger dongle (ST-LINK or I-jet) to the
M1 Discovery board using interconnection cable
• The connector is sensitive to movements. After finishing flashing and
debugging the board, disconnect the SWD dongle from the board.
iNEMO-M1 Hands On
28/04/2014
4
Open iNEMO_M1_Applications workspace
• Open the workspace from folder:
Hands On \ Discovery-M1_Fw_Package \ iNemo_M1_Applications \ IAR \ iNemo_M1_Applications.eww
• Choose an application:
iNEMO-M1 Hands On
28/04/2014
5
Try out an application
• Flash the M1 Discovery board with the first application (AccMag_AccDataReady)
• There are 9 ready-to-use applications:
• AccMag_AccDataReady – reading data from LSM303DLHC triggered by Data ready interrupt
from accelerometer
• AccMag_MagDataReady – reading data from LSM303DLHC triggered by Data ready interrupt
from magnetometer
• AccMag_Fifo – reading data from LSM303DLHC FIFO buffer
• AccMag_Thresholds – using LSM303DLHC interrupt engine to detect a motion
• Gyro_DataReady – reading data from L3GD20 triggered by Data ready interrupt
• Gyro_Continuous – reading data from L3GD20 not triggered
• Gyro_Fifo – reading data from L3GD20 FIFO buffer
• Gyro_Thresholds – using L3GD20 interrupt engine to detect a motion
• Press_DataReady – reading data from L3GD20 triggered by Data ready interrupt
• Find detailed description of these applications in folder:
Hands On \ Discovery-M1_Fw_Package \ iNemo_M1_Applications \ DOC \
INEMO_M1_Libraries_And_Examples.chm
• There are also 3 other applications – solutions of our todays tasks. Do not open
them now. 
iNEMO-M1 Hands On
28/04/2014
6
Find Serial line (COM port) number
Start → Control Panel → Device Manager → Ports
iNEMO-M1 Hands On
28/04/2014
7
Open Serial Terminal
• You can use any serial terminal
• You can find putty – serial terminal application for Windows – in the
SW subfolder of seminar folder
• Setup serial line session:
• Selection Connection type: Serial
• Serial line – COM port number you
found in the previous step
• Speed – 9600
• You can save the session for
next time
• Press Open to start the session
iNEMO-M1 Hands On
28/04/2014
8
Tasks
1. Wake up for battery life saving
2. Using FIFO to save history of an event
3. Compass with tilt compensation
General instructions
• Do not start from scratch - use already done examples and libraries
• Use datasheets and application notes provided
• Do not hesitate to ask for help
iNEMO-M1 Hands On
28/04/2014
11
TASK 1 – Instructions
Wake Up
for battery life saving
• Description: Setup sensor(s) to trigger an interrupt when the board is
moved
• Requirements:
• Req1: Movements in any direction are detected and indicated by LED1 flash
• Req2: Power consumption is as low as possible (Optional task)
• Real applications:
• Wake up the system (device) when user is going to use it
• Save power of the system when it is not used
iNEMO-M1 Hands On
28/04/2014
12
TASK 1 – Solution
Wake Up
for battery life saving
• Description: Setup sensor(s) to trigger an interrupt when the board is moved
• Sensor used: Accelerometer
• Project based on: AccMag_Thresholds, solution can be found in: Task_Wake_Up
• Req1: Movements in any direction are detected and indicated by LED1 flash
• Enable HP filter for AOI1 interrupt engine
• Enable High event on X, Y and Z axis
• Set threshold to 64mg
• Add LED1 usage (include iNEMO_Led.h, call iNEMO_LED_Init), flash the LED1 every time an
interrupt is detected
• Req2: Power consumption is as low as possible (Optional task)
• Enable Low power mode, disable High Resolution, select Little Endian mode
• Keep ODR low (below 50Hz)
• Do not enable magnetometer or gyro
iNEMO-M1 Hands On
28/04/2014
13
TASK 2 – Instructions
Using FIFO
to store history of an event
• Description: Setup the gyroscope to store history of a motion event
• Requirement:
• Req1: Store history of an event and show it in a terminal window
• Real applications:
• Store a movement and analyze it when there is a time for it
• Decrease power consumption of the system – reading data from FIFO, instead of
polling
iNEMO-M1 Hands On
28/04/2014
14
FIFO use case - Saving history of an event
Gyroscope data
Threshold level
Trigger event occurred
Data sampling
at ODR
Time
Sample no.
1
30 31 32
Data saved in FIFO
FIFO
► History of the event trigger can be read from the FIFO at any time.
(31 samples before trigger + trigger sample)
• Way of operation
• Data is being continuously stored in FIFO
• When pre-selected trigger occurs, FIFO stops storing new data.
• FIFO mode used: Stream-to-FIFO mode
iNEMO-M1 Hands On
28/04/2014
15
TASK 2 – Solution
Using FIFO
to store history of an event
• Description: Setup the gyroscope to store history of a motion event
• Sensor used: Gyroscope
• Project based on: L3GD20_Fifo and L3GD20_Thresholds, solution can be found in:
Task_Fifo_History
• Req1: Store history of an event and show it in a terminal window
• Configure gyro to detect an event (use code from L3GD20_Thresholds)
• INT1 pin is used to notify the MCU about the event – setup proper IRQ handler
• Setup FIFO to work in Stream to FIFO mode
•
•
•
•
Set FIFO watermark to 0
Read the entire content of the FIFO(32 samples) when trigger occurs
Once the FIFO is in FIFO mode and full of samples, it stops
To re-start the FIFO in Stream to FIFO mode, Bypass mode needs to be selected first
• Recommended: add LED1 usage (include iNEMO_Led.h, call iNEMO_LED_Init), flash
the LED1 every time an interrupt is detected
iNEMO-M1 Hands On
28/04/2014
16
TASK 3 – Instructions
Compass
with tilt compensation
• Description: Use sensor(s) to implement tilt compensated compass
• Requirements:
• Req1: Provide heading information, compensate it for a tilt
• Real applications:
• Compass
• Navigation
iNEMO-M1 Hands On
28/04/2014
17
TASK 3 – Solution
Compass
with tilt compensation
• Description: Use sensor(s) to implement tilt compensated compass
• Sensors used: Magnetometer and accelerometer
• Project based on: AccMag_MagDataReady, solution can be found in:
Task_Compass
• Req1: Provide heading information, compensate it for a tilt
• Use tilt compensated compass implementation from the iNEMO
firmware package
• Convert accelerometer data in m/s^2
• Convert magnetometer data in Gauss
• Use iNEMO_TiltedCompass function
• Convert result from radians to degrees
iNEMO-M1 Hands On
28/04/2014
18
Thank You
19