Application Note. Utilising the E2 Interface

Similar documents
Specification E2 Interface

Manual iaq-engine Indoor Air Quality sensor

The Cubesat Internal bus: The I2C

Tutorial for I 2 C Serial Protocol

Manual iaq-core Indoor Air Quality sensor module

XS S ERIES TM PMB US TM O PTION C ARD

Exercise 2 I 2 C Management 1/7

GT24C02. 2-Wire. 2Kb Serial EEPROM (Smart Card application)

SILICON MICROSTRUCTURES

The I2C BUS Interface

User-configurable Resolution. 9 to 12 bits (0.5 C to C)

AMS 5812 OEM pressure sensor with an analog and digital output

Preliminary Data MOS IC. Type Ordering Code Package SDA Q67100-H5096 P-DIP-8-1

GT24C256 2-WIRE. 256K Bits. Serial EEPROM

Preliminary Data MOS IC. Type Ordering Code Package SDA Q67100-H5092 P-DIP-8-1

Introduction to I2C & SPI. Chapter 22

Hello, and welcome to this presentation of the STM32 I²C interface. It covers the main features of this communication interface, which is widely used

or between microcontrollers)

DIGITAL HUMIDITY SENSOR HYT-131

ISSI 24 Series EEPROM Application Note. 1. Introduction. 2. Power supply & power on reset

The IIC interface based on ATmega8 realizes the applications of PS/2 keyboard/mouse in the system

User-configurable Resolution. 9 to 12 bits (0.5 C to C)

Two Wire Interface (TWI) also commonly called I2C

34 Series EEPROM Application Note. 1. Introduction. 2. Power supply & power on reset

How to Implement I 2 C Serial Communication Using Intel MCS-51 Microcontrollers

Application Note: AZD025 IQ Switch - ProxSense TM Series I2C Example Code for the IQS222

Temperature Sensor TMP2 PMOD Part 1

DESIGNING OF INTER INTEGRATED CIRCUIT USING VERILOG

I2C on the HMC6352 Compass

I2C interface Tutorial

um-fpu Application Note 8 Developing an I 2 C Interface for um-fpu V2

GT24C WIRE. 1024K Bits. Serial EEPROM

DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI DEPARTMENT OF ELECTRICAL AND ELECTRONICS ENGINEERING. EE Microcontroller Based System Design

Serial Peripheral Interface. What is it? Basic SPI. Capabilities. Protocol. Pros and Cons. Uses

I 2 C Communication. Embedded Systems Interfacing. 25 October 2011

Digital temperature and humidity sensor AM2315 Product Manual

Laboratory 5 Communication Interfaces

HDS Series I2C Application Notes

Emulating I2C Bus Master by using FlexIO

White Paper Using the MAX II altufm Megafunction I 2 C Interface

Write LED display data, in accordance with the address from the display from low to high, from low to high data byte operation.

GT34C02. 2Kb SPD EEPROM

GT24C64 2-WIRE. 64K Bits. Serial EEPROM

BL24C02/BL24C04/BL24C08/BL24C16

Using the Finisar GBIC I 2 C Test/Diagnostics Port

1 Introduction Revision History... 4

MI3. Protocol Manual. Miniature Infrared Sensor OEM Version. Rev. C4 Apr/

Thermo 6 click PID: MIKROE-2769

Remote 16-bit I/O expander for Fm+ I 2 C-bus with interrupt and reset. Description

SRS501 User s manual

GT24C32A 2-WIRE. 32K Bits. Serial EEPROM

Interfacing Z8 Encore! XP MCUs with an I 2 C-Based Character LCD

ZD24C32A. I 2 C-Compatible (2-wire) Serial EEPROM. 32-Kbit (4,096 x 8) DATASHEET. Features. Description. Low Voltage Operation

AN3281 Application note

THE INTERNATIONAL JOURNAL OF SCIENCE & TECHNOLEDGE

CAN / RS485. Product Description. Technical Reference Note. Interface Adapter. Special Features

Lesson I2C. I²C (Inter-Integrated Circuit) Lab Assignment: I2C Slave Driver

AMP DISPLAY INC. SPECIFICATIONS AMP DISPLAY INC 9856 SIXTH STREET RANCHO CUCAMONGA CA TEL: FAX:

Microcontroller Systems. ELET 3232 Topic 23: The I 2 C Bus

I2C Master-Slave Connection

DS1624 Digital Thermometer and Memory

80C51 Block Diagram. CSE Overview 1

