Done 1 NVB THF TLF T/R POL 1SHOT. Figure 1: Status register

Similar documents
DS1821 Programmable Digital Thermostat and Thermometer

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

APPLICATION NOTE Wire Communication with a Microchip PICmicro Microcontroller

EECE.3170: Microprocessor Systems Design I Summer 2017 Homework 5 Solution

Embedded Systems. PIC16F84A Sample Programs. Eng. Anis Nazer First Semester

DS1821 Programmable Digital Thermostat and Thermometer

ORDERING INFORMATION. OPERATION Measuring Temperature A block diagram of the DS1621 is shown in Figure 1. DESCRIPTION ORDERING PACKAGE

DS1625. Digital Thermometer and Thermostat FEATURES PIN ASSIGNMENT

Weekly Report: Interactive Wheel of Fortune Week 4 02/014/07-02/22/07 Written by: Yadverinder Singh

PIC PROGRAMMING START. The next stage is always the setting up of the PORTS, the symbol used to indicate this and all Processes is a Rectangle.

Chapter 5 Sections 1 6 Dr. Iyad Jafar

LPTCOM. Bruce Misner Lakehead University h d3 RD2 pin 21. RD3 pin h d4. RD4 pin 27 RD5 pin h d5. RD6 pin 29 RD7 pin H d6

Flow Charts and Assembler Programs

DS1631/DS1631A/DS1731 High-Precision Digital Thermometer and Thermostat

Performance & Applications

Lesson 14. Title of the Experiment: Introduction to Microcontroller (Activity number of the GCE Advanced Level practical Guide 27)

SOLUTIONS!! DO NOT DISTRIBUTE PRIOR TO EXAM!!

D:\PICstuff\PartCounter\PartCounter.asm

Lecture (04) PIC16F84A (3)

16.317: Microprocessor Systems Design I Fall 2013 Exam 3 Solution

Dept. of Computer Engineering Final Exam, First Semester: 2016/2017

When JP1 is cut, baud rate is Otherwise, baud rate is Factory default is that JP1 is shorted. (JP1 is jumper type in some model)

16.317: Microprocessor-Based Systems I Spring 2012

which means that writing to a port implies that the port pins are first read, then this value is modified and then written to the port data latch.

PIC 16F84A programming (II)

Assembly Language Instructions

University of Jordan Faculty of Engineering and Technology Department of Computer Engineering Embedded Systems Laboratory

DS1626/DS1726 High-Precision 3-Wire Digital Thermometer and Thermostat

CENG 336 INT. TO EMBEDDED SYSTEMS DEVELOPMENT. Spring 2006

DS18B20 Programmable Resolution 1-Wire Digital Thermometer

Binary Outputs and Timing

Chapter 4 Sections 1 4, 10 Dr. Iyad Jafar

SOLAR TRACKING SYSTEM USING PIC16F84A STEPPER MOTOR AND 555TIMER

Embedded Systems Programming and Architectures

DISCONTINUED. SPI Communication with AMT bit Absolute Encoder

DS Wire Digital Thermometer and Thermostat

APPLICATION NOTE 2361 Interfacing an SPI-Interface RTC with a PIC Microcontroller

PIC Discussion By Eng. Tamar Jomaa

Interfacing PIC Microcontrollers. ADC8BIT2 Schematic. This application demonstrates analogue input sampling

Hardware Interfacing. EE25M Introduction to microprocessors. Part V. 15 Interfacing methods. original author: Feisal Mohammed

EEE111A/B Microprocessors

ALU and Arithmetic Operations

Application Note - PIC Source Code v1.1.doc

GUIDE TO USE OF PIC 16F690 EEProm. The 16F690 PIC has a 256 byte EEProm (mapped to 0x x21FF).

16.317: Microprocessor-Based Systems I Summer 2012

EE 367 Introduction to Microprocessors Homework 6

A Better Mouse Trap. Consumer Appliance, Widget, Gadget APPLICATION OPERATION: Ontario, Canada

/ 28 HLL assembly Q4: Conditional instructions / 40 TOTAL SCORE / 100 EXTRA CREDIT / 10

Designed to GO... Universal Battery Monitor Using the bq2018 Power Minder IC. Typical Applications. Features. Figure 1. bq2018 Circuit Connection

