Intel Quark microcontroller D2000 How to communicate with MATLAB over UART

Similar documents
Intel System Studio for Microcontrollers

USB UART 4 click PID: MIKROE Weight: 23 g

OS3DM SUBMINIATURE 3D ORIENTATION SENSOR. Interface Control Document Rev. 1.8

Intel Galileo gen 2 Board

Web Site: Forums: forums.parallax.com Sales: Technical:

EXPERIMENT 7 Please visit to learn all features of arduino before you start the experiments

Building Interactive Devices and Objects. Prof. Dr. Michael Rohs, Dipl.-Inform. Sven Kratz MHCI Lab, LMU München

CourseContents: 1.Introduction to MATLAB. 2. Handling data and data flow in MATLAB. 3. Editing and Debugging M-FILES

Color 7 click. PID: MIKROE 3062 Weight: 19 g

I Introduction to Real-time Applications By Prawat Nagvajara

Pridgen Vermeer Robotics ATmega128 Revision 0

ZX Distance and Gesture Sensor SMD Hookup Guide

OS3D-FG MINIATURE 3D ORIENTATION SENSOR

User s Guide IoT Microcontroller Development Kit

USB Interfacing and Real Time Data Plotting with MATLAB

mmwave Sensor Raw Data Capture Using the DCA1000 Board and mmwave Studio

This manual provides information for the final user application developer on how to use SPC57S-Discovery microcontroller evaluation board.

Development Board (Quick start) LDM-MCp Q208 Evolution

RADON SS SENSOR pci/l

Pedometer 3 Click. PID: MIKROE 3259 Weight: 24 g

5/5/2016 Bluetooth Developer Studio Level 2 Profile Report PROFILE SERVICES. Generic Access - CHARACTERISTICS Device Name. Profile Name BBC MICROBIT

Renesas DALI Framework Quick Start Guide

REQUIRED MATERIALS Epiphany-DAQ board Wire Jumpers IR Rangefinder Sensor LED Resistors Breadboard Multimeter (if needed)

Advanced Embedded Systems

DAQ-1000 Data Acquisition and Control System Application

OS3D MINIATURE 3D ORIENTATION SENSOR. Interface Control Document Rev. 1.14

The RBE Development board is designed to use an AVR644P to control a robotics system. The Board has multiple functions and features.

ATMEGA32 MUSIC PLAYER

Hello Angles... A First Use Guide to the VS Product Series: RS232 Interface with LD Standard Communication Protocol & Analogue 4-20mA Output Signals.

Lab 8. Arduino and WiFi - IoT applications

RF Networking With MSP430 & the ez430-rf2500 Session 2 Miguel Morales, MSP430 Applications 6/5/2008 1

Goal: We want to build an autonomous vehicle (robot)

Arduino Uno. Power & Interface. Arduino Part 1. Introductory Medical Device Prototyping. Digital I/O Pins. Reset Button. USB Interface.

Introduction to Arduino. Wilson Wingston Sharon

3.3V regulator. JA H-bridge. Doc: page 1 of 7

LPMS-UTTL2 Quick Start Guide ver. 1.3

cytrynka PDB User Guide for power distribution board for zmr/qav/rcx 250 class copters

RN-171-EK Evaluation Board

The Riverside Robotic Society June 2016 ESP8266

Dual PT100 RTD to CAN-Bus Converter. v1.0 August 2018

RPLIDAR A2. Development Kit User Manual. Low Cost 360 Degree Laser Range Scanner. Model: A2M4. Shanghai Slamtec.Co.,Ltd rev.1.

PremierWave 2050 Enterprise Wi-Fi IoT Module Evaluation Kit User Guide

Xbee Shield. Introduction

Enabling IoT OSs for Intel Quark MCU Platforms: the fast way. OpenIoT Summit Europe Andre Guedes

RoboRemo User Manual v1.9.1

muse Capstone Course: Wireless Sensor Networks

LabVIEW Experiment 1 Light Sensor Calibration Using Arduino Data Acquisition (Arduino DAQ)

EVALUATION BOARD MANUAL EBSLSN Series. EVALUATION KIT MANUAL EKSLSN Series

Use of ISP1507-AL Evaluation Boards

USR-TCP Hard version: V2.0 File version: V

Modeling, Design, and Control of Robotic Mechanisms (MathWorks/Kyungnam Univ.) -1-

% Edit the above text to modify the response to help Video_Player. % Last Modified by GUIDE v May :38:12

Lesson 5 Arduino Prototype Development Platforms. Chapter-8 L05: "Internet of Things ", Raj Kamal, Publs.: McGraw-Hill Education

XC164CS Prototype Board

TA0139 USER MANUAL ARDUINO 2 WHEEL DRIVE WIRELESS BLUETOOTH ROBOT KIT