Standard EEPROM ICs. Interfacing SLx 24Cxx I 2 C-Bus Serial EEPROMs to 8051 Controller Family, especially to the Siemens C500 Controller Family

EE4390 Microprocessors. Lessons 2, 3 68HC12 Hardware Overview, Subsystems, and memory System

McMaster University Embedded Systems. Computer Engineering 4DS4 Lecture 6 Serial Peripherals Amin Vali Feb. 2016

AC/DC Modular Power Supply Series PMBus APPLICATION NOTES

Microcontrollers and Interfacing

DM-OLED X 64 BLUE GRAPHIC OLED DISPLAY MODULE WITH SPI, I2C INTERFACE

SERDESUB 913ROS DS90UB913Q Serializer and DS90UB914Q Deserializer Evaluation Kit User s Manual

XRA1201/1201P 16-BIT I2C/SMBUS GPIO EXPANDER

SRF02 Ultrasonic range finder Technical Specification

BV4218. I2C-LCD & Keypad. Product specification. December 2008 V0.a. ByVac 2006 ByVac Page 1 of 9

Parallel Data Transfer. Suppose you need to transfer data from one HCS12 to another. How can you do this?

Introduction the Serial Communications Parallel Communications Parallel Communications with Handshaking Serial Communications

XRA BIT I2C/SMBUS GPIO EXPANDER WITH INTEGRATED LEVEL SHIFTERS

Figure 1 Typical Application Circuit

MDP200 Series. Differential Pressure Sensor FEATURES APPLICATIONS DESCRIPTION

ECE 4510/5530 Microcontroller Applications Week 10

Digital Humidity & Temperature Sensor. With Two-Wire Interface

Digital Temperature and Humidity Sensor

Developer Notes INSTEON Thermostat v012. Developer Notes. INSTEON Thermostat. Revision History

MACHINE BREAKDOWN DETECTION SYSTEM

PI4IOE5V9675. Remote 16-bit I/O expander for Fm+ I 2 C-bus with interrupt Description. Features. Pin Configuration

K20/K21/K22/K30 plattforms

Global GPS NMEA over I²C Software Guide V 1.2

CubeSense. An integrated sun and nadir sensor module. Interface Control Document

RL78 Serial interfaces

Microtronix Avalon I 2 C

Lecture 25 March 23, 2012 Introduction to Serial Communications

Intelligent Infrared CO 2 Gas Sensor. (Model: MH-711A) Manual. Version: 3.3. Valid from: May 1st, 2014

AND8386/D. Bootloading BelaSigna 250 Using the I 2 C Interface APPLICATION NOTE

Page 1 MRK-D-0011, V1.1 Aeroqual SM50 User Guide

Interfacing an I 2 C Serial EEPROM to an MCS 96 Microcontroller

DS1845 Dual NV Potentiometer and Memory

1.3inch OLED User Manual

BV4205. I2C-10 Channel A to D. Product specification. January 2008 V0.a. ByVac Page 1 of 10

Codec. WM8731 Audio Codec

Handson Technology. I2C Specification and Devices. 1

RM24C64AF 64-Kbit 1.65V Minimum Non-volatile Fast Write Serial EEPROM I 2 C Bus

ADC to I 2 C. Data Sheet. 10 Channel Analog to Digital Converter. with output via I 2 C

Transcription:

Application Note Utilising the E2 Interface Version 1.03 Name Date Created Robert Mayr. 13.04.2011 Checked Released Reason for change Code batch according ACK/NACK

CONTENTS 1 INTRODUCTION... 3 2 EXAMPLE SYSTEM... 3 3 DATA TRANSMISSION METHOD... 3 3.1 Measured Value Interrogation... 4 3.1.1 Temperature... 4 3.1.2 Relative Humidity... 6 3.2 Status Interrogation... 6 4 SOFTWARE EXAMPLES FOR 8051 PROCESSORS... 7 4.1 General... 7 4.2 Main Module... 7 4.2.1 Example Code... 7 4.2.2 Header file... 8 4.3 Software Functions of the E2 Interface Module... 8 4.3.1 Temperature Interrogation... 8 4.3.2 Humidity Interrogation... 9 4.3.3 Status Interrogation... 9 4.3.4 Functions... 10 4.4 Return Values... 12 4.5 Bus Speed... 12 5 LITERATURE REFERENCES... 12 6 SUPPLEMENT... 13 6.1 Definitions and Prototypes for the E2 Interface Module... 13 application note e2-ee03_e_v1_03.doc Seite 2/13

