Data Acquisition System Using Master Slave Communication through ATmega32A Microcontroller

Similar documents
AVR151: Setup and Use of the SPI. Introduction. Features. Atmel AVR 8-bit Microcontroller APPLICATION NOTE

AVR125: ADC of tinyavr in Single Ended Mode. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

AVR126: ADC of megaavr in Single Ended Mode. Introduction. Features. AVR 8-bit Microcontrollers APPLICATION NOTE

Implementing SPI Communication Between MSP430 G2452 and LTC ADC

AVR1309: Using the XMEGA SPI. 8-bit Microcontrollers. Application Note. Features. 1 Introduction SCK MOSI MISO SS

Chapter 13. PIC Family Microcontroller

Using the HT46R46 I/O Ports to Implement Half-Duplex SPI Communication

Arbeitskreis Hardware. Prof. Dr. Michael Rohs, Dipl.-Inform. Sven Kratz MHCI Lab, LMU München

Elettronica dei Sistemi Digitali Costantino Giaconia SERIAL I/O COMMON PROTOCOLS

Implementing SPI Master and Slave Functionality Using the Z8 Encore! F083A

The Programming Interface

Introduction the Serial Communications Huang Sections 9.2, 10.2 SCI Block User Guide SPI Block User Guide

AVR319: Using the USI module for SPI communication. 8-bit Microcontrollers. Application Note. Features. Introduction

DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Question Bank Subject Name: EC Microprocessor & Microcontroller Year/Sem : II/IV

AUTOMATIC NIGHT LAMP WITH MORNING ALARM USING MICROPROCESSOR

Microcontroller Based Low Cost Portable PC Mouse and Keyboard Tester

Part 1. MAX BIT DAC with an Arduino Board. MIDI to Voltage Converter Part1

POCKET SCOPE 2. The idea 2. Design criteria 3

User s Manual of Board Microcontroller ET-MEGA2560-ADK ET-MEGA2560-ADK

A DIY Hardware Packet Sniffer

TURBO PROGRAMMER USB, MMC, SIM DEVELOPMENT KIT

Serial Communications

Data Sheet. Adaptive Design ltd. Arduino Dual L6470 Stepper Motor Shield V th November L6470 Stepper Motor Shield

AVR317: Using the Master SPI Mode of the USART module. 8-bit Microcontrollers. Application Note. Features. Introduction

USER GUIDE EDBG. Description

DATA LOGGER AND REMOTE MONITORING SYSTEM FOR MULTIPLE PARAMETER MEASUREMENT APPLICATIONS. G.S. Nhivekar, R.R.Mudholker

ET-BASE AVR ATmega64/128

Embedded Systems Design Course Applying the mbed microcontroller

Intelligent Wireless Emergency Alert System for Patient Monitoring using AT89S52 Microcontroller

Atmel Norway XMEGA Introduction

8-bit RISC Microcontroller. Application Note. AVR910: In-System Programming

Display Message on Notice Board using GSM

A 5 Degree Feedback Control Robotic Arm (Haptic Arm)

The I2C Bus. NXP Semiconductors: UM10204 I2C-bus specification and user manual HAW - Arduino 1

SafeSPI - Serial Peripheral Interface for Automotive Safety

Microtronics technologies Mobile:

AT15007: Differences between ATmega328/P and ATmega328PB. Introduction. Features. Atmel AVR 8-bit Microcontrollers APPLICATION NOTE

Lab Experiment 1: The LPC 2148 Education Board

2.0 Command and Data Handling Subsystem

Android Controlled Based Interface

Serial Communications

Serial port interface for microcontroller embedded into integrated power meter

AND8336. Design Examples of On Board Dual Supply Voltage Logic Translators. Prepared by: Jim Lepkowski ON Semiconductor.

SPI I2C LIN Ethernet. u Today: Wired embedded networks. u Next lecture: CAN bus u Then: wireless embedded network

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

Implementing MOD bus and CAN bus Protocol Conversion Interface

C8051F020 Utilization in an Embedded Digital Design Project Course. Daren R. Wilcox Southern Polytechnic State University Marietta, Georgia

International Journal of Electronics and Computer Science Engineering 1588

Develop a Dallas 1-Wire Master Using the Z8F1680 Series of MCUs

I2C PRESSURE MONITORING THROUGH USB PROTOCOL.

Embedded Ethernet Interface Using Arm Processor

Design of Online Embedded Web Server for Data Acquisition System # Author

Hello, and welcome to this presentation of the STM32L4 reset and clock controller.

EVAL-UFDC-1/UFDC-1M-16

CAN bus board. EB018

8051 MICROCONTROLLER COURSE