Physics 120/220. Microcontrollers Extras. Prof. Anyes Taffard

AVR Intermediate Development Board. Product Manual. Contents. 1) Overview 2) Features 3) Using the board 4) Troubleshooting and getting help

Gaussmeter click. PID: MIKROE 3099 Weight: 23 g

Quick Start Guide Sense2GoL Module. July 12 th 2018

WM1030 Rev Introduction. Ultra low power DASH7 Modem. Applications. Description. 868 / 915 MHz. Features. WIZZILAB Technical datasheet 1/10

Hello Angles... A First Use Guide to the SOLAR Product Series: RS485 Interface with LD Standard Communication Protocol.

DT-ROBOT Line Follower

Robosoft Systems in association with JNCE presents. Swarm Robotics

Application Note: MatLab data processing for Motion Capture. Zhichao Lu Team 8 Documents Prep. Date: April 5, 2013

Lab 8: Sensor Characterization Lab (Analog)

Xbee module configuration from a µcontroller

Serial Peripheral Interface Bus SPI

RN-XV-EK Evaluation Board

Lab-3: LCDs Serial Communication Analog Inputs Temperature Measurement System

Various power connectors. 3.3V regulator. 64K Flash (Internal) 2K EEPROM (Internal) 4K SRAM (Internal) JA Mem Adr/ Data. Doc: page 1 of 9

Intel Edison Workshop

LPMS-RS232AL2 Quick Start Guide ver. 1.2

Pressure 4 click. PID: MIKROE 3020 Weight: 24 g

Embedded Robotics. Software Development & Education Center

XC2287M HOT. Solution ASC. Uses a timer triggered LED to toggle with ASC Interrupt

AT02667: XMEGA-E5 Xplained Hardware User's Guide. Features. Description. AVR XMEGA Microcontrollers APPLICATION NOTE

Embedded Systems. Software Development & Education Center. (Design & Development with Various µc)

Stepper 6 click. PID: MIKROE 3214 Weight: 26 g

Product description Rev. 3 11/06/14

UM2092 User manual. Basic metrology firmware for the STM32F103RD and the STPM32 devices. Introduction

XMC1000 LED Lighting Application Kit. Getting Started

PS Telematik-Projekt: Wireless Embedded Systems

AeroCore 2 for Intel Joule Module

Mio- x AHRS. Attitude and Heading Reference System. Engineering Specifications

Software GUI user guide for STEVAL-ISV021V1, STEVAL- IDS002V1 and STEVAL-IDS003V1 evaluation boards

Hello Angles... A First Use Guide to the SOLAR Product Series: RS485 Interface with ModBus RTU Communication Protocol.

BMF055 Example Project BSX Lite Integration

SC03MPC: 0.3 Mega Pixels Serial JPEG Camera Infrared User Manual. Introduction

Exercise: PWM Generation using the N2HET

How to upgrade firmware of Pi-931-X34CC and Pi-931-XA5 reader module

INTMOD485-LH Protocol Converter

Mu.S.E. Operating Manual

LDC1000 SENT Bridge MSP-EXP430F5529LP based Getting Started

HMR3200/HMR3300. Digital Compass Solutions. User s Guide HMR3200/HMR3300 SENSOR PRODUCTS

COL862 - Low Power Computing

SUMP PUMP MONITOR USER MANUAL

RoBoard RB-100 Manual V2.00 The Heart of Robotics. Jan 2009 DMP Electronics Inc

EXL x240 Graphic LCD Smart Module 3,8 SHORT FORM TECHNICAL SPECIFICATIONS. Via di Corticella, Bologna, Italy

Slave Embedded Serial Bluetooth board Features and Benefits

Homeworks on FFT Instr. and Meas. for Communication Systems- Gianfranco Miele. Name Surname

Transcription:

Intel Quark microcontroller D2000 How to communicate with MATLAB over UART Introduction Intel System Studio 2016 for Microcontrollers is an integrated tool suite for developing, optimizing, and debugging systems and firmware for the Intel Quark microcontroller D2000 and Intel Quark SE microcontroller development boards, which offers a microcontroller core to enable applications from device control to edge sensing IoT solutions. Objective of this document This document explains how to communicate with MATLAB over UART of D2000. Most of IoT applications would collect sensory data and send it to back-end analytic server, but it is important to analyze actual sensor data before send it to server. During the development phase, developer would check the reliability of data acquisition from the sensor on serial terminal such as Putty or in Excel when user can import those data into spreadsheet. One of popular tool of those data analysis in visual figure is to use MATLAB and this document shows how configure the Intel Quark microcontroller D2000 s UART so that MATLAB collect sensor data to plot these data in visual axes. Communicate over UART Figure 1 Visualization of data from Intel Quark microcontroller D2000 over UART 1

