MEAS KMA36 XPLAINED PRO BOARD Digital Humidity Digital Component Sensor (DCS) Development Tools Performance User programmable parameters Low power mode -40C to 125C accuracy:1C Sleep and automatic wake-up through I2C Programmable zero position Device address hardware configurable Operates from 3.0V to 3.6V Features 20-pin Xplained Pro compatible connector I2C interface Xplained Pro Hardware identification Chip Atmel Studio 6 Project available for download C C code available for download Programmable resolution up to 13 bits Very low hysteresis High accuracy mode Schematic The KMA36 Xplained Pro provides the necessary hardware to interface the KMA36, A universal magnetic encoder for precise rotational measurement. To any system that utilizes Xplained Pro compatible expansion ports configurable for I2C communication. The KMA36 sensor feature a system-on chip technology that combines a magnetoresistive element along with analog to digital converter and signal processing in a standard small package. This model can operate from 3.0V to 3.6V, by using Anisotropic Magneto Resistive(AMR) technology, the KMA36 can determine contactlessly the magnetic angle of an external magnet over 360. Refer to the KMA36 data sheet for detailed information regarding operation of the IC: http://www.te.com/usa-en/product-CAT-MRS0001.html Specifications Contactless angle measurement from 0 to 360 Programmable resolution up to 13 bits I2C communication Very low hysteresis Incremental model Programmable zero position low power consumption SENSOR SOLUTIONS /// MEAS KMA36 XPLAINED PRO BOARD 05/2016 Page 1 MEAS KMA36 XPLAINED PRO BOARD Digital Humidity DCS Development Tools Connector Pin Assignments (I2C Communications) System Plug Connector JP1 Pin No. Signal Description Pin No. Signal Description 1 ID Hardware identification 11 SDA TWI Serial Data 2 GND Ground 12 SCL TWI Serial Clock 3 N/C Not Connected 13 N/C Not Connected 4 N/C Not Connected 14 N/C Not Connected 5 N/C Not Connected 15 N/C Not Connected 6 N/C Not Connected 16 N/C Not Connected 7 N/C Not Connected 17 N/C Not Connected 8 N/C Not Connected 18 N/C Not Connected 9 N/C Not Connected 19 GND Ground 10 N/C Not Connected 20 Vdd Power Supply Dimensions (mm) Detailed Description I2C Interface The peripheral module can interface to the host being plugged directly into an Xplained Pro extension port (configured for I 2C) through connector JP1. External Control Signals The IC operates as an I2C slave using the standard 2 wire I2C connection scheme. The IC is controlled either by the host (through the Xplained Pro connector). In cases where one or more of the SCL and SDA signals are driven from an external source, 10k resistors R1, R2 provide pull-up. However, this also increases the apparent load to the external driving source. If the external source is not capable of driving these loads (10k), they should be removed. Reference Materials The complete software kit is available for download at: Link to KMA36_CPROJ.zip SENSOR SOLUTIONS /// MEAS KMA36 XPLAINED PRO BOARD 05/2016 Page 2 MEAS KMA36 XPLAINED PRO BOARD Digital Humidity DCS Development Tools Drivers & Software Detailed example software and drivers are available that execute directly without modification on a number of development boards that support an integrated or synthesized microprocessor. The download contains several source files intended to accelerate customer evaluation and design. The source code is written in standard ANSI C format, and all development documentation including theory/operation, register description, and function prototypes are documented in the interface file. Functions Summary Enumerations enum enum enum kma36_status { kma36_status_ok, kma36_status_no_i2c_acknowledge, kma36_status_i2c_transfer_error, kma36_status_crc_error } kma36_i2c_address { kma36_i2c_address_GND, kma36_i2c_address_DCOILP, kma36_i2c_address_DCOILN, kma36_i2c_address_DVCC_SE, kma36_i2c_address_VCC } kma36_oversampling { kma36_oversampling_2 = 0, kma36_oversampling_4, kma36_oversampling_8, kma36_oversampling_32 } Functions enum kma36_status void bool void enum kma36_status enum kma36_status enum kma36_status enum kma36_status enum kma36_status enum kma36_status enum kma36_status enum kma36_status enum kma36_status enum kma36_status enum kma36_status kma36_read_data (uint8_t *) Reads the KMA36 user register. kma36_init (void) Configures the SERCOM I2C master to be used with the kma36 device. kma36_is_connected (void) Check whether KMA36 device is connected. kma36_set_i2c_address (enum kma36_i2c_address) Configures KMA36 I2C address to be used depending on HW configuration The address depends on connection of one of following pins (GND, DCOILP, DCOILN, DVCC_SE, VCC) with A0 pin. kma36_sleep_enter (void) Request KMA36 to enter sleep mode. kma36_sleep_exit (void) Request KMA36 to exit sleep mode. kma36_enable_low_power_mode (void) Request KMA36 to enable low power mode. In this mode, only 180 measurements are possible. kma36_disable_low_power_mode (void) Request KMA36 to disable low power mode. kma36_enable_counter (void) Request KMA36 to enable full turn counting. kma36_disable_counter (void) Request KMA36 to disable full turn counting. kma36_enable_fast_rate (void) Request KMA36 to enable fast measurement update rate In fast mode, measurement accuracy is reduced Update rate = 1 / ( 1.4ms x oversampling x const ) kma36_disable_fast_rate (void) Request KMA36 to disable fast measurement update rate. kma36_set_accuracy (enum kma36_oversampling) Set KMA36 accuracy - unit is to be discussed Resolution impacts the measurement update rate. Update rate = 1 / ( 1.4ms x oversampling x const ) kma36_set_resolution (uint16_t) Set KMA36 resolution. kma36_read_angle (float *) Read KMA36 current angle. SENSOR SOLUTIONS /// MEAS KMA36 XPLAINED PRO BOARD 05/2016 Page 3 MEAS KMA36 XPLAINED PRO BOARD Digital Humidity DCS Development Tools Project Setup This project is based on ATSAMD20J18 board with Measurement Specialties Xplained Pro extension board connected to EXT1 pad as shown on figure below. Running the Application 1. Download the KMA36 Xplained Pro example package on TE Website 1. Decompress the archive file 2. Open the .cproj project file with Atmel Studio 6 3. You will now be able to build the KMA36example project - 4. Finally, run the build result on your Xplained Pro Board - Application Code This section is intended to provide a basic example of functionality. /** * \file main.c * * \brief KMA36 Universal magnetic encoder sensor application file * * Copyright (c) 2014 Measurement Specialties. All rights reserved. * */ #include float angle; uint8_t err_cnt = 0; int main (void) { enum kma36_status status; float last_angle = 0; float variation = 0; SENSOR SOLUTIONS /// MEAS KMA36 XPLAINED PRO BOARD 05/2016 Page 4 MEAS KMA36 XPLAINED PRO BOARD Digital Humidity DCS Development Tools uint16_t n = 0; uint8_t read_data[7]; system_init(); delay_init(); // Configure device and enable kma36_init(); // Set address kma36_set_i2c_address(kma36_i2c_address_GND); if( !kma36_is_connected() ) return -1; status = kma36_sleep_enter(); if( status != kma36_status_ok) return -1; delay_s(2); while( !kma36_is_connected() ); status = kma36_sleep_exit(); if( status != kma36_status_ok) return -1; status = kma36_enable_counter(); if( status != kma36_status_ok) return -1; status = kma36_enable_fast_rate(); if( status != kma36_status_ok) return -1; status = kma36_set_accuracy(kma36_oversampling_4); if( status != kma36_status_ok) return -1; status = kma36_set_resolution(10); if( status != kma36_status_ok) return -1; status = kma36_enable_low_power_mode(); if( status != kma36_status_ok) return -1; // Monitor angle every 10ms while (1) { SENSOR SOLUTIONS /// MEAS KMA36 XPLAINED PRO BOARD 05/2016 Page 5 MEAS KMA36 XPLAINED PRO BOARD Digital Humidity DCS Development Tools status = kma36_read_angle(&angle); if( status != kma36_status_ok) return -1; variation += angle - last_angle; // Look for significant angle variation if ( variation >= 1 ) { // Yes, so turn LED on. port_pin_set_output_level(LED_0_PIN, LED_0_ACTIVE); variation = 0; } else if ( variation <= -1 ) { // No, so turn LED off. port_pin_set_output_level(LED_0_PIN, LED_0_INACTIVE); variation = 0; } delay_ms(10); last_angle = angle; n++; if( n==50 ) n=0; } } Ordering Information Description Part Number MEAS KMA36 XPLAINED PRO BOARD DPP401A000 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. PRODUCT SHEET te.com/sensorsolutions Measurement Specialties, Inc., a TE Connectivity company. MEAS, Measurement Specialties (logo), TE Connectivity and TE connectivity (logo) are trademarks. All other logos, products and/or company names referred to herein might be trademarks of their respective owners. The information given herein, including drawings, illustrations and schematics which are intended for illustration purposes only, is believed to be reliable. However, TE Connectivity makes no warranties as to its accuracy or completeness and disclaims any liability in connection with its use. TE Connectivity`s obligations shall only be as set forth in TE Connectivity`s Standard Terms and Conditions of Sale for this product and in no case will TE Connectivity be liable for any incidental, indirect or consequential damages arising out of the sale, resale, use or misuse of the product. Users of TE Connectivity products should make their own evaluation to determine the suitability of each such product for the specific application. (c) 2016 TE Connectivity Ltd. family of companies MEAS France SAS, a TE Connectivity company. Impasse Jeanne Benozzi CS 83 163 31027 Toulouse Cedex 3, FRANCE Tel:+33 (0) 5 820 822 02 Fax: +33 (0) 5 820 821 51 customercare.tlse@te.com All Rights Reserved. SENSOR SOLUTIONS /// MEAS KMA36 XPLAINED PRO BOARD 05/2016 Page 6