MLX90393 Getting Started Guide
Abstract
This guide was written with the goal of describing the basic setup and
troubleshooting steps required for integrating the MLX90393 Triaxis™ device
in an application. A simple rotary sensing application is used as an example.
Applicable Applications
All rotary, linear, and joystick applications using the MLX90393.
Recommended Tools and Resources
MLX90393 Datasheet
Oscilloscope or I2C->PC adaptor with I2C decoding
MLX90393 EVB (evaluation board) and MBED LPC1768 board
Convention, Acronyms, and
Abbreviations
Number Format and Text
Values in hexadecimal are shown with a preceding “0x”. For
example: 0x12 is decimal 18.
Binary values are shown with a preceding “0b”. For example:
0b10010 is decimal 18.
Textual descriptions are shown in this format
Code examples are shown in this format
Warnings and cautions are shown in this format
Acronyms
SDA = Serial Data Line
SCK = Serial Clock Line
VDD = Analog Supply
VDD_IO = Digital Supply
Rev 004
MSb = Most Significant Bit
LSb = Least Significant Bit
MSB = Most Significant Byte
LSB = Least Significant Byte
Page 1 of 23
Jun-15
MLX90393 Getting Started Guide
Table of Contents
Abstract..............................................................................................................................................................................1
Applicable Applications......................................................................................................................................................1
Recommended Tools and Resources .................................................................................................................................1
Convention, Acronyms, and Abbreviations .......................................................................................................................1
Number Format and Text ..............................................................................................................................................1
Acronyms .......................................................................................................................................................................1
Table of Contents ...............................................................................................................................................................2
Pinout.................................................................................................................................................................................4
Axis Definition ....................................................................................................................................................................5
Practical getting started .....................................................................................................................................................6
Practical getting started guide ......................................................................................................................................7
MLX90393 interface library for mbed ...........................................................................................................................7
CherryStone soft-and firmware releases & compatibility .............................................................................................8
Communication .................................................................................................................................................................9
2
I C Protocol ....................................................................................................................................................................9
SPI Protocol .................................................................................................................................................................10
Memory Model ................................................................................................................................................................11
HALLCONF ...................................................................................................................................................................11
GAIN_SEL .....................................................................................................................................................................11
Z_SERIES ......................................................................................................................................................................11
BURST_DATA_RATE .....................................................................................................................................................11
BURST_SEL ...................................................................................................................................................................12
TCMP_EN .....................................................................................................................................................................12
EXT_TRIG .....................................................................................................................................................................12
WOC_DIFF ...................................................................................................................................................................12
COMM_MODE .............................................................................................................................................................12
TRIG_INT_SEL ..............................................................................................................................................................12
OSR ..............................................................................................................................................................................12
DIG_FILT ......................................................................................................................................................................12
RES_XYZ .......................................................................................................................................................................12
OSR2 ............................................................................................................................................................................13
SENS_TC_LT & SENS_TC_HT ........................................................................................................................................13
OFFSET_X, OFFSET_Y & OFFSET_Z ...............................................................................................................................13
WOXY_THRESHOLD, WOZ_THRESHOLD & WOT_THRESHOLD....................................................................................13
Address 10-31 ..............................................................................................................................................................13
Key Commands ................................................................................................................................................................14
Rev 004
Page 2 of 23
Jun-15
MLX90393 Getting Started Guide
CONTROL COMMANDS ................................................................................................................................................14
Exit (EX)........................................................................................................................................................................14
Reset (RT) ....................................................................................................................................................................15
MEMORY COMMANDS ................................................................................................................................................15
Memory Store (HS) ......................................................................................................................................................15
Memory Recall (HR).....................................................................................................................................................15
Read Register (RR) .......................................................................................................................................................15
Write Register (WR).....................................................................................................................................................15
MEASUREMENT COMMANDS .....................................................................................................................................15
Start Burst Mode (SB) ..................................................................................................................................................15
Single Measurement (SM) ...........................................................................................................................................16
Read Measurement (RM) ............................................................................................................................................16
Start Wake-up on Change (SWOC) ..............................................................................................................................16
Application specific ..........................................................................................................................................................17
Resolution....................................................................................................................................................................17
Calculation of conversion time ....................................................................................................................................17
Sensitivity .........................................................................................................................................................................18
Available hardware (EVB) ............................................................................................................................................19
Example #1: Rotary Application .......................................................................................................................................20
Magnetic Configuration ...............................................................................................................................................20
Suggested EEPROM Configuration ..............................................................................................................................20
Rotary Code Example ..................................................................................................................................................21
Rev 004
Page 3 of 23
Jun-15
MLX90393 Getting Started Guide
Pinout
NC
NC
A1
A0
The pinout for the MLX90393 is below.
VSS
VDDIO
NC
INT/
TRG
MLX90393
NC
SDA/
MOSI
SCLK
NC
CS
MISO
INT
VDD
PIN 1
Figure 1: Pinout
Pin Number
1
Pin Function
Data ready signal output pin, active high (DRDY flag)
Chip select, used when communicating in SPI mode
2
CS
Pull high when in I2C mode
3
SCLK
Serial clock for both SPI and I2C mode
4, 9, 10, 14, 16
NC
5
SDA/MOSI Data input pin in SPI mode, data input/output pin in I2C mode
6
MISO
Data output pin in SPI mode
7
INT/TRIG Trigger pin, can be used to start measurement
8
VDDIO
Power supply for digital
11
A1
Bit 1 of the 7-bit I2C address (0 0 0 1 1 A1 A0)
12
A0
Bit 0 of the 7-bit I2C address (0 0 0 1 1 A1 A0)
13
VSS
Ground
15
Vdd
Power supply
Rev 004
Pin Name
INT
Page 4 of 23
Jun-15
MLX90393 Getting Started Guide
Axis Definition
The axes of the MLX90393 are defined in the datasheet and are shown below.
Figure 2: MLX90393 QFN Axis Definitions
Rev 004
Page 5 of 23
Jun-15
MLX90393 Getting Started Guide
Practical getting started
Legend:
Software
Firmware
Communication
Application Diagram I2C
Getting Started in practice
Application Diagram SPI
Host PC/ Laptop
· Download LabVIEW Run-Time Engine (12.0) à install
· Download NI-VISA Driver (5.0.3) à install
· Download MBED USB-driver à install (connect mbed)
Mbed LPC1768
· Download MBED -Firmware à upload to mbed and reset
MLX90393
· Make physical connections between PC,MBED and MLX90393
MBED USBdriver
CherryStone.exe
USB
Physical USB-cable
Firmware (SPI or I2C)
9039X
.h
9039X
.cpp
Physical connection
cables (I2C)
OR
USB
SPI
Main.cpp
SPI
NI-VISA
Driver
I2C
LabVIEW Run-Time
Engine
I2C
Host PC/Laptop
· Download CherryStone.exe à install and run
Physical connection
cables (SPI)
Host PC / Laptop
MLX9039X
MBED LPC1768
Implementation / Installation sequence
CherryStone.exe
LabVIEW Run-Time Engine
NI-VISA Driver
Rev 004
Firmware (SPI or I2C)
MBED Driver
MLX9039X
SPI OR I2C - protocol
Page 6 of 23
Jun-15
MLX90393 Getting Started Guide
Practical getting started guide
1.
NI LabView Runtime Engine
A first step before installing the CherryStone executable is installing LabVIEW Run-Time Engine 12.0. This software
can be downloaded directly from National Instruments website.
32-bit version: Click here
http://www.ni.com/download/labview-run-time-engine-2012/3433/en/
2.
NI VISA-driver
Visa Driver: Click here
http://www.ni.com/download/ni-visa-run-time-engine-5.0.3/2257/en
3.
MBED driver
Make sure your mbed is connected while executing this step
Mbed Driver: Click here
http://developer.mbed.org/media/downloads/drivers/mbedWinSerial_16466.exe
4.
CherryStone Software Executable
CherryStone (= the interface program, refer to diagram shown earlier in this document): Click here
5.
MBED firmware
MBED SPI firmware: Click here
2
MBED I C firmware: Click here
Upload the firmware to mbed:
·
·
·
Connect your mbed to your PC/laptop - a new drive called “MBED” should appear.
Download the firmware from the Melexis website (either SPI, or I2C) and drag and drop the file directly into
the drive”.
Once the bin-file is uploaded, the mbed must be reset by pressing the push button at the center of the
mbed.
MLX90393 interface library for mbed
Sample code and a complete library holding all MLX90393’s functions are written for mbed and can be downloaded
from www.mbed.org/teams/melexis or directly from our website
The MBED used at Melexis is the LPC1768. Please note that the firmware BIN files made available have been
compiled for this specific MBED hardware. When using other MBED devices, or other microcontrollers in general, the
source code is recommended as a starting point for software development.
Rev 004
Page 7 of 23
Jun-15
MLX90393 Getting Started Guide
CherryStone soft-and firmware releases & compatibility
Date
January 2015
Rev 004
CherryStone.exe
CherryStone.bin
CherryStone 3
CherryStone3_I2C(SDA = p9, SCL = p10, A1=p21, A0=p22).bin
CherryStone3_SPI(MOSI =p5, MISO = p6, CLK= p7, CS=p8).bin
Page 8 of 23
Jun-15
MLX90393 Getting Started Guide
Communication
The MLX90393 can be used with either an SPI or an I2C bus. The use of both protocols will be explained in the next
sections. This user guide gives a brief introduction to our user interface tool for quick ‘plug and play’ solutions that
enables you to communicate with the MLX90393 without having to make the effort of implementing the
communication protocol yourself.
I2C Protocol
2
One initial hurdle with starting work with the MLX90393 is configuring the I C bus correctly. The clock frequency can
2
be set between 10kHz (low-speed mode), 100kHz(standard mode), 400kHz (Fast mode). Every I C device on the bus
2
must also be assigned an address. The two LSB’s of the MLX90393 I C address can be selected via the A0 and A1 pins
allowing for four different addresses. In this document it is assumed that the A0 and A1 pins are shorted to ground.
2
This results in an I C address of 0x19 (for MBED, in other environments this might be defined in another way).
2
The7 bit I C address in MBED is defined as follows as a byte:
7 bit I2C address
0
0
0
1
1
A1
A0
1
Defined by Melexis
Defined by connecting pins
A0 and A1 to GND/ VDD
R/W bit set
2
Figure 3: MBED I C address definition
The orange section is set in the NVRAM of the IC, the yellow section depends on how pins A0 and A1 are connected.
The last bit should be set for the MBED, no matter if one reads or write to the IC. The MBED will send on the bus the
correct R/W bit automatically.
The MLX90393 operates on a command / response configuration and can be broken down into two sequences:
Command Write and Response Read.
Command Write:
To initiate a communication sequence the master addresses the slave with the write bit set. If the MLX90393
recognizes the address it responds with an ACK. The master then issues the command to the MLX90393. If accepted,
the MLX90393 responds with another ACK.
SCL
1
SDA
2
3
4
5
I2C_ADDR[6:0]
6
7
8
9
W
ACK
1
2
3
4
5
COMMAND[7:0]
6
7
8
9
ACK
S
2
Figure 4: Sending an I C command
Response Read:
To read back the response the master addresses the MLX90393 with the R bit set. The master then sends enough
clock pulses to clock out all the required data bytes. The number of data bytes depends on the command transmitted
Rev 004
Page 9 of 23
Jun-15
MLX90393 Getting Started Guide
and can range from zero (eg: NOP message) to eight (eg: measurement with all axes, temp, and a status byte). The
number of data bytes is indicated in the status byte which is always the first byte read out from the MLX90393.
SCL
1
2
SDA
3
4
5
6
7
I2C_ADDR[6:0]
8
9
R
ACK
1
2
3
4
5
6
7
8
STATUS_BYTE[7:0]
9
ACK
Sr
P
2
Figure 5: I C readback of status byte
Note: Failure to readdress the slave after the Command Write will result in the transaction failing.
SPI Protocol
One initial hurdle with starting work with the MLX90393 is configuring the SPI bus correctly. The chip can handle
clock frequencies up to 10MHz. The SPI communication is implemented in a half-duplex way, showing high
2
similarities with the I C communication. Addressing on the bus is done through the \CS instead of physical addresses.
Both three- and four-wire SPI is possible (three wire by shorting the MISO and MOSI). SPI mode 3 is implemented:
CPHA=1 (data changed on leading edge and captured on trailing edge, and CPOL=1 (high level is inactive state). The
Chip Select line is active-low.
The MLX90393 operates on a command / response configuration and both are sequentially done in one go in SPI.
The communication is also bundled in bytes, equally MSB first and MSByte first. A command can of course consist of
more than 1 byte as can the response be from the MLX90393 in the form of multiple bytes after the status byte.
Figure 6 shows an example of an SPI command being followed by the readback of the status byte.
/CS
SCL
1
MOSI
2
3
4
5
6
7
8
1
COMMAND[7:0]
MISO
2
3
4
5
6
7
8
X (4-wire SPI) or Z (3-wire SPI)
Z (3 & 4-wire SPI)
STATUS_BYTE[7:0]
ADD
NADD
Figure 6: SPI example
Rev 004
Page 10 of 23
Jun-15
MLX90393 Getting Started Guide
Memory Model
As the code example will be modifying the register contents it is useful to review the memory model of the
MLX90393. It operates with a dual memory model consisting of volatile and nonvolatile areas. During operating
conditions the values in the volatile memory are used and are loaded from nonvolatile memory at power up or when
a recall command is issued. It is necessary to know that if the write register command is issued this affects the
volatile memory only. A store command is needed to permanently store the modifications. Refer to the datasheet for
more details. The first 32 addresses are programmable by the user.
VOLATILE
MEMORY
NON-VOLATILE
MEMORY
CUSTOMER AREA
CUSTOMER AREA
STORE (HS)
RECALL (HR)
MELEXIS AREA
RR
MELEXIS AREA
WR
Figure 7: Memory model
15
0
1 TRIG_INT_SEL
2
3
4
5
6
7
8
9
14
13
COMM_MODE
RESERVED
12
11
RESERVED_LOW
WOC_DIFF
EXT_TRIG
OSR2
SENS_TC_HT
10
TCMP_EN
9
8
7
Z_SERIES
BURST_SEL
RES_XYZ
6
5
GAIN_SEL
4
3
2
1
0
HALLCONF
BURST_DATA_RATE
DIG_FILT
SENS_TC_LT
OSR
OFFSET_X
OFFSET_Y
OFFSET_Z
WOXY_THRESHOLD
WOZ_THRESHOLD
WOT_THRESHOLD
Figure 8: Memory map of customer area
HALLCONF
Spinning and chopping rate adjustment.
HALLCONF[3:2] defines the duration of one Hall plate spinning phase in clock cycles: #clocks/spinning_phase = 8 *
HALLCONF[3:2]
2
. Default this value is 3.
HALLCONF[1:0] defines the number of amplifier chopping periods inside one spinning phase:
HALLCONF[1:0]
#chopping_periods/spinning_phase = 2
. Default this value is 0.
The default HALLCONF is 0xC.
GAIN_SEL
Selection of the gain, adjustable from 0 to 7. See sensitivity table for sensitivity of the IC in LSB/G for each setting of
the gain and the resolution.
Z_SERIES
Connection of the Hall plates for Z-axis measurements. Recommended setting: 0x0.
BURST_DATA_RATE
This parameter controls the data rate in burst mode and in WOC mode. The rate is defined as the time between the
end of one measurement and the start of a new measurement, regardless of the fact if the data is read out or not. A
Rev 004
Page 11 of 23
Jun-15
MLX90393 Getting Started Guide
value of 0x0 means a continuous burst mode, other value encode as follows: interval = 20ms * BURST_DATA_RATE.
The max is 0x3F, corresponding to 1260ms. This interval can be observed by looking at the DRDY flag.
BURST_SEL
This parameter determines the measurements (X, Y, Z and Temp, or any combination of them) to be performed in the
case that the SB or SWOC command did not specify the measurements. The bit order is (from MSB to LSB): ZYXT.
TCMP_EN
Enables the temperature compensation. Please refer to the application note on the temperature compensation for
more info.
EXT_TRIG
When this bit is set, the external pin INT/TRIG can be used to start a measurement. This only works when
TRIG_INT_SEL is not set (digital input). Otherwise, changes at this pin will be ignored. The axes to be measured are
specified by BURST_SEL.
WOC_DIFF
Absolute or derivative WOC mode:
If 0, an absolute mode is used. Measurements are compared to the first measurements;
If 1, a relative mode is used. Measurements are compared to the previous ones.
COMM_MODE
Defines the communication mode. If it is 0x0 or 0x1, the IC can be used both by I2C and SPI. If 0x2, only SPI can be
used and if 0x3 only I2C can be used.
TRIG_INT_SEL
Selects the function of the INT/TRIG pin. When set, the pin is used as digital output, otherwise it is an input.
OSR
Defines the oversampling rate of the ADC decimation filter for magnetic measurements. OSR_ADC = 64 * 2
will directly impact the measurement time for magnetic measurements.
Note: The chip will not work properly with the following combinations: OSR=0 and DIG_FILT=0, OSR=0 and
DIG_FILT=1 and OSR=1 and DIG_FILT=0
OSR
. This
DIG_FILT
DIG_FILT
A control for the digital filter. An averaging over a certain amount (2
) will be done. This will directly impact the
measurement time for magnetic measurements.
Note: The chip will not work properly with the following combinations: OSR=0 and DIG_FILT=0, OSR=0 and
DIG_FILT=1 and OSR=1 and DIG_FILT=0
RES_XYZ
This 6 bit parameter consists out of three parts, one for each axis. The two MSBs act on the Z-axis, the 2 LSBs on the
X-axis and the middle 2 bits on the Y-axis. Internally each magnetic measurement is 19 bits long. On the output, only
16 bits can be read out. This parameter selects for each axis which 16 bits to read out. Please refer to section Error!
eference source not found. for further detailed information.
Rev 004
Page 12 of 23
Jun-15
MLX90393 Getting Started Guide
OSR2
Defines the oversampling rate of the ADC decimation filter for a temperature measurement. OSR_ADC = 64 * 2
This will directly impact the measurement time for the temperature measurement.
OSR
.
SENS_TC_LT & SENS_TC_HT
These parameters are used for the temperature compensation for the sensitivity drift of the Hall elements.
SENS_TC_HT is the parameter for temperatures above 35 degC, SENS_TC_LT is the parameter for temperatures
below 35 degC. Please refer to the application note on the temperature compensation for more info. These values
can be blindly programmed to the values given in this document (if not already programmed).
OFFSET_X, OFFSET_Y & OFFSET_Z
These parameters are used to compensate the offset in case the temperature compensation is enabled. They are not
used with TCMP disabled. Please refer to the application note on the temperature compensation for more info. These
values can be blindly programmed to the values given in this document (if not already programmed).
WOXY_THRESHOLD, WOZ_THRESHOLD & WOT_THRESHOLD
Defines the wake up thresholds on X, Y, Z axis or on temperature. The resolution of the temperature sensor is
45.2LSB/K.
Address 10-31
Address 10 to 31 are free to use by the customer. For example traceability information could be stored in here.
Rev 004
Page 13 of 23
Jun-15
MLX90393 Getting Started Guide
Key Commands
Table 1 shows an overview of all commands possible with the MLX90393. The amount of bytes to be sent and read
back is different for each command. In case more bytes are needed, first byte #1 is sent, then byte #2 and so on.
Table 1: Commands overview
Command
Symbol
CMD byte #1
CMD byte #2
CMD byte #3
CMD byte #4
# bytes to read back
EXit
EX
1000 0000
-
-
-
1 (status)
Start Burst mode
SB
0001 zyxt
-
-
-
1 (status)
Start Wake-up On
Change
SWOC
0010 zyxt
-
-
-
1 (status)
Start Measurement
(polling mode)
SM
0011 zyxt
-
-
-
1 (status)
Read Measurement
RM
0100 zyxt
-
-
-
1 (status) + 2*[z+x+y+t]
(data)
Read from a Register
RR
0101 0000
A[5:0]