1 Introduction This Application Noteexplains the use of an E2 Interface (ref. [1]) based on a simple example. The E2 Interface is used for the digital, bidirectional data transmission between a master module and a slave module. The data transmission takes place via synchronous and serial modes, and the Master is responsible for generating the clock pulse. The Slave cannot transmit any data independently. As an example, the temperature, the relative humidity of air and the status of a transmitter are to be read periodically with an E2 Interface. The section below provides a brief description of the system structure,explains the principle of the data transmission and gives a software example (in language C). 2 Example System The E2 Interface is designed as Master/Slave setup. Independently of a special hardware interface (SM or I²C Bus Interface), an 8051 range processor is used as the communication master in this example. The pins P0.7 (SCL) and P0.6 (DAT) will be used as clock or data lines. These pins are configured as open drain I/O pins and connected to the supply voltage via two external pull-up resistors.. A transmitter of the type EE03 is used as the slave. V CC V CC Master- Processor optional microcontroller with I/O Ports P0.6 P0.7 Data Clock GND R up R up Module with E2 Interface e.g. EE03, EE07... Figure 1 Setup of Master and Slave Note Note the compatibility of the voltage level between the E2 Interface levels [1] and the Master processor. 3 Data Transmission Method Only the use (several times) of the Read Byte from Slave command is necessary for data interrogation (ref. [1]). The Read Byte from Slave command is a bidirectional command, which allows only 1 data byte to be transmitted from the Slave to the Master. With a control byte, the Master notifies the Slave which data byte it wishes to retrieve. The Slave answers in the same Frame with the requested data byte and a checksum. If the value to be transmitted consists of several bytes, then a repeated execution of the Read Byte from Slave command is necessary. The detailed structure of the command is described in [1]. application note e2-ee03_e_v1_03.doc Seite 3/13

3.1 Measured Value Interrogation 3.1.1 Temperature The data transmission method is explained using a multi-stage temperature interrogation. To transmit a 16 bit temperature value, a 2-fold execution of the Read Byte from Slave command is necessary. The measured value of the temperature corresponds to the measured variable 2 of the EE03 module (ref. [2]). To ensure that the data is consistent, it is necessary to interrogate the low-byte of a measured value first (ref. [1]). The following steps are to be carried out for the temperature value interrogation First Read Byte from Slave command for reading in the temperature_low value Apply Start condition and control byte (0xA1) to the bus Read in and check ACK/NACK of the Slave Read in data byte temp_low Transmit acknowledgement to the Slave Read in checksum from the Slave Transmit NACK and Stop condition to the Slave (the first Read Byte from Slave command is thereby completed) Control of the checksum If the checksum is correct, the second Read Byte from Slave command can be started to read in the temperature_high value Apply Start condition and control byte (0xB1) to the bus Read in and check ACK/NACK of the Slave Read in data byte temp_high Transmit acknowledgement to the Slave Read in checksum from the Slave Transmit NACK and Stop condition to the Slave (The second Read Byte from Slave command is thereby completed) Control of the checksum With a positive control of the checksum, the Master can determine the actual temperature value. After combining the High- and Low bytes to form a 16-bit value, this is divided by 100. To obtain the temperature in C, an offset of 273.15 needs to be subtracted. Temperature[ C] = (Temp_high * 0x100 + Temp_low) / 100 273.15 Figure 2 provides the flow chart of this sequence. application note e2-ee03_e_v1_03.doc Seite 4/13

Start set default values (default temperature = error code) send E2 start condition send 0xA1 no ACK received? yes send E2 stop condition read temp_low Send ACK read checksum send NACK send E2 stop condition no checksum OK? yes send E2 start condition send 0xB1 read ACK read temp_high send ACK read checksum send NACK send E2 stop condition no checksum OK? yes calculate temperature overwrite default value return temperature value (or return default error code) Figure 2 Flow chart of a Temperature Interrogation application note e2-ee03_e_v1_03.doc Seite 5/13