Table of Contents Intel Quark microcontroller D2000 How to communicate with MATLAB over UART... 1 Introduction... 1 Objective of this document... 1 1. Intel Quark microcontroller D2000 Application implementation... 3 1.1 Overview... 3 1.2 Read a magneto sensor (BMC150) to log the heading... 4 1.3 Read a ADC value from ambient light sensor... 4 1.4 Transfer ADC data in a string format to host machine... 5 2. MATLAB Application which present sensor data in GUIDE axes... 7 2.1 MATLAB scripts for serial opening to communicate with Intel Quark microcontroller Intel Quark microcontroller D2000... 7 2.2 MATLAB scripts for parsing serial string and put into matrix... 8 2.3 Plot sensor data of light intensity which comes from ambient light sensor... 9 3. Hardware connection for UART Intel Quark microcontroller D2000... 10 4. Reference... 11 2

1. Intel Quark microcontroller D2000 Application implementation 1.1 Overview The example of communication with MATLAB would read sensory data and transfer it to host machine over UART channel, the MATLAB script receives this data and fill in the matrix while plotting in axes in real time. You shall start from creating an reference application of magneto and add ADC reading routine to check the ambient sensor according to the different heading of Intel Quark microcontroller D2000. The Figure 1 shows implemented application of a SunFlower which read ambient light sensor values while swiping it using servo motor and send light intensity data, heading from magneto sensor over UART. Ambient Light Servo Motor Sensors Command Button Figure 2 Light sensor monitoring application on Intel Quark microcontroller D2000 3