/ 40 Q3: Writing PIC / 40 assembly language TOTAL SCORE / 100 EXTRA CREDIT / 10

Chapter 5. Problems All programming problems should include design pseudo code either as a separate design document on embedded comments in the code.

TOPIC 3 INTRODUCTION TO PIC ASSEMBLY LANGUAGE. E4160 Microprocessor & Microcontroller System. Prepared by : Puziah Yahaya JKE, POLISAS / DEC 2010

Laboratory Exercise 5 - Analog to Digital Conversion

Jordan University of Science and Technology Electrical Engineering Department Microcontrollers and Embedded Systems Spring 2011

INTEGRATED CIRTUIT OF DIGITAL THERMOMETER OF INDUSTRIAL TEMPERATURE RANGE (functional equivalent of DS18B20 "Maxim-Dallas Semiconductor")

Figure 1: Pushbutton without Pull-up.

More (up a level)... Connecting the Nokia 3510i LCD to a Microchip PIC16F84 microcontroller

EE6008-Microcontroller Based System Design Department Of EEE/ DCE

SOLUTIONS!! DO NOT DISTRIBUTE!!

Instuction set

CENG-336 Introduction to Embedded Systems Development. Timers

DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI DEPARTMENT OF ELECTRICAL AND ELECTRONICS ENGINEERING. EE6008 Microcontroller based system design

Chapter 3: Further Microcontrollers

PIC Discussion. By Eng. Tamar Jomaa

The University of Texas at Arlington Lecture 5

DS2223/DS2224. EconoRAM FEATURES PACKAGE OUTLINE. PIN CONNECTIONS Pin 1 GND Ground Pin 2 DQ Data In/Out Pin 3 V CC Supply Pin 4 GND Ground

Week1. EEE305 Microcontroller Key Points

Discrete Logic Replacement A Keypad Controller for Bi-directional Key Matrix

Mechatronics and Measurement. Lecturer:Dung-An Wang Lecture 6

Section 11. Timer0. Timer0 HIGHLIGHTS. This section of the manual contains the following major topics:

ECE Homework #3

DS1920 Temperature ibutton

CONNECT TO THE PIC. A Simple Development Board

LAB WORK 2. 1) Debugger-Select Tool-MPLAB SIM View-Program Memory Trace the program by F7 button. Lab Work

Timer2 Interrupts. NDSU Timer2 Interrupts September 20, Background:

DERTS Design Requirements (1): Microcontroller Architecture & Programming

DS75 Digital Thermometer and Thermostat

PIC16F87X 13.0 INSTRUCTION SET SUMMARY INSTRUCTIONS DESCRIPTIONS

AN587. Interfacing to an LCD Module. Interfacing to an LCD Module INTRODUCTION OPERATION CONTROL SIGNAL FUNCTIONS TABLE 2: CONDITIONAL ASSEMBLY FLAGS

REMOTE TEMPERATURE MONITORING SYSTEM VIA INTERNET, USING A DS18B20 SENSOR

ECE Test #1: Name

Chapter 10 Sections 1,2,9,10 Dr. Iyad Jafar

Digital Thermometer and Thermostat in SOT23

16.317: Microprocessor Systems Design I Fall Exam 3 December 15, Name: ID #:

DS 1682 Total Elapsed Time Recorder with Alarm

KIT 134. INTRODUCTION TO LCD S

ECE 354 Computer Systems Lab II. Interrupts, Strings, and Busses

Digital Thermometer and Thermostat

Introduction to PIC Programming

ME 6405 Introduction to Mechatronics

DS1676 Total Elapsed Time Recorder, Erasable

1 Introduction to Computers and Computer Terminology Programs Memory Processor Data Sheet Example Application...

Interrupts. ELEC 330 Digital Systems Engineering Dr. Ron Hayne. Images Courtesy of Ramesh Gaonkar and Delmar Learning

Chapter 11: Interrupt On Change

16.317: Microprocessor Systems Design I Fall 2014

Section 16. Basic Sychronous Serial Port (BSSP)

16.317: Microprocessor Systems Design I Fall 2015

Section 13. Timer0 HIGHLIGHTS. Timer0. This section of the manual contains the following major topics:

Embedded Based Temperature Monitoring System

CHAPTER 6 CONCLUSION AND SCOPE FOR FUTURE WORK

Transcription:

