Storing a Program and Data

Slides:



Advertisements
Similar presentations
PICAXE Memory.
Advertisements

1 Chapter 2 The Digital World. 2 Digital Data Representation.
What is memory? Memory is used to store information within a computer, either programs or data. Programs and data cannot be used directly from a disk or.
Overview Memory definitions Random Access Memory (RAM)
Registers  Flip-flops are available in a variety of configurations. A simple one with two independent D flip-flops with clear and preset signals is illustrated.
Basic Computer Organization CH-4 Richard Gomez 6/14/01 Computer Science Quote: John Von Neumann If people do not believe that mathematics is simple, it.
Binary “There are 10 types of people in the world… those that understand binary and those that don’t.”
COMPONENTS OF THE SYSTEM UNIT
Khaled A. Al-Utaibi Memory Devices Khaled A. Al-Utaibi
Memory Main memory consists of a number of storage locations, each of which is identified by a unique address The ability of the CPU to identify each location.
Stuart Cunningham - Computer Platforms COMPUTER PLATFORMS Von Neumann Architecture & Terminology & Performance Week 3.
Chapter 3 Computer Hard ware
Random access memory.
The CPU The Central Presentation Unit Main Memory and Addresses Address bus and Address Space Data Bus Control Bus The Instructions set Mnemonics Opcodes.
 Computer memory is device that is used to store data or programs (sequences of instructions) on a temporary or permanent basis for use in an electronic.
GCSE Information Technology Storing data Data storage devices can be divided into 2 main categories: Backing storage is used to store programs and data.
© Banff and Buchan College 2007 DH2T 34 Computer Architecture 1 LO2 Lesson One Memory.
Memory and Programmable Logic Memory device: Device to which binary information is transferred for storage, and from which information is available for.
Supplemental reading Main Memory. REVIEW CPU-stands for central processing unit; it is the key component in a digital computer; it interprets computer.
PLC ARCHITECTURE – Memory 1 by Dr. Amin Danial Asham.
Storage of Data Instructions and data are held in main memory which is divided into millions of addressable storage.
© GCSE Computing Computing Hardware Starter. Creating a spreadsheet to demonstrate the size of memory. 1 byte = 1 character or about 1 pixel of information.
CS 1428 Foundations of Computer Science I. Two Main Components  Hardware  Physical media that uses electrical current to process instructions.  Software.
Memory Devices 1. Memory concepts 2. RAMs 3. ROMs 4. Memory expansion & address decoding applications 5. Magnetic and Optical Storage.
Copyright © 2006 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill Technology Education Chapter 1 Looking Inside the Computer System.
Components of Computer. Memory Unit Most important part of the computer Used to store data and instructions that are currently in use Main memory consists.
Computer Architecture and Number Systems
MEMORY BYTES. MEMORY BYTES MEMORY MEMORY OUR Internal External.
Consider this number: , Ones (7 ones) Tens (no tens)
UNIT 2 – CHAPTER 1 – LESSON 1 DIGITAL INFORMATION.
Internal Memory.
Memory Main memory consists of a number of storage locations, each of which is identified by a unique address The ability of the CPU to identify each location.
Memory Main memory consists of a number of storage locations, each of which is identified by a unique address The ability of the CPU to identify each location.
Chapter 7.2 Computer Architecture
Data Representation in Computer Systems
Storage devices of Computer Submitted By Pravesh Kumar UPS Beetia
Principles & Applications
Memory Units Memories store data in units from one to eight bits. The most common unit is the byte, which by definition is 8 bits. Computer memories are.
Number Systems.
Introduction to Computers
Memory chips Memory chips have two main properties that determine their application, storage capacity (size) and access time(speed). A memory chip contains.
Electronics Technology
Introduction to Computers
COMPUTER MEMORY & DATA STORAGE
COMPUTER MEMORY & DATA STORAGE
Discrete Versus Analog Devices
Number Systems and Codes
Decimal System The radix or base of a number system determines
Serial EEPROM (Atmel 24C-512)
Computer Memory BY- Dinesh Lohiya.
Topics Introduction Hardware and Software How Computers Store Data
Machine Architecture and Number Systems
PICAXE BASIC The programming language used by the PICAXE microcontrollers is called BASIC. BASIC is a very early programming language and designed to make.
2.C Memory GCSE Computing Langley Park School for Boys.
Machine Architecture and Number Systems
Machine Architecture and Number Systems
Machine Architecture and Number Systems
Machine Architecture and Number Systems
How to Represent Numbers on a Computer
Chapter Four Data Representation in Computers By Bezawit E.
INTRODUCTION TO MEMORY AND MEMORY DESIGN 1
Scientific Notation.
Information Technology Department
AS Level ICT Selection and use of storage requirements, media, and devices: storage and storage capacity Unit 1 Topic a - Selection and use of storage.
Machine Architecture and Number Systems
Computer Memory.
Presentation transcript:

Storing a Program and Data PICAXE-08M2 Memory Storing a Program and Data Before you can begin programming your Temperature Logger, you will need to understand the three types of memory inside the PICAXE-08M2

Three Types Program Memory Random Access Memory (RAM) Data Memory The PICAXE-08M2 microcontroller inside the Temperature Logger uses three types of memory. These are the Program Memory, RAM, and Data Memory.

Bits and Bytes Bit – a single 0 or 1 Byte – eight bits All data and programs stored in PICAXE memory are written as bits. A bit is a single one or zero. This is the same as a yes and a no or a on and a off. Inside the PICAXE-08M2, each bit is stored as a voltage or no voltage within a memory cell. A bit is very limited, it can only represent a zero or one. We need to store larger numbers than that, so eight bits are grouped together in what is called a byte. The smallest byte is eight zeros, or 0000 0000. The largest byte is eight ones, or 1111 1111. Although not commonly used in the PICAXE, four bits grouped together is called a nibble. This makes one nibble half the size of one byte (get it?). Since the largest single digit in a bit is one, it is called the base two or binary numbering system. Recall that we use the base ten or decimal counting system, so our largest single digit is nine. Any base ten number can be represented as a base two number. You won’t need to know how this is done in order to use your Temperature Logger, but you will find it is a useful ability as you develop your programming skills. Suffice to say, a byte of 0000 0000 represents a zero in base ten and a byte of 1111 1111 represents a 255 in base ten. The largest number that can be stored in a nibble is 15. All the memory in the PICAXE is accessed, with a few exceptions, in whole bytes. When using your Temperature Logger, you will only work with whole bytes of data or programs.

Program Memory Used to store the operational program Non-volatile Bytes not accessible The Temperature Logger’s directions about how to operate is called a program. The program is created by you on a PC and then downloaded into the PICAXE. You need to keep a copy on your PC because you can’t upload a PICAXE’s program back to a PC. Once you are happy with a program, you don’t normally change it in the PICAXE. Also, your program does not change the program memory. Your program is static until you create a new program and download it into the PICAXE. Once downloaded into a PICAXE, the program remains in memory even when the battery is disconnected. As soon as the battery is reconnected, the PICAXE begins carrying out the instructions in its program. Since data stored in Program Memory doesn’t get erased when the power is removed, it is called non-volatile memory. The specific form used in the PICAXE is called electrically erasable programmable read-only memory, or EEPROM. EEPROM has the benefit of permanently storing the program while also being capable of being overwritten with a new program. The number of times that you can overwrite your program is limited to at least 100 thousand times. You can also expect your Temperature Logger program of remaining viable for at least ten years. Normally you won’t access each byte in Program Memory. So when you create a program and download it to the PICAXE, software on the PC will take care of which bytes each program instruction is stored. The Program Memory in the PICAXE-08M2 is 2,048 bytes in size. That’s enough room to store a program with 600 lines of instruction. You will only need a small amount of the Program Memory for the Temperature Logger.