1.2 Read a magneto sensor (BMC150) to log the heading There is a 6-axis ecompass-bmc150 on Intel Quark microcontroller D2000, It measures the earth s geomagnetic field as well as dynamic and static acceleration in all three dimensions and outputs tiltcompensated heading or orientation information. Table 1 shows the magneto sensor reading routine which was copied when you create a reference example of magneto form Intel System Studio for Microcontrollers. Table 1 Magneto sensor reading routine static void read_magneto_callback(void) { #ifdef USE_BMC_150 double heading; bmc150_read_mag(&mag); heading = atan2(mag.y, mag.x); if (heading < 0) { heading += 2 * M_PI; heading_in_degree = (int)(heading * 180 / M_PI); #else heading_in_degree = 0; #endif //QM_PRINTF("mag x %d y %d z %d deg %d direction %s\r\n", mag.x, mag.y, // mag.z, heading_in_degree, degrees_to_direction(heading_in_degree)); 1.3 Read a ADC value from ambient light sensor The SunFlower reads the ambient light sensors accordance with different heading and checks which angle of position would be the best heading for getting intensive lighting. Table 2 shows the ADC reading routine which use two ADC channels to read ambient light sensors and simple average then store it to local variables. Table 2 ADC reading from two ambient light sensors static int read_adc_callback( void ) { #ifdef USE_LIGHT_SENSOR qm_adc_xfer_t xfer; qm_adc_channel_t channels[] = {QM_ADC_CH_8, QM_ADC_CH_9; 4

uint8_t i; /******************************* * ADC polled mode example ******************************/ /* Set up xfer */ xfer.ch = channels; xfer.ch_len = NUM_CHANNELS; xfer.samples = samples_polled; xfer.samples_len = NUM_SAMPLES_POLLED; /* Run the conversion */ if (qm_adc_convert(qm_adc_0, &xfer)) { QM_PRINTF("ERROR: qm_adc_convert failed \r\n"); return 1; avg_light_value[0] = (unsigned int)samples_polled[0]; avg_light_value[1] = (unsigned int)samples_polled[1]; /* Print the values of the samples */ for (i = 0; i < NUM_SAMPLES_POLLED; i+=2) { // Get the average avg_light_value[0] = (avg_light_value[0] + (unsigned int)samples_polled[i]) / 2; avg_light_value[1] = (avg_light_value[1] + (unsigned int)samples_polled[i+1]) / 2; #endif return 0; // success 1.4 Transfer ADC data in a string format to host machine In the SunFlower application, there is 10mS timer which keep run in the whole life cycle then the timer callback can be utilized to check the serial message from the host machine to get user command and also read the magneto sensor and ambient light sensor. Finally it sends log sensory date over UART to plot those sensor data on MATLAB axes on the fly. Table 3 shows the actual serial transferring routine which use UART channel to host machine which would receive those data in MATLB. Table 3 Transfer sensory data over UART to host machine case STS_RUN: // 1 adjust_pwm_value( fakemotooutput ); if( idirection > 0 ) fakemotooutput += 1; else fakemotooutput -= 1; if( fakemotooutput >= MAX_PWM_DUTY_RATIO ) { 5

idirection = -1; if( fakemotooutput <= MIN_PWM_DUTY_RATIO ) { idirection = 1; read_magneto_callback(); read_adc_callback(); QM_PRINTF("%d, %d, %d, %d, %d \r\n", ticks, fakemotooutput, \ (int)heading_in_degree, (int)(avg_light_value[0]), (int)(avg_light_value[1]) ); // When we have button click event if( button_clicked == 1 ) { imainnext = STS_STOP; button_clicked = 0; break; 6

2. MATLAB Application which present sensor data in GUIDE axes 2.1 MATLAB scripts for serial opening to communicate with Intel Quark microcontroller Intel Quark microcontroller D2000 In MATLAB workspace, the liens shows how to create serial object which will be opened to communicate with Intel Quark microcontroller D2000 and due to RF serial module s constraint of max baudrate, the 57600bps was selected. Table 4 Create serial object in MATLAB Global SerialPortHandle; SerialPortHandle = serial('com5', 'BAUDRATE', 57600); Then UI dialogue was implemented using GUIDE feature of the MATLAB to open & close serial port and start & stop timer which plot the ADC data on dedicated axes periodically. The following code block shows the call-back function of Open button in dialogue. Table 5 Call-back function of the "Open" button function pushbutton1_callback(hobject, eventdata, handles) global SerialPortHandle; global bserialopen; % hobject handle to pushbutton1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) disp('open the COM port'); %axes( handles.lightsensor ); try fopen(serialporthandle); bserialopen = 1; catch fclose(instrfind); disp('error! Please check serial port is available'); end And next code block shows the call-back function of Close button in dialogue which only close the serial port when we successfully open the serial before. 7

Table 6 Call-back function of the "Close" button function pushbutton3_callback(hobject, eventdata, handles) % hobject handle to pushbutton3 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global SerialPortHandle global updatetimer global bserialopen; disp('close the COM port'); if( bserialopen == 1 ) fclose( SerialPortHandle); end delete( SerialPortHandle); delete(updatetimer); 2.2 MATLAB scripts for parsing serial string and put into matrix As a next step, you need to create a simple m file in the MATLAB and Table 4 explain who parse the serial string data in MATLAB and put it into integer matrix. This SerialRxCallBack was registered as receive callback function when the serial port is initialized and called at every receiving of terminator character of LF then read full one line string. Then, it would convert formatted string to integer array and copy it into matrix which will be used when plot the sensory date in figure. Table 7 Call-back function for receive characters from the serial function SerialRxCallBack( hobject, ~ ) global LightSensorA; global LightSensorA_avg; global LightSensorB; global LightSensorB_avg; global HeadingInDegree; OneLine = 'temp'; OneRow = (1:5); OneLine = fscanf(hobject, '%s'); %disp(oneline); OneRow = sscanf( OneLine, '%d, %d, %d, %d, %d'); % OneRow(2) : 25 ~ 80 if OneRow(2) < 81 & OneRow(2) > 24 index = OneRow(2)-24; HeadingInDegree(index) = OneRow(3); LightSensorA(index) = OneRow(4); LightSensorA_avg(index) = (LightSensorA_avg(index) + LightSensorA(index))/2 LightSensorB(index) = OneRow(5); 8

LightSensorB_avg(index) = (LightSensorB_avg(index) + LightSensorB(index))/2 end end 2.3 Plot sensor data of light intensity which comes from ambient light sensor When the SunFlower application run on Intel Quark microcontroller D2000, it transfers sensory data over UART at every 10mS and Figure 3 shows real-time data of intensity of light and heading from magneto sensor. As you can see, it s easy to analyze the trending data and compare it with other values of sensor data in the fly. It would help developer to check if those data is expected one and also do more post processing using plenty of signal processing method which was provided by the MATLAB. Figure 3 Real-time data of intensity of light accordance with heading 9

3. Hardware connection for UART Intel Quark microcontroller D2000 In the ISSM 2016 getting started document, you can check the required hardware configuration for the Intel Quark microcontroller D2000 reference platform with the following information. A. Make sure that your JTAG-Jumpers are set properly (white lines) B. Connect to your host machine with a USB cable to power up your board and connect with JTAG C. Optionally, attach the UART-A pins to a FTDI cable to get the serial output of your board Connect GND (brown) on the serial to the board s GND pin Connect TXD (red) on the serial cable to the board s RX pin Connect RXD (yellow) on the serial cable to the board s TX pin. Figure 4 Serial connection on Intel Quark microcontroller D2000 10

4. Reference Intel System Studio for Microcontrollers Getting start http://www.intel.com/content/www/us/en/embedded/products/quark/mcu/d2000/overview. html Intel Quark microcontroller D2000 Microcontroller CRB User Guide: http://www.intel.com/content/dam/www/public/us/en/documents/guides/quark-d2000-userguide.pdf Intel Quark microcontroller D2000 Microcontroller Datasheet: http://www.intel.com/content/www/us/en/embedded/products/quark/mcu/d2000/quarkd2000-datasheet.html 11