If an occupancy of room is zero, i.e. room is empty then light source will be switched off automatically

SMARTCARD XPRO. Preface. SMART ARM-based Microcontrollers USER GUIDE

Designing VM2 Application Boards

Arduino ADK Back. For information on using the board with the Android OS, see Google's ADK documentation.

Surveillance System Using Wireless Sensor Networks

AN4646 Application note

Intelligent Home Automation and Security System

Design and Functional Verification of A SPI Master Slave Core Using System Verilog

Patient Health Monitoring Using Wireless Body Area Network

SPI. Overview and Use of the PICmicro Serial Peripheral Interface. Getting Started: SPI

Palaparthi.Jagadeesh Chand. Associate Professor in ECE Department, Nimra Institute of Science & Technology, Vijayawada, A.P.

Interfacing Analog to Digital Data Converters

Using Xbee in Serial Communication

INTERNATIONAL JOURNAL OF ELECTRONICS AND COMMUNICATION ENGINEERING & TECHNOLOGY (IJECET)

APPLICATION NOTE Atmel AT02509: In House Unit with Bluetooth Low Energy Module Hardware User Guide 8-bit Atmel Microcontroller Features Description

Design of Wireless Home automation and security system using PIC Microcontroller

Microcontrollers in Practice

Final Design Report 19 April Project Name: utouch

Embedded Systems on ARM Cortex-M3 (4weeks/45hrs)

S7 for Windows S7-300/400

Analog-to-Digital Converters

PICNet 1. PICNet 1 PIC18 Network & SD/MMC Development Board. Features. Applications. Description

Home Security System Using Gsm Modem

Measurement and Analysis Introduction of ISO7816 (Smart Card)

Remote PLC system using GSM network with application to home security system

M25P05-A. 512-Kbit, serial flash memory, 50 MHz SPI bus interface. Features

PROJECT PRESENTATION ON CELLPHONE OPERATED ROBOTIC ASSISTANT

Chapter 2 Logic Gates and Introduction to Computer Architecture

8-Bit Flash Microcontroller for Smart Cards. AT89SCXXXXA Summary. Features. Description. Complete datasheet available under NDA

MicroMag3 3-Axis Magnetic Sensor Module

CHAPTER 11: Flip Flops

Section bit A/D Converter

Lecture N -1- PHYS Microcontrollers

Data Acquisition Module with I2C interface «I2C-FLEXEL» User s Guide

A+ Guide to Managing and Maintaining Your PC, 7e. Chapter 1 Introducing Hardware

Keywords: GPS, GSM, AVR Microcontroller, SMS.

Development of an Internet based Embedded System for Smart House Controlling and Monitoring

Pmod peripheral modules are powered by the host via the interface s power and ground pins.

Data Transfer between Two USB Devices without using PC

Hardware and Logic Implementation of Multiple Alarm System for GSM BTS Rooms

DESIGN AND IMPLEMENTATION OF ONLINE PATIENT MONITORING SYSTEM

- 35mA Standby, mA Speaking pre-defined phrases with up to 1925 total characters.

Location-Aware and Safer Cards: Enhancing RFID Security and Privacy

2011, The McGraw-Hill Companies, Inc. Chapter 3

Transcription:

International Journal of Engineering Research and Development e-issn: 2278-067X, p-issn: 2278-800X, www.ijerd.com Volume 6, Issue 8 (April 2013), PP. 46-52 Data Acquisition System Using Master Slave Communication through ATmega32A Microcontroller Yadav Raghvendra Satyanarayan 1, Yadav Satyendra Satyanarayan 2 1, 2 M.Tech, Instrumentation & Control Engineering, Faculty of Technology Dharmsinh Desai University, Nadiad, Gujarat, India Abstract:- This paper presents a data acquisition system using master slave communication using ATmega32A microcontroller. In this system, we can do the analog to digital conversion using slave microcontrollers. Then by using SPI (Serial Peripheral Interface) protocol we can get that slave microcontrollers data to the master microcontroller and save that analog to digital convertor data to the master microcontroller memory. We can use those data for further processing. Keywords:- ATmega32A microcontroller, Data Acquisition System, Analog to Digital Converter, Master Slave Communication, SPI (Serial Peripheral Interface) Protocol, I. INTRODUCTION As we know that this project is based on the data acquisition system so, it is necessary to understand the data acquisition system first.[6] In data acquisition system there are number of stages involved as shown below: Fig.1: Block diagram of Data Acquisition System Each stages of this Data Acquisition system described below: A. Sensor Sensor is a device which provides a usable output in response to a specified measurand. [1] B. Signal Conditioning This is a stage of data acquisition system which converts the analog signal coming from the sensors into appropriate range of analog signal which is used for the analog to digital converter. C. Analog Multiplexer Multiplexer selects one of channel of analog signal from multiple analog signal channels. D. Sample & Hold Circuit 46