Introduction to Microprocessors Feisal Mohammed 12th January 2001 Mini-project This project is to implement a temperature monitor using the PicStic4, the DS1821 temperature sensor and a LCD display. The monitor is to take readings of the ambient temperature every 5 seconds and display these readings on the LCD. The sections that follow explain how the DS1821 communicates and shows a partial implementation of the software to communicate with it. 1 DS1821 Registers The DS1821 temperature sensor 1 communicates via a 1-wire protocol. The DS1821 can operate as a thermostat or a thermometer, the factory settings default to thermometer using the 1-wire protocol to control the device. The data sheet details the specifics of the timing to initialize the device, write or read bits and from these basic functions, the functions for taking a temperature measurement can be developed. The DS1821 has a status register, shown in Figure 1, that controls its modes of operation. There is also a register that keeps the last temperature measured. Finally, there are two other registers which are used only in thermostat mode; the TH and TL registers. The TH register contains the highest temperature above which the output becomes high, and the output will stay active until the temperature falls below the temperature in the TL register. Done 1 NVB THF TLF T/R POL 1SHOT Figure 1: Status register The bits in the STATUS register have the following meanings: DONE Conversion Done bit. 1 = Conversion complete, 0 = conversion in progress. NVB Nonvolatile memory busy flag. 1 = Write to an EE memory cell in progress, 0 = nonvolatile memory is not busy. A write to EE may take up to 10 ms. THF Temperature High Flag. This bit will normally be 0, but will be set to 1 when the temperature exceeds the value of TH. It will remain 1 until reset by writing 0 into this location. This feature provides a method of determining if the DS1821 has ever been subjected to temperatures above TH. This bit is nonvolatile, and is stored in EE memory. TLF Temperature Low Flag. This bit will normally be 0, but will be set to 1 when the temperature is lower than the value of TL. It will remain 1 until reset by writing 0 into this location. This feature provides 1 The DS1821 data sheet is available from the EE25M resource site.

a method of determining if the DS1821 has ever been subjected to temperatures below TL. This bit is nonvolatile, and is stored in EE memory. T/R Power-up mode bit. If set to a 1, the DS1821 will power up in a thermostat mode. If set to a 0, the device will power up in 1-Wire read mode. This bit is nonvolatile. POL Output Polarity Bit. 1 = active high, 0 = active low. This bit is nonvolatile. 1SHOT One-Shot Mode. If 1SHOT is 1, the DS1821 will perform one temperature conversion upon reception of the Start Convert command. If 1SHOT is 0, the DS1821 will continuously perform temperature conversions. Note that the One-Shot mode is available only when the device is in 1-Wire mode. In thermostat mode, the device continuously performs temperature conversions. This bit is nonvolatile. Since all the bits except the DONE bit are non-volatile, the DS1821 needs only to be configured once, before logging starts. 2 Sample Software development In the following sections, the software for reading of the temperature is designed and implemented. The 1-wire protocol can be implemented in a layered fashion, shown in Figure 2 where the innermost layers operate on the bit level. This is an effective way of simplifying the development of the implementation of the protocol. At each level, we will define the modules/functions and how they will interact with the other Byte level operations Bit level operations Read Temperature Figure 2: Layering layers. Now the DS1821 requires that a reset/presence signal be sent before any writing of commands or reading of data is done and the sequence looks like the following: Reset/presence Command function Transaction/Data This reset/presence can be implemented in the innermost layer. The function structure now looks like Figure 3. There may be other functions that will be needed but these can be added as we proceed. It is assumed that all the low-level functions always leave the 1-wire bus in the floating state. Also high-level functions will be 2

readtemperature inittemperature readtempbyte writetempbyte writetempbit readtempbit resetpresence Figure 3: Initial structure written such that the value will be the status of the operation i.e. whether the function was successful or not. We will also need some variables for storing the temperature and for temporary storage. These are given as follows DQ equ 0 ; DQ is RB0 base equ 0x0C temperature equ base+0 ; temperature storage ds_count equ base+1 ; counter ds_ equ base+3 ; for values ds_bit equ base+4 ; to hold a bit read It is assumes that any parameter needed to be passed to a subroutine will be placed in the W register before the subroutine is ed. 2.1 inittemperature This function initializes the DS1821 and is done only once. The pseudocode is as follows. if cannot send reset/presence then error end if Send command byte to enable writing to STATUS register Send configuration byte We can now implement the code. In al the routines, any parameters that are to be passed are placed in the W register before ing the routine and any values are in the ds_ register. ; This function s 1 on success, zero otherwise. ; It initializes the DS1821 in preparation for sampling ; temperatures. 3