RAM Memory Used to collect sensor readings Used to perform mathematical operations Volatile Accessible Random access memory, or RAM is a type of memory that is fast and updated often. The program inside the Temperature Logger will use RAM all the time to store the results of a temperature reading. And since RAM memory is broken into one byte chunks, the largest number that can be stored in a single RAM location is 255. It cannot be used to store negative numbers or fractions. When a PICAXE program needs to perform a mathematical operation, like multiplying two numbers, the results are stored in RAM. So anywhere when numbers need to be created or updated, the results are stored in RAM. The problem with RAM is that a number stored in it evaporates away when the power is removed. If it is important to remember a number for a long period of time, then it must be copied from RAM and into EEPROM. Because a number stored in RAM is erased when the power is removed, this type of memory is called volatile. Since the program needs to know where it is creating and manipulating data, the memory locations in RAM are named. The names are actually addresses and each memory location has a unique address. Think of RAM as being a house. Each house can contain contents and each house has an address. Following this model, we can say that a program will create a number and then specify which house to store the number. The address scheme used in RAM memory names each byte location in RAM with a B followed by a number. So the first memory location in RAM is called B0 (b-zero). The next one is called B1. There are 28 different bytes in RAM that can be directly accessed like this. That implies the last byte in RAM has an address of B27. Don’t get the address of a RAM byte confused with the number stored inside of it. So B0 could store a 15 while B1 could store a 213. The program can change and update each RAM location as often as it needs to. For example, B5 could initially store a value of 178. Later in the program, it could add 15 to the value stored in B5 to make it a 192. When you become a more sophisticated programmer, you will discover there are additional bytes in RAM. However, these are not accessed the same way that bytes B0 to B27 are accessed.

Data Memory Used to permanently store data Non-volatile Accessible The last kind of PICAXE memory is used by the Temperature Logger to store all the temperature readings. There is 256 bytes in Data Memory and since each temperature reading is one byte in size, the Temperature Logger can store 256 temperature readings. Data Memory is EEPROM, so it retains data even when the battery is disconnected. This permits the Temperature Logger to download temperature readings days, months, or even years later. The Data Memory has a limited number of times that it can be used, something over 100,000 times. This memory is like RAM in that each byte has an address that the program can reference. To write to a Data Memory location, the program uses the WRITE command. To read from a Data Memory location, the program uses the READ command. In normal operation, data written into Data Memory comes from the number stored in a RAM byte. When the data is read from Data Memory, it will be transferred to a RAM byte. To write the number stored in RAM byte B5 into Data Memory location 150, the command is WRITE 150,B5. The READ command is similar. To copy the number stored in Data Memory byte 81 into RAM byte B12, the command is READ 81,B12. It’s important to move numbers from Data Memory to RAM because while the numbers are stored only in Data Memory, humans cannot see them. Once the numbers are moved into RAM, they can be displayed on a PC.

Connecting all the Pieces A program must be written in order to make the Temperature Logger function. It is very unlikely the Temperature Logger will ever run out of Program Memory. It simply doesn’t take 600 lines of instructions to make the Temperature Logger function. The editing software used to create the Temperature Logger’s program will make all the arrangements to store the program into Program Memory. You need not concern yourself with the byte locations in Program Memory. Each byte in RAM can be accessed by the program stored in Program Memory. This is a two-way connection, the program can write a number into each RAM byte and can also read the number stored in each RAM byte. The program access each byte in RAM by using the address (or name) of the byte. So for example, B0, B1, etc. The data stored in each RAM byte is at the mercy of the battery. If it is disconnected, the number stored in each RAM byte vaporizes. If the program is to safe-guard the data, it must be stored in Data Memory. There are only 28 bytes of RAM. Data Memory is permanent until the program erases or overwrites the data. There are 256 bytes of Data Memory and the program access them with the READ and WRITE commands. The name or address of each byte in Data Memory is just a number, so 0, 1, 2, etc. Data Memory cannot directly access RAM and RAM cannot directly access Data Memory. The only way to move data between them is by using a program. The only data that can be displayed for human consumption is that data stored in RAM. Each temperature reading is created in RAM. So it is necessary to move temperature readings from RAM to Data Memory after each temperature reading. It is also necessary to move readings stored in Data Memory into RAM in order to display the readings.