This circuit simply doing the sampling of the analog signal and holding that analog signal at a constant value for a specified period of time up to completion of the conversion of analog signal into digital, or we can say it holds on to its last sampled value until the input is sampled again.[2] E. Program Sequencer This controls the timing of the selection of analog channel of multiplexer and timing of sample hold circuit and maintaining the perfect synchronization between these two circuits. F. Analog to Digital Converter This converts the analog signal into digital form. I have used ATmega32A (AVR Family) microcontroller because it have in-built analog to digital converter and it also supports the SPI protocol for communication. In SPI protocol, when the communication will establish between two microcontrollers at that time one will work as master microcontroller and second as slave microcontroller. In the microcontroller we can easily select one microcontroller as master and other as slave microcontroller. SPI (Serial Peripheral Interface) is a synchronous serial data link that operates in full duplex mode. SPI is four pins communication protocol which are MISO (Master In Slave Out), MOSI (Master Out Slave In), SCK (Serial Clock) and SS (Slave Select) pins. [3] We can add maximum 26 no. Of slaves for single master, but the circuitry becomes more complex so we can use fewer slaves to communicate with the master microcontroller. The selection of slave is done by the master by simply pull down (at zero voltage level) the pin PB4 (Active low Slave Select pin of ATmega32A) of slave microcontroller. Each microcontroller has eight channel in-built analog to digital converter. Every slave microcontrollers continuously do the analog to digital conversion of analog signals of different sensors. Sensors includes such as temperature sensor, pressure sensor, motion sensor, displacement sensor or any other sensors. Then each slave will store the A/D data into their individual memory. Then from the request of master the slave will send that data using SPI protocol to the master. II. HARDWARE We have used ATmega32A microcontroller. It has advanced RISC (Reduced Instruction Set Computing) architecture. It has 131 single cycle execution instructions. It has 32 KB of flash program memory, 1024 bytes EEPROM and 2 KB of SRAM. It has eight channel 10-bit ADC (Analog to Digital Converter) and SPI interface for communication. The SFR s (Special Function Register) related for the in-built ADC and SPI are explained below: A. ADC related SFR s The ADC related SFR s are listed below: [4] i) ADMUX ADC Multiplexer Selection Register : Bit 7:6 REFS1:0 (Reference Selection) Bits: Select the voltage reference for the ADC, as shown in table. If these bits are changed during a conversion, the change will not go in effect until this conversion is complete (ADIF in ADCSRA is set). TABLE I Voltage Reference Selections for ADC REFS1 REFS0 Voltage Reference Selection 0 0 A ref, Internal V ref turned off 0 1 AVCC with external capacitor at A ref pin 1 0 Reserved 1 1 Internal 2.56V Voltage Reference at A ref pin Bit 5 ADLAR (ADC Left Adjust Result): This bit affects the presentation of the ADC conversion result in the ADC Data Register. Write one to ADLAR to left adjust the result. Otherwise, the result is right adjusted. Bits 4:0 MUX4:0 (Analog Channel and Gain Selection Bits): The value of these bits selects, which combination of analog inputs are connected to the ADC. These bits also select the gain for the differential channels. If these bits are changed during a conversion, the change will not go in effect until this conversion is complete (ADIF in ADCSRA is set). ii) ADCSRA ADC Control and Status Register : 47