3.1.2 Relative Humidity The measured humidity value can be read similar to the method described above. The corresponding control bytes are 0x81 for the Low byte and 0x91 for the High byte of the measured humidity value. The actual humidity is calculated as follows rel. humidity[%rh] = (rh_high * 0x100 + rh_low) / 100 3.2 Status Interrogation To guarantee the validity of measured values, following the measured value interrogations, the status of the Slave module must also be read. For this, a further Read Byte from Slave command is executed and the control byte 0x71 applied to the bus. After receipt of the status byte, the checksum is read in and checked (as described above). As shown in [1], the second bit (Bit 1) in the status byte provides information about the validity of the measured value of the temperature. The first bit (Bit 0) is assigned to the measured value of the humidity. A 0 indicates a correct measured value has been transmitted. A 1 indicates a faulty measured value has been transmitted (e.g. with sensor failure). Besides the information on the validity of the last measurement, the status interrogation has another purpose as well. After each status interrogation from the Master, a new measurement is started in the Slave. During the measuring time, the Slave cannot process any enquiries to the E2 Interface. It is therefore advisable to read in the required measured values first, and then execute a status interrogation. By doing this the validity of the last measured values can be evaluated, and a new measurement is started at the same time. After waiting for the module-specific measuring time, the new values can be interrogated again. application note e2-ee03_e_v1_03.doc Seite 6/13

4 Software Examples for 8051 Processors 4.1 General In this Application Note, the functions the E2 Interface executes are grouped together in a separate software module. This achieves simple integration and reusability of the code. By including the header file in the main module of the master code as specified below, the example functions can be used directly for reading the temperature value, the relative air humidity and the status byte. The supplement specifies the required definitions of the variables and the function prototypes to be able to create a simple software module for the E2 Interface. 4.2 Main Module After the initialisation, typically customer-specific actions are executed in a continuous loop in the main module. One option calling the interface routines in a favorable sequence is provided using symbols. 4.2.1 Example Code #include "E2_Interface.h" void init_main (void) { /* initialise up */ dummy = EE03_status(); // to start a measurement while (1) // main loop { /* user Code */ // minimum delay of measurement period // see [2] humidity = RH_read(); // read humidity temperature = Temp_read(); // read temperature status = EE03_status(); // read status; start a new measurement /* analyse status and measured values */ application note e2-ee03_e_v1_03.doc Seite 7/13