; resetpresence also s 1 on success, zero otherwise inittemp resetpresence ; resetpresence takes no movf ds_,f ;... parameters btfsc STATUS,Z ; resetpresence failed 2.2 readtemperature movlw 0x0C ; enable write to STATUS writetempbyte movlw 0x43 ; 1shot conversion, active high, 1 wire mode writetempbyte movlw.1 movwf ds_ Reading of the temperature is just slightly more complicated, we must start the temperature conversion on the device, wait until it has finished conversion and finally read the sampled temperature. The temperature conversion typiy takes 0.4 s but can take as much as 1 s and when it is finished the DONE bit in the STATUS register is set to 1. start temperature conversion repeat delay for 200 ms read the STATUS register until DONE bit of the STATUS is set read converted temperature The code is then ; assume that result from reading will be ;... stored in variable ed temperature readtemp resetpresence btfsc STATUS,Z movlw 0xEE ; start conversion writetempbyte DS_loop_read movlw.200 ; every 200 ms Delay_ms btfsc resetpresence STATUS,Z 4

movlw btfss goto btfsc 0xAC writetempbyte readtempbyte ds_,7 ;... check the DONE bit DS_loop_read resetpresence STATUS,Z 2.3 readtempbyte movlw 0xAA ; read temperature writetempbyte readtempbyte movf ds_,w movwf temperature movlw 1 ; 1 movwf ds_ This function reads a byte and is based on the readtempbit function. Essentially, it s readtempbit eight times, and shifts the bits read into a word. ; readtempbyte movlw.8 ; set loop counter movwf ds_count DS_loop_rbyte readtempbit ; s bit in W rrf ds_bit ; shift bit into Carry rrf ds_,f ; Carry -> register decfsz ds_count goto DS_loop_rbyte 2.4 readtempbit The low-level read function, adjusts the delays such that the master will sample within 15 µs after the DQ line is pulled low. Afterwards the line is left floating to finish the 60 µs time slot plus recovery. 5

readtempbit bsf STATUS,RP0 ; take DQ low bcf TRISB,DQ bcf STATUS,RP0 bcf PORTB,DQ ; wait one cycle to settle bsf STATUS,RP0 ; float DQ bsf TRISB,DQ bcf STATUS,RP0 ; wait for 5 us movf PORTB,W movwf ds_bit ; store bit read ; assume that DQ is connected to RB0, if not ; insert appropriate number of rrf instructions here movlw.15 usec4 ; delay for 15 * 4 = 60 us 3 Presentation of the project The presentation of your final report is very important if you are to obtain full marks. Several points to note are: Refrain from including any extraneous matter, such as specification sheets for the PIC, LCD. etc. I have seen these sheets already and printing them again serves no purpose. Concentrate on what has been done. The idea of this project is for students to design and build a temperature monitor. Therefore I need to know what it is exactly that you have done, not what others have done. Avoid gratuitous comments in your code do not explain the op-code but rather explain what is intented by the code. 3.1 Content The report for the project should contain Overview There must be an overview of the system. This includes the functionality and a physical view of the system. The overview serves to summarize the behavior and set the goals of the system. 6

Circuit diagram The physical layout of the circuit is presented. Any calculations, choices of resistor and/or capacitor values are also shown here along with explanations. Software structure It is essential to show the structure of the software, as an overall picture and in increasing detail. It is much better to have several diagrams that show increasing level of detail than to have everything compressed into one complicated diagram. Testing Testing determines if the completed system meets its requirements. It is not sufficient to say it works. Saying that means that you have not done sufficient tests to validate your work. The result of testing is an assurance that a system will perform as specified, therefore simplistic testing where only a small subset of all inputs or environments are applied will not give that assurance. Discussion A discussion is not a list of problems encountered, it is an analysis of how well the objectives were met, any special problems encountered, possible improvements and further work. You should also mention any trade-offs that were made during development. 3.2 Marking Scheme The marking scheme is given in the following table: Area Marks allocated Presentation 4 Design 5 Implementation 6 Discussion 5 7