Bit 7 ADEN (ADC Enable): Writing this bit to one enables the ADC. By writing it to zero, the ADC is turned off. Turning the ADC off while a conversion is in progress will terminate this conversion. Bit 6 ADSC (ADC Start Conversion): In Single Conversion mode, write this bit to one to start each conversion. In Free Running Mode, write this bit to one to start the first conversion. ADSC will read as one as long as a conversion is in progress. When the conversion is complete, it returns to zero. Writing zero to this bit has no effect. Bit 5 ADATE (ADC Auto Trigger Enable): When this bit is written to one, Auto Triggering of the ADC is enabled. Bit 4 ADIF (ADC Interrupt Flag): This bit is set when an ADC conversion completes and the Data Registers are updated. The ADC Conversion Complete Interrupt is executed if the ADIE bit and the I-bit in SREG are set. Bit 3 ADIE (ADC Interrupt Enable): When this bit is written to one, the ADC Conversion Complete Interrupt is activated. Bits 2:0 ADPS2:0 (ADC Pre-scalar Select Bits): These bits determine the division factor between the XTAL frequency and the input clock to the ADC. iii) ADCL and ADCH The ADC Data Register iv) SFIOR Special Function IO Register : Bit 7:5 ADTS2:0 (ADC Auto Trigger Source): If ADATE in ADCSRA is written to one, the value of these bits selects which source will trigger an ADC conversion. If ADATE is cleared, the ADTS2:0 settings will have no effect. A conversion will be triggered by the rising edge of the selected Interrupt Flag. Note that switching from a trigger source that is cleared to a trigger source that is set will generate a positive edge on the trigger signal. B. SPI related SFR s The SPI related SFR s are listed below: [5] i) SPDR SPI Data Register: The SPI Data Register is a read/write register used for data transfer between the Register File and the SPI Shift Register. Writing to the register initiates data transmission. Reading the register causes the Shift Register Receive buffer to be read. ii) SPCR - SPI Control Register: Bit 7 SPIE (SPI Interrupt Enable): This bit causes the SPI interrupt to be executed if SPIF bit in the SPSR Register is set and if the global interrupt enable bit in SREG is set. Bit 6 SPE (SPI Enable): When the SPE bit is written to one, the SPI is enabled. This bit must be set to enable any SPI operations. Bit 5 DORD (Data Order): When the DORD bit is written to one, the LSB of the data word is transmitted first. When the DORD bit is written to zero, the MSB of the data word is transmitted first. Bit 4 MSTR (Master/Slave Select): This bit selects Master SPI mode when written to one and Slave SPI mode when written logic zero. If SS is configured as an input and is driven low while MSTR is set, MSTR will be cleared, and SPIF in SPSR will become set. The user will then have to set MSTR to re-enable SPI Master mode. Bit 3 CPOL (Clock Polarity): When this bit is written to one, SCK is high when idle. When CPOL is written to zero, SCK is low when idle. 48

Bit 2 CPHA (Clock Phase): The settings of the Clock Phase bit (CPHA) determine if data is sampled on the leading (first) or trailing (last) edge of SCK. Bits 1,0 SPR1,SPR0 (SPI Clock Rate Select 1 and 0): These two bits control the SCK rate of the device configured as a Master. SPR1 and SPR0 have no effect on the Slave. The relationship between SCK and the Oscillator Clock frequency fosc is shown in the TABLE II. This SPI clock is also controlled by another bit of SPSR (SPI Status Register) which controls the speed of the SPI. That bit named as SPI2X, which increase the SPI speed doubles. TABLE II Relationship between SCK and the Oscillator Frequency SCK Frequency SPI2X SPR1 SPR0 Fosc/4 0 0 0 Fosc/16 0 0 1 Fosc/64 0 1 0 Fosc/128 0 1 1 Fosc/2 1 0 0 Fosc/8 1 0 1 Fosc/32 1 1 0 Fosc/64 1 1 1 iii) SPSR SPI Status Register : Bit 7 SPIF (SPI Interrupt Flag): When a serial transfer is complete, the SPIF Flag is set. An interrupt is generated if SPIE in SPCR is set and global interrupts are enabled. If SS is an input and is driven low when the SPI is in Master mode, this will also set the SPIF Flag. SPIF is cleared by hardware when executing the corresponding interrupt handling vector. Alternatively, the SPIF bit is cleared by first reading the SPI Status Register with SPIF set, then accessing the SPI Data Register (SPDR). Bit 6 WCOL (Write Collision Flag): The WCOL bit is set if the SPI Data Register (SPDR) is written during a data transfer. The WCOL bit (and the SPIF bit) is cleared by first reading the SPI Status Register with WCOL set, and then accessing the SPI Data Register. Bit 5:1 Reserved Bits: These bits are reserved bits in the ATmega32A and will always read as zero. Bit 0 SPI2X (Double SPI Speed Bit): When this bit is written logic one the SPI speed (SCK Frequency) will be doubled when the SPI is in Master mode (see Table II). This means that the minimum SCK period will be two CPU clock periods. When the SPI is configured as Slave, the SPI is only guaranteed to work at fosc/4 or lower. III. SYSTEM DEVELOPMENT As we have already discussed that using SPI protocol this system has been developed. From the block diagram of system we can understand that what is happening in the system. As shown in figure the master as well as slave we have used same chip ATmega32A microcontroller. In this system we have used only two slaves which are doing the ADC of analog signals and then transfer that ADC data to the master using SPI protocol. In this system we have used LCD for display of A/D converted data. We can also use the RS232 communication using USART communication between master and a PC and we can directly log the data to the PC and we can store it also. We can also connect the master with other interfaces IC s using SPI protocol such as external ADC IC s such as MCP3202, DS1307 real time clock IC etc. For this we have developed PCB for this project. In which, single PCB can use as master as well as slave also. Means a single design of PCB we can use for both master as well as slave. To develop the PCB we have used ARES Professional software which is very easy for developing the PCB layout as well as PCB schematic for any microcontroller based project or other small projects. We have developed single layer as well as double layer PCB for this project. After developing the PCB and mounting all the components the next stage of this project is to develop the programming for the master as well as slave microcontroller. 49