4.2.2 Header file To be able to implement the E2 Interface module routines, the following Header file (E2_Interface.h) needs to be imported into the master code main module /* headerfile for E2_Interface.c module */ float RH_read(void); float Temp_read(void); unsigned char EE03_status(void); 4.3 Software Functions of the E2 Interface Module The following functions permit the compilation of a complete E2-Interface software module using the definitions in the supplement. This code can be adapted to the required processor very easily. Only the DELAY_FACTOR, the HW-Pins and the designated functions are to be adapted. 4.3.1 Temperature Interrogation float Temp_read(void) { temperature = -300; E2Bus_start(); E2Bus_send(0xA1); if (check_ack()==ack) { temp_low = E2Bus_read(); send_ack(); checksum_03 = E2Bus_read(); send_nak(); // default value (error code) // MW2-low request // terminate communication if (((0xA1 + temp_low) % 256) == checksum_03) // checksum OK? { E2Bus_start(); E2Bus_send(0xB1); // MW2-high request check_ack(); temp_high = E2Bus_read(); send_ack(); // terminate communication checksum_03 = E2Bus_read(); send_nak(); if (((0xB1 + temp_high) % 256) == checksum_03) // checksum OK? { temp_ee03=temp_low+256*temp_high; //yes->calculate temperature temperature=((float)temp_ee03/100) - 273.15; // overwrite default (error) value return temperature; application note e2-ee03_e_v1_03.doc Seite 8/13

4.3.2 Humidity Interrogation float RH_read(void) {rh = -1; E2Bus_start(); E2Bus_send(0x81); if (check_ack()==ack) { rh_low = E2Bus_read(); send_ack(); checksum_03 = E2Bus_read(); send_nak(); // default value (error code) // MW1-low request // terminate communication return rh; if (((0x81 + rh_low) % 256) == checksum_03) // checksum OK? { E2Bus_start(); E2Bus_send(0x91); // MW1-high request check_ack(); rh_high = E2Bus_read(); send_ack(); checksum_03 = E2Bus_read(); send_nak(); // terminate communication if (((0x91 + rh_high) % 256) == checksum_03) { rh_ee03=rh_low+256*(unsigned int)rh_high; // yes-> calculate humidity value rh=(float)rh_ee03/100; // overwrite default (error) value // checksum OK? 4.3.3 Status Interrogation unsigned char EE03_status(void) {unsigned char stat_ee03; E2Bus_start(); // start condition for E2-Bus E2Bus_send(0x71); // main command for STATUS request if (check_ack()==ack) { stat_ee03 = E2Bus_read(); // read status byte send_ack(); checksum_03 = E2Bus_read(); // read checksum send_nak(); // send NAK... //... and stop condition to terminate if (((stat_ee03 + 0x71) % 256) == checksum_03) // checksum OK? return stat_ee03; return 0xFF; // in error case return 0xFF application note e2-ee03_e_v1_03.doc Seite 9/13

4.3.4 Functions void E2Bus_start(void) // send Start condition to E2 Interface {set_sda(); clear_sda(); void E2Bus_stop(void) // send Stop condition to E2 Interface {clear_scl(); delay(20*delay_faktor); clear_sda(); delay(20*delay_faktor); delay(20*delay_faktor); set_sda(); delay(20*delay_faktor); void E2Bus_send(unsigned char value) {unsigned char i; unsigned char maske = 0x80; // send Byte to E2 Interface for (i=8;i>0;i--) { clear_scl(); delay(10*delay_faktor); if ((value & maske)!= 0) {set_sda(); else {clear_sda(); delay(20*delay_faktor); maske >>= 1; clear_scl(); set_sda(); unsigned char E2Bus_read(void) {unsigned char data_in = 0x00; unsigned char maske = 0x80; // read Byte from E2 Interface for (maske=0x80;maske>0;maske >>=1) { clear_scl(); if (read_sda()) {data_in = maske; clear_scl(); return data_in; application note e2-ee03_e_v1_03.doc Seite 10/13

char check_ack(void) {bit input; // check for acknowledge input = read_sda(); if(input == 1) return NAK; else return ACK; void send_ack(void) // send acknowledge { clear_scl(); clear_sda(); clear_scl(); set_sda(); void send_nak(void) // send NOT-acknowledge { clear_scl(); set_sda(); clear_scl(); set_sda(); void delay(unsigned int value) // delay- routine { while (--value!= 0); // adapt this code for your target processor!!! void set_sda(void) { SDA = 1; // set port-pin (SDA) void clear_sda(void) { SDA = 0; // clear port-pin (SDA) bit read_sda(void) { return SDA; // read SDA-pin status void set_scl(void) { SCL = 1; // set port-pin (SCL) void clear_scl(void) { SCL = 0; // clear port-pin (SCL) application note e2-ee03_e_v1_03.doc Seite 11/13

4.4 Return Values The following format for the return values is used by the routines specified above Humidity (float) Temperature (float) Return Value Meaning 0.0...100.0 0.0 to 100.00% relative humidity -1 Error code Return Value Meaning > -273.15 temperature in Celsius (corresponding to measurement range) -300 Error code Status (unsigned char) The meaning of the individual bits in the status bytes is defined for all modules with E2 Interface in [1]. 4.5 Bus Speed The bus speed is defined by the clock frequency of the master processor and the constant DELAY_FACTOR (see function delay). The maximum bus speed that the Slave module can achieve is specified in its specification [2] or [3]. Attention The time delay is realised by means of a simple waiting loop. The optimisation level of the compiler should be selected so as to ensure that this loop is not optimised out! 5 Literature References [1] Specification E2-interface; E + E Elektronik [2] E2_interface_EE03; E + E Elektronik [3] E2_interface_EE07; E + E Elektronik application note e2-ee03_e_v1_03.doc Seite 12/13

6 Supplement 6.1 Definitions and Prototypes for the E2 Interface Module // SW-modul for E2 Interface // Target SiLabs C8051F005 // Compiler Keil C51 Version 5.1 // // created 04/2004 // #include "F000.h" // register definition for SiLabs C8051F00x // definitions #define DELAY_FAKTOR 10 // setup clock-frequency #define ACK 1 // define acknowledge #define NAK 0 // define not-acknowledge sbit SDA = P0^6; sbit SCL = P0^7; // define port-pin for data line // define port-pin for clock line // variables unsigned char rh_low; unsigned char rh_high; unsigned char temp_low; unsigned char temp_high; unsigned char checksum_03; unsigned int rh_ee03= 0; unsigned int temp_ee03= 0; float rh = 0; float temperature = 0; // functions char check_ack(void); void send_ack(void); void send_nak(void); void E2Bus_start(void); void E2Bus_stop(void); void E2Bus_send(unsigned char); void set_sda(void); void clear_sda(void); bit read_sda(void); void set_scl(void); void clear_scl(void); unsigned char E2Bus_read(void); void delay(unsigned int value); // send start condition // send stop condition // read one byte from E2-Bus application note e2-ee03_e_v1_03.doc Seite 13/13