Fig.2: Block diagram of Data Acquisition system using Master-Slave Communication The above figure is block diagram of the project. As we have already discussed above in this one controller works as master and others are works as slave. From above figure we can say that analog signals are given to the slave s in-built A/D converter that transfers those data to the master using SPI protocol. For that we must have to do the programming for master as well as for slave microcontroller also. For that, we have used AVR Studio 4 assembler to do the programming of the microcontrollers. We have used Sunrom s ICSP (In- Circuit Serial Programmer) for programming of microcontroller. That programmer is also based on the SPI protocol and according to that it selects a microcontroller as slave and loads the program into microcontroller s flash memory. This programmer we can use for the most of AVR Family of the Atmel microcontrollers. It is available with the USB connector so we can use it with our laptops easily and anywhere. For developing of this project we have used as hardwares are ATmega32A microcontroller, ICSP programmer as well as different types of sensors, which are generating electrical signal according to the change in measurand. Basically power supply is basic need of any project so, we have also used the +5V power supply to power up the microcontroller. We have used temperature sensor (LM35) as sensor to get the analog signal according to the temperature of its surrounding area. After developing of system, the next objective is programming and for that the flow chart of programming is necessary. IV. FLOW CHART Flowchart is the first requirement for developing the programming for any application for any microcontroller. As shown in Fig.3 the flowchart indicates the way or direction of the program. For this project the first requirement is initialization of LCD using program. We can connect the LCD with master or with slave as per our requirement. We have connected the LCD with the master controller. After that we have to select the controller as master or slave, for that we have to write 1 at the bit of MSTR of SPCR SFR of the controller, for other we will write zero so that controller will selects as slave. As we have informed above that the programming for master as well as slave are different that we can see from the flowchart of programming. By using programming skills we can easily make a program which is suitable for every slave controller. In that, master will simply polling all slaves one by one to get the ADC data of each slave. At that time each slave other than that slave (which is connected with the master using SPI protocol) will do the A/D conversion and store that A/D conversion data into their individual memory. Then master will select a slave for getting that ADC data, that time the slave will transmit that data to the master. If we use the RS232 communication using USART port of microcontroller we can directly get that data to the screen of PC and we can also do some further processing according to our requirement. We can also add the programming for the RS232 communication. We have only use the LCD for data display of the ADC of slave controllers. 50

Fig.3: Flowchart of programming of Data acquisition System using Master Slave communication V. CONCLUSIONS This system is useful for the data acquisition process. We can use this system into home automation field as well as into building automation application. As this is based on SPI protocol we can also use Zig-Bee as slave and we can develop a wireless network using multiple Zig-Bees as slave of the master microcontroller. This is very useful for the less number of analog inputs, instead of plc for the same process. We can communicate with microcontroller or log the digital data of the microcontroller using Ethernet module. Using this module we can see the data of the process as well as we can control the process using internet connection. For complex number of analog inputs this system requires more programming of the master microcontroller, which requires more time as well as more knowledge and management of the programming. 51

REFERENCES [1]. D. Patranabis, Sensors and Transducers, 2 nd Edition, Prentice Hall of India (PHI) Publication, New Delhi, 2007. [2]. Ramakant A. Gayakwad, Op-Amps and Linear Integrated Circuits, 4 th Edition, Prentice Hall of India (PHI) Publication, New Delhi,2007. [3]. Archana Ramesh R, M.S.R.Sekhar, Design and Verification of Serial Peripheral Interface using OVM, International Journal of Electronics Communication and Computer Technology (IJECCT), Volume 2, Issue 6 (November 2012), pp. 267-269. [4]. Datasheet of ATmega32A Microcontroller, Analog to Digital Converter, www.alldatasheet.com and www.atmel.com, pp.209-227. [5]. Datasheet of ATmega32A Microcontroller, Serial Peripheral Interface, www.alldatasheet.com and www.atmel.com, pp.138-146. [6]. Shaikh Yusuf H., Khan A. R and Behere S. H, AVR Microcontroller Based Data Acquisition System for Laboratory Experiments, Advances in Applied Science Research, 2012, 3 (1), pp. 208-215. 52