0% found this document useful (0 votes)
515 views344 pages

ELE604 Student Guide

2

Uploaded by

Goran Miljkovic
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
515 views344 pages

ELE604 Student Guide

2

Uploaded by

Goran Miljkovic
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 344

ELE604 Sensors and Measurement

Student Lab Manual

Dr. James Andrew Smith


Dept. of Electrical & Computer Engineering
Ryerson University

May 2, 2013
2 Edit Date: February 12, 2013
Contents

1 Introduction 1-1
1.0.1 About this document . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-1
1.0.2 Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-1
1.0.3 Found a Mistake? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-1
1.1 What is ELE604 Sensors and Measurement? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-1
1.2 The Design Process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2
1.3 Learning Objectives and Pedagogical Goals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2
1.3.1 Course Learning Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2

2 Semester Design Overview & Objectives 2-1


2.1 Straight to the Point . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-1
2.2 Preamble . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-1
2.3 Jargon & Vocabulary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-2
2.4 Background . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-2
2.4.1 Stress Measurement Technique . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-2
2.4.2 Tilt Angle Measurement Technique . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-4
2.5 Design Objectives & Specifications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-6
2.5.1 General Design Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-6
2.5.2 Specifications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-6
2.6 Suggested System Block Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-8
2.7 Suggested References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-8
2.8 Recommended Design and Measurement Process . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-9
2.9 Schedule . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-10
2.10 Grading Scheme . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-10
2.11 Report Writing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-10

3 Equipment & Tools 3-1


3.1 Equipment & Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-1
3.1.1 The Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-1
3.1.2 The Sensors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-1
3.1.3 The Microcontroller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-2
3.1.4 Circuits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-4
3.1.5 The Packaging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-4
3.1.6 Tools: Software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-4

4 Programming the 9s12 Esduino in C and Assembler 4-1


4.1 Setting up Codewarrior . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-1
4.2 Setting Up a C Project in Codewarrior . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-1
4.3 The Serial Monitor Debugging Tool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-1
4.4 An Example Assembler Program: read a switch and turn on LED . . . . . . . . . . . . . . . . . 4-2

3
4.5 More Examples of Sample Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-3

5 Grading 5-1

6 Week 1: No Labs! 6-1


6.1 Checklist . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-1

7 Week 2: Heartbeats and Time-Keeping 7-1


7.1 Straight to the Point . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-1
7.2 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-1
7.3 Background Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-2
7.4 Learning Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-2
7.5 Success Criteria . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-2
7.6 Pre-requisites & Pre-lab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-3
7.6.1 Establish preliminary microcontroller pin allocation . . . . . . . . . . . . . . . . . . . . . 7-4
7.7 Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-7
7.8 Exploration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-7
7.8.1 Lab Safety . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-7
7.8.2 Wiring Hook-up wire . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-8
7.8.3 Let there be Light . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-8
7.8.4 How good is the 9s12 at Measuring Time? . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-8
7.9 Skill Exercise . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-9
7.10 Communication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-9
7.11 Post-lab reflection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-10

8 Week 3: Displaying Data, Part 1: Serial to PC 8-1


8.1 Straight to the Point . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-1
8.2 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-1
8.3 Background Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-1
8.4 Learning Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-5
8.5 Success Criteria . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-6
8.6 Pre-lab & Pre-Requisites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-6
8.7 Exploration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-6
8.7.1 Heartbeat Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-6
8.7.2 Write Counter Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-7
8.7.3 Initialise the SCI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-7
8.7.4 Test SCI transmission of single character . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-7
8.7.5 Modify Serial Stream . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-7
8.7.6 Graph the Results in Matlab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-8
8.8 Skill Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-8
8.9 Bonus Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-8
8.10 Communication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-8
8.11 Post-lab reflection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-10
8.12 Post-lab work: Examine the LCD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-10

9 Week 4: Displaying Data, Part 2: Onboard LCD 9-1


9.1 Straight to the Point . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-1
9.2 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-1
9.3 Background Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-1
9.4 Learning Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-2
9.5 Success Criteria . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-2

4 Edit Date: February 12, 2013


9.6 Pre-lab & Pre-Requisites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-2
9.6.1 Source code snippets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-2
9.7 More Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-5
9.8 Exploration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-6
9.8.1 LCD Hardware for the Esduino . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-6
9.8.2 LCD Programming via SPI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-6
9.9 Skill Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-6
9.10 Bonus Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-6
9.10.1 All Sections, All Students . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-6
9.10.2 Section-by-Section, First Group to Finish . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-7
9.11 Communication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-7
9.12 Post-lab reflection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-8
9.13 Post-lab work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-8

10 Weeks 5 and 6: Milestone 1 – Switches and LEDs 10-1


10.1 Straight to the Point . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-1
10.2 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-1
10.3 Background Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-1
10.4 Learning Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-1
10.5 Success Criteria . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-3
10.6 Pre-lab & Pre-requisites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-3
10.7 Exploration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-3
10.7.1 BJT-driven LED . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-3
10.7.2 Temperature effects on currents through an LED . . . . . . . . . . . . . . . . . . . . . . . 10-4
10.7.3 Debounced Switch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-7
10.8 Skill Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-9
10.9 Bonus Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-9
10.10Communication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-10

11 Weeks 8 and 9: Accelerometer Setup and Testing (Milestone 2) 11-1


11.1 Straight to the Point . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-1
11.2 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-1
11.3 Background Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-1
11.4 Exploration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-2
11.4.1 Angle Measurement – Suggested Approach . . . . . . . . . . . . . . . . . . . . . . . . . . 11-2
11.4.2 Steps in the Development Strategy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-2
11.5 Skill Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-3
11.6 Bonus Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-3
11.7 Communication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-4
11.8 Post-lab reflection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-4

12 Weeks 10 & 11: Strain Gauge test and uC Integration 12-1


12.1 Straight to the Point . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-1
12.2 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-1
12.3 Pre-lab & Pre-requisites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-1
12.4 Background Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-1
12.5 Exploration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-1
12.5.1 Week 10: Simulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-1
12.5.2 Week 11: Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-2
12.6 Skill Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-3

5 Edit Date: February 12, 2013


12.7 Oral Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-3
12.8 Bonus Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-4
12.8.1 Week 10 Bonus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-4
12.8.2 Week 11 Bonus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-4
12.9 Communication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-5
12.10Post-lab reflection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-5

13 Weeks 12 -14: Integration and Demonstration (to be updated) 13-1


13.1 Straight to the Point . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-1
13.2 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-1
13.3 Success Criteria . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-1
13.4 Exploration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-1
13.4.1 Functional Sequence of Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-1
13.4.2 Recommended Design and Measurement Process . . . . . . . . . . . . . . . . . . . . . . . 13-3
13.4.3 Packaging and Build Quality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-3
13.5 Bonus Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-4
13.5.1 Packaging Bonus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-4
13.5.2 Software Bonus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-4
13.6 Communication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-5
13.6.1 Milestone 5 Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-5
13.7 Post-lab reflection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-5

Bibliography 13-9

A Additional Lab Safety Documentation A-1

B To Be Sorted Later B-1

C Lab Kit Parts List C-1

D AD620 Instrumentation Amplifier & Maxim Voltage Refs D-1

E MapleSim Tutorials E-1

F Building the Esduino LCD Shield (with driver code) F-1

G Esduino Schematics and Layout (Rev 1) G-1

H Building Esduino Board H-1

I Serial Communication to PC for data logging (with quick-start code) I-1


I.1 Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . I-1
I.2 To-Do . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . I-1
I.3 Serial Communication Code & Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . I-2
I.3.1 Test first using RealTerm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . I-2
I.3.2 Test using Matlab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . I-4

J Esduino Schematics and Layout (Rev 1) J-1

K Load Cell Usage K-1

L MEMSIC 2125 L-1

6 Edit Date: February 12, 2013


M Debugging: Serial Monitor vs. DBUG12 M-1

N The HC12 Serial Debugger N-1

O 9s12 Resource List & Codewarrior Programming “Short Courses” O-1

P Codewarrior and C Example P-1

Q Code Example Blinking an LED on PM5 Q-1


Q.1 Installation of the 9s12 bootloader . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Q-3
Q.1.1 Problems with a “locked” processor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Q-5
Q.2 Coding hints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Q-5

R IEEE Formatting for Report Writing R-1

7 Edit Date: February 12, 2013


8 Edit Date: February 12, 2013
Lab Safety

There is nothing more important than your safety. It is more important than the design. It is more important
than your marks. There are four main dangers in the lab:

Electrocution Many of the tools are connected to AC mains (110 or 220 VAC). Be careful when using these
devices. Always know where the Emergency Shut-off is. It’s typically a big red button on the wall. Look
for it!

Burns Watch where you put the soldering iron. It can easily burn your skin. Put the iron back into its holder
when it is not in your hand. Never set it down on the lab bench!

Fumes Solder smoke is bad for you! When soldering, turn on the table-top vents. Ensure that it is close
enough to your soldering iron to pull fumes away from you.

Projectiles When cutting wires, fragments can fly into your eyes. Wear glasses or goggles and, if possible and
safe, use your hand as a shield around the cutting tool (like a side-cutter). Don’t worry about looking
stupid. You’ll look even worse with wire sticking out of your eye.

Figure 1: Damage to hands from electrocution. (Cadaver images courtesy of Brosz and Associates)

These are real dangers. In the first lab session, Mr. Jim Koch will go over lab safety with you. If you have
any questions or concerns, please do not hesitate to ask. If you feel that a method or procedure is unsafe or
could be made safer, please bring it to our attention.1

1
Thanks to Wikipedia for the images: http://en.wikipedia.org/wiki/Hazard_symbol

9
10 Edit Date: February 12, 2013
Notes on Changes to the ELE 604 Lab &
Documentation

We want to provide you with the best learning experience for instrumentation systems design. In that light
we’ve watched trends outside of Ryerson and paid attention to internal feedback from students, staff and faculty.
ELE 604 has undergone changes almost every year since it first ran in 2009 because of this.
In 2011 we updated ELE604 to the 9s12-based Esduino system from Technological Arts, replacing the 8-bit
68HC11 board that had previously been used. The Esduino has a reduced component count, uses a 16-bit
processor and conforms to the ground-breaking Arduino form factor. In 2012 we updated the course, yet again,
so that students could use C rather than Assembler to program their Esduino-based instrumentation systems.
Bonus tasks were added to most labs in 2012, as well.
There will be some adjustments made over the course of the semester and in future years based on the
feedback from you, the students. We are open to hearing about your experiences and will do our best to
improve as we go along.
Documentation may change without notice (although we’ll do our best to give sufficient notice). Please keep
an eye out for the latest revision of this document.

11
12 Edit Date: February 12, 2013
Chapter 1

Introduction

1.0.1 About this document


The document was typeset in LATEXusing TeXworks and BibDesk on a MacBook Pro. Some figures were taken
from Dr. Mike Kassam’s original documentation. Photos were taken by Dr. James Smith or Mr. Ron Wong
unless otherwise noted.

1.0.2 Acknowledgements
This material is based on Dr. Mike Kassam’s original ELE744 “Electronics and Instrumentation” lab, and was
brought into ELE604 during its introduction in 2008/9 as a bridge between ELE504 and ELE744. Between
2009 and 2010 the Freescale HC11-based hardware was phased out and replaced with the Freescale 9s121 . I
would like to thank the faculty and staff who were involved in this transition, including Dr. Vadim Geurkov,
Mr. Ken Clowes, Mr. Nipin Malhotra, Dr. Andy Ye and Mr. Jim Koch. Mr. Jamil Jivraj provided feedback
on the course. Mr. Ron Wong did much of the underlying work to get the “Esduino” system integrated into
the course. Mr. Thomas Behan provided feedback and resources with a variety of hardware components. Mr.
Carl Barnes at Technological Arts provided much technical support and was very attentive to our feedback and
requests. Ms. Mehrnaz Shokrollahi capably introduced me to the HC11-based IPB in the first two years of
ELE604.

1.0.3 Found a Mistake?


Have you found a mistake in this manual? Do you have feedback that you’d like to share? Let me know. Send
me an email: jasmith@ee.ryerson.ca.

1.1 What is ELE604 Sensors and Measurement?


The ELE604 class is an optional course provided to Third Year Electrical Engineering undergraduate students
at Ryerson University. The course is described officially in the University Calendar as:

The course will cover the theory and principles of sensors and transducers (electrical, chemical and
mechanical). The topics covered include transduction techniques, linear/non-linear signal processing,
low noise amplifiers, instrumentation amplifiers, data converters. There will be small design projects
for the labs to reinforce sensor/transducer interfacing.

This document describes the work that students do with respect to “small design projects... to reinforce
sensor/transducer interfacing”.
1
The 9s12 is also referred to as the HCS12 or MC9S12

1-1
1.2 The Design Process
The typical Canadian engineering curriculum is designed to give you a taste of the engineering design process
in third year, preparing you for the design-centric courses in fourth year. ELE 604 is focused on providing you
with a meaningful design experience in that context. In Fig. 1.1 you will see the basic steps that you take.

Figure 1.1: The typical design process that engineers undertake.

You start by reading the project requirements and/or the specific lab requirements. Then you prototype
a solution to the problem at hand, testing it as required. If the test succeeds, or if you run out of time, you
generate a report. If it doesn’t work and you have more time you create a new prototype and test again.
This design process is tried-and-true, both in school and in industry. In ELE604 you get to try it out in a
hands-on way.

1.3 Learning Objectives and Pedagogical Goals


We have attempted to make the goals of the lab as clear as possible in order to aid you in the design process.

1.3.1 Course Learning Objectives


The following is from the course outline. At the end of this course, the successful student will be able to:

1. Produces a variety of documents using appropriate format, grammar, and citation styles for technical and
non- technical audiences; Cites evidence to construct and support an argument (7a)

2. Uses technical knowledge, design methodology, and appropriate design tools and related resources (4a).
Distinguishes between different design steps and carries out steps; Analyzes/evaluates progress of design.
(4c)

3. Develops further knowledge of uses of modern instrumentation, data collection techniques, and equipment
to conduct experiments and obtain valid data (5a)

4. Applies statistical procedures; Verifies and validates experimental results; Assesses accuracy/precision of
results (5b)

5. Lists current tools for analysis, simulation, visualization, synthesis, and design, and is competent in using
them; Understands the accuracy/limitations of tools and verifies the results’ credibility (5c).

1-2 Edit Date: February 12, 2013


Note: Numbers in parentheses (e.g. 10a) refer to the graduate attributes required by the Canadian Engi-
neering Accreditation Board. For more information, see: http://www.feas.ryerson.ca/quality_assurance/
accreditation.pdf

1-3 Edit Date: February 12, 2013


1-4 Edit Date: February 12, 2013
Chapter 2

Semester Design Overview & Objectives

2.1 Straight to the Point


This semester you’re going to design, build and test a Data Acquisition System. This lab guide steps you
through the process. This chapter gives an overview of the requirements for the project by the end of the
semester.

2.2 Preamble
Although the evolution of the microcontroller began in late 1970s and early 1980s with the Intel 8048 and 8051
[10, 6], and the Motorola 6800-based 6801 [4] and, later, the 68HC11 [8] its cost outweighed the advantages at
first for use in high-volume smart instrumentation. With the advent, and rapid development, of high-density
CMOS based Integrated Circuit (IC) technology, the microcontroller has emerged as one of the fundamental
building blocks in electronics technology. In most modern instrumentation designs, digital signal processing and
control are increasingly replacing some of the traditional forms of analog signal processing/conditioning. This
has generally resulted in flexible product designs that tend to be reliable and cost-effective for mass production,
to have increased functionality on significantly smaller packaging footprints, and to be easily scalable. In tandem
with the microcontroller evolution, the CMOS technology has also led to the emergence of a host of “smart” IC
based sensors and transducers (e.g. accelerometer, pressure, force, temperature, humidity, position, proximity,
flow, etc.) giving designers perhaps a broader latitude to create sophisticated product designs.1
For today’s engineers, the myriad of IC based analog and digital devices in the marketplace has resulted in an
increased blurring of the line between traditionally analog and digital based instrumentation, thus demanding
confidence and proficiency in their abilities to apply knowledge to conjure up “neat” engineering solutions that
would most likely entail blending and integration of analog circuits and digital signal processing, high-density
and high-speed devices, smart transducers, effective PCB grounding/layout techniques, and so on. In such
instrumentation designs, optimization and trade-offs between microcontroller (or DSP) resources and analog
signal processing/ conditioning circuitry to meet product requirement specifications can often be daunting.
Thus, the main thrust behind this Major Project is to expose middle-level students to make effective design
and implementation choices (and trade-offs) to create an intelligent instrumentation that potentially embodies
state-of-the-art digital (e.g. microcontroller, smart sensors, etc.) and traditional analog (e.g. passive sensors,
stable amplifiers, signal conditioners, A/D, compensation networks, etc.) circuitry for a Cantilever Beam load
cell application used in industries like Aerospace, Automotive, Construction, etc.

1
Much of this material was originally written by Dr. Mike Kassam for ELE744 and, later, for ELE604. The original source for
this chapter was “ELE604 Sensors and Measurements Major Laboratory Project” by Dr. M. Kassam & Dr. J. Smith, Ryerson
University 2009

2-1
2.3 Jargon & Vocabulary
PWM Pulse-Width Modulation

Duty Cycle In a series of pulses, the duty cycle is the percentage of time that these pulses are “high” (generally
5 Volts) versus the period of the signal. So if a complete period is 0.5 seconds and the pulse is high for
0.1
0.1 seconds, the Duty Cycle (or Duty Factor) is 0.5 100% = 20%.

Strain Gauge also known as a strain-gage. This is a piece of metal attached to some substrate material under
test. As it bends the gauge will deform.

Strain Deformation of an object when forces are applied. It is unitless. Symbol: .

Stress Amount of force per unit area. Its units are the same as pressure. Symbol: σ.

Modulus of Elasticity A description of the tendency of an object’s deformation as force is applied. Units
are the same as pressure. Symbol: E.

MEMS Micro Electro-Mechanical System.

Accelerometer A device capable of sensing acceleration.

Microcontroller This is similar to a microprocessor except that it is designed with more features to sense
and actuate (i.e. to control) a task, like home temperature regulation or firing a spark plug in car. A
microprocessor is more general in nature.

2.4 Background
In aircraft, it is often desirable to continuously sense and monitor stress points [11] along the wing span, and
the resultant deflection or inclination angle relative to its unstressed or resting longitudinal axis. The principles
behind such types of measurements can be demonstrated and implemented using a simple cantilever beam setup
as shown in Figure 2.1. For simplicity, the measurement of stress on the beam is limited to a single point and
the deflection angle, θ as depicted in Fig. 2.2. Brief summaries of stress and angle measurement principles are
given below, and the students are urged to review the lecture material, suggested reference articles and sensor
datasheets to gain further insights.

2.4.1 Stress Measurement Technique


Figure 2.2 shows how an applied force, F can be converted to strain, , and corresponding resistance change
using dual strain-gauges for measurement. The cantilever beam assumes a semicircular shape because of the
applied force, the top surface of the beam elongates and the bottom compresses. Students should investigate
the design advantage of using two identical strain-gauges mounted on either side of the beam at a fixed point
location, noting that either upward or downward application of vertical force should cause one strain-gauge to
stretch and the other to compress.
The equation for stress is as follows:

6F L
σ= (2.1)
W t2
where σ is the stress, F is the applied force, L is the distance from the gauge to the applied force, W is the
width of the cantilever, and t is the thickness of the cantilever (see Fig. 2.2). Stress (σ) is expressed in Newtons
per square meter. The applied force is measured in Newtons. The related equation for strain is
σ
= . (2.2)
E

2-2 Edit Date: February 12, 2013


Figure 2.1: Simple cantilever beam schematic. (Courtesy Dr. Mike Kassam)
 

Figure 2.2: Cantilever beam under load (Courtesy Dr. Mike Kassam)
 

Since σ is in Newtons per square meter, and E, the Modulus of Elasticity is also, strain is unitless ratio. This
shows that the Stress (σ) at a given point is directly proportional to the applied force magnitude, F and the
force distance, L (or the bending moment F L); and indirectly proportional to the beam width, W and the
square of the beam thickness, t. With all distance measurements in meters and the force in newtons, the Stress
(σ) will be found in units of newtons per square meter. Since modulus of elasticity, E in newtons per square
meter is known for the beam material, this allows the Strain () in meters per meter to be calculated. Once
this is accomplished, the resulting increase or decrease in the resistance of the strain-gauges can be determined.
Conversely, if the strain-gauge characteristics (e.g. GF , Ro , etc.) and resistance changes are known, then the
Strain () can be easily determined from the strain-gauges resistance changes, and from which both the Stress
(σ) and F can be calculated using the beam’s Eand dimensional values, respectively. As can be noted from
the equations, when the product (W t2 ) related to the dimensional Modulus of the beam is assumed relatively
unchanged and the applied force, F is known, then the Stress/Strain values linearly increase from zero (at
the force application point) to their maximum values at the fixed pivot point, allowing extrapolation of the
Stress/Strain along the cantilever beam from just a single measurement.
Students are encouraged to investigate similar techniques used in designs of load cells or force transducers.
A robust circuitry incorporating bridge amplifiers, bridge balancing and temperature compensation techniques,
proper signal conditioning and interface need to be designed to ensure accurate and repeatable measurements
of very small changes in the strain-gauge resistances converted to D.C. voltages.

2-3 Edit Date: February 12, 2013


Strain-Gauges vs. Load Cells
Load cells are capable of measuring strain, just like strain-gauges, but are more integrated. They are generally
designed using strain gauges already affixed to a substrate. This substrate material (a cantilever beam, for
instance) is then affixed to the system under test. By using load cells instead of discrete strain gauges we
remove some of the complexities of preparing the metal substrate, aligning the gauge, adhering it to the metal,
wiring it and shielding the wire. This tends to increase the cost of the measurement apparatus, but is suitable
for prototyping and simple testing, as is the case in ELE604.
The ELE604 lab utilises a Futek LBB200, described in the datasheet in Fig. 2.3. Note that the loadcell
contains a four-arm resistive bridge: three fixed 1 kΩ resistances and a fourth, variable resistance (the strain-
gauge).

Figure 2.3: The Futek LBB200 load cell. We use the FSH00889, with 4.5 N capacity. (Courtesy of Futek)

2.4.2 Tilt Angle Measurement Technique


Micro Electrical Mechanical Systems (MEMS) IC technology has resulted in a new generation of MEMS devices
to add a wide variety of functionality to products such as cellphones, automobiles, GPS, gaming consoles,
pedometers, appliances, etc. These newer MEMS devices are tilt and motion sensors, commonly known as
accelerometers, and are constructed with few (e.g. Analog Devices ADXL330) or no moving parts (e.g. MEMSIC
2125). In ELE604 we use the MEMSIC 2125 dual-axis accelerometer.
The basic principle of operation of the 2125 is based on differential thermal sensing of a heated gas bubble
in a hermetically sealed IC part. Constructing of this MEMSIC sensor in a standard CMOS process has

2-4 Edit Date: February 12, 2013


significantly lowered cost, thereby opening up a host of applications. With no moving parts, this thermal-based
MEMSIC accelerometer sensor is capable of surviving the high shocks experienced with consumer gadgets
(e.g. cellphones), both in the field and during mass production, since it eliminates the traditional problems of
stiction2 and particle issues with previous generation of capacitive-based MEMS IC accelerometers. In addition
to the acceleration sensing technology, the MEMSIC IC offers “smarts” by incorporating signal processing
and conditioning using built-in analog/digital ASIC designs to deliver stable digital outputs in the form of
Pulse-Width Modulated (PWM) clock stream where the duty-cycles are directly proportional to induced
accelerations. Unlike passive sensors (e.g. strain-gage), these smart MEMS sensors do not require additional
signal conditioning circuits thereby significantly reducing the components overhead. These transducers do
provide for accurate and repeatable measurements, and are mostly standalone devices directly interfaceable to
any type of microcontroller. Both static (gravity and tilt) and dynamic (vibration and motion) accelerations
can be reliably detected with the MEMSIC transducers, and the students are urged to research and review
references on MEMSIC technology to grasp the principles of operation behind its thermal-based acceleration
sensing and signal conditioning.
The MEMSIC 2125 device is a low-cost, dual-axis (x and y) accelerometer capable of measuring static and
dynamic accelerations with a range of ±3g (i.e. ±29.43 m/s2 ). A common application of it is in dual-axis tilt or
angle sensing. When a tilt angle lies on a vertical plane defined by the sensing axes and gravitational vector, the
absolute inclination angle, θ (referenced to horizontal) can be measured from any initial accelerometer orienta-
tion. Students are encouraged to review the MEMS2125 specifications and references to properly understand
the geometry of the angle measurements depending on either a horizontal or vertical position of the MEMSic
device relative to the gravitational vector. For the angle measurement requirement for this Cantilever project,
students should confirm that single-axis inclination is best measured and resolved from a vertical mounting of
the MEMSic device whereby the Ax and Ay accelerometer outputs can be effectively combined to obtain a good
resolution of angles through the full 360◦ arc range.
Students should refer to the data sheet to analyze and establish the relationship between angle, θ, and the
change in pulse-width relative to the 50% duty cycle. In addition, investigate why use of single axis (x or y) can
only provide measurement from 0 to 90 deg., whereas creative use of both x and y axis can allow measurements
from 0 to 180 deg.

Figure 2.4: Inclination from vertical orientation of the MEMSIC 2125 device. The gravity vector, g is shown,
as are the vertical (y) and horizontal x references. (image courtesy of Dr. Mike Kassam)

2
stiction: “static friction”. This is the friction that holds an object in place against a surface prior to it moving. It’s observable
when you have a non-moving object on a horizontal surface (like a box on a table) and you push on it. The coefficient of friction
is relatively high and will hold the box in place until you reach a certain force threshold. At this point the box will start to move,
and you’ll discover that you do not need to push as hard to keep in moving. This is because the coefficient of dynamic friction is
lower than that of static friction (stiction).

2-5 Edit Date: February 12, 2013


2.5 Design Objectives & Specifications
2.5.1 General Design Objectives
Analyze, simulate, design, implement and test a 9s12 microcontroller based instrumentation device for a can-
tilever beam load cell and accelerometer data-logging application to meet the requirement specifications (given
in Section 2.5.2). This design and development exercise should embody the following:

• Robust analog signal processing and conditioning circuitry for the strain-gage measurements and conver-
sions to ensure accuracy, resolution and repeatability.

• Computational and resource efficient algorithms for the tilt-angle measurement with desired resolution
and update rate.

• Well designed software structure and efficient use of the 9s12 architecture resources to implement an
integrated solution for simultaneous “real-time” measurements and display of Stress, Force and Tilt-angle
parameters.

• Seamless execution of the required User functions in “real-time”.

• Use of proper measurement techniques to establish Accuracy, Repeatability, etc. characteristics of the
strain-gage sensor (refer to lecture material and Textbook).

• Properly conceived testing methodologies to validate the overall specifications.

• Well documented source-code and schematics.

• Formal technical report.

2.5.2 Specifications
The end-of-semester final project must be able to perform some very specific functions. They are listed below.
Your data-logging device will resemble the conceptual view shown in Fig 2.5.2a. This can take many different
forms, such as the example shown in Fig. 2.5.2b.

 
(a) Conceptual View (b) An example implementation

Figure 2.5: A conceptual view (a) of what your instrumentation system might look like from the outside (image
courtesy of Dr. Mike Kassam), versus an actual student implementation (b).

2-6 Edit Date: February 12, 2013


Functional Sequence of Operations
The sequence of operations is described in the list below and is shown visually in Fig. 2.5.2.

1. On Power-up, the names of the lab partners should appear on the LCD.

2. If the button is pressed twice, in quick succession, the LCD should show if the force and angles are in
“safe” or “dangerous” zones. No LEDs should be flashing. This should continue unless the user presses
the button once (to exit).

3. If the button was not pushed, or if the user has exited the other mode, the “Angle” LED should light-up
& flash indicating angle measurement in progress. The LCD display should display Angle in “real-time”,
as shown in Fig. 2.5.2a.

4. For Force selection, the user momentarily presses the Push-button once to light-up & flash the “Force”
LED, indicating Force measurement. The LCD display should display Force in “real-time”, as shown in
Fig. 2.5.2b.

5. When the user presses the Push-button again, only the “Force & Angle” LED is turned on and flashing,
with “real-time” display of the parameters, as shown in Fig. 2.5.2c.

6. When the user presses the Push-button again, the cycle reverts to displaying Angle.

7. If, at any point, the user presses the button for ten seconds or more the system should begin streaming
data to a PC where it can be read by Matlab. The LCD should display that PC communication is in
effect.

  (a) Displaying Angle   (b) Displaying Force   (c) Displaying Both

Figure 2.6: Some of the operations to display. (images courtesy of Dr. Mike Kassam)

Electrical and Mechanical Considerations


Force Should cover range (in a contiguous manner) to maximum weight of 0.5 LB or 230 grams (maximum
beam deflection of 0.28mm). Minimum accuracy of ±2 %, and maximum drift of < 1%/min at room
temperature is required. The “dangerous” zone is 200 grams or more.

Angle Using a separate test-jig, angle range should cover tilt of 0◦ to 180◦ (in a contiguous manner) from the
horizontal, with minimum resolution of 0.2◦ . The “dangerous” zone is 160◦ or more.

Deterministic “real-time” Update Rate Update or refresh rate for all measured values ≤ 30 msecs.

LED “Flashing” Rate 0.5 second ON, 0.5 second OFF.

Cantilever Beam: Test jig on each lab bench has the strain-gage sensors and resistors mounted on the can-
tilever beam (from Futek), configured as a full bridge

Load Cell / Strain-Gauge Gauge is pre-mounted on 17-4PH Stainless Steel; GF = 2.0; Ro = 1000 Ω.

Voltage Reference The stable bridge excitation voltage should be set to 10V d.c. using the 10V Voltage
Reference IC provided in your Kit.

2-7 Edit Date: February 12, 2013


Accelerometer MEMSIC2125: Refer to Datasheets.

Microcontroller Technological Arts 9s12 Esduino board: Refer to Datasheets and Lab Manual.

2.6 Suggested System Block Diagram

Oscilloscope test Digital volt meter Test


5 V power supply
equipment equipment

Pushbutton
LED
switch(es)
Digital Digital
input output
Accelerometer 9s12 LED

ADC SPI
LED

External Voltage
reference LCD Display

Balancing Analog input


Loadcell
circuitry stage protection

+15 V and -15 V


power supply

Figure 2.7: This is the suggested block diagram for the complete system.

2.7 Suggested References


• ELE604 Lecture Material and Lab handouts.

• ELE604 Course Text: “Principles of Measurement Systems by John Bentley, Prentice Hall, 4th Edition,
2005

• Mc9s12c family reference manual, by Freescale

• “Operational Amplifiers with Linear Integrated Circuits”, Stanley, Prentice-Hall., 2002.

• “ Transducers: Theory & Application”, Allocca & Stuart, Reston Publishing,

• “ Microelectronic Circuits”, Sedra and Smith, 5th edition, Oxford University Press, 2003.

• “ Applications of Analog Integrated Circuits”, Soclof, Prentice Hall., 1996

2-8 Edit Date: February 12, 2013


• “ A User’s Guide to IC Instrumentation Amplifiers”, App. Note AN-244,& “Error Budget Analysis in IA
Applications” AN-539, www.analog.com

• www.parallax.com website for MEMSic technical information and applications.

• Appl.-Note-#007 “Inclination Sensing with Thermal Accelerometers” & Appl.-Note-#001 “Accelerometer


Fundamentals” : www.memsic.com/memsic/products/product.asp?product=56

• “It’s All About Angles”, Column #92, www.nutsvolts.com.

• “Electronic Angle Measurement”, Circuit Cellar, Issue 179, June 2005, www.circuitcellar.com

• MEMS2125 Accelerometer datasheets

• “Pieces of the Puzzle” & “Measuring Gage Factor”, The Mechanics www.vishay.com/brands/measurements_
group/guide/notebook/e5/e5.html

• “Cantilever Bending Beam Load Cell” Specifications from Futek Advanced Sensor Technology Inc., www.
futek.com

• Datasheets for the strain-gauge, IA amplifiers, voltage reference, etc. can be found on the ELE604 Course
website.

2.8 Recommended Design and Measurement Process


• Undertake a thorough background research and analysis work on the sensor technologies to understand
their operating principles and interfacing/conversion requirements. Analyze and properly understand the
functionality and specifications of the Cantilever Beam project, and then develop a high-level conceptual
design the engineering solution. Understand and analyze the design of the 9s12 based microcontroller
board, and make notes on the functionality, role and interfacing of all the logic devices around the 9s12
microcontroller.

• Populate and solder the microcontroller’s main components, fully test the microcontroller board and 9s12
operations, and the embedded Serial Monitor. Understand the architecture resources of the 9s12 (e.g.
Input Capture, Output Compare, Analogue to Digital Converter, Timers, Interrupt structure, etc.) to
formulate a proper software structure solution for the instrumentation requirements.

• Design, implement and test the push-button switch and the LEDs, together with your source-code to
monitor the switch and drive the LEDs,

• Develop a detailed high-level flow chart or pseudo-code for your software structure. Keep in mind that
while it is prudent to test the Strain-gage and accelerometer sensors independently, your software structure
should take into account the requirement of concurrent measurements in “real-time”. Dedicated in-code
algorithm and table-look-up schemes need to be used to meet the “real-time” specifications.

• Develop the interface and algorithms for the Tilt-Angle measurement (refer to the Lab Assignment Sheet).
Use the test-jig provided in the Lab to test your design, and make the appropriate measurements to validate
the specifications.

• From your design analysis, use MapleSim software package to capture and simulate your designs for the
various analog signal processing/conditioning circuitry required to reliably measure the Force (and stress)
on the Cantilever beam (refer to the Lab Assignment Sheet). Familiarize yourselves with the finer details
of the cantilever beam test jig supplied in the Lab. Compare the simulated results with your theoretical
analysis & predictions. Generate and plot all the relevant signals.

2-9 Edit Date: February 12, 2013


• Once the simulation results are verified, draw detailed schematics of your design, and then implement
the physical hardware and thoroughly test your design. After the strain-gage sensor circuitry is properly
balanced (refer to the Lab Assignment Sheet), you need to use appropriate measurement techniques (refer
to Lecture material and Textbook) to establish the Accuracy, Repeatability, etc. characteristics of your
strain-gage sensor & circuitry that provide the Force measurement.

• Once the Angle and Force (or Stress) functions are independently tested, your source-code should be
evolved to integrate both sets of measurements to realize the full functionality of the instrumentation.
Make appropriate measurements to your integrated design to validate compliance to the desired specifi-
cations.

• Prepare a formal technical report as per the guidelines provided. One formal report per Lab group is
required (limited to maximum of 12 pages, not including source code, references, and Appendix)

2.9 Schedule
The schedule is outline in Fig. 2.8.
Note: Failure to submit and/or demonstrate the above deliverables as scheduled will result in an automatic
zero mark for each of the missed milestone. No exceptions.

2.10 Grading Scheme


We have endeavoured to make the grading scheme for each lab as clear as possible by including a marking guide
at the end of chapters in which it is appropriate.

2.11 Report Writing


You are expected to follow IEEE-style templates when writing your lab reports. You are also required to include
an official FEAS cover sheet (signed) with each report.

2-10 Edit Date: February 12, 2013


Week Title Detail Time Room Angle Sensing
2 Heartbeats and When starting to use a new 2 Hours ENG 307 Lab: In Weeks 9 and 10, Analysis,
Time-Keeping microcontroller there are two keys design and implementation of
things that you need to set up: a accelerometer H/W & S/W to
“heartbeat” light and an accurate display Angle as per specifications.
clock. In this lab, you’ll end up doing Obtain test results. Analysis, design
both. and simulations of strain-gage
circuitry. In Week 11, oral & demo
An introduction to the lab will be to Lab Instr. during scheduled lab
done, including an overview of session:- Demonstrate ANGLE
safety and equipment. measurement function as per
3 Displaying Data You’ve got to display the data that’s 2 Hours ENG 307 specification. Submit test results,
Part 1 – Serial to processed in your Data Acquisition algorithms and source-code listing.
PC System. The PC is a good device for In Week 11, submit Milestone: test
this because it’s powerful, especially results, algorithms and source-code
when leveraged with software like listing in IEEE format, with IEEE-
Matlab.
style references.
4 Displaying Data You need to be able to display 2 Hours ENG 307
12,13,14 Integration & Pre-lab: Schedule presentation time 6 Hours n/a
Part 2 – Onboard measurement data directly on your
Esduino board when taking Demonstration with lab instructor.
LCD
measurements. Here, you’ll build an
add-on board with a Liquid Crystal Lab: In week 12, Work on
Display (LCD). integrating the Angle and Force
5 Milestone 1: In Week 2 you implemented code to 2 Hours ENG 307 functions, per the specifications. In
flash an LED. This week you’ll design week 13, complete demonstration of
Switches and
a hardware LED driver and learn how all functions per specifications.
LEDs Seamless deterministic/real-time
to avoid the biggest problem with
switches: contact bounce! MapleSim execution of all functions, and any

2-11
will be used for design. enhancements implemented. Final
6,8 Strain Gauge test Pre-lab: Prepare Milestone 2 4 Hours n/a source-code version to be
documentation. compiled/assembled during the
demo. A printed copy to be
Lab: In Week 6, implement and test submitted to Lab Instructor. Submit
analog circuitry design for strain- Milestone 4 in week 13: Show final
gage, and then interface to schematic, algorithms (including
microcontroller. Implement S/W to flow-chart) and test results. Wrap
provide FORCE function per up design in Week 14.
specifications. Undertake the
measurements to characterize the Post-lab: Hand in Milestone 5 (Final
strain-gage sensor & circuitry. Report) by email to TA by last day
Continue to work on integrating of classes at 11:59pm (i.e. before
FORCE & ANGLE functions per final exams). Only one formal report
specifications. In Week 8, per group is required (following

Figure 2.8: Schedule (from the course outline)


demonstrate FORCE measurement IEEE format for document and
functions as per specifications & referencing). Reports will be graded
provide your measurement data & as per the marking scheme.
analysis on Accuracy, Repeatability,
etc of the sensor. Submit Milestone
2: test results, algorithms and
source-code listing.
9,10,11 Accelerometer Pre-lab: Prepare Milestone 4 6 Hours n/a
documentation.

Edit Date: February 12, 2013


2-12 Edit Date: February 12, 2013
Chapter 3

Equipment & Tools

3.1 Equipment & Tools


3.1.1 The Tools
You will be using a number of important tools in the course of your lab work. They are shown in Fig 3.1.1. These
include a dual voltage power supply, a function generator, a bench-top multimeter, an oscilloscope, a soldering
iron and a ventilator / fume hood. The teaching assistants and technical staff will go over the equipment with
you. Please feel free to ask any questions you may have to them.

3.1.2 The Sensors


There are two main sensor used in this lab, a load cell and an accelerometer. Both are described in some detail
in the previous chapter, as well as in the appendix.

The Load cell

The load cell is effectively a pre-packaged strain gauge mounted on a cantilever (bending) beam. We will be
going over strain gauge theory in the class. At this point it is sufficient to say that the resistance of the load
cell’s strain gauge changes as the beam bends. You can use this to determine a relationship between the force
applied to bend the beam and the changing voltage that is output by the load cell.

The test jig

The test jig is set up to permit you to hang small masses off of it. Do not overload it beyond the capacity (as
detailed by the TAs and technical staff).

The Accelerometer

The MEMSic accelerometer is described in the previous chapter. Additional information can be found in the
Appendix and online. Given that the part is sold by Parallax, there is a surprising amount of online resources
for you to examine.

The test jig

You will provided with a test jig that will permit you to rotate the accelerometer in a vertical plane. You will
attach your own accelerometer to this test jig, which includes a protractor for visually estimating the angle.

3-1
3.1.3 The Microcontroller
Introduction
Microcontrollers are useful devices for creating embedded systems – engineered products that interact with us
in often mundane but eminently useful ways. The next time you use a public toilet (see Fig. 3.3) and it flushes
itself you can thank the microcontroller embedded in it.
In the late 1990s a series of 8bit HC11 microcontroller boards were introduced into the EE and COE
curriculum at Ryerson [9]. These 8bit devices were best-in-class for teaching a series of courses involving
embedded microprocessors and microcontrollers. Even our colleagues in Mechanical Engineering are using
these HC11s! However, starting in 2009, we began to look for alternatives since Freescale had categorized the
HC11 as “not suitable for new designs”. After examining a number of options (ARM, AVR, PIC, 8051, etc.) the
“NewRyeMicro” committee realized that the HC11’s descendant, the Freescale 9s12, was the superior choice.
Like the HC11 before it, the 9s12 is designed for automotive and industrial use, but the lessons-learned are
notable: better debugging methods, smaller chips, tighter integration of onboard modules, true 16bit operation,
onboard flash, etc. Many of the support components required for useful operation of the HC11 are no longer
needed, or are found onboard the 9s12. Plus, many of our in-house technical and teaching resources could be
easily adapted to the new processor.

The Freescale 9s12


The MC9s12 C32CFAE25 variant of the 9s12 that we use has 32k of Flash, 2k of RAM, 4 MHz clock1 and a 48
pin LQFP package. It has support for SPI (Serial Comms to Devices), SCI (Serial Comms to Host Computer),
A/D (Analogue to Digital Conversion), PWM (Pulse Width Modulation) and Timers [15].
Why are we using the Freescale 9s12? There are a number of reasons.

1. Best documentation. Freescale’s technical documentation, as well as the undergraduate-level textbook


quantity and quality are unrivalled. For example, there are few ARM textbooks on the market and most
are aimed at more advanced students or professionals2 . There are more books on the HC12/9s12, and
most are aimed squarely at mid-level undergraduate students like yourselves. Even better, the number of
resources increases if you include the related HC11 and HC16. This is because 9s12 pedagogical resources
are often derived from HC11 resources developed in the 1980s and 1990s. There have been 20 - 30 years
to refine this material.

2. Local resources. The 9s12 board we use, the Esduino, is designed, manufactured and supported by a
Mississauga-based company. We’ve had in-person meetings with the designer, Mr. Carl Barnes, and he
has been very responsive to our needs. Stores like Creatron stock the Esduino and support components.

3. Form-factor. The AVR-based Arduino has been a game-changer in the hobbiest market3 . It is immensely
popular and has spawned the development of countless main and application (“shield”) boards. We are
leveraging the Arduino’s physical layout with the Esduino, allowing you to use most Arduino shields with
your project, if you so choose.

4. Local education. Most of you already have a background on the 9s12 from COE538. While it’s not a
prerequisite, it is certainly advantageous here.

5. Real-world use. The 9s12 is found in many automotive applications, where hard real-time operation is
required. The next time you fire-up your BMW or Mini Cooper it could be a 9s12 running your engine.
1
The 9s12 microcontroller is 4MHz, but is 25MHz when phase-locked-loop (PLL) is activated. It’s 25MHz when running under
Codewarrior “Load” - serial monitor
2
ARM texts: http://www.keil.com/books/armbooks.asp
3
For an excellent explanation for why the Arduino changed the microcontroller market refer to http://blog.makezine.com/
archive/2011/02/why-the-arduino-won-and-why-its-here-to-stay.html

3-2 Edit Date: February 12, 2013


That said, there are plenty of alternatives to the 9s12 including:

PIC The 16-bit versions fixed architectural problems in the original 8-bit PICs. The 16-bit are also more
prototype friendly than the 32-bit versions due to DIP packaging.

8051 These 8-bit processors are sold by a number of different companies and have been around since the 1980s.

AVR These 8- and 32-bit micros are very popular with hobbyists, in large part due to the Arduino boards.

ARM Hugely popular in high-end embedded systems like cellular telephones. These 32-bit systems generally
need an operating system and are not for beginners.

PowerPC Like ARM, these are 32-bit, and are not recommended for beginners. They’re found in the XBox
360 and Wii, as well as in automotive applications.

Coldfire Originally descended from the Motorola 68000 family (think Amiga and earliest Macintosh comput-
ers), these are 32-bit, and are not recommended for beginners.

HC08 These are smaller, less powerful (8-bit) Freescale processors often found in automotive applications.

The 9s12 strikes a good balance between power, cost and development resources. You will be able to use
it for ELE604, as well as other courses like the fourth year Engineering Design Project (ELE700/800). It will
also provide you with the right framework for using other microcontrollers and microprocessors, like the PIC
or ARM, in the future.
In future designs work, you should be open to all microcontroller options. Most are just as capable to
perform basic tasks as the others. Most have the same hardware features (UARTs, timers, ADCs) as the
others. The differences are subtle and should be examined with care.

The Technological Arts Esduino: from AVR to 9s12


Microcontroller development systems, like the can cost thousands of dollars, often putting them out of reach
of students and hobbyists. Furthermore, the software development tools were costly and had steep learning
curves. A few years ago, the AVR-based Arduino changed that. This 8-bit system developed in Italy, combined
a slick user interface (which hid many of the gory details of initializing the hardware) with a good price tag:
under $50. It was a hit with hobbyists, developers and researchers – many of whom had no engineering or
computer science background.
The groundswell in interest led to an array of end-user-designed application boards, called “shields”. There
now exist shields for GPS, Zigbee, driving LEDs and motors, gaming interfaces, displays, etc. These readily
available and adaptable shields make the Arduino platform even more appealing as it permits engineers like
yourselves to explore new designs and applications with fewer limitations.
However, the Arduino’s core is an 8-bit AVR microcontroller which doesn’t have the pedagogical resources
that the 16-bit 9s12 does. So, Technological Arts has released a “best of both worlds” 9s12 board, that is
hardware compatible with Arduino shields, but which offers more computational and pedagogical “oumph”.

9s12 History
1. Motorola 6800 (8-bit; 1974 [4, 7])

(a) Motorola 6805 (8-bit)


i. Motorola HC08 (8-bit)
ii. Freescale 9s08 (8-bit)
(b) Motorola 68HC11 (8-bit; 1985)
i. 68HC16 (16-bit with DSP)

3-3 Edit Date: February 12, 2013


ii. 68HC12 (16-bit; 1996 [17])
A. HCS12 (16-bit; 2000 [13])4
B. S12X (16-bit, with RISC co-proc.; 2004 [14])

Resources

1. The original HC11 IPB construction guide: http://www.ee.ryerson.ca/~jkoch/ele744_2005/Assembly/


Steps_Index.html

2. http://uhaweb.hartford.edu/jmhill/suppnotes/

3. Freescale University Programs: http://www.freescale.com/webapp/sps/site/homepage.jsp?nodeId=


06258A&tid=CEV20070620UNIVPROG

4. Software for Tech. Arts 9s12c32: http://www.freescale.com/webapp/sps/site/overview.jsp?nodeId=


06258A258025700498 or http://www.ece.utexas.edu/~valvano/metrowerks/

5. Planning on doing an extra-curricular student project? Freescale sponsors them: http://www.freescale.


com/webapp/sps/site/overview.jsp?nodeId=06258A258025752572

6. Courseware: http://www.freescale.com/webapp/sps/site/overview.jsp?nodeId=06258A2580257B

3.1.4 Circuits
Circuits will be prototyped on “breadboards”. This means that the design can be easily modified and tested
without having to solder. The breadboards provided in your lab kit can be taped to the small printed circuit
“proto” boards that are Esduino compatible. So you can even test the circuit while it is mounted on the
Esduino. Then, if you appropriate, you can remove the breadboard and directly solder to the protoboard.
The LCD board, for instance, will be made of a soldered protoboard without prototyping on a breadboard
first. You will also attach switches and LEDs to this protoboard.

3.1.5 The Packaging


You will be strongly encouraged to develop packaging for your sensing and measurement system. You can use
metal or plastic cases, for instance; you can add a lid and connectors on the case’s wall. Examples of off-the-shelf
cases that you can use include Pelican cases or Otter boxes, tin cans, electrical junction boxes, etc. These can
be found at hardware stores and outdoor stores.

3.1.6 Tools: Software


Programming the Microcontroller: Codewarrior

We use Codewarrior to program the 9s12. Most of you will have taken COE538, in which the 9s12 has been
introduced. The variant of the 9s12 that we use is similar but has a slightly different memory structure. There
are also fewer pins and resources on this version of the chip. A number of guides for using Codewarrior and
Assembler are found in the Appendix. A short introduction on how to get set up is found in the next chapter.
4
The HCS12 family includes the 9s12 parts, the first being the MC9S12DP256. [13]

3-4 Edit Date: February 12, 2013


Simulations
Simulators are important tools in the development process. In this course we use two simulation systems:
Codewarrior’s built-in simulator for the 9s12 and MapleSim for conducting simulations for analogue component
design. The Codewarrior simulator is engaged by simply changing the “target” for debugging (in the IDE) from
the Serial Monitor. MapleSim is available on the lab computers. There are two tutorials in the Appendix for
MapleSim: one for a simple sine-driven resistor and one for a BJT-driven LED (similar to what is required in
your design). They can be found in Appendix E.

3-5 Edit Date: February 12, 2013


(a) Power Supply (b) Function Generator

(c) Multimeter (Bench-top) (d) Oscilloscope

(e) Soldering Iron and Ventilator

Figure 3.1: Each lab bench is supplied with key tools: (a) A variable power supply, capable of ± 15 VDC
output, (b) a function genertor for providing 5VDC pulses to your microcontroller, (c) a multimeter for testing
resistance and (primarily DC) voltage signals and power lines, (d) an oscilloscope for examining time-varying
voltages, and (e) a soldering iron and ventilator.

3-6 Edit Date: February 12, 2013


Data Sheets
16-bit Microcontrollers Features Benefits 9S12C32DGV1 MC9S12C32 Device User Guide

Clock Reset Generator Module 9S12DP256BDGV2 MC9S12A256 Device Guide


S12DP256BPIMV2 MC9S12A256 Port Integration Module
> Clock monitor > Reliable, robust operation

MC9S12C32
Block Guide
> Clock generation > Provides high performance using cost-effective S12ATD10B8CV2 HCS12 10-bit 8-channel Analog to
reference crystals Digital Block Guide
> Reset generation
S12BDMV4 HCS12 Background Debug (BDM)
> Reduces generated noise Block Guide
> Phase-lock loop (PLL) clock
frequency multiplier > Reduces power consumption S12BKVD1 HCS12 Breakpoint (BKP) Block Guide
> Limp home mode > Easily able to implement real-time clock S12CPUV2 HCS12 CPU Reference Manual
S12CRGV2 HCS12 Clock Reset Generator
> Real-time interrupt Block Guide
Target Applications > Watchdog S12ECT16B8CV1 HCS12 16-bit 8-channel Enhanced
Features Benefits Capture Timer Block Guide
> Automotive applications 8-bit or 16-bit Pulse Width Modulation (PWM)
High-Performance 16-bit HCS12 CPU Core S12EETS4KV2 HCS12 4K EEPROM Block Guide
> Industrial control > 6-channel, 8-bit or 3-channel, 16-bit PWM > Efficiently implement motor control, battery S12FTS256KV2 HCS12 256K Flash Block Guide
> 25 MHz bus operation at 3.3V to 5V for > Opcode compatible with the 68HC11 charging or digital-to-analog (DAC) functions
40 ns minimum instruction cycle time and 68HC12 > PWM supports center-aligned or S12IICV2 HCS12 I2C Block Guide
left-aligned output S12INTV1 HCS12 Interrupt (INT) Block Guide
> C-optimized architecture produces extremely
compact code > Separate control for each pulse width S12MEBIV3 HCS12 Multiplexed External Bus
Overview and duty cycle Interface (MEBI) Block Guide
On-Chip Debug Interface
Freescale Semiconductor’s HCS12 family of > Programmable clock select logic with a wide S12MMCV4 HCS12 Module Mapping
> Single-wire background debug mode > Real-time emulation of MCU functions at full Control (MMC) Block Guide
range of frequencies
microcontrollers (MCUs) is the next generation operating voltage and frequency range with no S12PWM8B8CV1 HCS12 8-bit 8-channel Pulse-Width
> On-chip trace buffer with nine flexible trigger limitations like traditional emulators > Fast emergency shutdown input Modulator Block Guide
of the highly successful 68HC12 architecture. modes and multiple hardware breakpoints
> Real-time in-circuit emulation and debug One Serial Communications Interface S12SCIV2 HCS12 Serial Communications
Using Freescale’s industry-leading, 0.25 µs Flash, > Non-intrusive emulation without expensive and cumbersome Interface Block Guide
box emulators > 8192 prescaler option > Asynchronous communication between the S12SPIV2 HCS12 Serial Peripheral Interface
the MC9S12C32 is part of a pin-compatible MCU and a terminal, computer or a network Block Guide
> Read/write memory and registers while of MCUs
family that scales from 32 KB to 128 KB of running at full speed S12VREGV1 HCS12 Voltage Regulator Block Guide
> Exact baud rate matching
Flash memory. The MC9S12C32 provides an > Bus state analysis without the expense of a
upward migration path from Freescale’s traditional emulator One Serial Peripheral Interface

68HC08, 68HC11 and 68HC12 architectures Network Module > Up to 6.25 Mbps > High-speed synchronous communication Cost-Effective Development Tools
between multiple MCUs or between MCU For more information on development tools, please refer to
for applications that need large memory, many > One MSCAN module implementing the CAN 0 > Programmable bit rate up to 1 Mbps and serial peripherals the Freescale Development Tool Selector Guide (SG1011).
A/B protocol
peripherals and high performance. > FIFO receive approach superior for Up to 58 Input/Output (I/O) Lines M68MOD912C32 MC9S12C32 MCU module board;
• Five receive buffers per module with FIFO event-driven networks $24.95 stand-alone MCU board in a 32-pin
storage scheme > Programmable pull-ups/pull-downs > Reduced system cost DIP form factor
• Three transmit buffers per module with > Dual drive capability > Ability to tailor application for minimum EMC M68DKIT912C32 MC9S12C32 demo kit that
internal prioritization or high current loads $49.95 includes docking board,
M68MOD912C32 and
Integrated Third-Generation Flash Memory power supply
> In-application reprogrammable > Flexibility to change code in the field Application Notes and Engineering Bulletins M68DKIT912C32-E Universal Power supply included
> Self-timed, fast programming > Efficient end of line programming $64.95
AN2206 Security and Protection on the HCS12 Family
• Fast Flash page erase—20 ms (512 bytes) > Total program time for 128 KB code is less M68EVB912C32 Evaluation board for development
AN1280 Using and Extending D-Bug12 Routines $150 and evaluation of MC9S12C32
than five seconds
• Can program 16 bits in 20 µs while in AN2255 MSCAN Low-Power Applications application code
burst mode > Reduces production programming cost
HCS12 CPU M68EVB912C32E Universal Power supply included
through ultra-fast programming AN2287 HCS12 External Bus Design
> 3.3V to 5V Flash program/erase/read $170
> No external high voltage or charge pump AN2302 EEPROM Emulation for the MC9S12C32
SCI > Flash granularity—512 byte Flash erase/ M68CYCLONEPRO HC08/HCS08/HC12/HCS12
32 KB Flash required
2 byte Flash program BCANPSV2.0 Bosch Controller Area Network (CAN) Version 2.0 Protocol Standard $499 stand-alone Flash programmer or
> Virtual EEPROM implementation, Flash array in-circuit emulator, debugger, Flash
SPI > Flexible block protection and security usable for EE extension HCS12CFAMILYPP HCS12 C-Family Product Proposal programmer; USB, serial or Ethernet
interface options
2 KB RAM 10-bit Analog-to-Digital Converter (ADC)
Vreg USBMULTILINKBDM Universal HCS08/HCS12 in-circuit
3.3V to 5V > One 8-channel ADC > Fast, easy conversion from analog $99 emulator, debugger, and Flash
Internal Bus

inputs like temperature, pressure Package Options 48-Pin LQFP programmer; USB PC interface
ATDO > 7 µs, 10-bit single conversion time; scan and fluid levels to digital values 0.5 mm Pitch
10-Key Wake-Up 10-bit, 8-ch. mode available for CPU processing Part Number Package Temp. Range 7 mm x 7 mm Body
80-Lead QFP/LQFP CWX-H12-SE CodeWarrior™ Special Edition for
IRQ Ports MC9S12C32CFA 48 LQFP -40˚C to +85˚C
0.65 mm Pitch Free HCS12 MCUs; includes integrated
Timer Module MC9S12C32VFA 48 LQFP -40˚C to +105˚C 14 mm x 14 mm Body development environment (IDE),
Timer MC9S12C32MFA 48 LQFP -40˚C to +125˚C
> 8-channel timer, each channel configurable as > Flexible, programmable linker, debugger, unlimited
16-bit, 8-ch. MC9S12C32CPB 52 LQFP -40˚C to +85˚C 52-Pin LQFP
DBG12 either input capture or output compare timer system 0.65 mm Pitch
assembler, Processor Expert™
MC9S12C32VPB 52 LQFP -40˚C to +105˚C
10 mm x 10 mm Body auto-code generator, full-chip
MC9S12C32MPB 52 LQFP -40˚C to +125˚C
> Simple pulse width modulation simulation and limited C compiler
1 x CAN MC9S12C32CFU 80 QFP -40˚C to +85˚C
PWM (PWM) mode
2.0 A/B 8-ch., 6-ch./16-bit, 3-ch. MC9S12C32VFU 80 QFP -40˚C to +105˚C
> 16-bit pulse accumulator MC9S12C32MFU 80 QFP -40˚C to +125˚C

Learn More: For more information about Freescale products, please visit www.freescale.com.

Freescale™ and the Freescale logo are trademarks of Freescale Semiconductor, Inc. All other product or service names
are the property of their respective owners. This product incorporates SuperFlash® technology licensed from SST.
© Freescale Semiconductor, Inc. 2005
Document Number: MC9S12C32FS
REV 1

Figure 3.2: The promotional datasheet for the 9s12 variant used on the Esduino

(a) AED and Ticket Machine (b) Toilet (c) Car (d) Legged Robot

Figure 3.3: Applications of embedded systems: (a) an Automated External Defibrillator and transit ticket
machine, (b) an automated toilet, (c) a car and (d) a robot.

3-7 Edit Date: February 12, 2013


Device User Guide — 9S12C128DGV1/D V01.05

Device User Guide — 9S12C128DGV1/D V01.05

PP5/KWP5/PW5

PM0/RXCAN
PM1/TXCAN
PM2/MISO

PM4/MOSI
$0000 1K Register Space

PM5/SCK

PS0/RXD
PS1/TXD
PAGE MAP

PM3/SS
VDDX
$03FF Mappable to any 2K Boundary

VSSX

VSSA
$0000
$0400

$3800 $3800 2K Bytes RAM

48
47
46
45
44
43
42
41
40
39
38
37
PW0/IOC0/PT0 1 36 VRH
$3FFF Mappable to any 2K Boundary
$4000
PW1/IOC1/PT1 2 35 VDDA
PW2/IOC2/PT2 3 34 PAD07/AN07
$3E
PW3/IOC3/PT3 4 33 PAD06/AN06
VDD1 5 32 PAD05/AN05
$8000
$8000 VSS1 6 MC9S12C-Family 31 PAD04/AN04
MC9S12GC-Family PAD03/AN03
16K Page Window PW4/IOC4/PT4 7 30
EXT 2 * 16K Flash EEPROM Pages PPAGE
IOC5/PT5 8 29 PAD02/AN02
$BFFF
IOC6/PT6 9 28 PAD01/AN01
$C000
$C000 16K Fixed Flash EEPROM
IOC7/PT7 10 27 PAD00/AN00
MODC/BKGD 11 26 PA0
$3F
$FFFF
$FF00 BDM PB4 12 25 XIRQ/PE0
13
14
15
16
17
18
19
20
21
22
23
24
$FF00 (If Active)
$FFFF VECTORS VECTORS VECTORS $FFFF

NORMAL EXPANDED SPECIAL


XCLKS/PE7
ECLK/PE4
VSSR
VDDR
RESET
VDDPLL
XFC
VSSPLL
EXTAL
XTAL
TEST/VPP
IRQ/PE1
SINGLE CHIP SINGLE CHIP

The figure shows a useful map, which is not the map out of reset. After reset the map is:
$0000 - $03FF: Register Space
$0800 - $0FFF: 2K RAM
Flash Erase Sector Size is 512 Bytes

(a) Memory
Figure 1-5 MC9S12C32 and MC9S12GC32 Map
User Configurable Memory Map (b) Pin Layout

Figure 3.4: The memory map and pin layout of the MC9S12C32 processor used on the Esduino. From [?]
Figure 2-3 Pin Assignments in 48 LQFP for MC9S12C-Family

32

54

3-8 Edit Date: February 12, 2013


[JB4] TX/RX Communications Routing:
Place two shunts in the positions shown Esduino
US = USB-to-SCI (of the MCU) 9S12C-based Arduino-compatible*
When Xbee Option is present: Rev. 1
UX = USB-to-Xbee (for configuring via Host) [JB3]: Digital11 Source
SX = SCI-to-Xbee (for wireless communications) 1-2 (left): PM4
[U4]: Serial Memory [JB2]: Digital10 Source 1-3 (down): PP5 (PAD1)
Footprint for optional 1-2 (left): PT4 1-4 (right): PT5
[J14][J15]: USB2MCU module goes here, SPI memory device. 2-3 (right): PM3
to provide USB interface to host PC; [D2]: User LED [U1]:
or supply your own TTL-level signals (on DIG13) Freescale 9S12C 16-bit microcontroller
to/from Host
[JB8] PS/PM SELECT:

PT3
PT7
PT6
PT2
PT1

PM5
PM2
PAD07
PAD06
DIG1
DIG0

PT0
Select between PS0/PS1
J14 US JB4
GND J3 and PM0/PM1 assignments
[J9][J10]: [Xbee Option]

>
<

D2
+5V

J1
for DIG0 and DIG1 pins

D13
D12
D11
D10
D9P
D8
D7
D4
Plug ADXB here for XBee Interface U4

GND
DTR

SX UX
UX SX
AREF
PT4 PM3 S M
(3V/5V compatible). SPI [J11] BDM IN:
DIG11

PWM D6
PWM D5
<TX US J6 C17
D2 JB2

1 PWM D3
GND J15 DI PM4 PT5
JB8
[J6]: SPI peripheral connector Standard 6-pin Background
RX > ADXB +5 JB3
SPI signals, Output Enable, +5V, J10 Esduino Debug Mode connector for
SCK
PP5
JB1
BDM IN
and Ground are all brought out to www.TechnologicalArts.com advanced debugging use
SS* R5 J11 LOAD
VIN C6
this convenient connector for easy OE* J5 JB6 SW1
USB [SW1 and JB6]:
interfacing to SPI peripherals DO C5 MAN
PB4 R1
G C7
When JB6 set to MAN, use SW1 to
[JB1]: 5V Source Selector PWR PE7 select Serial Monitor mode.
D3 C10
AUTO RUN
PE4
1-2 (lower): 5V from USB Y1 When JB6 set to AUTO, Serial
U1
R6 D1 PA0 R3
J8

3-9
2-3 (upper): 5V from U1 via VIN C1 C11 PM0 Monitor mode must be controlled

+
J9 Y2 JB5 PM1
[D1]: Power indicator LED by host via DTR line on serial port.
R2 3V 5V J7 AN7
J12 C16 VDD VRH AR
AN6
C15 C14 JB7
[J7] PB4, PE7,PE4,PA0: C9 [J8] PM0 - PM1:
U3
Four bonus Digital pins. RESET +
VIN
AN0
AN1
AN2
AN3
AN4
AN5

GND
GND

3V3 5V Two bonus Digital pins;


J2

J4

may be used with an external

SW2
REV. 1 J13
[U3]: 3.3V regulator (800 mA max.) transceiver to implement a
CAN interface.
PAD00
PAD01
PAD02
PAD05

PAD03
PAD04

[J7] AN6 - AN7:


[SW2]: Reset button [JB5]: 3V/5V Operation [J2] AN0 - AN1: Two bonus Analog Inputs;
1-2 (left): 3.3V Six Analog Inputs;
Power Configurations: may be used as digital
2-3 (right): 5V Any of these may be
Instead of deriving 5V to power the board from the USB Host inputs or outputs instead
connection, it can be derived from on-board regulator U1. used as digital inputs
Two different power connections are provided: J12 and J13. or outputs instead
The 2-pin J13 Molex connector is the default, while J12 is an
Order Codes:
optional barrel jack connector (2.1mm center-positive) ESD12C32 (with 9S12C32; surface-mount devices only)
compatible with most common AC-to-DC adapters. If J12 is ESD12C128 (with 9S12C128; surface-mount devices only)
present, and a voltage supply is plugged in, it will ESD12C32-KIT (ESD12C32 plus kit of through-hole parts)
automatically override J13. The applied voltage (VIN) can be ESD12C128-KIT (ESD12C128 plus kit of through-hole parts)
anywhere in the range of 7 to 15V DC. To choose VIN as ESD12C32-UR (fully assembled with 9S12C32, USB2MCU and connectors)
the source of system 5V (via regulator U1), set jumper block ESD12C128-UR (fully assembled with 9S12C128, USB2MCU and connectors)
JB1 to the 2-3 (upper) position. * Footprint and pinout are compatible with
standard Arduino-style shields; Arduino
www.TechnologicalArts.com software environment support pending. JANUARY 2011

Figure 3.5: The Esduino functionality is displayed here. Layout (Rev 1) courtesy of Technological Arts.

Edit Date: February 12, 2013


http://www.ee.ryerson.ca:8080/~jkoch/supplier.html

Suppliers
Digi-Key

Edmund Scientific Company

Electro Sonic

Future Electronics

Jameco

Mondial Electronics INC

Mouser Electronics

NEWARK

Self Serve Electronic Parts and Accessory Stores


Etobicoke

A-1 Electronics Parts 196 North Queen Street (416) 255-0343 www.a1parts.com

Mississauga

RTC Electronics 1350 Matheson Blvd. Unit 10A (905) 624-9986


AA Electronics 1350 Matheson Blvd. Unit 8 (905) 206-0931
Sayal Electronics 1350 Matheson Blvd. Units 3-4 (905) 238-8640 www.sayal.com
DNP Technologies 7-5015 Maingate Drive (905) 625-3353 www.dnptechnologies.com

North East

Electro Sonic 1100 Gordon Baker Rd (416) 494-1555 www.e-sonic.com


Active Tech 3790 Victoria Park Avenue, Suite #100 (416) 498-9886 www.active123.com
Sayal Electronics 3791 Victoria Park Ave. Units 1- 5 (416) 494-8999 www.sayal.com

Toronto

Electronic Surplus Industries Ltd. 53 Sheffield Street (416) 240-1950


Active Surplus Annex 345 Queen Street West (416) 593-0967 www.activesurplus.com
Honson Computer 306 College Street (416) 922-1158 http://www.honson.com
Creatron Inc. 255 College Street (416) 977-9258 Creatron Inc

Hardware Stores
Polytechnic Hardware 131 Dundas Street East, Toronto (416) 350-7272

Hobby Shops
John's Hobbies 2188 Danforth Ave, Toronto (416) 421-1850 John's Hobbies
Panther Hobbies & Trains 2580 Wharton Glen Ave., Mississauga (905) 848-0743 www.pantherhobbies.com
North Star Hobbies 2200 Dundas Street East, Mississauga (905) 566-4758 www.northstar-hobbies.com
Efston Science 3350 Dufferin Street, Toronto (888) 777-5255 www.eScience.ca

Please e-mail me if your store needs to be added, deleted, updated.

Back to Index

Links to Electronics companies

Figure 3.6: Supplier list, provided by Mr. Jim Koch on his website.

3-10 Edit Date: February 12, 2013


Chapter 4

Programming the 9s12 Esduino in C and Assembler

While you undertook 9s12 programming in Assembler in your COE538 class, in ELE604 we encourage you to
mix-and-match Assembler and C. The basic structure of your code, as well as aspects that are not time-critical
should be developed in C, while time-critical components should be targetted for Assembler programming.

4.1 Setting up Codewarrior


You can download the Special Edition of Codewarrior for free from Freescale. It’s a pretty straight-forward
setup. You may require setup of the USB drivers if you wish to run the software on a laptop or at home.
Instructions for setting up the USB-serial drivers can be found in Fig. 4.3.
A tutorial for Codewarrior is found in the Appendix.

4.2 Setting Up a C Project in Codewarrior


While you are encouraged to explore different methods of programming and debugging the 9s12 board, the
standard (and supported) approach is using C and the HCS12 Serial Monitor:

1. Start up Codewarrior.

2. Select “Create New Project” in the Startup window that appears

3. In the HC(S)12(X) Microntrollers New Project window,

(a) Select the derivative: HCS12 − > HCS12C Family − > MC9S1232
(b) Select the default connection: HCS12 Serial Monitor

4. Select C

(a) Click on “Finish”

A tutorial for Codewarrior (and C programming) can be found in Appendix P, starting on page P-1

4.3 The Serial Monitor Debugging Tool


Using your PC you will run a program to analyze code on the actual microcontroller itself. The debugging
software in Codewarrior is activated by pressing the icon with the green arrow and bug on it. It will open up a
debugging window that uses the “serial monitor” code built in to the 9s12 chip. Will use this to verify memory
and registers on the 9s12.

4-1
A tutorial on using the Serial Monitor for interacting with the 9s12 can be found in Appendix N, starting
on page N-1.
On the lab PCs in ELE306 and ELE307 the default “COM Port” is 3. While the PCs run Linux you can
access Codewarrior through the Windows VMWare virtual machine.

4.4 An Example Assembler Program: read a switch and turn on LED


Given that you are all fluent in HCS12 assembler programming at this point, the following is an example of
a simple assembler program for the Esduino. You are encouraged to enter the code for this program into
Codewarrior and to run the built-in Simulator prior to actually building the Esduino board.
You can use the code in Listing 4.1 to examine the operation of your LED and switch. Note that this
code polls the switch. It’s effective in this simple example, but will not be when you have more sensors and
peripherals. At that point, you will have to use interrupt-driven code. However, for now, it’s sufficient.
If you run the Codewarrior simulator on this code it will load up and will permit you to conduct step-by-step
run through the instructions.
Listing 4.1: Example for Reading Switch & Turning on LED. Code courtesy of Technological Arts and
Freescale/Metrowerks.
; ∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗
; ∗ This s t a t i o n e r y s e r v e s as t h e framework f o r a ∗
; ∗ user a p p l i c a t i o n ( s i n g l e f i l e , absolute assembly a p p l i c a t i o n ) ∗
; ∗ For a more c o m p r e h e n s i v e p r o g r a m t h a t ∗
; ∗ d e m o n s t r a t e s t h e more a d v a n c e d f u n c t i o n a l i t y o f t h i s ∗
; ∗ processor , please see the demonstration a p p l i c a t i o n s ∗
; ∗ l o c a t e d in the examples s u b d i r e c t o r y of the ∗
; ∗ F r e e s c a l e C o d e W a r r i o r f o r t h e HC12 Program d i r e c t o r y ∗
; ∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗

; ∗ PROGRAM DESCRIPTION :
; ∗ A p u s h b u t t o n w i r e d f r o m PT1 ( i . e . DIG5 on E s d u i n o ) t o Ground will
; ∗ t u r n o f f on−b o a r d LED D2 ( on PM5) w h i l e p r e s s e d .

; export symbols
XDEF Entry , Startup ; e x p o r t ’ Entry ’ symbol
ABSENTRY Entry ; for a b s o l u t e a s s e m b l y : mark t h i s as application entry point

; Include d e r i v a t i v e −s p e c i f i c d e f i n i t i o n s
INCLUDE ’ d e r i v a t i v e . i n c ’

ROMStart EQU $4000 ; absolute address to p l a c e my c o d e / c o n s t a n t data

; v a r i a b l e / data section

ifdef HCS12 SERIALMON


ORG $3FFF − (RAMEnd − RAMStart )
else
ORG RAMStart
endif
; Insert here your data definition .

; code section
ORG ROMStart

Entry :
Startup :
; remap t h e RAM &amp ; EEPROM h e r e . S e e EB386 . p d f
ifdef HCS12 SERIALMON
; s e t r e g i s t e r s at $0000
CLR $11 ; INITRG= $ 0
; s e t ram t o end a t $3FFF
LDAB #$39
STAB $10 ; INITRM= $ 3 9

; s e t eeprom t o end a t $0FFF


LDAA #$9
STAA $12 ; INITEE= $ 9

LDS #$3FFF+1 ; S e e EB386 . p d f , initialize the stack pointer


else
LDS #RAMEnd+1 ; initialize the stack pointer
endif

CLI ; enable interrupts

MOVB #%00100000 ,DDRM ; make PM5 o u t p u t ( for d r i v i n g on−b o a r d LED D2 )

4-2 Edit Date: February 12, 2013


CLR PTM ; e n s u r e LED i s o f f
MOVB #%00000010 ,PERT ; e n a b l e p u l l u p r e s i s t o r s on PTT f o r pushbutton
CLR DDRT ; e n s u r e PORT T p i n s a r e a l l i n p u t s

mainLoop :
b r s e t PTIT , #%00000010 , LEDON ; if switch is open t h e n t u r n on LED

LEDOFF LDAA #%00000000 ; else turn o f f LED


STAA PTM
BRA mainLoop

LEDON LDAA #%00100000


STAA PTM
BRA mainLoop

; ∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗
;∗ Interrupt Vectors ∗
; ∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗
ORG $FFFE
DC.W Entry ; Reset Vector

4.5 More Examples of Sample Code


There are C and Assembler examples in a number of places, including

• Assembler examples: check the Appendix. One of which is an example of programming Interrupt Services
Routines (ISR).

• C examples: http://support.technologicalarts.ca/docs/Esduino/Code/C/CW/

4-3 Edit Date: February 12, 2013


Configuring Windows USB Virtual COM Ports Select the COM port Number dropdown box and select a COM port number 2, 3, or 4 (usually COM1 is already
in use).
The various USB interface modules made by Technological Arts are based on the popular FTDI chip,
FT232RL. Usually, Windows will recognize them when you plug them into a USB port on your computer. If it
doesn't, you will need to download and install the appropriate driver from the FTDI website
(www.ftdichip.com). Drivers are provided for various versions of Windows. Download and install the correct
version for your computer’s configuration before proceeding. This article will assume you are using XP.

Now connect a USB cable between a USB port on your PC and the USB interface module you are using. Win-
dows should report a new device has been found and proceed to initialize it.

To determine which virtual COMport it has been assigned to, right


click the MyComputer icon on your Windows desktop, and select
Properties from the popup menu. Next, click on the Hardware tab,
and click on the Device Manager button.

Click on the + sign next to Ports


(COM & LPT). The list of avail-
able ports will be revealed. You The port number may be reported as in use but you can disregard that at this point, if you know that nothing is

BDMPods/ConfiguringVirtualCOMports.pdf)
will see one entitled USB Serial currently using it.
Port, with the assigned COM port
number identified in brackets.

4-4
To work with most of the tools you are likely to use with microcontrollers, the COM port should be 1, 2, 3, or 4.
If it is higher than COM4, you’ll probably want to change it. Do this by right-clicking the line USB Serial Port
and select Properties from the popup menu.

Click on the Port Settings tab, and then click the


Advanced... Button.

Click OK, and if Windows warns you about a duplicate, ignore the warning and click Yes. Click OK and then
OK to the port settings. Then close the Device Manager window. If you want to confirm the port change has
indeed been made, click on Device Manager again and check the listed Ports. Now close the System Proper-
ties window.

At this point, you are ready to use the virtual COM port in any application!

Note that, if you unplug the USB device and plug it back in later, Windows will still remember the COM port
assignment, so you won't need to go through this procedure again.

wwwwww..TTeecchhnnoollooggiiccaallAArrttss..ccoomm
!eevv..    00

Edit Date: February 12, 2013


ning VMWare or Parallels. Courtesy of Technological Arts (http://support.technologicalarts.ca/docs/
cal Arts Esduino. This should work for regular Windows PCs, as well as Mac and Linux machines run-
Figure 4.1: How to configure / setup USB for a computer to communicate & program the Technologi-
when Serial Monitor is Used

0xF780 User. Int Vectors

0xFFFF Vectors* Monitor


Desired Mapping

Int. Serial
0xF77F

0xF7FF
0xF800
0x0400

0x3800

remaps memory after Reset.


Built-in Serial Monitor

(SW2 on Esduino
must be set
to "Load")
0x0FFF
0x0800

0xC000

0xFFFF
0x03FF

0xFF00
0x8000
0x0000
Immediately after Reset

Int. Vectors
2kB RAM

EEPROM

EEPROM
Registers

(16kB)

(16kB)
Flash

Flash

Figure 4.2: You will have to assign different parts of the code to different locations in memory. “Scratch”
variables will be placed in RAM, the main code will be stored in Flash EEPROM, as will the interrupt vector
table. Control registers are located in teh first 1kByte of memory. The RAM is found starting at $3800. Flash
EEPROM is set to start at $4000. The code is modeled after ex. 11-18 in [12] while the memory model for the
MC9s12c32 is from [1, p. 32]

4-5 Edit Date: February 12, 2013


4-6 Edit Date: February 12, 2013
Chapter 5

Grading

Each component of the lab has a particular weight (with respect to your lab grade) associated with it:

Week 2 report 5%.

Week 3 report 5%.

Week 4 report 5%.

Milestone 1 5%.

Milestone 2 25%.

Milestone 3 25%.

Milestone 4 15%.

Milestone 5 15%.

5-1
5-2 Edit Date: February 12, 2013
Chapter 6

Week 1: No Labs!

There are no labs in the first week of school. However, you should find a lab partner (two partners per group)
and buy the lab kit. One lab kit is to be purchased per group. Please see Mr. Jim Koch for the purchase.

6.1 Checklist
The following is a checklist of things that you are expected to do during this week:

◦ Find a lab partner


◦ Buy lab kit (January 11; Time: 10:30-4:30; Room: ENG 310) from Mr. Jim Koch)
◦ Prepare yourself for the Lab in Week 2. Read the source code and plan your pin allocation.

6-1
6-2 Edit Date: February 12, 2013
Chapter 7

Week 2: Heartbeats and Time-Keeping

7.1 Straight to the Point


When starting to use a new microcontroller there are two keys things that you need to set up: a “heartbeat”
light and an accurate clock. In this lab, you’ll end up doing both.

7.2 Overview
In this lab you will familiarize yourself with the measurement system (or “Data Acquisition System”) that will
form the basis of all lab work this semester. To this end, you will program the 9s12-based Esduino board to
flash it’s onboard LED at a specific frequency. You will then measure the duration of these pulses and calculate
the average and standard deviation of these measurements. The Esduino is shown in Fig. 7.1.
Prior to underaking the above, you will go over the semester’s lab schedule. A discussion of lab safety will
be held. You will also be given an overview of the equipment in the lab. The lab kit, that you should have
purchased with your partner earlier, will be discussed from a general perspective.
The main design goals and suggested methodologies will then be introduced. A review of reporting re-
quirements (IEEE standard format, issues related to plagiarism in report writing, as well as coding) will be
undertaken.

Figure 7.1: The Esduino Board

7-1
7.3 Background Information
You are expected to become familiar with lab safety, the design goals, the components and equipment which
you will be using over the course of the semester. This first lab is designed to help with this.
In terms of lab safety, there are chemical, electrical and physical hazards. Some are discussed in introductory
part of this manual. Given that you will sometimes work outside of standard lab hours, and therefore be
unsupervised, it is important that you take responsibility for being pro-active with safety.
The Esduino board, as explained earlier in a previous chapter, is based on the AVR-based Arduino system.
However, because the 9s12 is different than the AVR Atmega, it is important to have a clear understanding of
what functionality is offered on each of the headers of the Esduino. In terms of the input/output assignment of
pins on the Esduino board you need to become familiar with the various “ports” on the 9s12 chip. Many of the
Port T and Port M pins are made available on the “north” end of the Esduino, as shown in Fig. 7.2. Port T is
most often used for digital devices that have particular timing characteristics (like flashing LEDs at particular
frequencies, or measuring the time between a user pressing a switch). Many of the Port T pins are found on
headers J1 and J3 of the Esduino. Port AN is the analogue input port; most of its pins can be found on header
J2 (with Analogue reference on J7 and J3) on the “south” end of the board.
Codewarrior (originally a Canadian product!) is offered for free by Freescale. It is suitable for both Assembly
and C programming of the 9s12 Esduino board. You used it to program an HCS12 microcontroller board in
the Assembly language. In ELE 604 you will do most of your work in C, with some Assembler in certain places.
Codewarrior has components that permit the “host” Windows computer to connect to the “target” Esduino in a
number of ways, including through a USB cable. When using the USB cable, Codewarrior will communicate to
the Esduino via a small program that resides at the end of Flash EEPROM memory called the “Serial Monitor”
[16]. You can access this mode via the “debug” button in Codewarrior1 .

7.4 Learning Objectives


In this learning module you will demonstrate basic knowledge required to begin undertaking lab tasks in ELE604.
The following are the minimum set of learning objectives for you:

1. Identify potential lab hazards

2. Solder “hook up” wires together

3. Demonstrate some basic knowledge of the microcontroller system to be used

4. Establish preliminary plan of microcontroller pin allocation

5. Make sure that your Esduino is working by having it flash its LED

6. Measure pulse period of Esduino LED (including average and standard deviation)

7. Develop familiarity with report submission requirements

7.5 Success Criteria


At the end of the lab session you will have

1. Established preliminary plan of microcontroller pin allocation on J1, J2, J3, J4 headers on the Esduino.

(a) Hand-in your wiring plan to the TA in the first 30 minutes of the lab. Make sure your name is on
the paper.
1
The debug button looks like a bug on top of a green triangle

7-2 Edit Date: February 12, 2013


[JB4] TX/RX Communications Routing:
Place two shunts in the positions shown Esduino
US = USB-to-SCI (of the MCU) 9S12C-based Arduino-compatible*
When Xbee Option is present: Rev. 1
UX = USB-to-Xbee (for configuring via Host) [JB3]: Digital11 Source
SX = SCI-to-Xbee (for wireless communications) 1-2 (left): PM4
[U4]: Serial Memory [JB2]: Digital10 Source 1-3 (down): PP5 (PAD1)
Footprint for optional 1-2 (left): PT4 1-4 (right): PT5
[J14][J15]: USB2MCU module goes here, SPI memory device. 2-3 (right): PM3
to provide USB interface to host PC; [D2]: User LED [U1]:
or supply your own TTL-level signals (on DIG13) Freescale 9S12C 16-bit microcontroller

PAD07

PAD06
to/from Host

DIG1
DIG0
[JB8] PS/PM SELECT:

PM5
PM2

PT3
PT7
PT6
PT2
PT1

PT0
Select between PS0/PS1
J14 US JB4
[J9][J10]: [Xbee Option]
GND J3 and PM0/PM1 assignments

SX UX
+5V

UX SX
for DIG0 and DIG1 pins

AREF

D2
GND

D9P
D13
D12

D10

>
<
D11
Plug ADXB here for XBee Interface

J1
D8

D7

D4
PWM D6
PWM D5

1 PWM D3
DTR U4
PM3
PT4 M
(3V/5V compatible).
S
<TX US J6
SPI
D2 JB2 DIG11 [J11] BDM IN:
J15 C17
GND PM4 PT5 Standard 6-pin Background

JB8
DI
[J6]: SPI peripheral connector RX >

BDM IN
ADXB
SPI signals, Output Enable, +5V, J10 +5
Esduino JB3 Debug Mode connector for
PP5
and Ground are all brought out to
SCK JB1
www.TechnologicalArts.com advanced debugging use
SS* R5 J11 LOAD
this convenient connector for easy OE*
VIN
J5
C6
JB6 SW1 [SW1 and JB6]:
interfacing to SPI peripherals DO
USB
C5 MAN
G
PB4 R1
C7
When JB6 set to MAN, use SW1 to
[JB1]: 5V Source Selector PWR PE7
AUTO select Serial Monitor mode.
C10 RUN
1-2 (lower): 5V from USB PE4
D3
Y1
U1
When JB6 set to AUTO, Serial
PA0
2-3 (upper): 5V from U1 via VIN R6 D1
C1 C11
R3
J8 PM0 Monitor mode must be controlled
by host via DTR line on serial port.

+
J9 Y2 JB5 PM1
[D1]: Power indicator LED 3V 5V J7 AN7
J12 R2
C16 VDD VRH AR
AN6
[J7] PB4, PE7,PE4,PA0: C15 C14 JB7
[J8] PM0 - PM1:

RESET
U3 C9

GND
GND
Four bonus Digital pins.

AN0
AN1
AN2
AN3
AN4
AN5
VIN
+
3V3 5V Two bonus Digital pins;

J2
SW2

J4
REV. 1 J13 may be used with an external
[U3]: 3.3V regulator (800 mA max.) transceiver to implement a

PAD00
PAD01
PAD02

PAD05
PAD03
PAD04
CAN interface.
[J7] AN6 - AN7:
[SW2]: Reset button [JB5]: 3V/5V Operation [J2] AN0 - AN1: Two bonus Analog Inputs;
1-2 (left): 3.3V Six Analog Inputs;
Power Configurations: may be used as digital
2-3 (right): 5V Any of these may be
Instead of deriving 5V to power the board from the USB Host inputs or outputs instead
connection, it can be derived from on-board regulator U1. used as digital inputs
Two different power connections are provided: J12 and J13. or outputs instead
The 2-pin J13 Molex connector is the default, while J12 is an
Order Codes:
optional barrel jack connector (2.1mm center-positive) ESD12C32 (with 9S12C32; surface-mount devices only)
compatible with most common AC-to-DC adapters. If J12 is ESD12C128 (with 9S12C128; surface-mount devices only)
present, and a voltage supply is plugged in, it will ESD12C32-KIT (ESD12C32 plus kit of through-hole parts)
automatically override J13. The applied voltage (VIN) can be ESD12C128-KIT (ESD12C128 plus kit of through-hole parts)
anywhere in the range of 7 to 15V DC. To choose VIN as ESD12C32-UR (fully assembled with 9S12C32, USB2MCU and connectors)
the source of system 5V (via regulator U1), set jumper block ESD12C128-UR (fully assembled with 9S12C128, USB2MCU and connectors)
JB1 to the 2-3 (upper) position. * Footprint and pinout are compatible with
standard Arduino-style shields; Arduino
www.TechnologicalArts.com software environment support pending. JANUARY 2011

Figure 7.2: The Esduino functionality is displayed here. The layout of the Rev 1 board is courtesy of Techno-
logical Arts.

2. Identified a minimum of three serious potential lab hazards


3. Created two male-male test wires
4. Answered the skill questions
5. Measured the duration of the pulses on the Esduino D13 pin (connected to its LED)
6. Summarize all of the results in a short, IEEE-style report
7. Begun preparation of the report to be emailed to your TA as a PDF within one day of the lab.

7.6 Pre-requisites & Pre-lab


Prior to the lab in the second week of the semester you are expected to have
1. Dug out your oscilloscope probe from ELE 202 or ELE 404. You’ll need it for this lab.
2. Examined the source code listing in Listing 7.1 on page 7-4 and transcribe to a text file for use during
the lab
3. purchased the lab kit (with a partner)
4. read background documentation on the design project (see Chapter 2 on page 2-1), the microcontroller
and the software development tools in Ch. 3
5. Established the pin allocation for the Esduino microcontroller (see Section 7.6.1 on page 7-4)

7-3 Edit Date: February 12, 2013


7.6.1 Establish preliminary microcontroller pin allocation
Based on the documentation in Ch. 2 you are to interface a number of devices to the Technological Arts Esduino
microcontroller board, shown in Fig. 7.2, including (but not necessarily limited to):

1. Switches

2. an LCD (a display)

3. an Accelerometer (MEMSIC 2125)

4. a Loadcell (Futek LBB200)

5. LEDs (lights)

Go over the Esduino and Freescale documentation and create a list of pins on the different ports (Port T,
Port M, Port A, etc.). Some of this information is found in Ch. 3, some in the Appendix, some in the MC9S12C
Family Reference Manual, as well as in other sources. It is your task to explore in order to find the answer(s)2 .

More thoughts on the design


You will be interfacing to the Esduino board through four main headers (located on the north and south ends
of the board). On the north side are the digital headers, J1 and J3 On the south side are the analogue headers,
J2.
Referring to Fig. 3.5 and [15] you need to determine which pins on J1, J2, J3, J4 can be used the for
following:

Switches 1 switch is needed (digital input)

LEDs 3 LEDs are needed (digital output)

Accelerometer 2 pulse-width modulated outputs from MEMSIC 2125 to two digital inputs on 9s12

Loadcell 1 analogue input

LCD Serial Peripheral Interface to the LCD requires SCK, MOSI and OE*.

Serial Comms to Host Computer RS232 TX and RX lines are needed.

Listing 7.1: This code will permit the LED on the Esduino board to flash at a fixed frequency
/∗ =======================================================================
∗ B a s i c LED t i m i n g / d e l a y c o d e

∗ b y James Andrew Smith ,
∗ Input : Nothing
∗ O u t p u t : F l a s h i n g LED

∗ PROGRAM SUMMARY: t h i s c o d e i s d e s i g n e d t o f l a s h t h e LED c o n n e c t e d t o t h e
∗ D13 p i n o f t h e E s d u i n o b o a r d . The D13 p i n c o r r e s p o n d s
∗ t o Pin 5 o f P o r t M on t h e 9 s 1 2 c 3 2 c h i p . The TCNT t i m e r
∗ i s used to provide the timing f o r the f l a s h i n g of the
∗ LED .

∗ Test 1:
∗ T e s t e d on Rev 1 E s d u i n o on Oct . 2 0 , 2 0 1 1 w i t h a P&E BDM c a b l e on a . . .
∗ Mac−b a s e d P a r a l l e l s v i r t u a l m a c h i n e r u n n i n g Windows XP . ( James S m i t h )
∗ 1 . F i l e : C: \ Documents and S e t t i n g s \ A d m i n i s t r a t o r \ . . .
∗ My Documents \ P r o j e c t 2 4
∗ 2 . V i r t u a l Machine : / U s e r s / j a s m i t h / Documents / P a r a l l e l s / . . .
∗ Windows XP − M a t l a b & 9 s 1 2 . pvm

∗ Test 2:
∗ M o d i f i e d and t e s t e d on Dec 2 , 2 0 1 1 t o r u n o f f s e r i a l m o n i t o r ( a s s u m i n g 25MHz
∗ i n t e r n a l c l o c k ) , u s i n g t h e same s e t u p b u t w i t h o u t t h e BDM.

2
Like any good design, there are multiple approaches. There is no single answer.

7-4 Edit Date: February 12, 2013


SPI SPI SPI
MEMSIC Serial
(SCK) (MOSI) Here?
What Connects (OE*)
SW (computer)
LED SW SW LED LED

J3 J1

RX
TX
D9P
D13
D12

D10

D8

D7
D6
D5
D4
D3
D2
D11
GND
AREF

Pin 9s12 Function


D2: PAD06
D3: PT0
D4: PAD07
D5: PT1
D6: PT2
D7: PT6
D8: PT7
D9: PT3
D10: PT4 or PM3 (Select @ JB2)
D11: PM4, PP5(PAD1), or PT5 (Select @ JB3)
D12: PM2
D13: PM5

Figure 7.3: What function will be assigned to which pins on the Esduino? Hint: most will be on J1, J2, J3, J4.
The analogue pins are not listed here, but you will need to include them, too.




∗ M o d i f i e d and t e s t e d on Dec 1 , 2 0 1 1 t o r u n o f f s e r i a l m o n i t o r ( a s s u m i n g 25MHz
∗ i n t e r n a l c l o c k ) , u s i n g t h e same s e t u p b u t w i t h o u t t h e BDM.

∗ S o u r c e s : 1 . b a s e d on c o d e b y F r e d Cady ( f r o m Academic F r e e s c a l e w e b s i t e )
∗ 2 . a s s e m b l e r c o d e b y Ron Wong
∗ 3 . c o d e b y V a l v a n o ( h t t p : / / www . e c e . u t e x a s . e d u /˜ v a l v a n o / S t a r t e r f i l e s / )
∗ 4 . Pg 450 i n MC9s12C manual ( Rev01 . 2 3 )

∗ C a v e a t s : You w i l l b e u s i n g t h e s e r i a l m o n i t o r ( n o t a BDM c a b l e ) t o p r o g r a m
∗ your Esduino board . Keep t h i s i n mind a s t h e s e r i a l m o n i t o r may
∗ e n g a g e t h e PLL ( P h a s e L o c k e d Loop ) and d r i v e t h e b u s c l o c k o f t h e
∗ 9 s 1 2 f a s t e r ( o r s l o w e r ) t h a n was t e s t e d h e r e .

∗ ======================================================================= ∗/

#include <h i d e f . h> /∗ common d e f i n e s and m a c r o s ∗/


#include ” d e r i v a t i v e . h” /∗ d e r i v a t i v e − s p e c i f i c d e f i n i t i o n s ∗/

// PRAGMA STATEMENTS
#pragma LINK INFO DERIVATIVE ” mc9s12c32 ”

// DEFINE STATEMENTS
#d e f i n e DELAY 500 // assume 1ms ” u n i t s ” o f d e l a y . 500=500ms
#d e f i n e ONE MILLISEC FOR TSCR2 1US 1000 // Timer : 1 0 0 0 x 1 m i c r o s e c = 1 m i l l i s e c
#d e f i n e ONE MILLISEC FOR TSCR2 333NS 3000 // Timer : 3 0 0 0 x 333 n a n o s e c= ˜1 m i l l i s e c

// INITIALIZATION CALLS
void p o r t m i n i t ( void ) ; // I n i t . P o r t M’ s PM5 f o r LED f l a s h i n g
void Timer mwait ( unsigned short msec ) ; // Timer w i l l w a i t i n 1 ms i n c r e m e n t s
void T i m e r I n i t ( void ) ; // I n i t i a l i s e t h e Timer .

// VARIABLE DECLARATIONS (GLOBAL)


/∗ None . ∗/

/∗ − − − − − − − − − − − − − − − − − − − −
∗ MAIN FUNCTION
∗ − − − − − − − − − − − − − − − − − − − − − ∗/

void main ( void ) {


short c o u n t e r ;

/∗ I n i t i a l i s e any interrupts ∗/
EnableInterrupts ;

/∗ I n i t i a l i s e t h e Timer ∗/
Timer Init ( ) ;

/∗ S e t up PM5 ’ s LED ( on Pin 5 o f P o r t M) ; i t ’ s Pin D13 on t h e E s d u i n o . ∗/


port m init ();

/∗ DO ∗/

7-5 Edit Date: February 12, 2013


for ( ; ; ) {
c o u n t e r ++;
Timer mwait (DELAY ) ; // 0 . 5 s e c wait

// T o g g l e PM5 : ”HEARTBEAT” − F l i p LED b i t


// on P o r t M, B i t −5 (PM5)
i f (PTM PTM5 == 1 ) PTM PTM5 = 0 ;
e l s e PTM PTM5 = 1 ;

} /∗ w a i t f o r e v e r ∗/

/∗ −−−−−−−−−−−−−−−−−−−−T i m e r I n i t −−−−−−−−−−−−−−−
∗ i n i t i a l i z e t i m e r m o d u l e t o 1 u s ( Run Mode ) TCNT c l o c k

∗ O t h e r w i s e t o 1280 ns i f u s i n g S e r i a l Monitor .

∗ i n p u t s : none
∗ o u t p u t s : none

∗ I f ” b u s c l o c k ” i s 8MHz , t h e n TSCR2=0 x 0 3 ( d i v i d e b y 8 )
∗ I f ” b u s c l o c k ” c l o c k i s 4MHz , t h e n TSCR2=0 x 0 2 ( d i v i d e b y 4 )
∗ R e f e r e n c e : p g 450 o f t h e MC9s12C f a m i l y manual ( r e v 0 1 . 2 3 )

∗ N o t e : The E s d u i n o c r y s t a l i s 8 MHz , b u t t h e b u s c l o c k ( i n t e r n a l , ’E C l o c k ’ )
∗ i s n o t 8 Mhz b y d e f a u l t . You n e e d t o c h a n g e t h e p h a s e −l o c k e d l o o p ( PLL ) t o
∗ modify t h i s .

∗ By d e f a u l t t h e E s d u i n o a p p e a r s h a v e a 4MHz b u s c l o c k ( when programmed w i t h BDM) .
∗ I n s e r i a l m o n i t o r mode i t ’ s 24 Mhz . So s e t TSCR2 a s c l o s e a s p o s s i b l e t o
∗ 1 us ( 1 . 2 8 us ) .

∗ Bottom t h r e e b i t s o f TSCR2 ( PR2 , PR1 , PR0 ) d e t e r m i n e TCNT p e r i o d
∗ divide 8MHz i n t e r n a l b u s c l o c k
∗ 000 1 125 n s
∗ 001 2 250 n s
∗ 010 4 500 n s
∗ 011 8 1 us
∗ 100 16 2 us
∗ 101 32 4 us
∗ 110 64 8 us
∗ 111 128 16 u s

∗ f o r a 4MHz i n t e r n a l b u s c l o c k ( E s d u i n o programmed w i t h a BDM o r i n Run mode )
∗ 000 1 250 n s
∗ 001 2 500 n s
∗ 010 4 1000 ns
∗ 011 8 2 us
∗ 100 16 4 us
∗ 101 32 8 us
∗ 110 64 16 u s
∗ 111 128 32 u s

∗ f o r a 16 MHz i n t e r n a l b u s c l o c k ( Need t o a d j u s t PLL f o r t h i s )
∗ 000 1 xxxns
∗ 001 2 125 n s
∗ 010 4 250 n s
∗ 011 8 500 n s
∗ 100 16 1 us
∗ 101 32 2 us
∗ 110 64 4 us
∗ 111 128 8 us

∗ f o r a 24 MHz i n t e r n a l b u s c l o c k ( E s d u i n o w i t h S e r i a l M o n i t o r i n Load mode )
∗ 000 1 4 1 . 6 7 ns 0.04167 us
∗ 001 2 8 3 . 3 3 ns 0.08333 us
∗ 010 4 1 6 6 . 6 7 ns 0.16667 us
∗ 011 8 3 3 3 . 3 3 ns 0.33333 us
∗ 100 16 6 6 6 . 6 7 ns 0.66667 us
∗ 101 32 1 3 3 3 . 3 3 ns 1.33333 us
∗ 110 64 2 6 6 6 . 6 7 ns 2.66667 us
∗ 111 128 5 3 3 3 . 3 3 ns 5.33333 us

∗ R e f e r t o Pg 450 i n MC9s12C manual ( Rev01 . 2 3 )
∗ −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− ∗/
void T i m e r I n i t ( void ) {
TSCR1 = 0 x80 ; // E n a b l e TCNT;
TSCR2 = 0 x03 ; // d i v i d e b y TCNT p r e s c a l e f o r E s d u i n o . TCNT a t 0 . 3 3 3 u s
PACTL = 0 ; // t i m e r p r e s c a l e u s e d f o r TCNT

//−−−−−−−−−−−−−−−−−−−−−T i m e r m w a i t−−−−−−−−−−−−−−−−−−−−−
// w a i t s p e c i f i e d number o f msec
// I n p u t : number o f msec t o w a i t
// O u t p u t : none
// a s s u m e s TCNT t i m e r i s r u n n i n g a t 1 u s
void Timer mwait ( unsigned short msec ) {
unsigned short s t a r t T i m e ;
f o r ( ; msec >0; msec−−){
s t a r t T i m e = TCNT;
// w h i l e ( (TCNT−s t a r t T i m e ) <= ONE MILLISEC FOR TSCR2 1US ) { }
while ( (TCNT−s t a r t T i m e ) <= ONE MILLISEC FOR TSCR2 333NS ) { }

7-6 Edit Date: February 12, 2013


}
}

/∗ − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − −
∗ F u n c t i o n : ” p o r t m i n i t ( ) ” : I n i t i a l i s e P o r t M f o r LED u s a g e
∗ − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − ∗/
void p o r t m i n i t ( void )
{
/∗ P o r t M i s s e t up t o f l a s h t h e E s d u i n o ’ s b u i l t −i n LED∗/
asm{
MOVB #32 ,DDRM
CLR PTM
}
}

7.7 Resources
1. The IEEE-style template for report writing: http://www.ee.ryerson.ca/~jasmith/courses/ele604/
docs/IEEE_trans_template_ELE604.doc

2. The FEAS lab report cover page: http://www.ee.ryerson.ca/~jasmith/courses/ele604/docs/StandardCoverPageLabReports.doc

3. In this Student Manual

(a) The chapter on Equipment and Tools, Ch. 3 of this manual.


(b) The chapter on design aspects of this lab, Ch. 2 of this manual.
(c) IEEE formatting documents in Appendix R of this manual.

4. The Technological Arts website, http://www.technologicalarts.com/, (Tech. Arts makes the Esduino)

• Source code examples: http://support.technologicalarts.ca/docs/Esduino/Code/

5. Freescale HCS12 University website: http://www.freescale.com/webapp/sps/site/overview.jsp?code=


UNIV_REFERENCE_HCS12_CAT

(a) Look under the HCS12C category as well as Course Material − > HCS12C
(b) The Microcontroller - General Principles by Fred Cady (search for “LABS12CINTRO01S.doc”)
(c) General Principals - Software Development by Fred Cady (search for “LABS12CINTRO02S.doc”)
(d) Exploring Embedded C Programming by Fred Cady (search for “LABS12CINTRO06.doc”)
(e) Serial Monitor Program for HCS12 MCUs by Jim Williams, Application Note AN2548/D [16]
(f) MC9S12C Family / MC9S12GC Family Reference Manual, #MC9S12C128 Rev 01.23 05/2007 by
Freescale Semiconductor (available as a free download online)

6. The website for the AVR-based Arduino project, http://www.arduino.cc/ (this is related to the Es-
duino).

7.8 Exploration
7.8.1 Lab Safety
Mr. Jim Koch will provide you with an overview of lab safety and etiquette. He will identify a number of safety
hazards in the lab, as well as ways that you can mitigate risk with respect to these hazards. Feel free to ask
questions of Mr. Koch, the TA or the course instructor with respect to lab safety. If you see equipment or items
that you are unfamiliar with but which you may feel pose a hazard, feel free to enquire as to their nature.

7-7 Edit Date: February 12, 2013


7.8.2 Wiring Hook-up wire
Using the multi-stranded wire provided in your lab kit, as well as the heat shrink tubing, solder and male pins,
you are to create a minimum of two “hook-up” wires that will be used on the breadboards included in your lab
kit. This will give you some experience soldering. The TA will go over how to prevent “cold” (fragile) solder
connections. The hook-up wire should be about 10cm long and should terminate at both ends with a male pin.

7.8.3 Let there be Light


The most classic way to debug how the microcontroller is operating during execution of a program is to have an
LED light up based on a particular condition. This could be an analogue voltage exceeding a certain threshold
or a timer counter achieving a certain time value.
Code Listing 7.1 illustrates how the voltage on Port M, Pin 5 can be changed to light up the LED on the
north end of the Esduino board. This LED is also connected to the D13 pin on Header J3. Read over the code
listing to see how the voltage – and hence the LED’s light – is toggled on and off. In this case, we will use the
LED to indicate how the TCNT counter achieves a particular time value over and over. The end result is that
the LED will flash like a “heartbeat” on a regular basis. You will use this to evaluate how well time is measured
on the Esduino...

7.8.4 How good is the 9s12 at Measuring Time?


Implement the code in Listing 7.1, on page 7-4. To do this, start a new ‘C’ project in Codewarrior and replace
the main.c file with the listing provide. Upload your code to the board using the Codewarrior and the built-in
serial monitor.
With a stop watch, measure 100 flashes of the LED. What is the average period of the LED flashing? Next,
use the oscilloscope to measure the average and standard deviation, as shown in Fig. 7.4. If the oscilloscope
cannot provide these two values, transfer the data to a PC and process it in Excel or Matlab. Your TA is
familiar with the process of processing data in Matlab and can guide you. How do you connect the oscilloscope
to the Esduino? Use this guide:
1. turn off your Esduino
2. place one of your “hook up” wires into the GND line on the south header, J4. (refer to Fig. 7.2 on page
7-3)
3. connect the other end of the hook up wire to the ground alligator clip on the oscilloscope lead
4. place the other “hook up” wire into D13 on header J3 (refer to Fig. 7.2 on page 7-3)
5. connect the other end of that hook up wire to the pin on the oscilloscope lead.
6. Turn on your Esduino and run the code from the Serial Monitor
7. Measure the response on your oscilloscope, as shown in Fig. 7.4. Save the waveform to a USB as a CSV
file.
The objective is to have the LED flash with a period of one second. If it is not flashing at this rate what
would you have to change to make it happen. Does it work the same way when the Esduino is in “run” or
“load” mode?

Inline Assembly
The Port M initialisation function is written using “inline assembly”, similar to the coding that you did in
COE 538. In many cases, writing your code in assembly will make it more efficient. By combining an overall
structure in C with specific function written in assembler you can achieve a good compromise between readability
/ maintainability and processing time.

7-8 Edit Date: February 12, 2013


Figure 7.4: Screen capture of the pulsing from the Esduino.

7.9 Skill Exercise


1. Which analogue-related pins are found on Esduino headers J2 and J3

2. Why are labels on the headers not the same as the 9s12 pin numbers? For instance, why is the 8th pin on
J1 labelled D7 and not PT6 on the Esduino circuit board? Hint: what AVR-based board is the Esduino
derived from?

3. Why is DELAY defined as 500 in the LED blinking code in Listing 7.1 when we want the LED to flash
once per 1000 ms?

4. What would you need to do to set the bus clock of the 9s12 to a different frequency?

5. What is the average period of the flashing LED? What is the standard deviation? Provide a screenshot
of the oscilloscope calculation or a copy of your Excel/Matlab work.

6. In what file is PTM PTM5 defined?

7.10 Communication
Work with your partner to

1. Hand-in your wiring plan to the TA in the first 30 minutes of the lab. Make sure your name is on the
paper.

2. Demonstrate one soldered “hook up” wire per partner to the TA

3. Establish preliminary plan of microcontroller pin allocation

4. Identify at least three serious potential lab hazards

5. Answer the “Skill Exercise” questions above.

In reporting to the TA, you will be required to provide preliminary answers prior to leaving the lab. You will
then email a PDF report to the TA with formal evidence that you were able to achieve the above items. The
PDF does not need to be long (one to two pages is sufficient) but must adhere to IEEE reporting standards.

7-9 Edit Date: February 12, 2013


The email is due the day after your lab. It must be emailed to the TA at this point.
A marking guide / rubric is found at the end of this chapter. Use it as a guideline for fulfilling the
requirements for the document that you are to submit to the TA.

7.11 Post-lab reflection


Have you identified many potential hazards in the lab? Can you think of any that were maybe not addressed
during the lab session? If so, bring it to the attention of the TA or course instructor.
Could you have soldered the “hook-up” wire better? Will it stand-up to all the circuit testing and prototyping
you will do? What could you do to make the wire better? Consider going to Creatron Inc. on College St. to
purchase hook-up wire there and compare to how you did it? Could you do better next time?
For those of you who are rusty with the material from COE 538, supplemental material is provided in the
Appendix. You are encouraged to explore the Codewarrior simulator for the 9s12 prior to constructing the
Esduino board in order to become more familiar with it.
It may be useful to adjust the internal bus clock (“E clock”) beyond what it runs at by default. You will
need to adjust the PLL (Phase-locked Loop). Sample code for this can be found here: www.ece.utexas.edu/
~valvano/metrowerks/Howtobuild_S12C32.pdf.

7-10 Edit Date: February 12, 2013


Download the Template from the
BME 100 webpage. Don’t make the
document from scratch!

Write your
name in the Using the IEEE Template
“header” Write
here Student ID
Title is 24 pt Times New Roman TNR font
in the
header
A subtitle which narrows the Here
scope of your project is good!

Student ID
Introduce your topic here. Put and Full
your “Thesis statement” here. Name here.

Headings are in capital letters and


numbered with Roman Numerals, Figures, drawings, etc.
in 10 pt TNR font. need to be cited (with
the [#]) if you did not
do them yourself.

Add an “Acknowledgements” section if


you got help on your project.

References, based on the


Table captions are on the top. If Refworks output, are in 8pt
you copy or modify someone’s Times New Roman font.
table, you need to cite it (with
the [#]).
ELE604 Week 2 Marking Guide (Lab) 2011
• Preliminary Wire Plan (10% of total)
o No Mistakes (10/10)
o Minor Mistakes (5/10) Deductions
o Major Mistakes (0/10) • Lateness (Report)
o -25 pts (up to 1 day)
• Measured data (30% of total) o -100 pts (beyond one day)
o ‘Scope Screen (10) • Lateness (Wire plan in Lab)
o Average Period (10) o -25 pts (after 30 minutes)
o Std. Dev. Of Period (10) • Font Modification (IEEE Template: Times
New Roman 10pt in main body, 24pt in title,
• 3 Lab Hazards (30% of total mark) 8pt in References)
o Three Good (30/30) o -25 pts (any changes)
o Two Good (20/30) • No Cover Sheet (FEAS official)
o One Good (10/30 o -25 pts
o None right (0/30) • Template Modification (margins, borders,
header placement, etc.)
• Skill Questions (30% of total mark) o -25 pts (any changes)
o Six correct (30/30) • Number of Pages
o Five correct (25/30) o -25 pts (~3/4 of req’d)
o Four correct (20/30) o -50 pts (~1/2 of req’d)
o Three correct (15/30) o -75 pts (anything less)
o Two correct (10/30)
o One correct (5/30)
o None correct (0)

Left Column Total Right Column Deduction

Your grade:

How is your grade calculated?

In the left column, your citations, language and content are evaluated. The marking is based on how well you
perform in each of those items. The individual scores are added up and written in the box below the column.
Afterwards, deductions are is made based on the factors in the right hand column. The deductions are
cumulative and can reduce your grade to 0 (minimum).
** Note: Use the IEEE Template Word document for ELE604! **
** Don’t change the template! **
** Go to www.ee.ryerson.ca/~jasmith/courses/ele604/support_docs for the template **
Page Number Mark Adjustment
- Based on length requirement. If you submit only about 75% of the number of pages you were
supposed to, your mark will be reduced by 25%.
- If you submit less than 75% of a complete page it is considered an incomplete page and is not
considered in your total page count.
- If a disproportionate amount of your article is taken up by tables, figures or quotations from other sources
your mark will be reduced accordingly. Be reasonable with your usage of figures, photos, images, diagrams,
tables and quotations. (For instance, if three-quarters of a page is taken up by a table or figures, leaving little
room for your own text, then the Page Number Adjustment will apply)
- Examples:
1) Hand in a two page project that was supposed to be four pages: your project mark will drop by
50 points.
2) Hand in a 3.5 page project instead of four pages: your project mark will drop by 25 points.
3) Hand in a four page paper, but one complete page is a table from another source, your project
mark will drop by 25 points.

Plagiarism, Copying, etc.


Remember: Plagiarism is wrong! If you copy from a book, journal or online source (or your friend)
without permission and/or citation you will receive 0 and may receive a record on your transcript.
Chapter 8

Week 3: Displaying Data, Part 1: Serial to PC

8.1 Straight to the Point


You’ve got to display the data that’s processed in your Data Acquisition System. The PC is a good device for
this because it’s powerful, especially when leveraged with software like Matlab.1

8.2 Overview
You’ll recreate the heartbeat code from the previous lab prior to conducting work on the serial port. You’ll
then set up a pair of counters whose value will later be transmitted to the PC via serial communication. After
a set time you’ll flash a “finished” signal on the Esduino’s LED. These steps are essential to help debug further
operations on your microcontroller. Then, you will write a program for the Esduino which outputs a stream of
data to be read by the PC on your lab bench. You’ll need to translate integer values into ASCII characters.
Finally, transcribe a Matlab program on the PC to read the data stream and to display it in a graph, as shown
in Fig. 8.1.

8.3 Background Information


In the last lab you got a taste for how systems should be designed, built and tested in small pieces: always start
with the least complex component! Last week, this was the LED as a display unit. However, in next year’s
EDP project, as well as projects you will tackle in industry, you likely will need to display more information
that what a simple LED can help you with.
With this in mind, you’ll be introduced to Matlab as a tool for data manipulation and display. It’s a
PC-based, industry-standard program, so this will be a useful experience for you. However, before Matlab can
process and display the data you’ll need to get the information off of your Esduino microcontroller board and
into the PC.
The 9s12c32 on the Esduino has a Serial Communication Interface (SCI) module that is capable of sending
information via a serial cable to a PC. Often, the SCI is connected to an RS-232 or RS-485 transceiver which
handles voltages that would usually be found on these types of cables. However, the Esduino has a special board,
the USB2MCU, which converts the voltages and data to be USB-compatible. On the PC-side, a software driver
tricks the operating system into thinking that the USB cable is actually an RS-232 cable. This is useful since
a lot of software has been written for RS-232, but few computers have that port anymore. That’s why the
Esduino comes with a USB interface – it has to plug into something.
Wait a minute! You use the USB cable to program the Esduino board using the memory-resident Serial
Monitor program that lives on the 9s12c32 chip. How can the same cable be used for both programming the
1
Mathworks Matlab and National Instruments Labview are two powerful PC-based products for data manipulation and display.
Both are heavily used in industry.

8-1
Figure 8.1: This is an Esduino board transmitting data to a Linux PC running Matlab. Note the USB cable in
the bottom-left and Matlab figure in the upper-right corners.

Esduino and for reporting data from the program you’ll write? The answer lies in the 9s12c32’s “Run” and
“Load” modes, as per JB6 seen in Fig. 7.2 on page 7-3. When you move the jumper on JB6 from “Auto”
(Automatic) to “Man” (Manual), you’ll be able to tell the 9s12c32 that you wish to operate with the Serial
Monitor on (“Load” on SW1) or off (“Run”). When in “Run” mode, the code your wrote will execute and
will permit you to stream serial data to the PC but you won’t be able to use the Serial Monitor to examine or
debug it – you’ll have to rely on LEDs and other external debugging tools. This is why the heartbeat LED is
so important.
Please note that when the Serial Monitor is running, the internal clock of the 9s12c32 will be at 24 MHz.
When you operate in “Run” mode, it will operate at 4 MHz. The reason is that the Phase Locked Loop (PLL)
module is engaged by the Serial Monitor to increase the frequency, but the PLL must be explictly called in your
own code in order to get it above 4MHz.
The internal clock of the 9s12c32 is important for many reasons, including:

• It affects the TIM timer module and, hence, code that relies on TCNT, for instance.

• It affects the rate of transmission of data on the SCI.

8-2 Edit Date: February 12, 2013


The rate of transmission in a serial device such as the SCI is called the “Baud” rate. It is calculated as:

Eclk
BR = (8.1)
16 ∗ [SCIBDH SCIBDL]
where BR is the Baud rate, Eclk is the internal clock frequency in Hz and [SCIBDH SCIBDL] is he 16-bit
value of these two registers, converted to Decimal from Hex or Binary. What would SCIBDH and SCIBDL
need to be if BR was 19200 baud and the Eclk was 4 MHz? You’ll need to know this for your lab.
You will need to get software on the PC to recognize and decode the serial data from your microcontroller.
Matlab is the main application that we will focus on. Matlab contains routines for speaking to serial devices2
such as the Esduino The Matlab serial routines are discussed here:

• For simple example, refer to http://www.mathworks.com/help/techdoc/matlab_external/f92576.html.

• For advanced examples, refer to Matlab Instrument Control Toolbox here: http://www.mathworks.com/
products/instrument/hardware/serial.html

Prior to testing your code in Matlab, you will want to verify that your microcontroller is sending serial
data correctly. This is usually done using a dedicated terminal program, such as RealTerm (on Windows) or
minicom (on Linux). When using the Linux machines in the ELCE Department, the Esduino will be detected at
“/dev/ttyUSB0” (that’s a zero at the end). So replace references to “COM8” or other Windows Communications
Ports with the Linux device name.
RealTerm (http://realterm.sourceforge.net/) is a very capable serial terminal program for Windows.
It’s much better than HyperTerm, and it’s free! Use it to test out the serial output from your Esduino first.
An example screenshot for RealTerm is found in Fig. 8.2.
Once you’ve established that serial communication is occuring in RealTerm or minicom, you’ll want to
implement the following commands in Matlab (change “COM8” for “/dev/ttyUSB0” if you are on a Linux
machine in the Department):

>> a=serial(’COM8’); % Use Device Manager (Windows) to verify this port. Assign to ‘a’
>> set(a,’BaudRate’,19200); % Set the speed to match the code running on Esduino.
>> fopen(a); % Open the ‘‘file’’ for ‘a’.
>> a % Report what is going on with this ‘file’

Serial Port Object : Serial-COM8

Communication Settings
Port: COM8
BaudRate: 19200
Terminator: ’LF’

Communication State
Status: open
RecordStatus: off

Read/Write State
TransferStatus: idle
BytesAvailable: 10
ValuesReceived: 40
ValuesSent: 0
2
The serial routines in Matlab permit you to connect very complex instruments, like oscilloscopes, power supplies, etc.! This
would be really useful for automated testing systems in industry.

8-3 Edit Date: February 12, 2013


Figure 8.2: RealTerm is set up for 19200 baud. Use the Windows Device Manager (right) to identify the correct
COM port that RealTerm is to use (COM 8 in this case, but it will likely be different on your computer!)

>> out=fscanf(a); % Wait for serial data to arrive. (waits for a Carriage Return?).
>> fclose(a) % close the ‘a’ file
>> delete(a) % delete the ‘a’ file
>> clear a % clear the variable, too.
>> out % What did Matlab capture on the serial port? It’s stored in ‘out’

out =

This is whatever the Esduino is spitting out via the SCI module onto the serial port of the PC

8-4 Edit Date: February 12, 2013


Figure 8.3: Matlab is set up for 19200 baud. Use the Windows Device Manager (right) to identify the correct
COM port that Matlab is to use (COM 8 in this case, but it will likely be different on your computer!)

8.4 Learning Objectives


In this learning module you will demonstrate the transmission of data from a microcontroller and the display
of said data on a computer on your lab bench. The following are the minimum set of learning objectives:

• Develop familiarity with the Serial Communication Interface (SCI) of the 9s12c32

• Understand how to enable Matlab to read raw ASCII character data from a serial port

• Develop an understanding for the sequence of verifiable steps that are recommended for establishing
communication between a microcontroller and a remote display terminal (PC)

• understand how to switch the 9s12c32’s memory-resident serial monitor off in order to run a program that
utilises the SCI.

• Deveop familitarity with basic graphing in Matlab

• Develop familiarity with parsing data in Matlab

8-5 Edit Date: February 12, 2013


• Undertsand how to modify timer characteristics on the 9s12c32 to compensate for changes in internal bus
clock frequency

8.5 Success Criteria


To judge the successful completion of your lab, you should read the following criteria for success:

• Display a graph in Matlab representing all of the time and data values streamed from the Esduino to your
TA. Include a labelled version in your report.

• Screenshot of your datastream in RealTerm or equivalent terminal program, included in your report

• A flashing LED “heartbeat” demonstrated to the TA, at the frequency specified in Section 8.7.1

• Summarize your results in a short, IEEE-style report, as per the instructions in the Communication
section

• Email your report to your TA by deadline described in the Communication section

• Your TA checked (and recorded on a check-sheet) that

– Your heartbeat LED flashed at the correct frequency.


– Your “end-of-transmssion” LED signal message worked
– Your test transmission of ‘A’ to a terminal program occurred
– Your data stream was captured by Matlab and displayed in a graph

8.6 Pre-lab & Pre-Requisites


Go over the following prior to the lab:

Complete the Week 2 lab

Review the methods for adjusting the Timer module’s frequency

Review the SCI (Serial Communication Interface) registers for the 9s12c32, as per the manual. What registers
need to be adjusted to change the transmission rate? How is it affected by the 9s12c32’s internal bus
clock?

8.7 Exploration
The following are the tasks that youa re to undertake in this lab session.

8.7.1 Heartbeat Code


Begin a new Codewarrior project. In the main.c file, write heartbeat code which will flash the PM5 LED

• Once per second for Section 1

• Once per two seconds for Section 2

• Once per three seconds for Section 3

Test and demonstrate to your TA. Have TA record your successful completion of this portion of the lab.

8-6 Edit Date: February 12, 2013


8.7.2 Write Counter Code
Establish two 16-bit integer counters, one to keep track of time and the other is your data value. Your time
counter must increment once per flash of your PM5 LED. Your data counter must increment at twice the rate
of the time counter. After one minute of execution, stop the counting and have the LED flash visibly three
times in quick succession.
Test and demonstrate to your TA. Have TA record your successful completion of this portion of the lab.

8.7.3 Initialise the SCI


You need to configure the SCI for transmission. Assume that you will do so by placing the ESduino in “Run”
mode so that the Serial Monitor is off. This makes the 9s12c32’s internal clock run at 4 MHz instead of 24
MHz. In your initialisation, set up the SCI for 19200 baud, no Parity, 1 start bit, 1 stop bit, and enable the
transmitter (but not the receiver) of the SCI.

8.7.4 Test SCI transmission of single character


Test the transmission of a single character (ASCII ‘A’ (Hex: 0x41)). Write a routine that sends the letter ‘A’
(ASCII ‘A’ (Hex: 0x41)) to the serial port once per LED-heartbeat flash. Use RealTerm in VMWare Windows
to read the serial line. Turn off the HiWave debugger program first. In fact, follow these instruction:

• Download your code using the Serial Monitor. Do not run it.

• Unplug power to the Esduino.

• Turn off the Hi-Wave debugger program

• Make sure Jumper JB6 is set to “Man”, and not to “Auto”. (see Fig. 7.2 on page 7-3)

• Move SW1 to “Run” mode (see Fig. 7.2 on page 7-3)

• Plug in power to Esduino. Press reset (SW2 of Fig. 7.2 on page 7-3)

Does the LED still flash? If not, check JB6 and SW1. Is it running at the right frequency? Remember the
internal clock has been reduced to 4MHz! Still no serial data? Unplug the serial line and recheck your code
with only LED/Timing intact.
If the LED was working fine, configure RealTerm for 19200 baud, Stop/Start bits, No parity, hardware flow
control off. Select the right serial port, too (typically 3 or 5). Click “Open” and “Change” as shown in Fig. 8.2
on page 8-4. Then reset Esduino and check for characters in RealTerm.
Test and demonstrate to your TA. Have TA record your successful completion of this portion of the lab.

8.7.5 Modify Serial Stream


Change your code so that it now outputs T TimeValue CR LF D DataValue CR LF, where T and D
are markers to tell Matlab what is Time and what is Data, CR and LF and the ASCII characters for Carriage
Return and Line Feed (0x0D and 0x0A), and TimeValue is the value of your time counter, while DataValue is
the value of your data counter.
Use the sprintf() function in the stdio.h library to convert integer values to ASCII for serial transmission.
Verify the transmission in RealTerm (on a Windows machine) or minicom (on a Linux machine; minicom
should default to “/dev/ttyUSB0”).
Test and demonstrate to your TA. Have TA record your successful completion of this portion of the lab.

8-7 Edit Date: February 12, 2013


8.7.6 Graph the Results in Matlab
Using the example given in the Background, write a Matlab script that will then call plot() to plot the data
(Time information on the x-axis, with the remaining data on the y-axis.) Remember that if you are running
Matlab under Linux, you will need to name the communication port that the Esduino is connected to. In the
Department labs it is “/dev/ttyUSB0”.
Test and demonstrate to your TA. Have TA record your successful completion of this portion of the lab.

8.8 Skill Questions


1. What is the Serial Monitor? Answer in less than 30 words.

2. What is the difference in function between the Serial Monitor and a Background Debugger Module (BDM)?
Answer in less than 30 words.

3. Draw a block diagram which shows the flow of information between the PC and the 9s12c32 chip on your
Esduino. To be included are: PC, Esduino Board, 9s12c32, SCI module, USB2MCU, USB cable, USB
port, Matlab.

8.9 Bonus Objectives


Bonus points are awarded to the first group in a particular lab section that is able to accomplish all of the
demonstrable items of the lab, plus the bonus objective, listed below. The bonus activity must be demonstrated
to the lab TA prior to the end of the lab session. The bonus is applied to your current lab and cannot result
in a mark above 100% for the current lab assignment. Your final lab grade cannot exceed 100%, however.

• Section 1: determine and implement a method for running the serial interface between the Esduino and
Matlab at a baud rate above 19200 baud. (10% bonus to this week’s grade)

• Section 2: Plot individual data points on a Matlab graph immediately as they arrive via the serial
communication routines. No significant lag should be perceivable by the TA. (10% bonus to this week’s
grade)

• Sections 3 and 4: Demonstrate reception of serial data by the microcontrolller from the PC by flashing
the Esduino’s LED a fixed number of times: five times for the ASCII ’A’ character and ten times for the
ASCII ’B’ character. (10% bonus to this week’s grade)

In each case you must demonstrate the functionality to the TA during the lab and you must include a copy
of your source code in your report.

8.10 Communication
Work with your partner to

1. Demonstrate all of the demonstratable items to the TA prior to the end of the lab

2. Answer the “Skill Questions” above.

3. Save screen capture of the RealTerm program

4. Save graphical copies of your Matlab graphs

8-8 Edit Date: February 12, 2013


In reporting to the TA, you will be required to provide preliminary answers prior to leaving the lab. You
will then email a PDF report to the TA with formal evidence that you were able to achieve the above items.
The report must be two to three pages in length and must adhere to IEEE reporting standards.
The email containing the report is due two days after your lab. It must be emailed to the TA by 11:59
pm on the second day after your lab.
Include the following sections in your lab report:

• An official cover page, signed by both partners

• Header with Student Names and IDs

• Title

• Author list (with names and student IDs) below the title

• Abstact (three to five sentences)

– Be brief and to the point.

• Introduction (ten to twenty sentences)

– What is the lab about? Don’t just copy the lab description (that’s plagiarism!). Write it in your
own words.
– Reference books, tech manuals, etc. that are useful for your lab.

• Methods (ten to thirty sentences)

– Each paragraph should describe a different component of the lab that you undertook.
– What hardware and software was used in each section. What did you do with them?

• Results and Discussion (ten to thirty sentences)

– Give “hard” numbers here as part of your results. Graphed results should be here, too.
– As part of the discussion, ask yourself what the results tell you about the operation of your Esduino
board as a Data Acquisition System. Was the gathering of one piece of data particularly hard? If so,
describe that and how it relates to the values your got – reference your data and the figures by saying
“as seen in Figure XX and Table YY.” Look at the “Post-Lab Reflection” in the lab description.
Does it give you ideas for further discussion?

• Conclusion (five to ten sentences)

• Skill Questions

– answer the questions here.

• Appendix (does not counter towards your page count)

– include a copy of your source code. Submit the text file separate from your document.

A marking guide / rubric is found at the end of this chapter. Use it as a guideline for fulfilling the
requirements for the document that you are to submit to the TA.

8-9 Edit Date: February 12, 2013


8.11 Post-lab reflection
How would you develop a system that could automatically monitor the operation of the Esduino from a inac-
cessible location? What kind of messages would the local PC need to send to the Esduino? What kind of cable
and data transmission standard would be needed, if USB cables were too short?
More immediately, how can this system help you calibrate the load cell and accelerometer sensors in future
labs? In the past, students had to take individual measurements by hand. With a serial connection to the PC
what advantages does this present to you that previous students didn’t have?
In the future, what kind of summer or full-time engineering job could you have that would benefit from this
kind of system?

8.12 Post-lab work: Examine the LCD


Next week, you will build and test the LCD module that will attach to the Esduino board. Because the lab
session is so short, you’ll have to plan the wiring for the LCD module ahead of time. Make sure that you
understand how the LCD will connect to the Esduino, via the Serial Peripheral Interface (SPI). This is the
second serial interface that the Esduino’s 9s12c32 has. It operates differently than the SCI, so you’ll have to
review its function.

8-10 Edit Date: February 12, 2013


ELE604 Week 3 Marking Guide (Lab) 2012
• Counter Code (10% of total mark)
o 3-Flash LED shown in lab (10/10)
o Counters coded but no Flashing (5/10)
o Neither (0/10)
• SCI Transmission of ‘A’ (20% of total)
o ‘A’ TX’d: 9s12 to terminal (20/20) Deductions
o No TX, but code is “reasonable” • Lateness (Report)
(10/20) o -25 pts (up to 1 day)
o Otherwise (0/20) o -100 pts (beyond one day)
• Serial Stream (20% of total mark) • Lateness (Wire plan in Lab)
o Time+Data serial stream in terminal o -25 pts (after 30 minutes)
(20/20) • Font Modification (IEEE Template: Times
o No serial stream, but “reasonable” code New Roman 10pt in main body, 24pt in title,
(10/20) 8pt in References)
o Otherwise (0/20) o -25 pts (any changes)
• Graphed Data in Matlab (20% of total mark) • No Cover Sheet (FEAS official)
o Graph of both counters, for about one o -25 pts
minute of data (20/20) • Template Modification (margins, borders,
o Matlab captures any data from 9s12 header placement, etc.)
(10/20) o -25 pts (any changes)
o Otherwise (0/20) • Number of Pages
• Skill Questions (30% of total mark) o -25 pts (~3/4 of req’d)
o Three correct (30/30) o -50 pts (~1/2 of req’d)
o Two correct (20/30) o -75 pts (anything less)
o One correct (10/30)
o None correct (0)

Left Column Total Right Column Deduction

Your grade:

How is your grade calculated?

In the left column, your citations, language and content are evaluated. The marking is based on how well you
perform in each of those items. The individual scores are added up and written in the box below the column.
Afterwards, deductions are is made based on the factors in the right hand column. The deductions are
cumulative and can reduce your grade to 0 (minimum).
** Note: Use the IEEE Template Word document for ELE604! **
** Don’t change the template! **
** Go to www.ee.ryerson.ca/~jasmith/courses/ele604/support_docs for the template **
Page Number Mark Adjustment
- Based on length requirement. If you submit only about 75% of the number of pages you were
supposed to, your mark will be reduced by 25%.
- If you submit less than 75% of a complete page it is considered an incomplete page and is not
considered in your total page count.
- If a disproportionate amount of your article is taken up by tables, figures or quotations from other sources
your mark will be reduced accordingly. Be reasonable with your usage of figures, photos, images, diagrams,
tables and quotations. (For instance, if three-quarters of a page is taken up by a table or figures, leaving little
room for your own text, then the Page Number Adjustment will apply)
- Examples:
1) Hand in a two page project that was supposed to be four pages: your project mark will drop by
50 points.
2) Hand in a 3.5 page project instead of four pages: your project mark will drop by 25 points.
3) Hand in a four page paper, but one complete page is a table from another source, your project
mark will drop by 25 points.

Plagiarism, Copying, etc.


Remember: Plagiarism is wrong! If you copy from a book, journal or online source (or your friend)
without permission and/or citation you will receive 0 and may receive a record on your transcript.
8-12 Edit Date: February 12, 2013
Chapter 9

Week 4: Displaying Data, Part 2: Onboard LCD

9.1 Straight to the Point


You need to be able to display measurement data directly on your Esduino board when taking measurements.
Here, you’ll build an add-on board with a Liquid Crystal Display (LCD) that will display your name and the
name of your lab partner.

9.2 Overview
Last week, you demonstrated how to send data from your microntroller to a PC for display. This week, you
will build the LCD board (as shown in Fig. 9.1) and test it using the code provided. The Esduino is hardware
compatible with the very popular Arduino platform. This experience will enable you to more easily explore
other Arduino-compatible application boards in your future endeavours.1

Figure 9.1: An example of an LCD “shield” for the Esduino board.

9.3 Background Information


Liquid Crystal Displays (LCDs) are commonly used to display information on microcontroller and micropro-
cessors. They generally have a built-in controller that responds to commands using either serial or parallel
interfaces. The LCD in your COE 538 class had a parallel interface, whereas the LCD used on the Esduino has
a serial interface. More specifically, the LCD board uses the Serial Peripheral Interface (SPI) that is common
on many microcontrollers, microprocessors and digital signal processors. Why serial instead of parallel? The
1
The Arduino application boards are called “shields” and include GPS modules, motor drivers, graphical LCDs, Muscle EMG
sensor interfaces, autopilot navigation boards for aircraft, etc. Find out more here: http://www.arduino.cc/en/Main/arduinoShields

9-1
Esduino doesn’t have enough free pins to support both a parallel LCD display and all the other devices that
we need to connect to it!

9.4 Learning Objectives


• Improve solder skills
• Discover how to develop an application board that is compatible with both the Esduino and alternative
Arduino
• Become more familiar with the Codewarrior IDE
• Become familiar with an example Serial Peripheral Interface (SPI) device
• Increase familiarity with the operation of pins and headers on the Esduino

9.5 Success Criteria


This week, successful students will have built an LCD board and tested it on the TA’s Esduino, then on their
own.

9.6 Pre-lab & Pre-Requisites


You are required to go over the following material prior to the lab.

uC board design The functionality described in Fig 7.2. What is the difference between Port T and Port AN
pins? How is the USB connection used?
Review LCD specifications They are found at http://www.lcd-module.com/eng/pdf/doma/dog-me.pdf
and in Appendix F.
Review SPI specifications on Esduino What does SPI stand for? What is the difference between MISO
and MOSI? What voltage levels are used on the 9s12’s SPI port? Which headers on the Esduino contain
SPI pins?

Below you will find snippets of source code that need to be incorporated into your lab project. The code
snippets don’t include any information on how to call these functions, nor how they should be inserted into
your main function. The timer setup function is not included, either. That is up to you to determine!

9.6.1 Source code snippets


The following are components that should be incorporated in your code for this lab. This code snippets help
to initialise and drive operation of the LCD. Review them as part of your preparation for the lab. Listing 9.1
describes how to set up the SPI module to permit one-way communication from the 9s12 master to the LCD
slave. The next listing, Listing 9.2 contains two similar functions for either sending 8-bit command or data
packets to the LCD module.
The commands in Listing 9.2 are then called by the LCD initialisation routine in Listing 9.3 to start up the
LCD module. It is important to note that the sample code given is for a “162” version of the LCD; that is,
a two-line LCD. Your LCD has three lines (rows). You will need to examine the datasheet for the LCD and
determine what changes need to be made to the code to accomodate the third row.
Once you have initialised the LCD Listing 9.4 describes methods for manipulating the LCD’s cursor. There
are other methods, described in LCD’s documentation, which have not been included. Finally, Listing 9.5
describes the method for sending a string to the LCD.

9-2 Edit Date: February 12, 2013


Listing 9.1: SPI Initialisation code
/∗ − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − −
∗ F u n c t i o n : ” s p i l c d i n i t ( ) ” : I n i t i a l i s e SPI f o r u s e w i t h t h e LCD

∗ T h i s f u n c t i o n c o n f i g u r e s t h e SPI m o d u l e on t h e 9 s 1 2 c 3 2 .

∗ Input : nothing
∗ Output : n o t h i n g

∗ We n e e d t o c o n f i g u r e t h e f o l l o w i n g SPI p i n s :

∗ MOSI : M a s t e r−Out−S l a v e −I n PM4
∗ SS∗ / OE∗ : S l a v e S e l e c t / Output Enable PT3
∗ SCK : Clock PM5

∗ N o t e t h a t we ’ v e r e p l a c e d t h e S l a v e S e l e c t ( n o r m a l l y f o u n d on PM3) w i t h
∗ an O u t p u t E n a b l e (OE) on PT3 .

∗ Source :
∗ 1 . Ron Wong ’ s a s s e m b l e r c o d e ( 2 0 1 1 )
∗ 2 . MC9s12C−F a m i l y manual R . 0 1 . 2 3 , p g . 4 1 9 .
∗ − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − ∗/
void s p i l c d i n i t ( void )
{
// C o n f i g u r e S l a v e S e l e c t / O u t p u t E n a b l e . Note t h a t i t i s a c t i v e low .
DDRT DDRT3=1; // S e t P o r t T ’ s PT3 a s o u t p u t .

// S e t P o r t M, MISO i s i n p u t ( 0 ) and SCK a s o u t p u t ( 1 )


DDRM DDRM2=0; // MISO ( M a s t e r I n S l a v e Out ) i s an i n p u t
DDRM DDRM5=1; // SCK ( C l o c k ) i s an o u t p u t

// S e t t h e SPI c o n t r o l r e g i s t e r s
SPICR1=0x50 ; // SPI C o n t r o l R e g i s t e r 1 , b i t 7 : I n t e r r u p t Enable , b i t 4 : MSTR
SPICR2=0x00 ; // SPI C o n t r o l R e g i s t e r 2 , b i t [ 7 : 0 ] − Disabled

/∗ S e t t h e SPI b a u d r a t e r e g i s t e r
∗ For a Baud r a t e o f 375 kHz and an i n t e r n a l b u s c l o c k o f 24MHz
∗ we n e e d t o s e t t h e d i v i s o r t o 64 ( a s p e r t h e e q u a t i o n on
∗ MC9s12C−F a m i l y manual R . 0 1 . 2 3 , p g . 4 1 9 . )
∗/
SPIBR=0x05 ; // d i v i s o r i s 2 ˆ ( 0 x 0 5 + 1 ) = 6 4 . ; BR = 2 4 0 0 0 0 0 0 / 6 4 .
}

Listing 9.2: SPI-based commands to the LCD

/∗ − − − − − − − − − − − − − − − − − − −− − − − − − − −
∗ Function : spi write lcd command ()

∗ i n p u t : 8− b i t ( c h a r ) v a l u e
∗ o u t p u t : commands t o LCD ( m o s t l y u n s e e n b y u s e r )

∗ M o d i f i e d f r o m C−v e r s i o n o f t h e SPI w r i t i n g c o d e :
∗ www . e e . nmt . e d u /˜ e r i v e s / 3 0 8 0 8 / L e c t u r e 2 3 . p d f
∗ Assume t h a t PT3 i s t h e s l a v e s e l e c t .
∗ − − − − − − − − − − − − − − − − − − −− − − − − − − − ∗/
void s p i w r i t e l c d c o m m a n d ( char d a t a o u t ) {

i n t tmp ;

/∗ 8− b i t data length , 1 line , instruction table 1 ( see datasheet ) ∗/


asm{
BCLR PTT,# $08
}
while ( ( SPISR & 0 x20 ) ==0); /∗ w a i t u n t i l SPTEF f l a g s e t ∗/
SPIDR = dataout ; /∗ w r i t e d a t a t o d e v i c e ∗/
while ( ( SPISR & 0 x80 ) ==0); /∗ w a i t u n t i l t r a n s m i s s i o n c o m p l e t e ∗/
tmp = SPIDR ; /∗ Read d a t a r e g i s t e r t o c l e a r SPIF ∗/
asm{
BSET PTT,# $08
}
}

/∗ − − − − − − − − − − − − − − − − − − −− − − − − − − −
∗ Function : s p i w r i t e l c d d a t a ()

∗ i n p u t : 8− b i t ( c h a r ) v a l u e
∗ o u t p u t : s y m b o l s on t h e LCD .

∗ M o d i f i e d f r o m C−v e r s i o n o f t h e SPI w r i t i n g c o d e :
∗ www . e e . nmt . e d u /˜ e r i v e s / 3 0 8 0 8 / L e c t u r e 2 3 . p d f
∗ Assume t h a t PT3 i s t h e s l a v e s e l e c t .
∗ − − − − − − − − − − − − − − − − − − −− − − − − − − − ∗/
void s p i w r i t e l c d d a t a ( char d a t a o u t ) {

i n t tmp ;

/∗ 8− b i t data length , 1 line , instruction table 1 ( see datasheet ) ∗/


asm{
BSET PTT,# $08
}
while ( ( SPISR & 0 x20 ) ==0); /∗ w a i t u n t i l SPTEF f l a g set ∗/

9-3 Edit Date: February 12, 2013


SPIDR = d a t a o u t ; /∗ w r i t e d a t a t o d e v i c e ∗/
while ( ( SPISR & 0 x80 ) ==0); /∗ w a i t until t r a n s m i s s i o n c o m p l e t e ∗/
tmp = SPIDR ; /∗ Read d a t a r e g i s t e r t o c l e a r SPIF ∗/
asm{
BCLR PTT,# $08
}
}

Listing 9.3: LCD Initialisation code which is designed for a two-line LCD. You may need to modify the first six
steps for a three-line LCD
/∗ − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − −
∗ F u n c t i o n : ” l c d i n i t ( ) ” : I n i t i a l i s e t h e LCD w i t h a c u r s o r on t h e s c r e e n

∗ Code m o d i f i e d f r o m Ron Wong ’ s m a i n v 2 . asm (2011)

∗ The s e q u e n c e i s b a s e d on ” Example o f i n i t i a l i s a t i o n : 8 b i t / 5V EA DOGM163”
∗ f o u n d on p a g e 7 on dog−me . p d f ( h t t p : / / www . l c d −m o d u l e . d e / e n g / p d f /doma/ dog−me . p d f )
∗ C−v e r s i o n o f t h e SPI w r i t i n g c o d e :
∗ www . e e . nmt . e d u /˜ e r i v e s / 3 0 8 0 8 / L e c t u r e 2 3 . p d f

∗ 2 L i n e DOG D i s p l a y 1 6 2 , 5 v :
∗ 9 steps
∗ −−−−−−−−−−−−−−−−−−−−−−−−
∗ 1 . $39 ( Function s e t )
∗ 2 . $1C ( B i a s s e t )
∗ 3 . $ 5 2 ( Power C o n t r o l )
∗ 4 . $69 ( F o l l o w e r C o n t r o l )
∗ 5 . $74 ( C o n t r a s t Set )
∗ 6 . $38 ( Function Set )
∗ − − − − −
∗ 7 . $0F ( D i s p l a y On)
∗ 8 . $01 ( Clear D i s p l a y )
∗ 9 . $ 0 6 ( E n t r y Mode S e t )

∗ James A . S m i t h ; Oct / Dec 2 0 1 1 .
∗ − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − ∗/
void l c d i n i t ( void ) {

/∗ S t e p s 1 − 6 n e e d t o b e c u s t o m i z e d f o r e a c h EA Dog d i s p l a y ∗/
/∗ S t e p 1 ∗/
Timer mwait ( 5 0 ) ; /∗ n e e d 40 msec + a f t e r power−up ∗/
s p i w r i t e l c d c o m m a n d ( 0 x31 ) ; //

/∗ S t e p 2 ∗/
Timer mwait ( 5 0 ) ; /∗ T h i s can b e 2 msec o r less ∗/
s p i w r i t e l c d c o m m a n d ( 0 x1C ) ; //

/∗ S t e p 3 ∗/
Timer mwait ( 5 0 ) ; /∗ T h i s can b e 2 msec o r less ∗/
s p i w r i t e l c d c o m m a n d ( 0 x51 ) ; //

/∗ S t e p 4 ∗/
Timer mwait ( 5 0 ) ; /∗ T h i s can b e 2 msec o r less ∗/
s p i w r i t e l c d c o m m a n d ( 0 x6A ) ; //

/∗ S t e p 5 ∗/
Timer mwait ( 2 0 0 ) ; /∗ T h i s must b e 200 msec o r more ∗/
s p i w r i t e l c d c o m m a n d ( 0 x74 ) ; //

/∗ S t e p 6 ∗/
Timer mwait ( 5 0 ) ; /∗ T h i s can b e 2 msec o r less ∗/
s p i w r i t e l c d c o m m a n d ( 0 x30 ) ; //

/∗ S t e p s 7 − 9 a r e common b e t w e e n a l l EA DOG d i s p l a y s ∗/

/∗ S t e p 7 ( D i s p l a y On) ∗/
Timer mwait ( 5 0 ) ; /∗ T h i s can b e 2 msec o r less ∗/
s p i w r i t e l c d c o m m a n d ( 0 x0F ) ;

/∗ S t e p 8 ( C l e a r D i s p l a y ) ∗/
Timer mwait ( 5 0 ) ; /∗ T h i s can b e 2 msec o r less ∗/
s p i w r i t e l c d c o m m a n d ( 0 x01 ) ;

/∗ S t e p 9 ( E n t r y Mode S e t ) ∗/
Timer mwait ( 2 0 0 ) ; /∗ T h i s can b e 2 msec o r less ? ? ? ? ? ∗/
s p i w r i t e l c d c o m m a n d ( 0 x06 ) ;

/∗ S t e p s 10+ a r e n o t r e q u i r e d ∗/
Timer mwait ( 2 ) ; // DEBUG
s p i w r i t e l c d c o m m a n d ( 0 x33 ) ; // DEBUG

Listing 9.4: LCD cursor code


/∗ − − − − − − − − − − − − − − − − − − −− − − − − − − −
∗ Function : l c d c u r s o r o f f ()

9-4 Edit Date: February 12, 2013


∗ Turns t h e c u r s o r o f f on t h e LCD . This i s n ec e ss ar y
∗ b e f o r e l e t t e r s can b e w r i t t e n t o t h e s c r e e n .

∗ input : nothing .
∗ o u t p u t : t u r n s t h e LCD ’ s c u r s o r o f f
∗ − − − − − − − − − − − − − − − − − − −− − − − − − − − ∗/
void l c d c u r s o r o f f ( void ) {
Timer mwait ( 5 0 ) ; /∗ T h i s can b e 2 msec o r l e s s ∗/
s p i w r i t e l c d c o m m a n d ( 0 x0C ) ; /∗ command ∗/
}

/∗ − − − − − − − − − − − − − − − − − − −− − − − − − − −
∗ Function : lcd go home ()

∗ Sends t h e c u r s o r t o t h e upper r i g h t corner .

∗ input : nothing .
∗ o u t p u t : p o s i t i o n s t h e c u r s o r a t ” home ”
∗ − − − − − − − − − − − − − − − − − − −− − − − − − − − ∗/
void l c d g o h o m e ( void ) {
Timer mwait ( 2 ) ; /∗ T h i s can b e 2 msec o r l e s s ∗/
s p i w r i t e l c d c o m m a n d ( 0 x02 ) ; /∗ command ∗/
}

Listing 9.5: LCD string output


/∗ − − − − − − − − − − − − − − − − − − −− − − − − − − −
∗ Function : SPI LCD OutString ( )

∗ Outputs a string to t h e SPI−c o n n e c t e d LCD

∗ input : a pointer to a character s t r i n g . .
∗ o u t p u t : s t r i n g d i s p l a y e d on t h e SPI LCD

∗ B a s e d on SCI s e r i a l s t r i n g r o u t i n e b y Jon V a l v a n o .
∗ − − − − − − − − − − − − − − − − − − −− − − − − − − − ∗/

void SPI LCD OutString ( char ∗ p t ) {


while ( ∗ p t ) {
s p i w r i t e l c d d a t a (∗ pt ) ;
p t++;
}
}

9.7 More Resources


1. Freescale HCS12 University website: http://www.freescale.com/webapp/sps/site/overview.jsp?code=
UNIV_REFERENCE_HCS12_CAT

(a) Look under the HCS12C category as well as Course Material − > HCS12C
(b) The Microcontroller - General Principles by Fred Cady (search for “LABS12CINTRO01S.doc”)
(c) General Principals - Software Development by Fred Cady (search for “LABS12CINTRO02S.doc”)
(d) Exploring Embedded C Programming by Fred Cady (search for “LABS12CINTRO06.doc”)
(e) Serial Monitor Program for HCS12 MCUs by Jim Williams, Application Note AN2548/D [16]
(f) MC9S12C Family / MC9S12GC Family Reference Manual, #MC9S12C128 Rev 01.23 05/2007 by
Freescale Semiconductor (available as a free download online)

2. LCD (EA DOGM163W-A) Datasheet:http://www.lcd-module.com/eng/pdf/doma/dog-me.pdf and Ap-


pendix F.

3. The chapter on Equipment and Tools, Ch. 3 of this manual.

4. The chapter on design aspects of this lab, Ch. 2 of this manual.

5. The Technological Arts website, http://www.technologicalarts.com/, (Tech. Arts makes the Esduino)

• Source code examples: http://support.technologicalarts.ca/docs/Esduino/Code/

6. The website for the AVR-based Arduino project, http://www.arduino.cc/ (this is related to the Es-
duino).

9-5 Edit Date: February 12, 2013


9.8 Exploration
You will have to divide up the work between both lab partners in order to work simultaneously towards the
goals of the lab. One of you should work on the C software and one of you on the LCD board assembly and
soldering. Make sure to discuss both aspects between yourselves as you proceed.

9.8.1 LCD Hardware for the Esduino


Your first task is to put together the LCD (Electronic Assembly ED DOGM163W-A, 3 Line, 5V SPI). Why?
Because it will be used to display all kinds of valuable information from your microcontroller. You should use
the guide in Appendix F on pg. F-1. It turns out that the SPI signals that we are interested in using are
available on the “North” headers of the Esduino. Which ones? Consider this as you plan your design. Make
sure to examine the LCD information in Appendix F beginning on page F-1.
Once you are done building the board, test it out on the TA’s Esduino. Once that works and your own
LCD code is done, test it out on your Esduino (see the next section).

9.8.2 LCD Programming via SPI


Your second task is to program the Esduino so that it can control the LCD. You will need to do so from the
Serial Monitor. Code snippets for setting up the SPI and for driving the LCD are given in Section 9.6.1 on
page 9-2. While the code snippets are helpful, there are a number of aspects missing from the code snippets
which you are responsible for implementing.
Your final version of the code should contain no “hard-coded” values in the body of the code. These should
be replaced with defined values (defined at the top of your .c file). For example, replace my_lcd(0x0A) with a
my_lcd(MY_PARAMETER) and, at the top of your file, #define MY_PARAMETER 0x0A
Test out your LCD with your Esduino and the code you prepared once you have tested the LCD hardware
on the TA’s Esduino. To test your LCD have it display your name and also the name of your lab partner.

9.9 Skill Questions


• Describe what changes you would need to implement if you wanted to drive two SPI slave devices from
the same SPI master? (e.g. two LCDs connected to one Esduino)

• What is meant by the Slave Select (or Output Enable) having a star beside it (or a bar above)?

• How many pins would be required to drive a parallel version of the EA DOG display?

9.10 Bonus Objectives


Many labs have bonus objectives. Here is a list for this lab.

9.10.1 All Sections, All Students


Any group that uses 30 gauge “wire-wrap” wire instead of 20-22 gauge wire to wire-up their LCD board gets
5% bonus. This is open to all students that complete the lab on time. The bonus is applied to your current lab
and cannot result in a mark above 100% for the current lab assignment. Your final lab grade cannot exceed
100%, however.

9-6 Edit Date: February 12, 2013


9.10.2 Section-by-Section, First Group to Finish
Bonus points are awarded to the first group in a particular lab section that is able to accomplish all of the
demonstrable items of the lab, plus the bonus objective, listed below. The bonus activity must be demonstrated
to the lab TA prior to the end of the lab session. The bonus is applied to your current lab and cannot result
in a mark above 100% for the current lab assignment. Your final lab grade cannot exceed 100%, however.

• Section 1: Make the letter ‘A’ scroll back-and-forth on the first line of your LCD. (10% bonus to this
week’s grade)

• Section 2: Rewrite the spi_write_lcd_command() and lcd_init() commands in Assembler so that they
function as well as the C versons. (10% bonus to this week’s grade)

• Sections 3 and 4: Have the LCD display a character sent to the Esduino from Matlab or from a PC-based
terminal program. (10% bonus to this week’s grade)

In each case you must demonstrate the functionality to the TA during the lab and you must include a copy
of your source code in your report.

9.11 Communication
Work with your partner to

1. Demonstrate all of the demonstratable items to the TA prior to the end of the lab

2. Answer the “Skill Questions” above.

In reporting to the TA, you will be required to provide preliminary answers prior to leaving the lab. You
will then email a PDF report to the TA with formal evidence that you were able to achieve the above items.
The report must be one-and-a-half to two pages in length and must adhere to IEEE reporting standards.
The email containing the report is due two days after your lab. It must be emailed to the TA by 11:59
pm on the second day after your lab.
Include the following sections in your lab report:

• An official cover page, signed by both partners

• Header with Student Names and IDs

• Title

• Author list (with names and student IDs) below the title

• Abstact (three to five sentences)

– Be brief and to the point.

• Introduction (ten to twenty sentences)

– What is the lab about? Don’t just copy the lab description (that’s plagiarism!). Write it in your
own words.
– Reference books, tech manuals, etc. that are useful for your lab.

• Methods (ten to thirty sentences)

– Each paragraph should describe a different component of the lab that you undertook.

9-7 Edit Date: February 12, 2013


– What hardware and software was used in each section. What did you do with them?

• Results and Discussion (ten to thirty sentences)

– There likely won’t be “hard numbers” to include here.


– Rather, describe the qualitative (not quantitative) result of displaying information on the LCD.
– How do you think that this LCD will help you with future tasks in the lab?

• Conclusion (five to ten sentences)

• Skill Questions

– answer the questions here.

• Appendix (does not counter towards your page count)

– include a copy of your source code. Submit the text file separate from your document.

A marking guide / rubric is found at the end of this chapter. Use it as a guideline for fulfilling the
requirements for the document that you are to submit to the TA.

9.12 Post-lab reflection


How do you think that you can utilise this LCD in your future labs? Can this display complement the data
that you gather and display in Matlab? When would you use this display rather than the PC?

9.13 Post-lab work


In the next lab you will return to the LED. This time, however, you will design and implement driver hardware
for the LED. In addition you will explore noise in switches (bouncing).
To prepare yourself for the next lab you should explore the MapleSim simulation software. There are two
tutorials in the Appendix. MapleSim will be used to simulate the source of bouncing in switches and you will
use it to explore filtering methods.

9-8 Edit Date: February 12, 2013


ELE604 Week 4 Marking Guide (Lab) 2012
• Soldered LCD Board (30%)
o Fully functional on TA board (30/30)
o Intermittent function (20/30) Deductions
o No function; visual inspection okay • Lateness (Report)
(10/30) o -25 pts (up to 1 day)
o Otherwise (0/30) o -100 pts (beyond one day)
• LCD Code (30% of total mark) • Font Modification (IEEE Template: Times
o Full function on TA or group board New Roman 10pt in main body, 24pt in title,
(30/30) 8pt in References)
o Partially working (displaying) on either o -25 pts (any changes)
board (15/30) • No Cover Sheet (FEAS official)
o Otherwise (0/30) o -25 pts
• No hard-coded numbers in code body; replaced • Template Modification (margins, borders,
with “defines” (10% of total) header placement, etc.)
o Yes (10/10) o -25 pts (any changes)
o No (0/10) • Number of Pages
• Skill Questions (30% of total mark) o -25 pts (~3/4 of req’d)
o Three correct (30/30) o -50 pts (~1/2 of req’d)
o Two correct (20/30) o -75 pts (anything less)
o One correct (10/30) • No Source code as separate file
o None correct (0) o -25 pts

Left Column Total Right Column Deduction

Your grade:

How is your grade calculated?

In the left column, your citations, language and content are evaluated. The marking is based on how well you
perform in each of those items. The individual scores are added up and written in the box below the column.
Afterwards, deductions are is made based on the factors in the right hand column. The deductions are
cumulative and can reduce your grade to 0 (minimum).
** Note: Use the IEEE Template Word document for ELE604! **
** Don’t change the template! **
** Go to www.ee.ryerson.ca/~jasmith/courses/ele604/support_docs for the template **
Page Number Mark Adjustment
- Based on length requirement. If you submit only about 75% of the number of pages you were
supposed to, your mark will be reduced by 25%.
- If you submit less than 75% of a complete page it is considered an incomplete page and is not
considered in your total page count.
- If a disproportionate amount of your article is taken up by tables, figures or quotations from other sources
your mark will be reduced accordingly. Be reasonable with your usage of figures, photos, images, diagrams,
tables and quotations. (For instance, if three-quarters of a page is taken up by a table or figures, leaving little
room for your own text, then the Page Number Adjustment will apply)
- Examples:
1) Hand in a two page project that was supposed to be four pages: your project mark will drop by
50 points.
2) Hand in a 3.5 page project instead of four pages: your project mark will drop by 25 points.
3) Hand in a four page paper, but one complete page is a table from another source, your project
mark will drop by 25 points.

Plagiarism, Copying, etc.


Remember: Plagiarism is wrong! If you copy from a book, journal or online source (or your friend)
without permission and/or citation you will receive 0 and may receive a record on your transcript.
9-10 Edit Date: February 12, 2013
Chapter 10

Weeks 5 and 6: Milestone 1 – Switches and LEDs

10.1 Straight to the Point


In Week 2 you implemented code to flash an LED. This week you’ll design a hardware LED driver and learn
how to avoid the biggest problem with switches: contact bounce!

10.2 Overview
In this session you are to demonstrate to the TA a fully-functioning microcontroller, with LEDs and a switch.
You are to write and run a test program which demonstrates this. You are to submit a four page, IEEE format
report afterwards, for “Milestone 1”.

10.3 Background Information


The digital outputs of the 9s12 chips can drive many devices. The maximum current that can be sunk or
sourced by the digital pins is in the neighbourhood of tens of milliamps (see the rating for ID in the “Absolute
Maximum Ratings” of the Freescale MC9S12C Family Data Sheet. Some devices can be driven directly by
these digital pins. The LED on the D13 line of the Esduino board is an example of this. It draws very little
current.
Other devices that you would want to interface to the 9s12 require an amplifier to provide some “extra
muscle”. High-current LED lamps, motors or relays are very good examples of devices that need more current
than can be provided by the 9s12. A simple transistor can be configured to act as the amplifier, as shown in
Fig. 10.2. To properly design for this configuration, you need to know that the objective is to drive the BJT
into saturation, so that it approximates an open circuit to ground between the emitter and collector terminals.
You’ll need to driver sufficient current into the base to drive the BJT to saturation, and you’ll also need to
make sure that you don’t run too much current through either the LED or the collector/emitter of the BJT.
You can implement the code which handles the reading of the switch as either poll-based or interrupt based
(i.e. with an Interrupt Service Routine). At this point, it is an open choice and likely will not make a big
difference in performance. However, when you add more sensors and need to interact with the LCD you may
find that performance is better if the switch is handled with an ISR.

10.4 Learning Objectives


1. More soldering practice
2. Simulation of analogue circuitry in design of LED driver
3. Independant writing of code capable of reading a switch input and turning on LEDs.

10-1
LEDs LCD PC (Matlab)

Esduino

overprotect cct switches accelerometer

amplifier

balancing cct

10v ref load cell

+/- 15v

Figure 10.1: Overview of the components in your system (including some you haven’t dealt with yet).

5v

D
Rc

Q1
b

Figure 10.2: Turning on an LED (D1 ) with a BJT (Q1 ). Two resistors limit current into either the base
or the collector of the BJT. The input signal is assumed to be a series of five-volt pulses coming from the
microcontroller.

10-2 Edit Date: February 12, 2013


4. General familiarization with MapleSim

5. Model equation extraction in MapleSim

10.5 Success Criteria


By the end of this lab you should have a system capable of outputting to and receiving from a number of
devices, including LEDs, switches and (from the previous labs) a PC and LCD, as shown in Fig. 10.1. In this
lab your success will result in large part in your ability to

1. First Week: Design

(a) Do the pre-lab MapleSim tutorials and show to TA’s that they are done both MapleSim tutorials &
report on them.
(b) Undertake the Diode parameter sweep simulation in MapleSim
(c) Simulate a BJT-Driven LED to aid in design of your circuit
(d) Simulate a filter for debouncing a switch

2. Second Week: Implementation & Reporting

(a) Create a design for a debounced circuit after testing in a multi-domain simulator (MapleSim)
(b) Implement three transistor-driven LEDs and one momentary switch on the LCD prototype board.
(c) Write and test code which is capable of reading the switch and lighting up the LEDs.
(d) Demonstration of functioning LEDs and switch to the TA
(e) Submit report

10.6 Pre-lab & Pre-requisites


1. The Esduino and LCD boards must be built, tested and working.

2. Undertake the sinusoid MapleSim tutorial in the Appendix. Hand in printouts at beginning of Week 5
lab.

10.7 Exploration
There are a number of exercises to accomplish during the labs. The simulations should be done in the first
week. The circuit implementations and programming should be done in the second week.

10.7.1 BJT-driven LED


Please refer to the second tutorial document on MapleSim in the Appendix. It shows you how to set up the BJT
A simple transistor can be configured to act as the amplifier, as shown in Fig. 10.2. To properly design
for this configuration, you need to know that the objective is to drive the BJT into saturation, so that it
approximates an closed circuit to ground between the emitter and collector terminals. You’ll need to drive
sufficient current into the base to then drive the BJT to saturation, and you’ll also need to make sure that you
don’t run too much current through either the LED or the collector/emitter of the BJT.
Determine:

10-3 Edit Date: February 12, 2013


1. What is the resistor value, Rc required to permit the LED current, ILED , to be 10 mA, assuming that
the forward voltage drop of the LED is 1.1 v? Assume that βf ranges from 80 to 100. Assume that VCE
is 0 when the BJT is saturated.

2. What is the value of the resistor, Rb , required which does not exceed the maximum current rating of the
9s12 digital pins but will also provide sufficient current through the collector-emitter to drive the LED.
Assume that βf ranges from 80 to 100. Assume VBE to be 0.7 v when driven on.

Once you have determined these values, implement them in simulation to confirm. Use MapleSim, Spice,
Multisim or any other appropriate simulation. Provide a screenshot of your simulation setup in your
Milestone 1 report.

10.7.2 Temperature effects on currents through an LED


Resistors are temperature dependant, as described by Dunn in Ch 3 of his text. You can enable temperature
dependence of a resistor in MapleSim. Test the effect of varying temperature and resistor value on the current
through an LED. Note that the light brightness is directly proportional to current through the LED. Set up a
circuit in MapleSim as follows:

1. 10 volt battery driving a resistor an an LED (an ideal diode with a knee voltage of 1.2 volts)

2. The resistor should have a Tref of 200 K, an α of 0.001 K −1 and no heat port.

3. The resistor should have two parameters: R should be ResistorV alue and T should be T emperatureV alue.
These will be varied in simulation. You will need to add these to the Parameters of the main simulation.
Do this by clicking the icon under the question mark, in the upper-left corner.

4. Set the diode to have a Vknee of 1.2 volts. Keep the other defaults.

5. Set simulation time, tf to 2 seconds, the ck45 solver, adaptive integration to true, keep the default error
tolerances, 200 plot points. Compiler is optional.

6. add a probe to measure current. You may need to add a sensor first.

7. add a probe to measure diode voltage. You may need to add a sensor first.

Imagine that your system will be exposed to a temperature other than room temperature. Conduct a
parameter search for resistances from 50 to 100 Ohms and temperatures from 250 to 400 K. First, run the
simulation directly from MapleSim, with one or two combinations of temperature and resistance. Check that
currents and voltages are about right.
Next have Maple call the MapleSim a single time, as shown in Fig 10.3. Check the output to see if voltage
and current are correct.
Next modify the supplied Maple code to call the MapleSim model multiple times, in order to sweep through
the temperature and resistance parameters. Determine the relationship between those two parameters and the
resulting current. You’ll first need to set up your parameters, like in Fig. 10.4, and then you’ll need to run a
double for loop to sweep through the parameter space, like in Fig. 10.5. Finally, you’ll plot the results, as in
Fig. 10.6.
Also, have MapleSim generate the underlying equations. Provide the equations specified as part of the Skill
Questions section.

• Sections 1 and 4: Using the Attach Equations feature in MapleSim, describe the voltage at the resistor
as a function of current. Refer to Ch. 3 of the Dunn text.

10-4 Edit Date: February 12, 2013


# -------------------------------------------------------------------------------
# File: parameter sweep script dioderesistor v1.mw
# Title: sweep a pair of parameters in a MapleSim model.
#
# References:
# 1. http://orion.uwaterloo.ca/~hwolkowi/matrixcookbook.pdf
#2. http :// www.mapleprimes.com/ questions / 130186 K Gradient K Projection K Algorythm K With K Maple
# 3. http://www.maplesoft.com/support/help/Maple/view.aspx?path=plot3d%2foption
# 4. http://www.mapleprimes.com/questions/130024-Running-Parameter-Space-Searches
#
#
# Thanks: Bonnie Yue @ MapleSoft & Ronnie Wong @ Ryerson.
#` `
# This script will call an existing MapleSim model. It will modify two parameters
# within the model over boundaries set by you. It will then graph the output
# of the "parameter sweep" so that you can see the effect.
#
#
# ---------------------------- Set up Maple ---------------------------------
# Restart and add relevant toolboxes
restart; gc ; with ExcelTools : with LinearAlgebra : with plots :
#
# Define the directory with the MapleSim model
switchdir d "/Users/jasmith/research/Maple/MapleSim/diode_resistor" :
currentdir switchdir :
#` `
# Link the MapleSim model
A d MapleSim:-LinkModel 'filename'= "dioderesistor3_jan2013.msim" :
# --------------------------------------------------------------------------------
#
#
# put your cursor here and hit ENTER to execute this part of the script
> # This is what you do if you want to call the simulation only once.
simData d A:-Simulate output = datapoint, duration = 1.0, params = 'ResistorValue'= 100,'TemperatureValue'= 300 :
> simData 200, 1 ; # want to look at the time at the 200th "plot point"
1. (1)
> simData 150, 2 ; # Want to look at the 1st probe's value at the 150th plot point
0.000900990098126742 (2)
> simData 100, 3 ; # Want to look at the 2nd probe's value at the 100th plot point
0.900000008919902 (3)
>

Figure 10.3: First, tell Maple where and which files to simulate. Then run the simulation specifying which
parameters to modify.

10-5 Edit Date: February 12, 2013


Figure 10.4: When parameter sweeping you need to define the boundaries. Here’s how you do it. The first
parameter can be resistance, and the second temperature.

Figure 10.5: Vary each of the parameters and accumulate the resulting outputs from teh MapleSim simulation.

10-6 Edit Date: February 12, 2013


Figure 10.6: Make really nice surface plots

• Sections 2 and 3: Using the Attach Equations feature in MapleSim, describe current as a piecewise func-
tion. Refer to Example 1 of http://inst.eecs.berkeley.edu/~ee42/sp04/lectures/lecture16student.pdf
and page 42 of http://www.modprod.liu.se/MODPROD2011/1.252919/modprod2011-tutorial1-Fritzson-Modelica-Introduction.pdf for guidance. Note
that s is a variable that is dependant on both current and voltage.

10.7.3 Debounced Switch


Switches are electro-mechanical devices. In this case, input to a mechanism creates an electrical output. The
main mechanical components in a switch can be seen in Fig. 10.9. Because the mechanism is compliant
(“springy” or “bouncy”), the resulting electrical signal will turn on and off rapidly at first, before settling on
a final value (either on or off). The bounce, sometimes referred to as “chatter” (like your teeth when you’re
cold) or “contact bounce”, can be dealt with by adding a lot of damping (e.g. rubber sheets), through software
routines, or by adding electrical hardware filters. In this case, the first is impractical, the second risks reducing
the performance of the Esduino, but the third can be established on your circuit boards. So you are to implement
the third method – it is the most conservative and prudent approach.
The switches provided in your lab kit are normally open and contain no pull-up or pull-down resistors. To
ensure that the signal is normally high, even when no switch is connected, you require an external pull-up
resistor as shown in Fig. 10.7. The switch will have one terminal connected to ground, therefore resulting in
a 0 volt signal when pressed. By placing a capacitor as shown in Fig 10.7, you’ll be creating a low-pass filter.
Given the resistor value given in the figure, what is the capacitor value? To answer this you need to be aware
that:

• You need to be able to detect switch depressions of 15-20 ms or more.

• The bounces, in total, typically lasts up to 10 ms

Next, model the combined mechanical switch and electrical debounce filter. Modelling of this system
is tricky, since it is multi-domain (both mechanical and electrical). Traditional software such as Multisim
and Spice (electrical) or MSC.ADAMS and Working Model (mechanical) are single domain and cannot easily
accommodate systems such as this. MapleSim and Dymola use the Modelica modeling system to address this
problem.
To simulated a button press, have a 0.01 kg mass drop 1 mm onto an elasto-gap (spring-damper with a
zero-force gap) with a spring constant of 100000 N/m and a damping constant of 180 N/(m/s). The gap should

10-7 Edit Date: February 12, 2013


Figure 10.7: Filtering the switch for removing bounce. Set R1 to 4.7 kOhms, R2 to 100 kOhms. What is C?
Image adapted from: Art of Electronics, 2nd Ed.

Figure 10.8: Example MapleSim electromechanical model setup

10-8 Edit Date: February 12, 2013


Finger

Spring

Ground
Gap

Damper
} Switch

Figure 10.9: Basic mechanical components in a switch.

be 1 mm. Gravity should be the standard value on Earth.1 Your model should appear something like that in
Fig. 10.8. Note that the filter is in a subsystem block, so the details are not shown.
In your Milestone report, provide a screen capture of both your MapleSim schematic / model
and a graph comparing the switch’s mechanical movement with the electrical output.

10.8 Skill Questions


1. Based on the MapleSim parameter sweep that you did for the LED-resistor circuit, what is the effect of
lowering temperature on the resistor in terms of the brightness of the LED?

2. Provide the component equation for the LED simulation, as specified below

(a) Sections 1 and 4: Using the Attach Equations feature in MapleSim, describe the voltage at the
resistor as a function of current. Refer to Ch. 3 of the Dunn text.
(b) Sections 2 and 3: Using the Attach Equations feature in MapleSim, describe current as a piecewise
function. Refer to Example 1 of http://inst.eecs.berkeley.edu/~ee42/sp04/lectures/lecture16student.
pdf and page 42 of http://www.modprod.liu.se/MODPROD2011/1.252919/modprod2011-tutorial1-Fritzson-Mode
pdf for guidance. Note that s is a variable that is dependant on both current and voltage.

3. What is the maximum current that the 9s12 can sink or source on the digital pins?

4. How much current is drawn by the Esduino’s LED (on the D13 line)?

10.9 Bonus Objectives


Bonus points are awarded to the groups in a particular lab section that are able to accomplish all of the
demonstrable items of the lab, plus the bonus objective, listed below. The bonus activity must be demonstrated
to the lab TA during the lab and prior to the end of the lab session. The bonus is applied to the current lab
1
Elastogap settings: spring const: 1000000 N/m, damping const: 180 N/(m/s), s nominal = 0.0001 m, s rel0 = -0.01m. Integration
should be with the stiff integrator with tolerances set to 10−6

10-9 Edit Date: February 12, 2013


and cannot result in a mark above 100% for the current lab assignment. Your final lab grade cannot exceed
100%, however.
If multiple groups submit an entry for the bonus, then bonus marks will be shared and ranked to the inverse
of the executable code size (ELF or S19 file, whichever you download on to the microcontroller). The group
with the smallest working executable file for the bonus in question will receive the highest percentage of bonus
mark, according to this formula:
1
jB
Sj = P
n · 100% (10.1)
1
Bi
i=1

where Sj is the score of the j th group, and n groups have submitted bonus exercises. Bj is the code size, in
bytes, of the group’s executable code. The result is a percentage applied to the actual bonus score, found below.

• Section 1: Count the number of button presses on your switch and increment the count value on your
LCD (up to 10% bonus to this week’s grade)

• Section 2: Press a key in Matlab and have one of your new LEDs turn on. (up to 10% bonus to this
week’s grade)

• Section 3: Each time the button is pressed, have a number increment in Matlab (up to 10% bonus to this
week’s grade)

• Section 4: Have the LCD’s screen fill up with characters as long as the button is pressed. When you let
go of the button have the characters disappear slowly. (up to 10% bonus to this week’s grade)

In each case you must demonstrate the functionality to the TA during the lab and you must include a copy
of your source code in your report.

10.10 Communication
Begin preparation of the Milestone 1 documentation (four pages, IEEE format, with references). The Milestone
report is due one week after your lab at 11:59pm. You must email a PDF copy of the report to your TA
and it must include an official (signed) cover sheet. Note that you need to use the IEEE template (http:
//www.ee.ryerson.ca/~jasmith/courses/ele604/docs/IEEE_trans_template_ELE604.doc).
You are to document the simulations that you conducted in MapleSim and to discuss the result of the
implementation on your microcontroller system. Discuss why your analogue components were selected the way
they were. Also, what was the design decision that led to implementation of either poll-based or interrupt-based
servicing of the switch. Explain these design decisions.
In addition to following the IEEE format, the four-page documentation (minus appendices) must have the
following sections:

Cover Sheet This page includes:- the title of the report; authors’ names; for whom and when the report was
prepared; course name; and Statement of Declaration claiming ownership of the report content, signed by
both authors. This is the official FEAS cover sheet. (See the end of this chapter)

ABSTRACT an abstract is a short paragraph summarizing the report. One or two sentences for each of
the following items is appropriate: Objectives, Design Analysis, Procedure, Results, Conclusions and
Recommendations. Furthermore, write up your abstract first, before writing anything else. Use it to plan
your document. Note that the introduction and theory sections, as well as the skill questions should not
be mentioned here.An abstract can be thought of as an executive summary. The Corporate Executive or
your Engineering Manager may just want to read a short paragraph and to be able to put the report into

10-10 Edit Date: February 12, 2013


context with other related materials without spending much time reading the whole report. It is the first
thing you write and the last thing that you revise. Take great care in writing it as it is often the only
thing your manager reads. It should be independent and the rest of the report should be written as if the
abstract does not exist.
OBJECTIVES A short paragraph states the purposes of the study, and the technical specifications.
INTRODUCTION This page (or 2 to 3 paragraphs) explains the initiation of the study (product design),
the problem to be investigated, the approach or the method to be employed for the study.
THEORY Provide the theory on the principle of operations of all relevant sensor/transducer technologies; and
the foundational basis for any algorithm created. Develop all theoretical formulations or explanations for
the expected performance of the system under investigation. Use figures and/or graphs where appropriate.
DESIGN ANALYSIS The proposed system overview of the product should be provided and explained.
Explain the design methodology used, provide detail design analysis and explanations with proper circuit
schematics, algorithms, software structure, etc.
PROCEDURE Describe the simulation and experimental (as appropriate) methodology and detail the pro-
cedures for performing various tests and/or experiments, for both the Simulations and actual hardware
implementation.
RESULTS & OBSERVATIONS Record all data in several tables and/or plots. Photographs, oscilloscope
tracings and waveform drawings should be reported in this section for both the Simulations and hardware
designs. Any requirements for simulation plots should go here.
SKILL QUESTIONS write the answers to the skill questions here.
CONCLUSIONS & RECOMMENDATIONS It is important to make a precise conclusion of the project
based on the Observations. List the major results together with short explanations and comments. Rec-
ommendations are also necessary in a report. In essence, the reader needs to know from your conclusions
about hoe the project worked and what limitations may be encountered.
REFERENCES List all reference materials in this section. This includes any lab material (lab manual,
hand-outs, etc.) provided to you.
APPENDIX In this section you may want to include a list of component parts used, cover page of any
specialized component, source-code; and whatever else you feel would be useful to the reader.
Use your Abstract to plan out the document. An example abstract is as follows:

Example Abstract
This is my introductory sentence, in which I give context for my project. Objectives:
The objectives of this project were to simulate a 7kg spacecraft in the first week and to
construct and launch it in the second week. Design Analysis: To produce a launch vehicle
with the specified mass requirements, new accelerometer and rocket booster designs were
required. Procedure: MapleSim was used to simulate the flight path and incorporated the
accelerometer for feedback to drive the variable mass booster. The experimental flight test
was performed with the Esduino controller at the Ryerson launch pad located at Dundas
Square. Results: The launch vehicle crashed and burned after 7 seconds of flight, taking
out the GAP advertisement above the Eaton Centre. Conclusions & Recommenda-
tions: The control code was written in poorly optimized C that did not adhere to realtime
requirements resulting in poor flight control. A better control code, written in Assembly,
with an average control loop of 1ms ± 0.001ms is recommended next time.

10-11 Edit Date: February 12, 2013


ELE604 Milestone 1 (weeks 5-6) Marking Guide (Lab) 2013

• MapleSim Sinusoid Tutorial Pre-lab Printouts at


beginning of Week 5 lab (10% of total)
o Complete (10/10) Deductions
o Not complete (0/10) • Lateness
• Switch & LED demo (30% of total) o -25 pts (up to 1 day)
o Worked (30/30) o -100 pts (beyond one day)
o Attempted (10/30) • Font Modification (IEEE Template:
o No attempt (0/30 Times New Roman 10pt in main
body, 24pt in title, 8pt in References)
• Determined Resistor values for LED & o -25 pts (any changes)
BJT (20% of total mark) • No Cover Sheet (FEAS official)
o Both (20/20) o -25 pts
o One (10/20) • Template Modification (margins,
o Neither (0/10) borders, header placement, etc.)
• MapleSim Switch Model (20%) o -25 pts (any changes)
o Complete (20/20) • Number of Pages
o Partial (10/20) o -25 pts (~3/4 of req’d)
o None (0/20) o -50 pts (~1/2 of req’d)
• Skill Questions (20% of total mark) o -75 pts (anything less)
o Each Question is worth 5%

Left Column Total Right Column Deduction

Your grade:

How is your grade calculated?

In the left column, your citations, language and content are evaluated. The marking is based on how well you
perform in each of those items. The individual scores are added up and written in the box below the column.

Afterwards, deductions are is made based on the factors in the right hand column. The deductions are
cumulative and can reduce your grade to 0 (minimum).

** Note: Use the IEEE Template Word document for ELE604! **


** Don’t change the template! **
** Go to http://www.ee.ryerson.ca/~jasmith/courses/ele604/docs/IEEE_trans_template_ELE604.doc
for the template **
Details
Page Number Mark Adjustment
- Based on length requirement. If you submit only about 75% of the number of pages you were
supposed to, your mark will be reduced by 25%.
- If you submit less than 75% of a complete page it is considered an incomplete page and is not
considered in your total page count.
- If a disproportionate amount of your article is taken up by tables, figures or quotations from other sources
your mark will be reduced accordingly. Be reasonable with your usage of figures, photos, images, diagrams,
tables and quotations. (For instance, if three-quarters of a page is taken up by a table or figures, leaving little
room for your own text, then the Page Number Adjustment will apply)
- Examples:
1) Hand in a two page project that was supposed to be four pages: your project mark will drop by
50 points.
2) Hand in a 3.5 page project instead of four pages: your project mark will drop by 25 points.
3) Hand in a four page paper, but one complete page is a table from another source, your project
Plagiarism, Copying, etc.
mark will drop
Remember: by 25 points.
Plagiarism is wrong! If you copy from a book, journal or online source (or your friend)
you will receive 0 and may receive a record on your transcript.
Department of Electrical & Computer Engineering
Program: Electrical Engineering

Course Number ELE604


Course Title Sensors and Measurement
Semester/Year Winter 2011
Instructor James A. Smith

Lab/Tutorial Report NO. 5

Report Title Milestone 1

Section No.
Group No.
Submission Date
Due Date

Name Student ID Signature*

(Note: remove the first 4 digits from your student ID)

*By signing above you attest that you have contributed to this submission and confirm that
all work you have contributed to this submission is your own work. Any suspicion of
copying or plagiarism in this work will result in an investigation of Academic Misconduct
and may result in a “0” on the work, an “F” in the course, or possibly more severe
penalties, as well as a Disciplinary Notice on your academic record under the Student
Code of Academic Conduct, which can be found online at:
www.ryerson.ca/senate/current/pol60.pdf.
10-14 Edit Date: February 12, 2013
Chapter 11

Weeks 8 and 9: Accelerometer Setup and Testing


(Milestone 2)

11.1 Straight to the Point


Get the MEMSIC accelerometer working with your Esduino.

11.2 Overview
This is a two-week lab. In weeks 8 and 9, you are to work on the analysis, design, and implementation of
accelerometer hardware and software. More specifically, analysis, design and implementation of accelerometer
hardware and software to display Angle as per specifications. Obtain test results. An in-person oral demon-
stration of the working device will be conducted with the TA up until Week 9. The report is due seven (7) days
after your Week 9 lab at 11:59 pm in PDF form, with signed cover page, emailed to your TA.

11.3 Background Information


It is important to review the datasheet for the MEMSIC accelerometer. Much of this can be found in the
Appendix. There are also some online resources that are worthwhile tracking down from Parallax, the company
that makes the carrier board for the MEMSIC device.
The MEMSIC 2125 contains two accelerometers, placed perpendicular to one another. Each outputs a
stream of pulses at a frequency of about 100 Hz (i.e. a period of 10 milliseconds). The time between pulses is
referred to as T2 , while the duration of the pulse is referred to as T1 . The Duty Factor is the ratio of time that
the signal is on versus the time that it is off. So if T2 is 10 ms and T1 is 5ms then the signal has a 50% duty
cycle. Here, we also define the following:

∆TX = T1 − 0.5T2 (11.1)


where ∆TX is directly proportional to the force of gravity felt by the individual accelerometer, on its x-axis.
This force, A(g), defined as
∆TX
T2 ∆TX
A(g) = = 8( ). (11.2)
0.125 T2
You will likely need to implement Interrupt Service Routines related to the timer module on the 9s12c32
chip found on the Esduino board. Search for and download the Freescale manual on the TIM (Timer Module)
for the 9s12c32. Also, download the main reference guide for the ’c32. Both have the listings for the important
registers related to timing and edge detection.

11-1
11.4 Exploration
Can you implement floating point mathematics on the 9s12? If so, what would the performance be, with respect
to a system like a laptop or desktop computer? What are alternatives to this that are common with embedded
systems such as the 9s12?1

11.4.1 Angle Measurement – Suggested Approach


To avoid potential problems with the angle measurement, you may want to follow the suggested design steps or
process:- Understand the timing outputs of the MEMSic device, keeping in mind that zero acceleration (or zero
angle along the horizontal axis) represents 50% duty cycle. The change in duty cycle relative to 50% represents
change in acceleration or angle. Refer to the Design Resource Assignment #2.
Review the 9s12 timer architecture, and determine the proper strategy to measure the pulse widths for Ax
and Ay outputs. Develop a proper interrupt structure so that the timing measurements are done automatically,
and at all times. Note:- If you have used interrupt for switch sensing, you need to be very careful with your
multiple interrupt prioritization strategy. Inherent mechanical debouncing of the switch can create problems for
an interrupt service routine. Normally, for this type of application where there are critical time measurement
processes happening in the background, the switch detection should be done using polling approach in the
MAIN program since your MAIN program has to loop around anyways. However, the choice is yours, but do
be careful if you are planning to use interrupt for your switch detection in combination with the interrupts you
will need for the pulse width measurements.
Develop the algorithm for measuring the angle from the pulse widths detected. This may involve the use of
a Look Up Table (LUT). If so, you will need to determine the values of the Look Up Table you need. You may
want to first keep it simple and measure 0 to 180 degrees in one degree increment. Once this works and you
can properly display the angle, you can always refine your LUT to achieve the resolution of 0.2 degree. THE
KEY to designing to meet the final specs is to do it by taking baby steps first, and then refine these as needed.
It will save you a lot of time with debugging code.
When testing your pulse width method using the Input Capture & Interrupt, you should test one channel
at a time (that is Ax or Ay) using the actual MEMSic output or a Function Generator (FG) in the Lab. You
can set up the FG for digital signal output at the same clock period as the MEMsic output, and you can
manually vary the duty cycle. NOTE:- when you connect the FG, make sure you connect its signal ground to
your Esduino board ground.
Design and develop a proper software structure incorporating the MAIN program and Interrupt Service
Routines. There are a few ways to structure your software but here are few points to keep in mind. In the MAIN
program, beyond all your initialization code, the program should continuously loop back while the interrupts are
being handled automatically in the background. In this Main program loop, wherever appropriate you should
consider structuring it with subroutines to (1) detect switch and manage LEDs; (2) monitor parameters passed
on from the interrupt service routines to do the calculations; (3) manage the LCD display; (4) etc., etc. This
structured approach makes it easier to test and debug code. It is important that you spend time developing
the ”roadmap” of your MAIN program structure so that you can implement the routines as needed.

11.4.2 Steps in the Development Strategy


Search for and download the Freescale manual on the TIM (Timer Module) for the 9s12c32. Also, download
the main reference guide for the ’c32. Both have the listings for the important registers related to timing and
edge detection.
We recommend the following steps in the development of your accelerometer interfacing:

1. Get Port T tested. Use simple polling and test for high and low values on the Port T pins that you will
use for the two Accelerometer outputs.
1
Hint: LUT

11-2 Edit Date: February 12, 2013


2. Edge Detection without Service Routine. Here you want to use particular bits in TFLG to test the
detection of edges.

3. Set up a simple Interrupt Service Routine. Declaring it in your main.c file is a good idea. The recom-
mended start for the ISR (for Input Capture 2, in this case) should be something like: void interrupt 10
IC2Han(void). Note the “10”. This changes for different hardware devices or “channels”. Don’t forget
to clear the relevant flag in TFLG at the end of the ISR! Consider doing something simple in this ISR,
like flashing an LED. Note, that Codewarrior has a special command called EnableInterrupts(); that
needs to be called between the code that initialises interrupts and the main execution code in main().

4. Measure time between pulse edges in the ISR. This is tricky. Make sure to debug the previous steps first.
Here, you should use TCTLx_EDGy (where x and y can be different values) to test which edge was detected.

5. Add the second channel’s ISR. Make sure that both work separately, then together.

6. Display data on LCD.

7. Calculate angles from data gathered in ISRs.

11.5 Skill Exercises


The following skill exercises need to be answered and included in your Milestone report. Please write your
answers in the “Design Analysis” section of the report, as per the Marking Guide. The following are the five
skill exercises:

1. If the MEMSIC 2125 x-axis is used on the vertical, which way would you orient the device to ensure
positive values for ∆TX .

2. For the measurement of 0 degrees to 90 degrees in increments of 0.2 degrees using the xaxis output, there
would be 450 data points in a Look Up Table (LUT). If one measures the numerical value of ∆TX , then
it can be compared with an appropriate entry in the Table. Manually generate such a table for values of
∆TX in increments of 0.2 degrees.

3. Show how you would set up a second LUT that could use the “offset” (obtained after the comparison)
from the above LUT to directly reference the appropriate angle (e.g. 23.4 deg, etc.) for direct display on
the LCD.

4. Show that for the xaxis output, the ∆TX will be redundant for the two required quadrants, 0 deg. 90 deg.
and 90 deg. 180 deg. Determine how the same LUT above can then be used to also measure the angles
in the 90 deg. - 180 deg. quadrant by appropriately using the information from the yaxis output.

5. If the T2 period of 10 msec is not accurate (refer to the datasheets for information on accuracy and error),
then how would you improve your accuracy and repeatability of the angle measurements.

11.6 Bonus Objectives


Bonus points are awarded to the groups in a particular lab section that are able to accomplish all of the
demonstrable items of the lab, plus the bonus objective, listed below. The bonus activity must be demonstrated
to the lab TA during the lab and prior to the end of the lab session. The bonus is applied to the current lab
and cannot result in a mark above 100% for the current lab assignment. Your final lab grade cannot exceed
100%, however.
If multiple groups submit an entry for the bonus, then bonus marks will be shared and ranked to the inverse
of the executable code size (ELF or S19 file, whichever you download on to the microcontroller). The group

11-3 Edit Date: February 12, 2013


with the smallest working executable file for the bonus in question will receive the highest percentage of bonus
mark, according to this formula:
1
Bj
Sj = n · 100% (11.3)
P 1
Bi
i=1

where Sj is the score of the j th group, and n groups have submitted bonus exercises. Bj is the code size, in
bytes, of the group’s executable code. The result is a percentage applied to the actual bonus score, found below.

• Section 1: Have Matlab graph the angular data from the Esduino and MEMSIC “live” so that points are
plotted in the graph as soon as they are received. (up to 10% bonus to this week’s grade)

• Section 2: Press a key in Matlab and have the Esduino’s display switch toggle between showing MEMSIC
angles in degrees and in radians (up to 10% bonus to this week’s grade)

• Section 3: Have the Esduino LCD display a bar graph whose bar is proportional to the angle of the
MEMSIC. It should update “live” as the MEMSIC rotates. The bar should also be able to distinguish
between clockwise and counterclockwise rotation. (up to 10% bonus to this week’s grade)

• Section 4: Mount the Accelerometer, LCD and Esduino in a protective box, with battery power. Drop it
from a height of 1 to 1.5 meters. Display the time of flight between the time it was dropped to the time
it impacted the ground.

In each case you must demonstrate the functionality to the TA during the lab and you must include a copy
of your source code in your report.

11.7 Communication
Please read the Marking Guide carefully prior to working on and submitting your work.
In Week 9 you will demonstrate your system to the teaching assistant (or before if you are ready). The TA
will ask you questions to determine your understanding of the system, as per the marking guide attached to
the end of this chapter. You will also be required to submit a four page (without appendix) written report as
part of Milestone 2, in IEEE format and as a PDF file, within seven days of your Week 9 session (emailed by
11:59pm of the seventh day, to the TA). Please use the section headings as outlined in the Marking Guide at
the end of this chapter.

11.8 Post-lab reflection


Begin analysis, design and simulations of strain-gauge circuitry related to the Futek Load cell starting in week
10.

11-4 Edit Date: February 12, 2013


ELE604 Milestone 2 Marking Guide (Lab) 2011

• Performance of LCD Display of Angle (needs to be


checked in live lab demo) (5pts)
o 0.2 degree resolution (5/5) Deductions
o 1 degree resolution (3/5) • Lateness of report
o 10 degree resolution (1/5) o -5 pts (up to 1 day)
o Could not display angle (0/5) o -25 pts (beyond one day)
• Written Explanation of Tilt Algorithm is clear, • Font Modification (IEEE Template: Times New
correct & concise (3 pts total) Roman 10pt in main body, 24pt in title, 8pt in
o Complete & correct Written explanation References)
(3/3) o -5 pts (any changes)
o Incomplete or slight error in written • No Cover Sheet (FEAS official) or unsigned
explanation (2/3) cover sheet
o No or incorrect written explanation (0/3) o -5 pts
• Graphical / Flow-chart Explanation of Tilt Algorithm • Template Modification (margins, borders, header
is clear, correct & concise (2 pts total) placement, etc.)
o Complete & correct graphical explanation o -5 pts (any changes)
(2/2) • No source code in appendix (not IEEE format)
o Incomplete / slight error in graphical o -5 pts
explanation (1/2) • No test results in report
o No or incorrect graphical explanation (0/2) o -5 pts
• Oral Questions (performed in lab). Answers need to • Number of Pages (four pages, two column, IEEE
be reiterated in the report. format)
o Correct explanation of how you ensured a o -5 pts (~3/4 of req’d)
30 ms refresh time (2/2) o -10 pts (~1/2 of req’d)
o Demonstrated understanding of MEMESic o -20 pts (anything less)
accelerometer & negative/positive
accelerations (1/1)
o Demonstrated insight into producing
optimized code for achieving design goals
(refresh rates) (1/1)
o Demonstration of knowledge of how to
measure the pulse width of the
accelerometer’s two axes. (1/1)
o Demonstration of examination of inaccuracy
of accelerometer pulse period and (possible)
compensation for inaccuracies (1/1)
• Written report includes
o Abstract, Objectives, Theory, Design
Analysis, Experimental Procedure, Results
and Observations, Conclusions and
Recommendations, Reference and Appendix
headings (1/1)
o Any heading missing (0/1)
• Overall Written Report Content (3/3)
o Clear, concise and accurate (3/3)
o Moderately unclear, inaccurate or verbose
(2/3)
o Unclear, inaccurate or verbose (0/3)
• Answers for the five design questions, written in the
``Design Analysis’’ section of the report (5/5))
o One point per correct answer.

Left Column Total /25 Right Column Deduction

Your grade: /25


ELE604 Milestone 2 Marking Guide (Lab) 2011

How is your grade calculated?

In the left column, your citations, language and content are evaluated. The marking is based on how well you
perform in each of those items. The individual scores are added up and written in the box below the column.

Afterwards, deductions are is made based on the factors in the right hand column. The deductions are
cumulative and can reduce your grade to 0 (minimum).

** Note: Use the IEEE Template Word document for ELE604! **


** Don’t change the template! **
** Go to www.ee.ryerson.ca/~jasmith/courses/ele604/support_docs for the template **

Plagiarism, Copying, etc.


Remember: Plagiarism is wrong! If you copy from a book, journal or online source (or your friend)
you will receive 0 and may receive a record on your transcript.
Chapter 12

Weeks 10 & 11: Strain Gauge test and uC Integration

12.1 Straight to the Point


Simulate the loadcell interface circuit in Week 10. Implement the loadcell circuit in Week 11.

12.2 Overview
In Week 10, implement and test analogue circuitry design for strain gauge and then interface to uC. Implement
software to provide force function per specifications. Undertake the measurements to characterize the strain-
gauge sensor and circuitry. Continue to work on integrating force and angle functions per specifications. In Week
11, demonstrate force measurement functions as per specifications and provide your measurement data analysis
on accuracy, repeatability, etc. of the sensor. Submit Milestone 3, test results, algorithms and source-code
listing.

12.3 Pre-lab & Pre-requisites


Review the design requirements for the loadcell component of this project. This can be found in Section 2.5.2
on page 2-6
Also, review the guide to the loadcell test jig found on page K-1.
Finally, review the oral questions that you will be asked by the TA. Determine your answers ahead of time.

12.4 Background Information


Refer to the introductory material in the lab manual. Also, read over the guide to the load cell test jig on page
K-1.

12.5 Exploration
The circuit in Fig. 12.1 is suggested for interfacing the Futek load cell to your microcontroller. In Week 10 you
are to simulate it using MapleSim. In Week 11 you are to demonstrate a working circuit to your TA.

12.5.1 Week 10: Simulation


The basic instrumentation amplifier is designed using three operational amplifiers. Two of these act as buffers
on the two inputs to the instrumentation amplifier. All of the resistors are set to the same value, except for the
gain resistor, RG , which is varied in order to adjust the amplifier’s gain. A good description of this can be found

12-1
Figure 12.1: Suggested interface circuit to connect the Futek load cell to the ADC on your microcontroller
board. Image courtesy of Dr. Mike Kassam.

in Fig. 7 of http://www.intersil.com/data/an/an1298.pdf. The AD620 instrumentation amplifier has its


non-gain resistors set to 24700 Ohms. Knowing this do the following work in developing your simulation:

1. Build an instrumentation amplifier from three ideal op amps and a network of resistors, as per Fig. 7 in
http://www.intersil.com/data/an/an1298.pdf. Set the gain to 1000. Test that the gain does, in fact,
provide you with amplification of the difference between the two inputs.

2. Simulate the protection circuitry in Fig. 12.1, above. Use ideal diodes in MapleSim. Set the knee voltage
in these diodes to 0.7v. Ensure that you get clamping of the output signal (from the instrumentation
amplifier) of -0.7 volts (if it goes negative) and 5.7 volts if it exceeds 5.7 volts.

3. Simulate the Wheatstone bridge found in the Futek Loadcell. Assume that the three arms are set to
1000 Ohms and that the fourth arm can vary between 997 Ohms and 1003 Ohms. Ensure that the
instrumentation amplifier clamps when exceeding these boundaries.

12.5.2 Week 11: Implementation


Review the design requirements for the loadcell component of this project. This can be found in Section 2.5.2
on page 2-6. Now, implement the circuitry that you simulated in Week 10. Consider placing all of this circuitry
on a separate daughter / prototyping card. You may wish to test it in breadboard form first.
You will need to devise three sub-circuits:

1. a differential amplifier with a gain of between 500 and 1000 (see skill questions for more details)

2. a clamping circuit to ensure that the maximum voltage into the 9s12’s ADC doesn’t exceed 5.7 volts and
doesn’t fall below -0.7volts.

3. a zero-adjust circuit to balance the loadcell’s bridge externally.

12-2 Edit Date: February 12, 2013


You will need to achieve a particular level of accuracy. See the marking guide for the three acceptable levels
(each has a different grade associated with it). See the design specifications in the earlier part of the lab guide
for how the information should be displayed on the Esduino’s LCD.

12.6 Skill Exercises


The skill exercises are to be answered in your short Milestone 3 report. Refer to Fig. 12.1 when examining
these questions.

1. The potentiometer, P1 can be used to zero adjust the load cell. Under no-load, the output voltage of the
Instrumentation Amplifier (IA) should be zero.

(a) Explain how you would set up the procedure to properly zero-adjust your load cell configuration.
(b) From a robust calibration perspective, what purpose is served by adding 1K resistor to each end of
potentiometer, P1?.
(c) If the IA output is always negative (below zero) instead of the positive value required under load,
where would the possible error be in your connections?

2. If you use or change to a different test jig, would you need to zero-adjust again? Why?

3. For the Bridge and zero-adjust circuitry, why is it necessary to use the +10V voltage reference instead of
simply using the +15V power supply?

4. Referring to the IA datasheets, determine the value of RG required to set the IA gain of 1000. To obtain
close to a full scale output of 0 to 5V for the range of weight measurements specified, what should the IA
gain be?

5. During power-up, the output of the IA can temporarily saturate and swing to either +15V or 15V, and
this can seriously damage your microcontroller which is powered by a +5V supply.

(a) Analyze the protection circuitry, and show that the input to your microcontroller will be clamped
to +5.7V and 0.7V when the output of the IA is at +15V and 15V, respectively. Use the MapleSim
simulator to verify the operation of the clamping circuit. Include screenshots of your schematic and
your graphed results.
(b) Is the 1K series resistor sufficiently small relative to the input resistance of the A/D input to avoid
significant attenuation of the IA output signal? (refer to the 9s12c32 datasheets).
(c) When the IA output is at +15V and -15V, determine the value of the current that flows through
each diode, respectively. Do these diode currents fall within the maximum current permitted for the
diode you have selected? (refer to diode datasheet).

6. What is the purpose of VH and VL (Also known as VRH and VRL )inputs of the ADC of the microcontroller?
For the ADC of the 9s12, what is the smallest mass that can be accurately resolved in 8bit mode? What
about 10bit mode?

12.7 Oral Questions


These are to be answered during the Week 11 demonstrations to the TA:

1. Why use a DC-offset for your differential voltage?

2. How did you maintain a stable Vref for your bridge and why is it important?

12-3 Edit Date: February 12, 2013


3. Why is amplification of the differential voltage important?

4. How did you balance your bridge (brief description)?

5. Why are we using an instrumentation amplifier and not other amplifiers?

12.8 Bonus Objectives


Bonus points are awarded to the groups in a particular lab section that are able to accomplish all of the
demonstrable items of the lab, plus the bonus objective, listed below. The bonus activity must be demonstrated
to the lab TA during the lab and prior to the end of the lab session. The bonus is applied to the current lab
and cannot result in a mark above 100% for the current lab assignment. Your final lab grade cannot exceed
100%, however.
If multiple groups submit an entry for the bonus, then bonus marks will be shared and ranked to the inverse
of the executable code size (ELF or S19 file, whichever you download on to the microcontroller). The group
with the smallest working executable file for the bonus in question will receive the highest percentage of bonus
mark, according to this formula:
1
Bj
Sj = n · 100% (12.1)
P 1
Bi
i=1

where Sj is the score of the j th group, and n groups have submitted bonus exercises. Bj is the code size, in
bytes, of the group’s executable code. The result is a percentage applied to the actual bonus score, found below.

12.8.1 Week 10 Bonus


These can only be completed during a student’s scheduled Week 10 lab session.

• Section 1: Modify the circuit simulation so that the strain gauge arm in the Wheatstone bridge is variable.
Have a plot of the voltage coming out of the clamping circuit which shows variability of output based on
changing resistance within the bridge (to simulate loading of the load cell). As the loading changes make
sure that the clamping action is visible in the plot. (5% bonus to Milestone 3’s grade)

• Section 2: Modify the circuit simulation so that the input is a force in Newtons, which is then converted
to voltage. This voltage is then to be fed into the differential amplifier. Vary the input force from 0 to
4.5 N. What is the output voltage into the ADC? Plot it. (5% bonus to Milestone 3’s grade)

• Sections 3 and 4: Implement the bridge zero-adjust circuitry in simulation. Demonstrate that you can
adjust the zero-adjust circuitry values to compensate for an unbalanced loadcell bridge within the sim-
ulated loadcell. You must also have the instrumentation amplifier and clamping circuitry included and
functional in your simulation.(5% bonus to Milestone 3’s grade)

12.8.2 Week 11 Bonus


These can be completed during either the Week 10 or 11 lab sessions.

• Section 1: Have Matlab graph the force data from the Esduino and load cell “live” so that points are
plotted in the graph as soon as they are received. (5% bonus to Milestone 3’s grade)

• Section 2: Press a key in Matlab and have the Esduino’s display switch toggle between showing Force in
Newtons and in Kg (5% bonus to this week’s grade)

12-4 Edit Date: February 12, 2013


• Sections 3 and 4: Have the Esduino LCD display a bar graph whose bar is proportional to the force on
the load cell. (5% bonus to Milestone 3’s grade)

In each case you must demonstrate the functionality to the TA during the lab and you must include a copy
of your source code in your report.

12.9 Communication
You will need to demonstrate your simulations in Week 10 and your working system to the TA in Week 11. You
will then submit a standard four page written report one week after your Week 11 lab, by 11:59pm of the night
in question. You need to email the TA your PDF document, including a standard signed FEAS cover sheet.

12.10 Post-lab reflection


After Week 11 you will be integrating all of the features that you have developed over the semester (LEDs,
LCD, accelerometers and load cell). Review the design specifications at the beginning of the lab guide.

12-5 Edit Date: February 12, 2013


ELE604 Milestone 3 Marking Guide (Lab) 2012

• Demo Maple Simulation of (needs to be checked in live


lab demo in Week 10) (3 pts) Deductions
o All three simulations working (3/3) • Lateness of report
o Two of three simulations working (2/3) o -5 pts (up to 1 day)
o One of three simulations working (1/3 o -25 pts (beyond one day)
o No simulations (0/3) • Font Modification (IEEE Template: Times New
• Demo of Hardware (needs to be checked in live lab Roman 10pt in main body, 24pt in title, 8pt in
demo in Week 11) (6 pts) References)
o On start-up, display Stress/Force = 0 o -5 pts (any changes)
o Force/stress measure for max deflection: • No Cover Sheet (FEAS official) or unsigned
0.5cm cover sheet
o Accuracy o -5 pts
 2% • Template Modification (margins, borders, header
 5% placement, etc.)
 10% o -5 pts (any changes)
o Signal is not noisy • No source code in appendix (not IEEE format)
• Written Skill Questions in Report (put in Design o -5 pts
Analysis Section) (6 pts total) • No test results in report
o Six of six correct (6/6) o -5 pts
o Five of six correct (5/6) • Number of Pages (four pages, two column, IEEE
o Four of six correct (4/6) format)
o Three of six correct (3/6) o -5 pts (~3/4 of req’d)
o Two of six correct (2/6) o -10 pts (~1/2 of req’d)
o One of six correct (1/6) o -20 pts (anything less)
o None correct (0/6)
• Oral Questions during Week 11 demo. (5 pts total)
o Five of five correct (5/5)
o Four of five correct (4/5)
o Three of five correct (3/5)
o Two of five correct (2/5)
o One of five correct (1/5)
o None correct (0/5)
• Written report includes (1 pt)
o Abstract, Objectives, Theory, Design
Analysis, Experimental Procedure, Results
and Observations, Conclusions and
Recommendations, Reference and Appendix
headings (1/1)
o Any heading missing (0/1)
• Overall Written Report Content (4 pts)
o Clear, concise and accurate (4/4)
o Moderately unclear, inaccurate or verbose
(2/4)
o Unclear, inaccurate or verbose (0/4)

Left Column Total /25 Right Column Deduction

Your grade: /25


ELE604 Milestone 3 Marking Guide (Lab) 2012

How is your grade calculated?

In the left column, your citations, language and content are evaluated. The marking is based on how well you
perform in each of those items. The individual scores are added up and written in the box below the column.

Afterwards, deductions are is made based on the factors in the right hand column. The deductions are
cumulative and can reduce your grade to 0 (minimum).

** Note: Use the IEEE Template Word document for ELE604! **


** Don’t change the template! **
** Go to www.ee.ryerson.ca/~jasmith/courses/ele604/support_docs for the template **

Plagiarism, Copying, etc.


Remember: Plagiarism is wrong! If you copy from a book, journal or online source (or your friend)
you will receive 0 and may receive a record on your transcript.
12-8 Edit Date: February 12, 2013
Chapter 13

Weeks 12 -14: Integration and Demonstration (to be


updated)

13.1 Straight to the Point


By the end of the semester you need to integrate all of the previous lab projects into a single 9s12-based Data
Acquisition.

13.2 Overview
In Weeks 12 and 13, work on integrating the angle and force functions, per the specifications. In Week 14,
complete demonstration of all functions per specifications. Seamless deterministic / realtime execution of
all functions, and any enhancements implemented by the final lab session. Final source-code version to be
compiled/assembled during the demo. The live demonstration, using the “Marking Scheme for Milestone 4”, is
the requirement for Milestone 4. There is nothing to hand in for Milestone 4 (i.e. there is no formal report...
the reporting milestone is Milestone 5). You are required to demonstrate the microcontroller functionality to
the TA during the scheduled lab session. There will be no extensions for the Milestone 4 demonstration.
The final lab report, Milestone 5, is to be a report on the design, development, testing and demonstration
of your sensing and measurement system. Marking will be as per the marking scheme.

13.3 Success Criteria


To determine success in this final stage of the ELE604 lab, you will be judged on both a live demonstration of
your sensing and measurement system (Milestone 4) and on the written report (Milestone 5). Look over the
specifications listed below and follow the marking guides at the end of this chapter.

13.4 Exploration
In addition to achieving the basic functional requirements you should explore different approaches to the user
experience.
The sequence of operations is described in the list below.

13.4.1 Functional Sequence of Operations


The sequence of operations is described in the list below and is shown visually in Fig. 13.4.1.

1. On Power-up, the names of the lab partners should appear on the LCD.

13-1
Oscilloscope test Digital volt meter Test
5 V power supply
equipment equipment

Pushbutton
LED
switch(es)
Digital Digital
input output
Accelerometer 9s12 LED

ADC SPI
LED

External Voltage
reference LCD Display

Balancing Analog input


Loadcell
circuitry stage protection

+15 V and -15 V


power supply

 
(a) Components (b) User Interface Concept (c) An example implementation

Figure 13.1: Your system should integrate the components in (a) to create a basic user interface (b) (image
courtesy of Dr. Mike Kassam). Many designs are possible. One example is shown in (c).

2. If the button is pressed twice, in quick succession, the LCD should show if the force and angles are in
“safe” or “dangerous” zones. No LEDs should be flashing. This should continue unless the user presses
the button once (to exit).

3. If the button was not pushed, or if the user has exited the other mode, the “Angle” LED should light-up
& flash indicating angle measurement in progress. The LCD display should display Angle in “real-time”,
as shown in Fig. 13.4.1a.

4. For Force selection, the user momentarily presses the Push-button once to light-up & flash the “Force”
LED, indicating Force measurement. The LCD display should display Force in “real-time”, as shown in
Fig. 13.4.1b.

5. When the user presses the Push-button again, only the “Force & Angle” LED is turned on and flashing,
with “real-time” display of the parameters, as shown in Fig. 13.4.1c.

6. When the user presses the Push-button again, the cycle reverts to displaying Angle.

7. If, at any point, the user presses the button for ten seconds or more the system should begin streaming
data to a PC where it can be read by Matlab. The LCD should display that PC communication is in
effect.

  (a) Step 1   (b) Step 2   (c) Step 3

Figure 13.2: After displaying a startup screen showing the names of the two partners, The sequence of operations
to display. (images courtesy of Dr. Mike Kassam)

Electrical and Mechanical Considerations


Force Should cover range (in a contiguous manner) to maximum weight of 0.5 LB or 230 grams (maximum
beam deflection of 0.28mm). Minimum accuracy of ±2 %, and maximum drift of < 1%/min at room
temperature is required. The “dangerous” zone is 200 grams or more.

13-2 Edit Date: February 12, 2013


Angle Using a separate test-jig, angle range should cover tilt of 0◦ to 180◦ (in a contiguous manner) from the
horizontal, with minimum resolution of 0.2◦ . The “dangerous” zone is 160◦ or more.
Deterministic “real-time” Update Rate Update or refresh rate for all measured values ≤ 30 msecs.
LED “Flashing” Rate 0.5 second ON, 0.5 second OFF.
Cantilever Beam: Test jig on each lab bench has the strain-gage sensors and resistors mounted on the can-
tilever beam (from Futek), configured as a full bridge
Load Cell / Strain-Gauge Gauge is pre-mounted on 17-4PH Stainless Steel; GF = 2.0; Ro = 1000 Ω.
Voltage Reference The stable bridge excitation voltage should be set to 10V d.c. using the 10V Voltage
Reference IC provided in your Kit.
Accelerometer MEMSIC2125: Refer to Datasheets.
Microcontroller Technological Arts 9s12 Esduino board: Refer to Datasheets and Lab Manual.

13.4.2 Recommended Design and Measurement Process


• Once the Angle and Force (or Stress) functions are independently tested (as they should have been in
your previous labs), your source-code should be evolved to integrate both sets of measurements to realize
the full functionality of the instrumentation. Make appropriate measurements to your integrated design
to validate compliance to the desired specifications.
• Prepare a formal technical report as per the guidelines provided. One formal report per Lab group is
required (limited to maximum of 12 pages, not including source code, references, and Appendix)

13.4.3 Packaging and Build Quality


In the development of Milestone 4 you should explore packaging issues for your sensing and measurement
system. Your TA will inspect the quality of the soldering and workmanship of the packaging. With respect to
packaging, you should consider the following:

• KISS: “Keep it Simple, Stupid!”.


– Simpler designs have less flaws
– Murphy’s Law: “If it can go wrong, it probably will.”
– Minimize connectors and long wires.
– Combine individual wires into bundled cables.
• Intuitive usage
– Nobody reads the manuals
– Is it obvious to the TA how your user interface works?
• Rugged design
– Can you pick up the system without it falling apart?
– Can you drop it without breaking it?
• In general: design for the local environmental conditions
– Can you design the box for transportation in a backpack or on the subway?
– How would you design it for dust, sand, snow, humidity, etc.

13-3 Edit Date: February 12, 2013


13.5 Bonus Objectives
Except where specified, bonus points are only awarded to the first group in a particular lab section that is
able to accomplish all of the demonstrable items of the lab, plus the bonus objective, listed below. The bonus
activity must be demonstrated to the lab TA prior to the end of the lab session. The bonus is applied to your
current lab and cannot result in a mark above 100% for the current lab assignment and will be added to your
final lab grade. Your final lab grade cannot exceed 100%.

13.5.1 Packaging Bonus


These can only be completed during a student’s scheduled Milestone 4 in-lab demonstration session. This bonus
is available to all groups in a particular lab section that can demonstrate it during the lab.

• All Students in all sections: A 3% bonus will be added to the Milestone 4 mark to all groups that place
their DAQ systems within a “sturdy” box that can, at minimum, reasonably protect the DAQ from objects
typically found in a student’s backpack. Cardboard or paper boxes do not qualify for a bonus.

13.5.2 Software Bonus


Bonus points are awarded to the groups in a particular lab section that are able to accomplish all of the
demonstrable items of the lab, plus the bonus objective, listed below. The bonus activity must be demonstrated
to the lab TA during the lab and prior to the end of the lab session. The bonus is applied to the current lab
and cannot result in a mark above 100% for the current lab assignment. Your final lab grade cannot exceed
100%, however.
If multiple groups submit an entry for the bonus, then bonus marks will be shared and ranked to the inverse
of the executable code size (ELF or S19 file, whichever you download on to the microcontroller). The group
with the smallest working executable file for the bonus in question will receive the highest percentage of bonus
mark, according to this formula:
1
Bj
Sj = n · 100% (13.1)
P 1
Bi
i=1

where Sj is the score of the j th group, and n groups have submitted bonus exercises. Bj is the code size, in
bytes, of the group’s executable code. The result is a percentage applied to the actual bonus score, found below.
These can only be completed during a student’s scheduled Milestone 4 in-lab demonstration session.

• Section 1: Create a Matlab script that requests the user to place four known masses on the loadcell and
then shows the characteristic linear input-output relationship between Mass and ADC on the 9s12. (5%
bonus to Milestone 5’s grade)

• Section 2: Display live mass values in Matlab with minimal lag. Make sure that it can show mass versus
time, so that if you slowly add the mass, the curve updates to show the change over time. (5% bonus to
Milestone 5’s grade)

• Sections 3 and 4: Create a Matlab script that can automatically read the mass value on the Esduino to
determine the zero offset and command the Esduino to adjust the offset without the use of the bias circuit
potentiometer (5% bonus to Milestone 5’s grade)

In each case you must demonstrate the functionality to the TA during the lab and you must include a copy
of your source code in your report.

13-4 Edit Date: February 12, 2013


13.6 Communication
You will need to demonstrate your system to the TA in Week 14 (Final Demo: Milestone 4). The final lab
report (Milestone 5) is due as an email to your TA on the last day of classes (i.e. before the examination period
begins): Friday, April 13 at 11:59pm.
To reiterate:

• Milestone 4: in-lab oral presentation and demonstration.

• Milestone 5: written report to be emailed on the last day of class before examinations (April 15 at
11:59pm)

13.6.1 Milestone 5 Requirements


Milestone 5 takes the form of a written report. It is to be in IEEE format, as before. It is to be between
six and ten pages in length (minimum six, maximum ten), without the Appendix. The Appendix should
include datasheets and relevant documentation from external sources. You are also to submit separate text
files including all source code (*.c and *.h produced by your group; do not include the Codewarrior-generated
system files).
Please review the Milestone 5 marking guide at the end of this chapter for details as to how your submission
will be graded.
We would love to hear your feedback on the use of the Esduino boards. While not a requirement for the
report, if you wish to briefly discuss your experience of the board (especially with respect to other systems you
may have had experience with), please do so.

13.7 Post-lab reflection


Consider how you could use the Esduino in an EDP project using off-the-shelf Arduino application “shields”.
Note that vendors of the 9s12, like Technological Arts and Wytec, sell more powerful boards, too!
Once you have handed in Milestone 5, you’re done! Study for the final exam and enjoy your summer!

13-5 Edit Date: February 12, 2013


ELE604 Milestone 4 Marking Guide (Live Demonstration) 2012

• State 1 demonstrated (LCD startup screen). Show the names


of the group members.
o Startup screen demonstrated (2/2)
o No startup screen (0/2)
• State 2 demonstrated (Angle Measurement). Show that LCD
doesn’t flicker and that the correct characters appear on the
LCD to show the measurement. Deductions
o Both items achieved (2/2) • Cannot demonstrate during lab
o One item achieved (1/2) o -15 pts
o Neither achieved (0/2)
• State 3 demonstrated (Stress / Force Measurement). Show
that LCD doesn’t flicker and that the correct characters
appear on the LCD to show the measurement.
o Both items achieved (2/2)
o One item achieved (1/2)
o Neither achieved (0/2)
• State 4 demonstrated (Stress/Force and Angle together) Show
that LCD doesn’t flicker and that the correct characters
appear on the LCD to show the measurement.
o Both items achieved (2/2)
o One item achieved (1/2)
o Neither achieved (0/2)
• Overall Implementation. Cycle through all states without
anomalies or “residual” characters on the LCD. LCD refresh
rate is “reasonable”, minimizing flicker and “old” characters.
o Both items achieved (2/2)
o One item achieved (1/2)
o Neither achieved (0/2)
• Oral Explanation. Explain to the TA how your code works
and how the sensors interact with microcontroller. You must
be exact in explaining how it works to get full marks. Both
group members must answer questions independently.
o Very good explanation. All questions answered
accurately (3/3)
o Moderate explanation. Some mistakes made.
(2/3)
o Okay explanation. Many mistakes made. (1/3)
o Unacceptable. Cannot answer basic questions
(0/3)

Right Column Deduction


Left Column Total

Your grade: /15

Group member signatures (Sign, Date & ID)

1.
2.
ELE604 Milestone 5 Marking Guide (Final Report) 2012

• Written report includes Deductions


o Abstract, Objectives, Theory, Design Analysis, • Lateness of report
Experimental Procedure, Results and o -5 pts (up to 1 day)
Observations, Conclusions and o -15 pts (beyond one day)
Recommendations, Reference and Appendix • Font Modification (IEEE Template: Times New Roman
headings (1/1) 10pt in main body, 24pt in title, 8pt in References)
o Any heading missing (0/1) o -5 pts (any changes)
• Overall Written Report Content • No Cover Sheet (FEAS official) or unsigned cover
o Clear, concise and accurate (2/2) sheet
o Moderately unclear, inaccurate or verbose (1/2) o -5 pts
o Unclear, inaccurate or verbose (0/2) • Template Modification (margins, borders, header
• Experimental Results for Accelerometer tilt measurement placement, etc.)
and Load Cell force measurement (in Results and o -5 pts (any changes)
Observations section) • No source code in separate text files (not IEEE format)
o Clear, concise and accurate (2/2) o -15 pts
o Moderately unclear, inaccurate or verbose (1/2) • Incomplete source code (student-generated *.c and *.h
o Unclear, inaccurate or verbose (0/2) code submitted in separate text files)
• Written explanation of how LCD refreshing was done to o -5 pts
provide clear, non-flickering performance (in Design • No test results in report
Analysis section) o -5 pts
o Complete & correct written explanation (2/2) • Number of Pages (six pages minimum, two column,
o Incomplete or slight error in written explanation IEEE format)
(1/2) o -5 pts (~3/4 of req’d)
o No or incorrect written explanation (0/2) o -10 pts (~1/2 of req’d)
• Written Explanation of Tilt Algorithm (accelerometer) is o -15 pts (anything less)
clear, correct & concise (in Design Analysis section)
o Complete & correct written explanation (2/2)
o Incomplete or slight error in written explanation
(1/2)
o No or incorrect written explanation (0/2)
• Graphical / Flow-chart Explanation of Tilt Algorithm
(accelerometer) is clear, correct & concise (in Design
Analysis section)
o Complete & correct graphical explanation (2/2)
o Incomplete / slight error in graphical explanation
(1/2)
o No or incorrect graphical explanation (0/2)
• Written Explanation of Force Algorithm (load cell) is
clear, correct & concise (in Design Analysis section)
o Complete & correct written explanation (2/2)
o Incomplete or slight error in written explanation
(1/2)
o No or incorrect written explanation (0/2)
• Graphical / Flow-chart Explanation of Force Algorithm
(load cell) is clear, correct & concise (in Design Analysis
section)
o Complete & correct graphical explanation (2/2)
o Incomplete / slight error in graphical explanation
(1/2)
o No or incorrect graphical explanation (0/2)

Left Column Total /15


Right Column Deduction

Your grade: /15


Department of Electrical & Computer Engineering
Program: Electrical Engineering

Course Number ELE604


Course Title Sensors and Measurement
Semester/Year Winter 2011
Instructor James A. Smith

Lab/Tutorial Report NO. 5

Report Title Final Lab Report

Section No.
Group No.
Submission Date n/a
Due Date Last class (11:59pm)

Name Student ID Signature*

(Note: remove the first 4 digits from your student ID)

*By signing above you attest that you have contributed to this submission and confirm that
all work you have contributed to this submission is your own work. Any suspicion of
copying or plagiarism in this work will result in an investigation of Academic Misconduct
and may result in a “0” on the work, an “F” in the course, or possibly more severe
penalties, as well as a Disciplinary Notice on your academic record under the Student
Code of Academic Conduct, which can be found online at:
www.ryerson.ca/senate/current/pol60.pdf.
Bibliography

[1] MC9S12C Family Device User Guide. Motorola Inc., v01.05 edition, February 2004.

[2] S12(X) Assembler Manual. Freescale Semiconductor, February 2009.

[3] MC9s12C Family MC9s12GC Family Reference Manual. Freescale Semiconductor, rev. 01.24 edition, May
2010.

[4] Motorola 6800. Online, December 2010. http://en.wikipedia.org/wiki/Motorola_6800.

[5] S12(X) Build Tools Reference Manual. Freescale Semiconductor, August 2010.

[6] George Adams, Jr. Henry Blume, Shep Hume, Ronald Towle, John Wharton, Bob Wickersheim, Bill Wong,
, John Ekiss, and David Laws. Intel 8051 microprocessor oral history panel. Technical Report X5007.2009,
Computer History Museum, Moutain View, California, USA, 2008. http://archive.computerhistory.
org/resources/access/text/Oral_History/102658339.05.01.acc.pdf.

[7] Thomas H. Bennett, John Ekiss, William (Bill) Lattin, Jeff Lavell, and David Laws. Motorola 6800 oral
history panel. Technical report, Computer History Museum, Tempe, Arizona, March 2008.

[8] Allan Hambley. Electrical Engineering: Principles and Applications. Pearson Education, fifth edition,
2008.

[9] Peter Hiscocks. Application notes. Online http://www.syscompdesign.com/AppNote.html, November


2010.

[10] Henry Blume Jr., John Ekiss, Yung Feng, Barbara Kline, Howard Raphael, David Stamm, and David Laws.
Oral history panel on the development and promotion of the intel 8048 microcontroller. Technical report,
Computer History Museum, Moutain View, California, USA, 2008. http://archive.computerhistory.
org/resources/access/text/Oral_History/102658328.05.01.acc.pdf.

[11] J. C. King. Strain-gauge rosette formulae. Aircraft Engineering and Aerospace Technology, 16(2):32 – 49,
1993. http://www.emeraldinsight.com/journals.htm?articleid=1678390.

[12] Muhammad Ali Mazidi and Danny Causey. HCS12 Microcontroller and Embedded Systems: Using Assembly
and C with CodeWarrior. Pearson Prentic Hall, 2009.

[13] Motorola Inc. Motorola achieves design wins of $1 billion+ for 16-bit microcontroller family. PR Newswire,
pages 1–1, Nov. 26 2001.

[14] Freescale Semiconductor. The xgate coprocessor. Technical Report XGATECOPROCFS, Freescale Semi-
conductor, 2004.

[15] Freescale Seminconductor. Mc9s12c family mc9s12gc family reference manual. Reference Manual
MC9S12C128 Rev 01.23, Freescale Semiconductor, June 2007.

13-9
[16] Jim Williams. Serial monitor program for hcs12 mcus. Application Note AN2548/D, Freescale Semiconduc-
tor, September 2003. http://www.freescale.com/files/microcontrollers/doc/app_note/AN2548.
pdf?fsrch=1.

[17] Ron Wilson. Seeks 16-bit hc11 migration path – moto spins new mcu line. Electronic Engineering Times,
(01921541):16–16, May 27 1996. MOTOROLA INC; (Copyright 1996 CMP Publications, Inc. All rights re-
served.); May 27, 1996; English; 16; ELECTRONICS; SEMICONDUCTORS; INDUSTRIAL TECHNOL-
OGY; TECHNOLOGY; COMMUNICATIONS; 208132261; EETIDQ; Manhasset; Wilson, Ron; 10660679;
565100; 16096; ELET.

10 Edit Date: February 12, 2013


Appendix A

Additional Lab Safety Documentation

A-1
Draft 01/18/11 Jim Koch

Lab Safety Overview

Emergency procedures, lab rules, and engineering support contact information is posted on the lab
door.

Lab Emergency Equipment.


• Red Push buttons.
◦ Pushing, kills power to the lab.
◦ Use in the event of electrocution, equipment fire etc.
◦ System must be reset by engineering support.
◦ Accidental activation, my subject you to Student Code of Conduct violation.
• Blue Emergency Pull
◦ Sends an alarm to Security who will dispatch one or more officers to the lab.
◦ Use in the event of electrocution, accident, or medical emergency.
◦ If possible call Security to let them know what the emergency is. 416-979-5040 or 80 on a
campus phone.
◦ It's best to call Security first before calling 911. They can respond faster and can better
direct emergency services if they are needed.
◦ Accidental activation, my subject you to Student Code of Conduct violation.

First Aid.
• Minor cuts/burn use small kit by door, if you use supplies let engineering support know.
• Minor and up injuries, See First Aider, Dan in ENG439.
• Ryerson Medical Centre KHW 181.
• St Michael's Hospital 70 Richmond Street East

No Food or Drink in the lab.


• Accidental spills into equipment or on the floor creates an immediate safety hazard. Contact
engineering support for cleanup.
• You are handling toxic materials in the lab which can transfer to the food/drink and be ingested.
• The mess left behind can attract bugs, and the next student using the station isn't going to be to
happy.
• Eating/Drinking in the lab my subject you to Student Code of Conduct violation.

Soldering.
• The soldering tip end is very hot and will burn flesh immediately, or cause a fire if left in
contact with combustible materials.
• Only lead free solder is to be used in the lab.
• Always return the iron to the stand.
• Turn off iron when finished for the day.
• When soldering and trimming leads safety glasses are required.
• When trimming soldered leads make sure they do not fly into your eyes or equipment vents etc.
• Use the fume extractors at all times.
• Never use plumbers solder paste as it contains acid and will eat away your circuit.

1
Draft 01/18/11 Jim Koch

• Wash hands after soldering.

Load cell weights.


• Load cell weights are made of lead and painted over.
• Wash hands after working with weights to avoid led contamination.

Lab equipment.
• Make sure the test equipment is on the correct range before taking measurements.
• Make sure the test you are about to perform does not exceed the test equipments rating.
• Report any defective or unsafe equipment to engineering support.
• Scope ground is earth ground. Green Wire in AC plug. Us caution when placing ground in your
circuit as it may short things out. If unsure, ask to borrow a differential probe which will isolate
grounds.
• Screen capture: HP/Agilent scopes, Run Windows XP, click on HP Bench Link Scope icon.
• Screen capture: Tektronix scope, type scope in the URL bar.
• If there is no power to the bench, make sure it's plugged into the floor outlet properly and that
the power bar mounted under the bench is plugged into the bench and turned on.

2
A-4 Edit Date: February 12, 2013
Appendix B

To Be Sorted Later

B-1
Freescale Semiconductor MC9S12CFAMPB
Rev. 5, 03/2006
Product Brief

MC9S12C-Family
16-Bit Microcontroller

Based on Freescale’s market-leading flash technology, members of the MC9S12C-Family deliver the
power and flexibility of our 16 Bit core (CPU12) family to a whole new range of cost and space sensitive,
general purpose Industrial and Automotive network applications. MC9S12C-Family members are
comprised of standard on-chip peripherals including a 16-bit central processing unit (CPU12), up to 128K
bytes of Flash EEPROM or ROM, up to 4K bytes of RAM, an asynchronous serial communications
interface (SCI), a serial peripheral interface (SPI), an 8-channel 16-bit timer module (TIM), a 6-channel
8-bit pulse width modulator (PWM), an 8-channel, 10-bit analog-to-digital converter (ADC) and up to one
CAN 2.0 A, B software compatible module (MSCAN12). The MC9S12C-Family has full 16-bit data paths
throughout. The inclusion of a PLL circuit allows power consumption and performance to be adjusted to
suit operational requirements. In addition to the I/O ports available in each module, up to 10 dedicated I/O
port bits are available with Wakeup capability from STOP or WAIT mode. The MC9S12C-Family is
available in 48-pin and 52-pin LQFP, and in 80-pin QFP packages (all RoHS Compliant J-STD-020C); the
80-pin version is pin-compatible with the HCS12B- and D-Family derivatives.
The C-Family includes ROM versions MC3S12C128/96/64/32/16 of all devices which provide a further
cost reduction path for applications with high volume and stable code.

1 Features
• 16-Bit HCS12 CORE
— HCS12 CPU
— MMC (memory map and interface)
— INT (interrupt control)
— BDM (background debug mode)
— DBG12 (enhanced debug12 module including breakpoints and change-of-flow trace buffer)
— Multiplexed Expansion Bus (available only in 80-pin package version)

© Freescale Semiconductor, Inc., 2005, 2006. All rights reserved.


Features

• 16-Bit HCS12 CPU


— Upward compatible with M68HC11 instruction set
— Interrupt stacking and programmer’s model identical to M68HC11
— Instruction queue
— Enhanced indexed addressing
• Wake-up Interrupt Inputs
— Up to 10-port bits available for wake up interrupt function
• Memory Options
— 16K, 32K, 64K, 96K and 128K Byte Flash EEPROM (erasable in 512-byte sectors) or
— 16K, 32K, 64K, 96K and 128K Byte ROM
— 1K, 2K, and 4K Byte RAM
• Analog-to-Digital Converters
— One 8-channel module with 10-bit resolution.
— External conversion trigger capability
• Up to One 1M Bit Per Second, CAN 2.0 A, B Software Compatible Modules
— Five receive and three transmit buffers
— Flexible identifier filter programmable as 2 x 32 bit, 4 x 16 bit or 8 x 8 bit
— Four separate interrupt channels for receive, transmit, error and wake-up
— Low-pass filter wake-up function
— Loop-back for self test operation
• Timer Module (TIM)
— 16-bit Counter with 7-bit Prescaler
— 8 programmable input capture or output compare channels
— Simple PWM Mode
— Modulo Reset of Timer Counter
— 16-Bit Pulse Accumulator
— External Event Counting
— Gated Time Accumulation
• 6 PWM Channels
— Programmable period and duty cycle
— 8-bit 6-channel or 16-bit 3-channel
— Separate control for each pulse width and duty cycle
— Center-aligned or left-aligned outputs
— Programmable clock select logic with a wide range of frequencies
— Fast emergency shutdown input

MC9S12C-Family, Rev. 5
2 Freescale Semiconductor
Features

• Serial Interfaces
— One asynchronous serial communications interface (SCI)
— One synchronous serial peripheral interface (SPI)
• CRG (Clock Reset Generator Module)
— Windowed COP watchdog,
— Real time interrupt,
— Clock monitor,
— Clock generation
— Reset Generation
— Phase-locked loop clock frequency multiplier
— Limp home mode in absence of external clock
— Low power 0.5 to 16 MHz crystal oscillator reference clock
• Operation Frequency
— 32MHz equivalent to 16MHz Bus Speed for single chip
— 32MHz equivalent to 16MHz Bus Speed in expanded bus modes
— Option: 50MHz equivalent to 25MHz Bus Speed
— Internal 2.5V Regulator
— Supports an input voltage range from 3.3V-10% to 5.5V
— Low power mode capability
— Includes low voltage reset (LVR) circuitry
— Includes low voltage interrupt (LVI) circuitry
• 48-pin LQFP, 52-pin LQFP, or 80-pin QFP Package (all RoHS Compliant J-STD-020C)
— Up to 58 I/O lines with 5V input and drive capability
— Up to 2 dedicated 5V input only lines (IRQ, XIRQ)
— 5V A/D converter inputs and 5V I/O
• Development Support
— Single-wire background debug™ mode (BDM)
— On-chip hardware breakpoints
— Enhanced DBG12 debug features

MC9S12C-Family, Rev. 5
Freescale Semiconductor 3
MC9S12C-Family Members

2 MC9S12C-Family Members
Table 1. List of MC9S12C-Family Members
Flash ROM RAM Package Device CAN SCI SPI A/D PWM Timer I/O
48LQFP MC9S12C128 1 1 1 8ch 6ch 8ch 31
128K 0 4K 52LQFP MC9S12C128 1 1 1 8ch 6ch 8ch 35
80QFP MC9S12C128 1 1 1 8ch 6ch 8ch 60
48LQFP MC9S12C96 1 1 1 8ch 6ch 8ch 31
96K 0 4K 52LQFP MC9S12C96 1 1 1 8ch 6ch 8ch 35
80QFP MC9S12C96 1 1 1 8ch 6ch 8ch 60
48LQFP MC9S12C64 1 1 1 8ch 6ch 8ch 31
64K 0 4K 52LQFP MC9S12C64 1 1 1 8ch 6ch 8ch 35
80QFP MC9S12C64 1 1 1 8ch 6ch 8ch 60
48LQFP MC9S12C32 1 1 1 8ch 6ch 8ch 31
32K 0 2K 52LQFP MC9S12C32 1 1 1 8ch 6ch 8ch 35
80QFP MC9S12C32 1 1 1 8ch 6ch 8ch 60
48LQFP MC9S12GC32 0 1 1 8ch 6ch 8ch 31
32K 0 2K 52LQFP MC9S12GC32 0 1 1 8ch 6ch 8ch 35
80QFP MC9S12GC32 0 1 1 8ch 6ch 8ch 60
48LQFP MC9S12GC16 0 1 1 8ch 6ch 8ch 31
16K 0 1K 52LQFP MC9S12GC16 0 1 1 8ch 6ch 8ch 35
80QFP MC9S12GC16 0 1 1 8ch 6ch 8ch 60
48LQFP MC3S12C128 1 1 1 8ch 6ch 8ch 31
0 128K 4K 52LQFP MC3S12C128 1 1 1 8ch 6ch 8ch 35
80QFP MC3S12C128 1 1 1 8ch 6ch 8ch 60
48LQFP MC3S12C96 1 1 1 8ch 6ch 8ch 31
0 96K 4K 52LQFP MC3S12C96 1 1 1 8ch 6ch 8ch 35
80QFP MC3S12C96 1 1 1 8ch 6ch 8ch 60
48LQFP MC3S12C64 1 1 1 8ch 6ch 8ch 31
0 64K 4K 52LQFP MC3S12C64 1 1 1 8ch 6ch 8ch 35
80QFP MC3S12C64 1 1 1 8ch 6ch 8ch 60
48LQFP MC3S12C32 1 1 1 8ch 6ch 8ch 31
0 32K 2K 52LQFP MC3S12C32 1 1 1 8ch 6ch 8ch 35
80QFP MC3S12C32 1 1 1 8ch 6ch 8ch 60
48LQFP MC3S12GC32 0 1 1 8ch 6ch 8ch 31
0 32K 2K 52LQFP MC3S12GC32 0 1 1 8ch 6ch 8ch 35
80QFP MC3S12GC32 0 1 1 8ch 6ch 8ch 60
48LQFP MC3S12GC16 0 1 1 8ch 6ch 8ch 31
0 16K 1K 52LQFP MC3S12GC16 0 1 1 8ch 6ch 8ch 35
80QFP MC3S12GC16 0 1 1 8ch 6ch 8ch 60

MC9S12C-Family, Rev. 5
4 Freescale Semiconductor
Pin Out Explanations

3 Pin Out Explanations


I/O is the sum of ports capable to act as digital input or output.
• For 80 Pin Versions:
— Port A = 8, B = 8, E = 6 + 2 input only, J = 2, M = 6, P = 8, S = 4, T = 8, PAD = 8.
— 12 inputs provide Interrupt capability (P = 8, J = 2, IRQ, XIRQ)
• For 52 Pin Versions:
— Port A = 3, B = 1, E = 2 + 2 input only, M = 6, P = 3, S = 2, T = 8, PAD = 8.
— 5 inputs provide Interrupt capability (P = 3, IRQ, XIRQ)
• For 48 Pin Versions:
— Port A = 1, B = 1, E = 2 + 2 input only, M = 6, P = 1, S = 2, T = 8, PAD = 8.
— 3 inputs provide Interrupt capability (P = 1, IRQ, XIRQ)

MC9S12C-Family, Rev. 5
Freescale Semiconductor 5
Block Diagram

4 Block Diagram
VSSR VDDA VDDA
VDDR ATD VSSA VSSA
VDDX VRH VRH
VSSX Voltage Regulator VRL VRL
AN0 PAD0
AN1 PAD1
AN2 PAD2

DDRAD
PTAD
AN3 PAD3
VDD2 32K, 64K, 96K, 128K Byte Flash/ROM AN4 PAD4
VSS2 AN5 PAD5
VDD1 AN6 PAD6
1K, 2K, 4K Byte RAM
VSS1 AN7 PAD7

BKGD Single-wire Background IOC0 PT0


Debug12 Module HCS12
CPU IOC1 PT1
XFC IOC2 MUX PT2

DDRT
VDDPLL IOC3 PT3

PTT
Clock and Timer
VSSPLL Reset Module IOC4 PT4
PLL Generation
EXTAL COP Watchdog IOC5 PT5
Module
XTAL Clock Monitor IOC6 PT6
RESET Periodic Interrupt IOC7 PT7
PE0 XIRQ PW0 PP0

Keypad Interrupt
PE1 IRQ PW1 PP1
System PW2
PE2 R/W PWM PP2
Integration
DDRE

DDRP
PTE

PTP
PE3 LSTRB/TAGLO Module Module PW3 PP3
PE4 ECLK (SIM) PW4 PP4
PE5 MODA/IPIPE0 PW5 PP5
PE6 MODB/IPIPE1 PP6
PE7 NOACC/XCLKS PP7
TEST/VPP

Key Int
DDRJ
PJ6

PTJ
PJ7
Multiplexed Address/Data Bus
RXD PS0
SCI

DDRS
TXD PS1

PTS
DDRA DDRB PS2
PS3
PTA PTB
RXCAN PM0
MSCAN
TXCAN PM1
DDRM
PB7
PB6
PB5

PB3
PB2
PB1
PB0
PB4
PA7
PA6
PA5
PA4
PA3
PA2
PA1
PA0

MISO PTM PM2


SS PM3
SPI
ADDR15
ADDR14
ADDR13
ADDR12
ADDR11
ADDR10

MOSI PM4
ADDR9

ADDR7
ADDR6
ADDR5

ADDR3
ADDR2
ADDR1
ADDR0
ADDR8

ADDR4

SCK PM5
DATA15
DATA14
DATA13
DATA12
DATA11
DATA10
DATA9

DATA7
DATA6
DATA5

DATA3
DATA2
DATA1
DATA0
DATA8

DATA4

Multiplexed
Wide Bus Signals shown in Bold are not available on the 52 or 48 Pin Package
Signals shown in Bold Italic are available in the 52, but not the 48 Pin Package

Internal Logic 2.5V I/O Driver 5V


VDD1,2 VDDX
VSS1,2 VSSX

PLL 2.5V A/D Converter 5V VRL is bonded internally to VSSA


VDDPLL VDDA for 52 and 48 Pin packages
VSSPLL VSSA

Voltage Regulator 5V & I/O


VDDR
VSSR

Figure 1. Block Diagram

MC9S12C-Family, Rev. 5
6 Freescale Semiconductor
User Configurable Memory Maps

5 User Configurable Memory Maps

$0000 1K Register Space

$0000 $03FF Mappable to any 2K Boundary


$0400 $0000
16K Fixed Flash EEPROM/ROM
$3FFF

$3000 $3000 4K Bytes RAM

$3FFF Mappable to any 4K Boundary


$4000
$4000

16K Fixed Flash EEPROM/ROM

$7FFF
$8000
$8000

16K Page Window


EXT 8 * 16K Flash EEPROM/ROM Pages

$BFFF
$C000
$C000 16K Fixed Flash EEPROM/ROM

$FFFF
$FF00 BDM
$FF00 (If Active)
$FFFF VECTORS VECTORS VECTORS $FFFF

NORMAL EXPANDED SPECIAL


SINGLE CHIP SINGLE CHIP

The figure shows a useful map, which is not the map out of reset. After reset the map is:
$0000 - $03FF: Register Space
$0000 - $0FFF: 4K RAM (only 3K visible $0400 - $0FFF)
Flash Erase Sector Size is 1024 Bytes

Figure 2. MCxS12C128 User Configurable Memory Map

MC9S12C-Family, Rev. 5
Freescale Semiconductor 7
User Configurable Memory Maps

$0000 1K Register Space

$0000 $03FF Mappable to any 2K Boundary


$0400 $0000
16K Fixed Flash EEPROM/ROM
$3FFF

$3000 $3000 4K Bytes RAM

$3FFF Mappable to any 4K Boundary


$4000
$4000

16K Fixed Flash EEPROM/ROM

$7FFF
$8000
$8000

16K Page Window


EXT 6 * 16K Flash EEPROM/ROM Pages

$BFFF
$C000
$C000 16K Fixed Flash EEPROM/ROM

$FFFF
$FF00 BDM
$FF00 (If Active)
$FFFF VECTORS VECTORS VECTORS $FFFF

NORMAL EXPANDED SPECIAL


SINGLE CHIP SINGLE CHIP

The figure shows a useful map, which is not the map out of reset. After reset the map is:
$0000 - $03FF: Register Space
$0000 - $0FFF: 4K RAM (only 3K visible $0400 - $0FFF)
Flash Erase Sector Size is 1024 Bytes

Figure 3. MCxS12C96 User Configurable Memory Map

MC9S12C-Family, Rev. 5
8 Freescale Semiconductor
User Configurable Memory Maps

$0000 1K Register Space

$0000 $03FF Mappable to any 2K Boundary


$0400 $0000
16K Fixed Flash EEPROM/ROM
$3FFF

$3000 $3000 4K Bytes RAM

$3FFF Mappable to any 4K Boundary


$4000
$4000

16K Fixed Flash EEPROM/ROM

$7FFF
$8000
$8000

16K Page Window


EXT 4 * 16K Flash EEPROM/ROM Pages

$BFFF
$C000
$C000 16K Fixed Flash EEPROM/ROM

$FFFF
$FF00 BDM
$FF00 (If Active)
$FFFF VECTORS VECTORS VECTORS $FFFF

NORMAL EXPANDED SPECIAL


SINGLE CHIP SINGLE CHIP

The figure shows a useful map, which is not the map out of reset. After reset the map is:
$0000 - $03FF: Register Space
$0000 - $0FFF: 4K RAM (only 3K visible $0400 - $0FFF)
Flash Erase Sector Size is 512 Bytes

Figure 4. MCxS12C64 User Configurable Memory Map

MC9S12C-Family, Rev. 5
Freescale Semiconductor 9
User Configurable Memory Maps

$0000 1K Register Space

$0000 $03FF Mappable to any 2K Boundary


$0400

$3800 $3800 2K Bytes RAM

$3FFF Mappable to any 2K Boundary


$4000

$8000
$8000

16K Page Window


EXT 2 * 16K Flash EEPROM/ROM Pages

$BFFF
$C000
$C000 16K Fixed Flash EEPROM/ROM

$FFFF
$FF00 BDM
$FF00 (If Active)
$FFFF VECTORS VECTORS VECTORS $FFFF

NORMAL EXPANDED SPECIAL


SINGLE CHIP SINGLE CHIP

The figure shows a useful map, which is not the map out of reset. After reset the map is:
$0000 - $03FF: Register Space
$0800 - $0FFF: 2K RAM
Flash Erase Sector Size is 512 Bytes

Figure 5. MCxS12C32 User Configurable Memory Map

MC9S12C-Family, Rev. 5
10 Freescale Semiconductor
User Configurable Memory Maps

$0000 1K Register Space

$0000 $03FF Mappable to any 2K Boundary


$0400

$3800 $3800 2K Bytes RAM

$3FFF Mappable to any 2K Boundary


$4000

$8000
$8000

16K Page Window


EXT 1 * 16K Flash EEPROM/ROM Page

$BFFF
$C000
$C000 16K Fixed Flash EEPROM/ROM

$FFFF
$FF00 BDM
$FF00 (If Active)
$FFFF VECTORS VECTORS VECTORS $FFFF

NORMAL EXPANDED SPECIAL


SINGLE CHIP SINGLE CHIP

The figure shows a useful map, which is not the map out of reset. After reset the map is:
$0000 - $03FF: Register Space
$0800 - $0FFF: 2K RAM
Flash Erase Sector Size is 512 Bytes

Figure 6. MCxS12C16 User Configurable Memory Map

MC9S12C-Family, Rev. 5
Freescale Semiconductor 11
User Configurable Memory Maps

$0000 1K Register Space

$0000 $03FF Mappable to any 2K Boundary


$0400

$3C00 $3C00 1K Bytes RAM

$3FFF Mappable to any 2K Boundary


$4000

$8000
$8000

16K Page Window


EXT 1 * 16K Flash EEPROM/ROM Page

$BFFF
$C000
$C000 16K Fixed Flash EEPROM/ROM

$FFFF
$FF00 BDM
$FF00 (If Active)
$FFFF VECTORS VECTORS VECTORS $FFFF

NORMAL EXPANDED SPECIAL


SINGLE CHIP SINGLE CHIP

The figure shows a useful map, which is not the map out of reset. After reset the map is:
$0000 - $03FF: Register Space
$0C00 - $0FFF: 1K RAM
Flash Erase Sector Size is 512 Bytes

Figure 7. MCxS12GC16 User Configurable Memory Map

MC9S12C-Family, Rev. 5
12 Freescale Semiconductor
Pin Assignments

6 Pin Assignments

PP6/KWP6/ROMONE
PP4/KWP4/PW4
PP5/KWP5/PW5

PM0/RXCAN
PM1/TXCAN
PP7/KWP7

PM4/MOSI
PM2/MISO

PJ6/KWJ6
PJ7/KWJ7
PM5/SCK

PS0/RXD
PS1/TXD
PM3/SS
VDDX
VSSX

VSSA
VRL
PS3
PS2
80
79
78
77
76
75
74
73
72
71
70
69
68
67
66
65
64
63
62
61
PW3/KWP3/PP3 1 60 VRH
PW2/KWP2/PP2 2 59 VDDA
PW1/KWP1/PP1 3 58 PAD07/AN07
PW0/KWP0/PP0 4 57 PAD06/AN06
PW0/IOC0/PT0 5 56 PAD05/AN05
PW1/IOC1/PT1 6 55 PAD04/AN04
PW2/IOC2/PT2 7 54 PAD03/AN03
PW3/IOC3/PT3 8 53 PAD02/AN02
VDD1 9 52 PAD01/AN01
VSS1 10 MC9S12C-Family 51 PAD00/AN00
PW4/IOC4/PT4 11 80 QFP 50 VSS2
IOC5/PT5 12 49 VDD2
IOC6/PT6 13 48 PA7/ADDR15/DATA15
IOC7/PT7 14 47 PA6/ADDR14/DATA14
MODC/TAGHI/BKGD 15 46 PA5/ADDR13/DATA13
ADDR0/DATA0/PB0 16 45 PA4/ADDR12/DATA12
ADDR1/DATA1/PB1 17 44 PA3/ADDR11/DATA11
ADDR2/DATA2/PB2 18 43 PA2/ADDR10/DATA10
ADDR3/DATA3/PB3 19 42 PA1/ADDR9/DATA9
ADDR4/DATA4/PB4 20 41 PA0/ADDR8/DATA8
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
ADDR5/DATA5/PB5
ADDR6/DATA6/PB6
ADDR7/DATA7/PB7
XCLKS/NOACC/PE7
MODB/IPIPE1/PE6
MODA/IPIPE0/PE5
ECLK/PE4
VSSR
VDDR

TEST/VPP
RESET
VDDPLL
XFC
VSSPLL
EXTAL
XTAL

LSTRB/TAGLO/PE3
R/W/PE2
IRQ/PE1
XIRQ/PE0

Signals shown in Bold are not available on the 52 or 48 Pin Package


Signals shown in Bold Italic are available in the 52, but not the 48 Pin Package

Figure 8. Pin Assignments for 80-pin QFP for MC9S12C-Family

!!! Pin-out is Subject to Change !!!

MC9S12C-Family, Rev. 5
Freescale Semiconductor 13
Pin Assignments

PP4/KWP4/PW4
PP5/KWP5/PW5

PM0/RXCAN
PM1/TXCAN

PM4/MOSI
PM2/MISO

PM5/SCK

PS0/RXD
PS1/TXD
PM3/SS
VDDX
VSSX

VSSA
52
51
50
49
48
47
46
45
44
43
42
41
40
PW3/KWP3/PP3 1 39 VRH
PW0/IOC0/PT0 2 38 VDDA
PW1/IOC1/PT1 3 37 PAD07/AN07
PW2/IOC2/PT2 4 36 PAD06/AN06
PW3/IOC3/PT3 5 35 PAD05/AN05
VDD1 6 34 PAD04/AN04
VSS1 7 MC9S12C-Family 33 PAD03/AN03
52 LQFP
PW4/IOC4/PT4 8 32 PAD02/AN02
IOC5/PT5 9 31 PAD01/AN01
IOC6/PT6 10 30 PAD00/AN00
IOC7/PT7 11 29 PA2
MODC/BKGD 12 28 PA1
PB4 13 27 PA0
14
15
16
17
18
19
20
21
22
23
24
25
26
XCLKS/PE7
ECLK/PE4

VDDR

VSSPLL
EXTAL
XTAL

IRQ/PE1
XIRQ/PE0
VSSR

VDDPLL
RESET

XFC

TEST/VPP

* Signals shown in Bold are not available on the 48 Pin Package

Figure 9. Pin Assignments for 52-pin LQFP for MC9S12C-Family

MC9S12C-Family, Rev. 5
14 Freescale Semiconductor
Pin Assignments

PM0/RXCAN
PM1/TXCAN
PP5/KWP5

PM2/MISO

PM4/MOSI
PM5/SCK

PS0/RXD
PS1/TXD
PM3/SS
VDDX
VSSX

VSSA
48
47
46
45
44
43
42
41
40
39
38
37
PW0/IOC0/PT0 1 36 VRH
PW1/IOC1/PT1 2 35 VDDA
PW2/IOC2/PT2 3 34 PAD07/AN07
PW3/IOC3/PT3 4 33 PAD06/AN06
VDD1 5 32 PAD05/AN05
VSS1 6 MC9S12C-Family 31 PAD04/AN04
48 LQFP
PW4/IOC4/PT4 7 30 PAD03/AN03
IOC5/PT5 8 29 PAD02/AN02
IOC6/PT6 9 28 PAD01/AN01
IOC7/PT7 10 27 PAD00/AN00
MODC/BKGD 11 26 PA0
PB4 12 25 XIRQ/PE0
13
14
15
16
17
18
19
20
21
22
23
24
VDDR
VSSR

RESET

XFC
XCLKS/PE7

VDDPLL
ECLK/PE4

VSSPLL
EXTAL
XTAL
TEST/VPP
IRQ/PE1

Figure 10. Pin Assignments for 48-pin LQFP for MC9S12C-Family

MC9S12C-Family, Rev. 5
Freescale Semiconductor 15
Package Mechanical Information

7 Package Mechanical Information


Refer to the following pages for detailed package dimensions.

MC9S12C-Family, Rev. 5
16 Freescale Semiconductor
Package Mechanical Information

MC9S12C-Family, Rev. 5
Freescale Semiconductor 17
Package Mechanical Information

MC9S12C-Family, Rev. 5
18 Freescale Semiconductor
Package Mechanical Information

MC9S12C-Family, Rev. 5
Freescale Semiconductor 19
Package Mechanical Information

MC9S12C-Family, Rev. 5
20 Freescale Semiconductor
Package Mechanical Information

MC9S12C-Family, Rev. 5
Freescale Semiconductor 21
Package Mechanical Information

MC9S12C-Family, Rev. 5
22 Freescale Semiconductor
Package Mechanical Information

MC9S12C-Family, Rev. 5
Freescale Semiconductor 23
Package Mechanical Information

MC9S12C-Family, Rev. 5
24 Freescale Semiconductor
Package Mechanical Information

MC9S12C-Family, Rev. 5
Freescale Semiconductor 25
How to Reach Us:
Home Page:
www.freescale.com

E-mail:
support@freescale.com

USA/Europe or Locations Not Listed:


Freescale Semiconductor
Technical Information Center, CH370
1300 N. Alma School Road
Chandler, Arizona 85224
+1-800-521-6274 or +1-480-768-2130
support@freescale.com

Europe, Middle East, and Africa: Information in this document is provided solely to enable system and software
Freescale Halbleiter Deutschland GmbH implementers to use Freescale Semiconductor products. There are no express or
Technical Information Center implied copyright licenses granted hereunder to design or fabricate any integrated
Schatzbogen 7 circuits or integrated circuits based on the information in this document.
81829 Muenchen, Germany
+44 1296 380 456 (English)
+46 8 52200080 (English) Freescale Semiconductor reserves the right to make changes without further notice to
+49 89 92103 559 (German) any products herein. Freescale Semiconductor makes no warranty, representation or
+33 1 69 35 48 48 (French) guarantee regarding the suitability of its products for any particular purpose, nor does
support@freescale.com Freescale Semiconductor assume any liability arising out of the application or use of any
product or circuit, and specifically disclaims any and all liability, including without
Japan: limitation consequential or incidental damages. “Typical” parameters that may be
Freescale Semiconductor Japan Ltd.
provided in Freescale Semiconductor data sheets and/or specifications can and do vary
Headquarters
ARCO Tower 15F in different applications and actual performance may vary over time. All operating
1-8-1, Shimo-Meguro, Meguro-ku, parameters, including “Typicals”, must be validated for each customer application by
Tokyo 153-0064 customer’s technical experts. Freescale Semiconductor does not convey any license
Japan under its patent rights nor the rights of others. Freescale Semiconductor products are
0120 191014 or +81 3 5437 9125 not designed, intended, or authorized for use as components in systems intended for
support.japan@freescale.com surgical implant into the body, or other applications intended to support or sustain life,
or for any other application in which the failure of the Freescale Semiconductor product
Asia/Pacific:
could create a situation where personal injury or death may occur. Should Buyer
Freescale Semiconductor Hong Kong Ltd.
Technical Information Center purchase or use Freescale Semiconductor products for any such unintended or
2 Dai King Street unauthorized application, Buyer shall indemnify and hold Freescale Semiconductor and
Tai Po Industrial Estate its officers, employees, subsidiaries, affiliates, and distributors harmless against all
Tai Po, N.T., Hong Kong claims, costs, damages, and expenses, and reasonable attorney fees arising out of,
+800 2666 8080 directly or indirectly, any claim of personal injury or death associated with such
support.asia@freescale.com unintended or unauthorized use, even if such claim alleges that Freescale
Semiconductor was negligent regarding the design or manufacture of the part.
For Literature Requests Only:
Freescale Semiconductor Literature Distribution Center
P.O. Box 5405 Freescale™ and the Freescale logo are trademarks of Freescale Semiconductor, Inc.
Denver, Colorado 80217 All other product or service names are the property of their respective owners.
1-800-441-2447 or 303-675-2140
Fax: 303-675-2150
LDCForFreescaleSemiconductor@hibbertgroup.com © Freescale Semiconductor, Inc. 2005, 2006. All rights reserved.

MC9S12CFAMPB
Rev. 5, 03/2006
B-28 Edit Date: February 12, 2013
Appendix C

Lab Kit Parts List

The following is the parts list for the lab kits.

Figure C.1: This is the parts list for the 2011 lab kit.

C-1
C-2 Edit Date: February 12, 2013
Appendix D

AD620 Instrumentation Amplifier & Maxim Voltage


Refs

D-1
Low Cost Low Power AD620
Instrumentation Amplifier
TABLE OF CONTENTS
AD620 Specifications .....................................................................................3 Input Protection ..........................................................................16

FEATURES CONNECTION DIAGRAM Absolute Maximum Ratings ............................................................5 RF Interference............................................................................16


Easy to use
ESD Caution ..................................................................................5 Common-Mode Rejection.........................................................17
Gain set with one external resistor
RG 1 8 RG
(Gain range 1 to 10,000) Typical Performance Characteristics ..............................................7 Grounding....................................................................................17
–IN 2 7 +VS
Wide power supply range (±2.3 V to ±18 V)
Higher performance than 3 op amp IA designs +IN 3 6 OUTPUT Theory of Operation .......................................................................13 Ground Returns for Input Bias Currents.................................18
Available in 8-lead DIP and SOIC packaging –VS 4 AD620 5 REF
Gain Selection..............................................................................16 Outline Dimensions........................................................................19
Low power, 1.3 mA max supply current

00775-0-001
TOP VIEW
Excellent dc performance (B grade) Input and Output Offset Voltage ..............................................16 Ordering Guide ...........................................................................20
50 µV max, input offset voltage Figure 1. 8-Lead PDIP (N), CERDIP (Q), and SOIC (R) Packages
0.6 µV/°C max, input offset drift Reference Terminal .....................................................................16
PRODUCT DESCRIPTION
1.0 nA max, input bias current
The AD620 is a low cost, high accuracy instrumentation
100 dB min common-mode rejection ratio (G = 10)
amplifier that requires only one external resistor to set gains of
Low noise REVISION HISTORY
1 to 10,000. Furthermore, the AD620 features 8-lead SOIC and
9 nV/√Hz @ 1 kHz, input voltage noise
DIP packaging that is smaller than discrete designs and offers 12/04—Rev. F to Rev. G 7/03—Data Sheet changed from REV. E to REV. F
0.28 µV p-p noise (0.1 Hz to 10 Hz)
lower power (only 1.3 mA max supply current), making it a
Excellent ac specifications Updated Format.................................................................. Universal Edit to FEATURES............................................................................1
good fit for battery-powered, portable (or remote) applications.
120 kHz bandwidth (G = 100) Changes to SPECIFICATIONS .......................................................2
Change to Features............................................................................1
15 µs settling time to 0.01% The AD620, with its high accuracy of 40 ppm maximum
Change to Product Description.......................................................1 Removed AD620CHIPS from ORDERING GUIDE ...................4
nonlinearity, low offset voltage of 50 µV max, and offset drift of
APPLICATIONS 0.6 µV/°C max, is ideal for use in precision data acquisition Changes to Specifications.................................................................3 Removed METALLIZATION PHOTOGRAPH...........................4
Weigh scales systems, such as weigh scales and transducer interfaces. Replaced TPCs 1–3 ...........................................................................5
Added Metallization Photograph....................................................4
ECG and medical instrumentation Furthermore, the low noise, low input bias current, and low power
Replaced Figure 4-Figure 6 ..............................................................6 Replaced TPC 12 ...............................................................................6
Transducer interface of the AD620 make it well suited for medical applications, such
as ECG and noninvasive blood pressure monitors. Replaced TPC 30 ...............................................................................9
Data acquisition systems Replaced Figure 15 ............................................................................7
Industrial process controls Replaced Figure 33 ..........................................................................10 Replaced TPCs 31 and 32...............................................................10
The low input bias current of 1.0 nA max is made possible with
Battery-powered and portable equipment the use of Superϐeta processing in the input stage. The AD620 Replaced Figure 4 ............................................................................10
Replaced Figure 34 and Figure 35.................................................10
works well as a preamplifier due to its low input voltage noise of Changes to Table I...........................................................................11
Replaced Figure 37 ..........................................................................10
9 nV/√Hz at 1 kHz, 0.28 µV p-p in the 0.1 Hz to 10 Hz band,
Changes to Table 3 ..........................................................................13 Changes to Figures 6 and 7 ............................................................12
and 0.1 pA/√Hz input current noise. Also, the AD620 is well
suited for multiplexed applications with its settling time of 15 µs Changes to Figure 41 and Figure 42 .............................................14 Changes to Figure 8 ........................................................................13
to 0.01%, and its cost is low enough to enable designs with one Edited INPUT PROTECTION section........................................13
Changes to Figure 43 ......................................................................15
in-amp per channel.
Change to Figure 44 ........................................................................17 Added new Figure 9........................................................................13
30,000 10,000

Changes to Input Protection section ............................................15 Changes to RF INTERFACE section ............................................14


25,000 3 OP AMP
IN-AMP 1,000 Edit to GROUND RETURNS FOR INPUT BIAS CURRENTS
(3 OP-07s) TYPICAL STANDARD
Deleted Figure 9...............................................................................15
20,000 BIPOLAR INPUT section...............................................................................................15
IN-AMP
100 Changes to RF Interference section ..............................................15
15,000 G = 100
Updated OUTLINE DIMENSIONS .............................................16
AD620A
Edit to Ground Returns for Input Bias Currents section...........17
10
10,000

(0.1 – 10Hz) (PV p-p)


RTI VOLTAGE NOISE
RG Added AD620CHIPS to Ordering Guide ....................................19
AD620 SUPEREETA
BIPOLAR INPUT
1 IN-AMP
5,000

TOTAL ERROR, PPM OF FULL SCALE


0 0.1
0 5 10 15 20 1k 10k 100k 1M 10M 100M
SUPPLY CURRENT (mA) SOURCE RESISTANCE (:)

00775-0-002
00775-0-003

Figure 2. Three Op Amp IA Designs vs. AD620 Figure 3. Total Voltage Noise vs. Source Resistance
Rev. G
Information furnished by Analog Devices is believed to be accurate and reliable.
However, no responsibility is assumed by Analog Devices for its use, nor for any
infringements of patents or other rights of third parties that may result from its use.
Specifications subject to change without notice. No license is granted by implication One Technology Way, P.O. Box 9106, Norwood, MA 02062-9106, U.S.A.
or otherwise under any patent or patent rights of Analog Devices. Trademarks and Tel: 781.329.4700 www.analog.com
registered trademarks are the property of their respective owners. Fax: 781.326.8703 © 2004 Analog Devices, Inc. All rights reserved. Rev. G | Page 2 of 20
AD620 AD620
AD620A AD620B AD620S1
SPECIFICATIONS Parameter Conditions Min Typ Max Min Typ Max Min Typ Max Unit
Typical @ 25°C, VS = ±15 V, and RL = 2 kΩ, unless otherwise noted. Common-Mode Rejection
Table 1. Ratio DC to 60 Hz with
AD620A AD620B AD620S1 1 kΩ Source Imbalance VCM = 0 V to ± 10 V
Parameter Conditions Min Typ Max Min Typ Max Min Typ Max Unit G=1 73 90 80 90 73 90 dB
GAIN G = 1 + (49.4 kΩ/RG) G = 10 93 110 100 110 93 110 dB
Gain Range 1 10,000 1 10,000 1 10,000 G = 100 110 130 120 130 110 130 dB
Gain Error2 VOUT = ±10 V G = 1000 110 130 120 130 110 130 dB
G=1 0.03 0.10 0.01 0.02 0.03 0.10 % OUTPUT
G = 10 0.15 0.30 0.10 0.15 0.15 0.30 % Output Swing RL = 10 kΩ
G = 100 0.15 0.30 0.10 0.15 0.15 0.30 % VS = ±2.3 V −VS + +VS − 1.2 −VS + 1.1 +VS − 1.2 −VS + 1.1 +VS − 1.2 V
G = 1000 0.40 0.70 0.35 0.50 0.40 0.70 % to ± 5 V 1.1
Nonlinearity VOUT = −10 V to +10 V Overtemperature −VS + 1.4 +VS − 1.3 −VS + 1.4 +VS − 1.3 −VS + 1.6 +VS − 1.3 V
G = 1–1000 RL = 10 kΩ 10 40 10 40 10 40 ppm VS = ±5 V −VS + 1.2 +VS − 1.4 −VS + 1.2 +VS − 1.4 −VS + 1.2 +VS − 1.4 V
G = 1–100 RL = 2 kΩ 10 95 10 95 10 95 ppm to ± 18 V
Gain vs. Temperature Overtemperature −VS + 1.6 +VS – 1.5 −VS + 1.6 +VS – 1.5 –VS + 2.3 +VS – 1.5 V
G=1 10 10 10 ppm/°C Short Circuit Current ±18 ±18 ±18 mA
Gain >12 −50 −50 −50 ppm/°C DYNAMIC RESPONSE
VOLTAGE OFFSET (Total RTI Error = VOSI + VOSO/G) Small Signal –3 dB Bandwidth
Input Offset, VOSI VS = ±5 V 30 125 15 50 30 125 µV G=1 1000 1000 1000 kHz
to ± 15 V G = 10 800 800 800 kHz
Overtemperature VS = ±5 V 185 85 225 µV G = 100 120 120 120 kHz
to ± 15 V G = 1000 12 12 12 kHz
Average TC VS = ±5 V 0.3 1.0 0.1 0.6 0.3 1.0 µV/°C Slew Rate 0.75 1.2 0.75 1.2 0.75 1.2 V/µs
to ± 15 V Settling Time to 0.01% 10 V Step
Output Offset, VOSO VS = ±15 V 400 1000 200 500 400 1000 µV G = 1–100 15 15 15 µs
VS = ± 5 V 1500 750 1500 µV G = 1000 150 150 150 µs
Overtemperature VS = ±5 V 2000 1000 2000 µV NOISE
to ± 15 V
Voltage Noise, 1 kHz 2
Average TC VS = ±5 V 5.0 15 2.5 7.0 5.0 15 µV/°C Total RTI Noise (e ni )  (e / G)2 no

to ± 15 V Input, Voltage Noise, eni 9 13 9 13 9 13 nV/√Hz


Offset Referred to the Output, Voltage Noise, eno 72 100 72 100 72 100 nV/√Hz
Input vs. Supply (PSR) VS = ±2.3 V RTI, 0.1 Hz to 10 Hz
to ±18 V G=1 3.0 3.0 6.0 3.0 6.0 µV p-p
G=1 80 100 80 100 80 100 dB G = 10 0.55 0.55 0.8 0.55 0.8 µV p-p
G = 10 95 120 100 120 95 120 dB G = 100–1000 0.28 0.28 0.4 0.28 0.4 µV p-p
G = 100 110 140 120 140 110 140 dB Current Noise f = 1 kHz 100 100 100 fA/√Hz
G = 1000 110 140 120 140 110 140 dB 0.1 Hz to 10 Hz 10 10 10 pA p-p
INPUT CURRENT REFERENCE INPUT
Input Bias Current 0.5 2.0 0.5 1.0 0.5 2 nA RIN 20 20 20 kΩ
Overtemperature 2.5 1.5 4 nA IIN VIN+, VREF = 0 50 60 50 60 50 60 µA
Average TC 3.0 3.0 8.0 pA/°C Voltage Range −VS + 1.6 +VS − 1.6 −VS + 1.6 +VS − 1.6 −VS + 1.6 +VS − 1.6 V
Input Offset Current 0.3 1.0 0.3 0.5 0.3 1.0 nA Gain to Output 1 ± 0.0001 1 ± 0.0001 1 ± 0.0001
Overtemperature 1.5 0.75 2.0 nA POWER SUPPLY
Average TC 1.5 1.5 8.0 pA/°C Operating Range4 ±2.3 ±18 ±2.3 ±18 ±2.3 ±18 V
INPUT Quiescent Current VS = ±2.3 V 0.9 1.3 0.9 1.3 0.9 1.3 mA
Input Impedance to ±18 V
Differential 10||2 10||2 10||2 GΩ_pF Overtemperature 1.1 1.6 1.1 1.6 1.1 1.6 mA
Common-Mode 10||2 10||2 10||2 GΩ_pF TEMPERATURE RANGE
Input Voltage Range3 VS = ±2.3 V −VS + 1.9 +VS − 1.2 −VS + 1.9 +VS − 1.2 −VS + 1.9 +VS − 1.2 V For Specified Performance −40 to +85 −40 to +85 −55 to +125 °C
to ±5 V
Overtemperature −VS + 2.1 +VS − 1.3 −VS + 2.1 +VS − 1.3 −VS + 2.1 +VS − 1.3 V
1
VS = ± 5 V −VS + 1.9 +VS − 1.4 −VS + 1.9 +VS − 1.4 −VS + 1.9 +VS − 1.4 V See Analog Devices military data sheet for 883B tested specifications.
2
to ±18 V Does not include effects of external resistor RG.
3
One input grounded. G = 1.
Overtemperature −VS + 2.1 +VS − 1.4 −VS + 2.1 +VS + 2.1 −VS + 2.3 +VS − 1.4 V 4
This is defined as the same supply range that is used to specify PSR.

Rev. G | Page 3 of 20 Rev. G | Page 4 of 20


AD620 AD620

ABSOLUTE MAXIMUM RATINGS


Table 2.
Parameter Rating Stresses above those listed under Absolute Maximum Ratings
Supply Voltage ±18 V may cause permanent damage to the device. This is a stress
Internal Power Dissipation1 650 mW rating only; functional operation of the device at these or any
Input Voltage (Common-Mode) ±VS other condition s above those indicated in the operational
Differential Input Voltage 25 V section of this specification is not implied. Exposure to absolute
Output Short-Circuit Duration Indefinite maximum rating conditions for extended periods may affect
Storage Temperature Range (Q) −65°C to +150°C device reliability.
Storage Temperature Range (N, R) −65°C to +125°C
Operating Temperature Range
AD620 (A, B) −40°C to +85°C
AD620 (S) −55°C to +125°C
Lead Temperature Range
(Soldering 10 seconds) 300°C

1
Specification is for device in free air:
8-Lead Plastic Package: θJA = 95°C
8-Lead CERDIP Package: θJA = 110°C
8-Lead SOIC Package: θJA = 155°C
00775-0-004

Figure 4. Metallization Photograph.


Dimensions shown in inches and (mm).
ESD CAUTION Contact sales for latest dimensions.
ESD (electrostatic discharge) sensitive device. Electrostatic charges as high as 4000 V readily accumulate on the
human body and test equipment and can discharge without detection. Although this product features
proprietary ESD protection circuitry, permanent damage may occur on devices subjected to high energy
electrostatic discharges. Therefore, proper ESD precautions are recommended to avoid performance
degradation or loss of functionality.

Rev. G | Page 5 of 20 Rev. G | Page 6 of 20


AD620 AD620
1000
TYPICAL PERFORMANCE CHARACTERISTICS
(@ 25°C, VS = ±15 V, RL = 2 kΩ, unless otherwise noted.)
50 2.0
SAMPLE SIZE = 360
1.5
40
1.0 100
+IB
–I B
0.5
30

CURRENT NOISE (fA/ Hz)


0

20
–0.5
00775-0-014

PERCENTAGE OF UNITS
10

INPUT BIAS CURRENT (nA)


–1.0 1 10 100 1000
10
FREQUENCY (Hz)
00775-0-011
–1.5

0 –2.0
–80 –40 0 40 80
Figure 11. Current Noise Spectral Density vs. Frequency Figure 14. 0.1 Hz to 10 Hz Current Noise, 5 pA/Div
–75 –25 25 75 125 175
TEMPERATURE (qC)

00775-0-008
INPUT OFFSET VOLTAGE (PV)

00775-0-005
Figure 5. Typical Distribution of Input Offset Voltage Figure 8. Input Bias Current vs. Temperature
100,000
50 2.0

SAMPLE SIZE = 850

40 10,000
1.5

FET INPUT
30 IN-AMP
1000
1.0

20

RTI NOISE (2.0PV/DIV)


AD620A
100

PERCENTAGE OF UNITS
0.5
10

CHANGE IN OFFSET VOLTAGE (PV)


TOTAL DRIFT FROM 25qC TO 85qC, RTI (PV)

00775-0-012

TIME (1 SEC/DIV) 10
0 0 1k 10k 100k 1M 10M
–1200 –600 0 600 1200 0 1 2 3 4 5
00775-0-015

SOURCE RESISTANCE (:)


WARM-UP TIME (Minutes)

00775-0-009
INPUT BIAS CURRENT (pA)

00775-0-006
Figure 6. Typical Distribution of Input Bias Current Figure 9. Change in Input Offset Voltage vs. Warm-Up Time Figure 12. 0.1 Hz to 10 Hz RTI Voltage Noise (G = 1) Figure 15. Total Drift vs. Source Resistance
50 1000

SAMPLE SIZE = 850


160
40 GAIN = 1

140 G = 1000
100
G = 100
30 120
GAIN = 10
G = 10
100
20 G=1
80
10

PERCENTAGE OF UNITS
CMR (dB)

60

VOLTAGE NOISE (nV/ Hz)


10
GAIN = 100, 1,000
RTI NOISE (0.1PV/DIV)

GAIN = 1000 40
BW LIMIT
0 1
–400 –200 0 200 400 20
1 10 100 1k 10k 100k
FREQUENCY (Hz)
00775-0-010

INPUT OFFSET CURRENT (pA)

00775-0-007
0
00775-0-013

TIME (1 SEC/DIV) 0.1 1 10 100 1k 10k 100k 1M


Figure 7. Typical Distribution of Input Offset Current
00775-0-016

Figure 10. Voltage Noise Spectral Density vs. Frequency (G = 1−1000)


FREQUENCY (Hz)

Figure 13. 0.1 Hz to 10 Hz RTI Voltage Noise (G = 1000) Figure 16. Typical CMR vs. Frequency, RTI, Zero to 1 kΩ Source Imbalance

Rev. G | Page 7 of 20 Rev. G | Page 8 of 20


AD620 AD620
180 35 30
G = 10, 100, 1000
160 30
.... .... .... .... .... .... .... .... .... ....
VS = ±15V
140 G = 10
G = 1000 25
20
120 G=1
20
100 G = 100
15

PSR (dB)
80
10
G = 10

BW LIMIT
10
60

OUTPUT VOLTAGE (V p-p)


.... .... .... .... .... .... .... .... .... ....
G=1 5

OUTPUT VOLTAGE SWING (V p-p)


40
G = 1000
G = 100
00775-0-026

20 0 0
0.1 1 10 100 1k 10k 100k 1M 1k 10k 100k 1M 0 100 1k 10k

00775-0-023
FREQUENCY (Hz)

00775-0-020

00775-0-017
FREQUENCY (Hz) LOAD RESISTANCE (:

Figure 23. Output Voltage Swing vs. Load Resistance Figure 26. Large Signal Response and Settling Time, G = 10 (0.5 mV = 0.01%)
Figure 17. Positive PSR vs. Frequency, RTI (G = 1−1000) Figure 20. Large Signal Frequency Response

180 +VS –0.0

160 –0.5
.... .... .... .... .... .... .... .... .... .... .... .... .... .... .... .... .... .... .... ....
140 –1.0

120 –1.5

100
G = 1000

PSR (dB)
80 +1.5
G = 100
60 +1.0 .... .... .... .... .... .... .... .... .... .... .... .... .... .... .... .... .... .... .... ....

INPUT VOLTAGE LIMIT (V)


G = 10

(REFERRED TO SUPPLY VOLTAGES)


40 +0.5
G=1
00775-0-024
00775-0-027

20 –VS +0.0
0.1 1 10 100 1k 10k 100k 1M 0 5 10 15 20

00775-0-018
FREQUENCY (Hz) SUPPLY VOLTAGE ± Volts

00775-0-021
Figure 24. Large Signal Pulse Response and Settling Time Figure 27. Small Signal Response, G = 10, RL = 2 kΩ, CL = 100 pF
Figure 18. Negative PSR vs. Frequency, RTI (G = 1−1000) Figure 21. Input Voltage Range vs. Supply Voltage, G = 1 G = 1 (0.5 mV = 0.01%)

1000 +VS –0.0

–0.5
.... .... .... .... .... .... .... .... .... .... .... .... .... .... .... .... .... .... .... ....
RL = 10k:
100 –1.0

RL = 2k:
–1.5

10

GAIN (V/V)
+1.5
RL = 2k:
1 +1.0 .... .... .... .... .... .... .... .... .... .... .... .... .... .... .... .... .... .... .... ....

OUTPUT VOLTAGE SWING (V)


(REFERRED TO SUPPLY VOLTAGES)
+0.5 RL = 10k:
00775-0-025
00775-0-030

0.1 –VS +0.0


100 1k 10k 100k 1M 10M 0 5 10 15 20
00775-0-022

FREQUENCY (Hz) SUPPLY VOLTAGE ± Volts

00775-0-019
Figure 25. Small Signal Response, G = 1, RL = 2 kΩ, CL = 100 pF Figure 28. Large Signal Response and Settling Time, G = 100 (0.5 mV = 0.01%)
Figure 19. Gain vs. Frequency Figure 22. Output Voltage Swing vs. Supply Voltage, G = 10

Rev. G | Page 9 of 20 Rev. G | Page 10 of 20


AD620 AD620
20 1k:
10k: * 10T 10k:
INPUT
10V p-p
.... .... .... .... .... .... .... .... ........ 100k :
.... .... .... .... .... .... .... .... ........ VOUT
15
TO 0.01%
TO 0.1% +VS
11k: 1k: 100 : 2
10 1 7
G = 1000 G=1

AD620 6

SETTLING TIME (Ps)


G = 100 G = 10
.... .... .... .... .... .... .... .... ........ 5 .... .... .... .... .... .... .... .... ........ 49.9: 499 : 5.49k :
5
8
4
3

00775-0-035

00775-0-029
0 –VS
0 5 10 15 20
00775-0-037

*ALL RESISTORS 1% TOLERANCE


OUTPUT STEP SIZE (V)

00775-0-032
Figure 35. Gain Nonlinearity, G = 100, RL = 10 kΩ
Figure 29. Small Signal Pulse Response, G = 100, RL = 2 kΩ, CL = 100 pF Figure 32. Settling Time vs. Step Size (G = 1) (100 µV = 10 ppm)
Figure 37. Settling Time Test Circuit

1000

.... .... .... .... .... .... .... .... ........


.... .... .... .... .... .... .... .... .... ....

100

10

SETTLING TIME (Ps)


.... .... .... .... .... .... .... .... ........
.... .... .... .... .... .... .... .... .... ....
00775-0-036

00775-0-030
1
1 10 100 1000

00775-0-033
GAIN Figure 36. Gain Nonlinearity, G = 1000, RL = 10 kΩ
(1 mV = 100 ppm)
Figure 30. Large Signal Response and Settling Time, Figure 33. Settling Time to 0.01% vs. Gain, for a 10 V Step
G = 1000 (0.5 mV = 0.01% )

.... .... .... .... .... .... .... .... ........ .... .... .... .... .... .... .... .... .... ....

.... .... .... .... .... .... .... .... ........ .... .... .... .... .... .... .... .... .... ....
00775-0-034

00775-0-031
Figure 31. Small Signal Pulse Response, G = 1000, RL = 2 kΩ, CL = 100 pF Figure 34. Gain Nonlinearity, G = 1, RL = 10 kΩ (10 µV = 1 ppm)

Rev. G | Page 11 of 20 Rev. G | Page 12 of 20


AD620 AD620
Regardless of the system in which it is being used, the AD620 Note that for the homebrew circuit, the OP07 specifications for
THEORY OF OPERATION input voltage offset and noise have been multiplied by √2. This
provides greater accuracy at low power and price. In simple
The input transistors Q1 and Q2 provide a single differential- systems, absolute accuracy and drift errors are by far the most is because a three op amp type in-amp has two op amps at its
pair bipolar input for high precision (Figure 38), yet offer 10× inputs, both contributing to the overall input error.
I1 20PA VB 20PA I2 significant contributors to error. In more complex systems
lower input bias current thanks to Superϐeta processing. with an intelligent processor, an autogain/autozero cycle will
Feedback through the Q1-A1-R1 loop and the Q2-A2-R2 loop remove all absolute accuracy and drift errors, leaving only the
A1 A2
10k: maintains constant collector current of the input devices Q1
C1 C2
resolution errors of gain, nonlinearity, and noise, thus allowing
10k:
and Q2, thereby impressing the input voltage across the external full 14-bit accuracy.
A3 OUTPUT gain setting resistor RG. This creates a differential gain from the
10V
10k: 10k: inputs to the A1/A2 outputs given by G = (R1 + R2)/RG + 1. The
10k: * 10k: *
R3 R1 R2 REF
400: OP07D
unity-gain subtractor, A3, removes any common-mode signal, RG
– IN Q1 Q2 +IN AD620A
R4 R = 350: R = 350: 499: 10k: **
yielding a single-ended output referred to the REF pin potential.
RG 400: REFERENCE
100: ** 10k: ** OP07D
GAIN GAIN
SENSE SENSE The value of RG also determines the transconductance of the
R = 350: R = 350: AD620A MONOLITHIC
preamp stage. As RG is reduced for larger gains, the INSTRUMENTATION OP07D
transconductance increases asymptotically to that of the input AMPLIFIER, G = 100 10k: * 10k:*

00775-0-038
–VS
transistors. This has three important advantages: (a) Open-loop
00775-0-040

SUPPLY CURRENT = 1.3mA MAX "HOMEBREW" IN-AMP, G = 100


Figure 38. Simplified Schematic of AD620 gain is boosted for increasing programmed gain, thus reducing *0.02% RESISTOR MATCH, 3ppm/qC TRACKING
**DISCRETE 1% RESISTOR, 100ppm/ qC TRACKING
SUPPLY CURRENT = 15mA MAX
00775-0-041

PRECISION BRIDGE TRANSDUCER

00775-0-039
The AD620 is a monolithic instrumentation amplifier based on gain related errors. (b) The gain-bandwidth product
a modification of the classic three op amp approach. Absolute (determined by C1 and C2 and the preamp transconductance)
value trimming allows the user to program gain accurately increases with programmed gain, thus optimizing frequency Figure 39. Make vs. Buy
(to 0.15% at G = 100) with only one resistor. Monolithic response. (c) The input voltage noise is reduced to a value of
construction and laser wafer trimming allow the tight matching 9 nV/√Hz, determined mainly by the collector current and base
and tracking of circuit components, thus ensuring the high level resistance of the input devices.
of performance inherent in this circuit.
The internal gain resistors, R1 and R2, are trimmed to an Table 3. Make vs. Buy Error Budget
absolute value of 24.7 kΩ, allowing the gain to be programmed Error, ppm of Full Scale
accurately with a single external resistor. Error Source AD620 Circuit Calculation “Homebrew” Circuit Calculation AD620 Homebrew
ABSOLUTE ACCURACY at TA = 25°C
The gain equation is then Input Offset Voltage, µV 125 µV/20 mV (150 µV × √2)/20 mV 6,250 10,607
Output Offset Voltage, µV 1000 µV/100 mV/20 mV ((150 µV × 2)/100)/20 mV 500 150
49.4 k:
G 1 Input Offset Current, nA 2 nA ×350 Ω/20 mV (6 nA ×350 Ω)/20 mV 18 53
RG CMR, dB 110 dB(3.16 ppm) ×5 V/20 mV (0.02% Match × 5 V)/20 mV/100 791 500

49.4 k: Total Absolute Error 7,559 11,310


RG
G 1 DRIFT TO 85°C
Gain Drift, ppm/°C (50 ppm + 10 ppm) ×60°C 100 ppm/°C Track × 60°C 3,600 6,000
Input Offset Voltage Drift, µV/°C 1 µV/°C × 60°C/20 mV (2.5 µV/°C × √2 × 60°C)/20 mV 3,000 10,607
Make vs. Buy: a Typical Bridge Application Error Budget Output Offset Voltage Drift, µV/°C 15 µV/°C × 60°C/100 mV/20 mV (2.5 µV/°C × 2 × 60°C)/100 mV/20 mV 450 150
The AD620 offers improved performance over “homebrew”
Total Drift Error 7,050 16,757
three op amp IA designs, along with smaller size, fewer
RESOLUTION
components, and 10× lower supply current. In the typical
Gain Nonlinearity, ppm of Full Scale 40 ppm 40 ppm 40 40
application, shown in Figure 39, a gain of 100 is required to
Typ 0.1 Hz to 10 Hz Voltage Noise, µV p-p 0.28 µV p-p/20 mV (0.38 µV p-p × √2)/20 mV 14 27
amplify a bridge output of 20 mV full-scale over the industrial
Total Resolution Error 54 67
temperature range of −40°C to +85°C. Table 3 shows how to
Grand Total Error 14,663 28,134
calculate the effect various error sources have on circuit
G = 100, VS = ±15 V.
accuracy. (All errors are min/max and referred to input.)

Rev. G | Page 13 of 20 Rev. G | Page 14 of 20


AD620 AD620
5V Precision V-I Converter INPUT AND OUTPUT OFFSET VOLTAGE
The AD620, along with another op amp and two resistors, The low errors of the AD620 are attributed to two sources,
20k: makes a precision current source (Figure 42). The op amp
7 input and output errors. The output error is divided by G when
3
3k: 3k: buffers the reference terminal to maintain good CMR. The
8 REF referred to the input. In practice, the input errors dominate at
G = 100 6
output voltage, VX, of the AD620 appears across R1, which
AD620B IN high gains, and the output errors dominate at low gains. The
499: DIGITAL
3k: 3k: 5 converts it to a current. This current, less only the input bias
1 10k: ADC DATA total VOS for a given gain is calculated as
OUTPUT current of the op amp, then flows out to the load.
2 4
AD705 AGND Total Error RTI = input error + (output error/G)
+VS
20k:
0.6mA
1.7mA 1.3mA 0.10mA Total Error RTO = (input error × G) + output error
MAX MAX 7
VIN+ 3
8 REFERENCE TERMINAL
+ VX –

00775-0-042
RG AD620 6
R1 The reference terminal potential defines the zero output voltage
Figure 40. A Pressure Monitor Circuit that Operates on a 5 V Single Supply 1 5
and is especially useful when the load does not share a precise
VIN– 2 4 I
L ground with the rest of the system. It provides a direct means of
–VS injecting a precise offset to the output, with an allowable range
Pressure Measurement Medical ECG AD705
of 2 V within the supply voltages. Parasitic resistance should be
Although useful in many bridge applications, such as weigh The low current noise of the AD620 allows its use in ECG Vx [(V IN+ ) – (V IN– )] G kept to a minimum for optimum CMR.
I L= =
scales, the AD620 is especially suitable for higher resistance monitors (Figure 41) where high source resistances of 1 MΩ or R1 R1
LOAD
pressure sensors powered at lower voltages where small size and higher are not uncommon. The AD620’s low power, low supply INPUT PROTECTION
00775-0-044

low power become more significant. voltage requirements, and space-saving 8-lead mini-DIP and The AD620 features 400 Ω of series thin film resistance at its
Figure 42. Precision Voltage-to-Current Converter (Operates on 1.8 mA, ±3 V)
SOIC package offerings make it an excellent choice for battery- inputs and will safely withstand input overloads of up to ±15 V
Figure 40 shows a 3 kΩ pressure transducer bridge powered powered data recorders. or ±60 mA for several hours. This is true for all gains and power
from 5 V. In such a circuit, the bridge consumes only 1.7 mA. GAIN SELECTION on and off, which is particularly important since the signal
Adding the AD620 and a buffered voltage divider allows the Furthermore, the low bias currents and low current noise,
The AD620’s gain is resistor-programmed by RG, or more source and amplifier may be powered separately. For longer
signal to be conditioned for only 3.8 mA of total supply current. coupled with the low voltage noise of the AD620, improve the
precisely, by whatever impedance appears between Pins 1 and 8. time periods, the current should not exceed 6 mA
dynamic range for better performance.
Small size and low cost make the AD620 especially attractive for The AD620 is designed to offer accurate gains using 0.1% to 1% (IIN ≤ VIN/400 Ω). For input overloads beyond the supplies,
voltage output pressure transducers. Since it delivers low noise The value of capacitor C1 is chosen to maintain stability of resistors. Table 4 shows required values of RG for various gains. clamping the inputs to the supplies (using a low leakage diode
and drift, it will also serve applications such as diagnostic the right leg drive loop. Proper safeguards, such as isolation, Note that for G = 1, the RG pins are unconnected (RG = ∞). For such as an FD333) will reduce the required resistance, yielding
noninvasive blood pressure measurement. must be added to this circuit to protect the patient from any arbitrary gain, RG can be calculated by using the formula: lower noise.
possible harm.
49.4 k: RF INTERFERENCE
RG
G 1 All instrumentation amplifiers rectify small out of band signals.
The disturbance may appear as a small dc voltage offset. High
To minimize gain error, avoid high parasitic resistance in series frequency signals can be filtered with a low pass R-C network
+3V
PATIENT/CIRCUIT with RG; to minimize gain drift, RG should have a low TC—less
PROTECTION/ISOLATION placed at the input of the instrumentation amplifier. Figure 43
than 10 ppm/°C—for the best performance. demonstrates such a configuration. The filter limits the input
signal according to the following relationship:
Table 4. Required Values of Gain Resistors
1% Std Table Calculated 0.1% Std Table Calculated 1
R1 R3 FilterFreq DIFF
C1 24.9k: 0.03Hz
10k: RG HIGH- OUTPUT Value of RG(Ω) Gain Value of RG(Ω ) Gain 2 SR(2C D  C C )
8.25k: AD620A PASS G = 143 1V/mV
R4 R2 G=7 FILTER 49.9 k 1.990 49.3 k 2.002
1M: 24.9k: 1
OUTPUT
12.4 k 4.984 12.4 k 4.984 FilterFreq CM
AMPLIFIER 5.49 k 9.998 5.49 k 9.998 2 SRC C
2.61 k 19.93 2.61 k 19.93
AD705J where CD ≥10CC.
1.00 k 50.40 1.01 k 49.91
499 100.0 499 100.0 CD affects the difference signal. CC affects the common-mode
–3V
249 199.4 249 199.4 signal. Any mismatch in R × CC will degrade the AD620’s
100 495.0 98.8 501.0
00775-0-043

CMRR. To avoid inadvertently reducing CMRR-bandwidth


49.9 991.0 49.3 1,003.0 performance, make sure that CC is at least one magnitude
Figure 41. A Medical ECG Monitor Circuit
smaller than CD. The effect of mismatched CCs is reduced with a
larger CD:CC ratio.

Rev. G | Page 15 of 20 Rev. G | Page 16 of 20


AD620 AD620
+15V +VS
+VS GROUND RETURNS FOR INPUT BIAS CURRENTS
– INPUT – INPUT
0.1P F 1 0P F Input bias currents are those currents necessary to bias the
AD648 input transistors of an amplifier. There must be a direct return
CC 100:
R +IN path for these currents. Therefore, when amplifying “floating”
+
VOUT input sources, such as transformers or ac-coupled sources, there RG AD620 VOUT
CD 499: AD620 RG
AD620 VOUT
R must be a dc path from each input to ground, as shown in
– REF 100: –VS LOAD
–IN Figure 47, Figure 48, and Figure 49. Refer to A Designer’s Guide
CC
REFERENCE
to Instrumentation Amplifiers (free from Analog Devices) for REFERENCE
+ INPUT
0.1P F 1 0P F + INPUT more information regarding in-amp applications. –VS

00775-0-046
–VS

00775-0-045
–15V

Figure 44. Differential Shield Driver TO POWER


+VS SUPPLY
Figure 43. Circuit to Attenuate RF Interference
00775-0-050

– INPUT GROUND

COMMON-MODE REJECTION Figure 48. Ground Returns for Bias Currents with Thermocouple Inputs
+VS
Instrumentation amplifiers, such as the AD620, offer high – INPUT
CMR, which is a measure of the change in output voltage when RG AD620 VOUT
both inputs are changed by equal amounts. These specifications RG
+VS
100: 2
are usually given for a full-range input voltage change and a AD548 AD620 VOUT LOAD – INPUT
RG
specified source imbalance. 2
REFERENCE + INPUT REFERENCE

For optimal CMR, the reference terminal should be tied to a + INPUT –VS
–VS RG AD620 VOUT

00775-0-047
low impedance point, and differences in capacitance and
resistance should be kept to a minimum between the two TO POWER
Figure 45. Common-Mode Shield Driver SUPPLY LOAD
00775-0-049

GROUND
inputs. In many applications, shielded cables are used to
minimize noise; for best CMR over frequency, the shield GROUNDING + INPUT REFERENCE
Figure 47. Ground Returns for Bias Currents with Transformer-Coupled Inputs
should be properly driven. Figure 44 and Figure 45 show active Since the AD620 output voltage is developed with respect to the 100k : 100k: –VS

data guards that are configured to improve ac common-mode potential on the reference terminal, it can solve many
rejections by “bootstrapping” the capacitances of input cable grounding problems by simply tying the REF pin to the TO POWER
SUPPLY
00775-0-051

shields, thus minimizing the capacitance mismatch between the appropriate “local ground.” GROUND

inputs.
To isolate low level analog signals from a noisy digital Figure 49. Ground Returns for Bias Currents with AC-Coupled Inputs
environment, many data-acquisition components have separate
analog and digital ground pins (Figure 46). It would be
convenient to use a single ground line; however, current
through ground wires and PC runs of the circuit card can cause
hundreds of millivolts of error. Therefore, separate ground
returns should be provided to minimize the current flow from
the sensitive points to the system ground. These ground returns
must be tied together at some point, usually best at the ADC
package shown in Figure 46.

ANALOG P.S. DIGITAL P.S.


+15V C –15V C +5V

0.1P F 0.1P F
1P F 1P F 1P F

+
AD620 DIGITAL
AD585 AD574A DATA
S/H ADC OUTPUT
00775-0-048

Figure 46. Basic Grounding Practice

Rev. G | Page 17 of 20 Rev. G | Page 18 of 20


AD620 AD620

OUTLINE DIMENSIONS
0.400 (10.16)
0.365 (9.27)
ORDERING GUIDE
0.355 (9.02) 5.00 (0.1968) Model Temperature Range Package Option1
4.80 (0.1890)
8 5 0.280 (7.11) AD620AN −40°C to +85°C N-8
0.250 (6.35) 8 5 AD620ANZ2 −40°C to +85°C N-8
1 0.240 (6.10)
4 4.00 (0.1574) 6.20 (0.2440)
0.325 (8.26)
0.310 (7.87) 3.80 (0.1497) 1 4 5.80 (0.2284) AD620BN −40°C to +85°C N-8
PIN 1
0.100 (2.54) 0.300 (7.62) AD620BNZ2 −40°C to +85°C N-8
BSC 0.060 (1.52) 0.195 (4.95)
0.210 MAX AD620AR −40°C to +85°C R-8
(5.33) 0.130 (3.30)
1.27 (0.0500) 0.50 (0.0196)
MAX 0.115 (2.92) BSC 1.75 (0.0688) u 45°
0.015 0.25 (0.0099) AD620ARZ2 −40°C to +85°C R-8
0.150 (3.81) (0.38)0.015 (0.38) 1.35 (0.0532)
MIN 0.25 (0.0098)
0.130 (3.30) GAUGE AD620AR-REEL −40°C to +85°C 13" REEL
0.115 (2.92) PLANE 0.014 (0.36) 0.10 (0.0040)
SEATING
PLANE 0.010 (0.25) 8° AD620ARZ-REEL2 −40°C to +85°C 13" REEL
0.51 (0.0201)
0.022 (0.56) 0.008 (0.20) COPLANARITY 0.25 (0.0098) 0° 1.27 (0.0500)
0.005 (0.13) 0.430 (10.92) SEATING 0.31 (0.0122) AD620AR-REEL7 −40°C to +85°C 7" REEL
0.018 (0.46) MAX 0.10 0.17 (0.0067) 0.40 (0.0157)
MIN PLANE
0.014 (0.36) AD620ARZ-REEL72 −40°C to +85°C 7" REEL
0.070 (1.78) COMPLIANT TO JEDEC STANDARDS MS-012AA
CONTROLLING DIMENSIONS ARE IN MILLIMETERS; INCH DIMENSIONS
AD620BR −40°C to +85°C R-8
0.060 (1.52)
0.045 (1.14) (IN PARENTHESES) ARE ROUNDED-OFF MILLIMETER EQUIVALENTS FOR AD620BRZ2 −40°C to +85°C R-8
REFERENCE ONLY AND ARE NOT APPROPRIATE FOR USE IN DESIGN
COMPLIANT TO JEDEC STANDARDS MS-001-BA AD620BR-REEL −40°C to +85°C 13" REEL
CONTROLLING DIMENSIONS ARE IN INCHES; MILLIMETER DIMENSIONS Figure 52. 8-Lead Standard Small Outline Package [SOIC]
(IN PARENTHESES) ARE ROUNDED-OFF INCH EQUIVALENTS FOR
AD620BRZ-RL2 −40°C to +85°C 13" REEL
REFERENCE ONLY AND ARE NOT APPROPRIATE FOR USE IN DESIGN.
CORNER LEADS MAY BE CONFIGURED AS WHOLE OR HALF LEADS.
Narrow Body (R-8) AD620BR-REEL7 −40°C to +85°C 7" REEL
Dimensions shown in millimeters and (inches) AD620BRZ-R72 −40°C to +85°C 7" REEL
Figure 50. 8-Lead Plastic Dual In-Line Package [PDIP]
AD620ACHIPS −40°C to +85°C Die Form
Narrow Body (N-8).
AD620SQ/883B −55°C to +125°C Q-8
Dimensions shown in inches and (millimeters)

0.005 (0.13) 0.055 (1.40) 1


N = Plastic DIP; Q = CERDIP; R = SOIC.
MIN MAX 2
Z = Pb-free part.
8 5

0.310 (7.87)
PIN 1 0.220 (5.59)
1 4

0.100 (2.54) BSC


0.405 (10.29) MAX 0.320 (8.13)
0.290 (7.37)
0.060 (1.52)
0.200 (5.08) 0.015 (0.38)
MAX

0.200 (5.08) 0.150 (3.81)


0.125 (3.18) MIN

0.023 (0.58) SEATING 0.015 (0.38)


0.070 (1.78) PLANE 15°
0.014 (0.36) 0.008 (0.20)
0.030 (0.76) 0°

CONTROLLING DIMENSIONS ARE IN INCHES; MILLIMETER DIMENSIONS


(IN PARENTHESES) ARE ROUNDED-OFF INCH EQUIVALENTS FOR
REFERENCE ONLY AND ARE NOT APPROPRIATE FOR USE IN DESIGN

Figure 51. 8-Lead Ceramic Dual In-Line Package [CERDIP] (Q-8)


Dimensions shown in inches and (millimeters)

© 2004 Analog Devices, Inc. All rights reserved. Trademarks


and registered trademarks are the property of their respective owners.
C00775–0–12/04(G)

Rev. G | Page 19 of 20 Rev. G | Page 20 of 20


19-0887; Rev 7; 4/07

+5V, +10V Precision +5V, +10V Precision


Voltage References Voltage References
General Description Features ABSOLUTE MAXIMUM RATINGS–REF01
The REF01/REF02 are industry-standard precision volt- ♦ Pretrimmed to +5V, +10V Input Voltage Output Short-Circuit Duration
age references. The stable 10V output of the REF01 REF01, E, H .........................................................................40V (to ground or VIN) .......................................................Indefinite
can be adjusted over a ±6% range with minimal effect ♦ Excellent Temperature Stability: 3ppm/°C (typ) REF01C ...............................................................................30V Storage Temperature Range .............................-65°C to +150°C
Continuous Power Dissipation Operating Temperature Range
on temperature stability. The 5V output REF02 can also ♦ Low Noise: 10µVP-P (REF02) Plastic Dip (P) (derate at 5.6mW/°C above +36°C) .....500mW REF01E, REF01H, REF01C
be adjusted over a ±6% range. The 10V REF01 has a Small Outline (S) (derate at 5.0mW/°C above +55°C) ..300mW (except REF01CESA)...........................................0°C to +70°C
single-supply operation over an input voltage range of ♦ Short-Circuit Protected
REF01CESA ......................................................-40°C to +85°C
13V to 33V, while the 5V REF02 has a single-supply ♦ Linear Temperature Transducer Output (REF02) Lead Temperature (soldering, 60s) .................................+300°C
operation over an input voltage range of 7V to 33V.
Stresses beyond those listed under “Absolute Maximum Ratings” may cause permanent damage to the device. These are stress ratings only, and functional
Both devices offer a low-current drain of 1mA. The operation of the device at these or any other conditions beyond those indicated in the operational sections of the specifications is not implied. Exposure to
REF02 also provides a TEMP pin whose output voltage absolute maximum rating conditions for extended periods may affect device reliability.
varies linearly with temperature, making this device

REF01/REF02
REF01/REF02
suitable for a wide variety of temperature-sensing and
control applications. For new designs, refer to the ELECTRICAL CHARACTERISTICS—REF01E/REF01H
MAX6035 or MAX6143 data sheets. (VIN = +15V, TA = +25°C, unless otherwise noted.)
REF01E REF01H
Ordering Information PARAMETER SYMBOL CONDITIONS UNITS
MIN TYP MAX MIN TYP MAX

MAX TEMPCO INITIAL ERROR PKG Output Voltage VO IL = 0 9.97 10.00 10.03 9.95 10.00 10.05 V
PART TEMP RANGE PIN-PACKAGE
(ppm/°C) (mV) CODE Output Adjustment Range ∆Vtrim RP = 10kΩ ±3.0 ±6.0 ±3.0 ±6.0 %

REF01EP 0°C to +70°C 8.5 ±30 8 Plastic DIP P8-2 Output Voltage Noise enP-P 0.1Hz to 10Hz (Note 1) 20 30 20 30 µVP-P

REF01EP+ 0°C to +70°C 8.5 ±30 8 Plastic DIP P8-2 Line Regulation VIN = 13V to 33V (Note 2) 0.006 0.010 0.006 0.010 %/V

REF01HP 0°C to +70°C 25 ±50 8 Plastic DIP P8-2 Load Regulation IL = 0 to 10mA (Note 2) 0.005 0.008 0.006 0.010 %/mA

REF01HP+ 0°C to +70°C 25 ±50 8 Plastic DIP P8-2 Turn-On Settling Time tON To ±0.1% of final value 400 400 µs

REF01HSA 0°C to +70°C 25 ±50 8 SO S8-2 Quiescent Supply Current ISY No load 1.0 1.4 1.0 1.4 mA

REF01HSA+ 0°C to +70°C 25 ±50 8 SO S8-2 To specified output


Load Current IL 10 21 10 21 mA
REF01CP 0°C to +70°C 65 ±100 8 Plastic DIP P8-2 voltage tolerance

REF01CP+ 0°C to +70°C 65 ±100 8 Plastic DIP P8-2 To specified output


Sink Current IS 0.3 0.5 0.3 0.5 mA
REF01CSA 0°C to +70°C 65 ±100 8 SO S8-2 voltage tolerance

REF01CSA+ 0°C to +70°C 65 ±100 8 SO S8-2 Short-Circuit Current ISC VO = 0V 30 30 mA

REF01CESA -40°C to +85°C 65 ±100 8 SO S8-2


REF01CESA+ -40°C to +85°C 65 ±100 8 SO S8-2 ELECTRICAL CHARACTERISTICS—REF01E/REF01H
+Denotes a lead-free package. (VIN = +15V, 0°C ≤ TA ≤ +70°C for REF01E and REF01H, IL = 0mA, unless otherwise noted.)
Ordering Information continued at end of data sheet.
REF01E REF01H
PARAMETER SYMBOL CONDITIONS UNITS
MIN TYP MAX MIN TYP MAX
Applications Typical Operating Circuit Output Voltage Change with 0°C ≤ TA ≤ +70°C
∆VOT 0.02 0.06 0.07 0.17 %
Analog-to-Digitial Converters +15V Temperature (Note 3)

Digitial-to-Analog Converters 2 Output Voltage Temperature


TCVO (Note 4) 3 8.5 10.0 25.0 ppm/°C
VIN Coefficient
Digital Voltmeters 6
VO OUTPUT
Voltage Regulators Change in VO Temperature
REF01 Coefficient with Output RP = 10kΩ 0.7 0.7 ppm/%
Threshold Detectors RP Adjustment
REF02 TRIM 5
10kΩ
GND Line Regulation 0°C ≤ TA ≤ +70°C
4 0.007 0.012 0.007 0.012 %/V
(VIN = 13V to 33V) (Note 2)

Load Regulation 0°C ≤ TA ≤ +70°C


0.006 0.010 0.007 0.012 %/mA
REFERENCE WITH TRIMMED OUTPUT. (IL = 0 to 8mA) (Note 2)

________________________________________________________________ Maxim Integrated Products 1 2 _______________________________________________________________________________________

For pricing, delivery, and ordering information, please contact Maxim/Dallas Direct! at
1-888-629-4642, or visit Maxim’s website at www.maxim-ic.com.
+5V, +10V Precision +5V, +10V Precision
Voltage References Voltage References
ELECTRICAL CHARACTERISTICS—REF01C ABSOLUTE MAXIMUM RATINGS–REF02
(VIN = +15V, TA = +25°C, IL = 0mA, unless otherwise noted.) Input Voltage Operating Temperature Range
REF02, E, H .........................................................................40V REF02E, REF02H .................................................0°C to +70°C
REF01C
REF02C ...............................................................................30V REF02C (except REF02CESA) ............................0°C to +70°C
PARAMETER SYMBOL CONDITIONS UNITS Continuous Power Dissipation REF02CESA ......................................................-40°C to +85°C
MIN TYP MAX Plastic Dip (P) (derate at 5.6mW/°C above +36°C) .....500mW Output Short-Circuit Duration
Output Voltage VO IL = 0mA 9.90 10.00 10.10 V Small Outline (S) (derate at 5.0mW/°C above +55°C) ..300mW (to ground or VIN) .......................................................Indefinite
Output Adjustment Range ∆Vtrim RP = 10kΩ ±2.7 ±6.0 %
Storage Temperature Range .............................-65°C to +150°C Lead Temperature (soldering, 60s) .................................+300°C

Output Voltage Noise enP-P 0.1Hz to 10Hz (Note 1) 25 35 µVP-P Stresses beyond those listed under “Absolute Maximum Ratings” may cause permanent damage to the device. These are stress ratings only, and functional
operation of the device at these or any other conditions beyond those indicated in the operational sections of the specifications is not implied. Exposure to
Line Regulation VIN = 13V to 30V (Note 2) 0.009 0.015 %/V
absolute maximum rating conditions for extended periods may affect device reliability.
IL = 0 to 8mA 0.006 0.015
Load Regulation (Note 2) %/mA
IL = 0 to 4mA 0.006 0.015

REF01/REF02
REF01/REF02
Turn-On Settling Time tON To ±0.1% of final value 400 µs ELECTRICAL CHARACTERISTICS—REF02E/REF02H
Quiescent Supply Current ISY No load 1.0 1.6 mA (VIN = +15V, TA = +25°C, unless otherwise noted.)
Load Current IL To specified output voltage tolerance 8 21 mA REF02E REF02H
PARAMETER SYMBOL CONDITIONS UNITS
Sink Current IS To specified output voltage tolerance 0.2 0.5 mA MIN TYP MAX MIN TYP MAX
Short-Circuit Current ISC VO = 0V 30 mA Output Voltage VO IL = 0 4.985 5.000 5.015 4.975 5.000 5.025 V
Output Adjustment Range ∆Vtrim RP = 10kΩ ±3 ±6 ±3 ±6 %
ELECTRICAL CHARACTERISTICS—REF01C Output Voltage Noise enP-P 0.1Hz to 10Hz (Note 5) 10 15 10 15 µVP-P
(VIN = +15V, TA = TMIN to TMAX, unless otherwise noted.) Line Regulation VIN = 8V to 33V (Note 6) 0.006 0.010 0.006 0.010 %/V
REF01C Load Regulation IL = 0 to 10mA (Note 6) 0.005 0.010 0.006 0.010 %/mA
PARAMETER SYMBOL CONDITIONS UNITS
MIN TYP MAX Turn-On Settling Time tON To ±0.1% of final value 230 230 µs
Output Voltage Change with Quiescent Supply Current ISY No load 1.0 1.4 1.0 1.4 mA
∆VOT (Note 3) 0.14 0.45 %
Temperature Load Current IL To specified output voltage tolerance 10 21 10 21 mA
Output Voltage Temperature Sink Current IS To specified output voltage tolerance 0.3 0.5 0.3 0.5 mA
TCVO (Note 4) 20 65 ppm/°C
Coefficient Short-Circuit Current ISC VO = 0V 30 30 mA
Change in VO Temperature Temperature Voltage Output VT (Note 7) 630 630 mV
RP = 10kΩ 0.7 ppm/%
Coefficient with Output Adjustment

Line Regulation VIN = 13V to 30V (Note 2) 0.011 0.018 %/V


Load Regulation IL = 0 to 5mA (Note 2) 0.008 0.018 %/mA ELECTRICAL CHARACTERISTICS—REF02E/REF02H
(VIN = +15V, 0°C ≤ TA ≤ +70°C for REF02E and REF02H, IL = 0mA, unless otherwise noted.)
Note 1: Guaranteed by design.
Note 2: Line and load regulation specifications include the effect of self heating. 100% production tested at T A = +25°C and guaranteed REF02E REF02H
by design for TA = TMIN to TMAX, as specified. PARAMETER SYMBOL CONDITIONS UNITS
MIN TYP MAX MIN TYP MAX
Note 3: ∆VOT is defined as the absolute difference between the maximum output voltage and the minimum output voltage over the
specified temperature range expressed as a percentage of 10V. Guaranteed by design. Output Voltage Change with 0°C ≤ TA ≤ +70°C
∆VOT 0.02 0.06 0.07 0.17 %
Temperature (Note 8)
V -V 
∆VOT =  MAX MIN  × 100
 10V  Output Voltage Temperature
TCVO (Note 9) 3 8.5 10 25 ppm/°C
Coefficient
Note 4: TCVO is defined as ∆VOT divided by the temperature range. Guaranteed by design.
Change in VO Temperature
Coefficient with Output RP = 10kΩ 0.7 0.7 ppm/%
Adjustment
Output Adjustment binary applications (see the Typical Operating Circuit).
Line Regulation 0°C ≤ TA ≤ +70°C
The REF01 trim terminal can be used to adjust the volt- Adjustment of the output does not significantly affect the 0.007 0.012 0.007 0.012 %/V
(VIN = 8V to 33V) (Note 6)
age over a 10V ±600mV range. This feature allows the temperature performance of the device. The tempera-
system designer to trim system errors by setting the ref- ture coefficient change is approximately 0.7ppm/°C for Load Regulation 0°C ≤ TA ≤ +70°C
0.006 0.010 0.007 0.012 %/mA
erence to a voltage other than 10V, including 10.240V for 100mV of output adjustment. (IL = 0 to 8mA) (Note 6)

_______________________________________________________________________________________ 3 4 _______________________________________________________________________________________
+5V, +10V Precision +5V, +10V Precision
Voltage References Voltage References
ELECTRICAL CHARACTERISTICS—REF02E/REF02H (continued) ELECTRICAL CHARACTERISTICS–REF02 (continued)
(VIN = +15V, 0°C ≤ TA ≤ +70°C for REF02E and REF02H, IL = 0mA, unless otherwise noted.) (VIN = +15V, TA = TMIN to TMAX, IL = 0mA, unless otherwise noted.)

REF02E REF02H Note 5: Guaranteed by design.


PARAMETER SYMBOL CONDITIONS UNITS Note 6: Line and load regulation specifications include the effect of self heating. 100% production tested at T A = +25°C and guaranteed
MIN TYP MAX MIN TYP MAX
by design for TA = TMIN to TMAX, as specified.
Temperature Voltage Output Note 7: Limit current in or out of pin 3 to 50nA and capacitance on pin 3 to 30pF.
TCVT (Note 7) 2.1 2.1 mV/°C
Temperature Coefficient Note 8: ∆VOT is defined as the absolute difference between the maximum output voltage and the minimum output voltage over the
specified temperature range expressed as a percentage of 5V. Guaranteed by design.
V -V 
∆VOT =  MAX MIN  × 100
 5V 
ELECTRICAL CHARACTERISTICS—REF02C
Note 9: TCVO is defined as ∆VOT divided by the temperature range. Guaranteed by design.
(VIN = +15V, TA = +25°C, unless otherwise noted.)

REF01/REF02
REF01/REF02
REF02C
PARAMETER SYMBOL CONDITIONS UNITS
MIN TYP MAX
Output Voltage VO IL = 0mA 4.950 5.000 5.050 V
Output Adjustment
Output Adjustment Range ∆Vtrim RP = 10kΩ ±2.7 ±6.0 % 880
The REF02 trim terminal can be used to adjust the out-
Output Voltage Noise enP-P 0.1Hz to 10Hz (Note 5) 12 18 µVP-P 830
put voltage over a 5V ±300mV range. This feature
Line Regulation VIN = 8V to 30V (Note 6) 0.009 0.015 %/V 780
allows the system designer to trim system errors by set-
IL = 0 to 8mA 0.006 0.015 ting the reference to a voltage other than 5V (refer to 730
Load Regulation (Note 6) %/mA
IL = 0 to 4mA the Typical Operating Circuit). 680

Turn-On Settling Time tON To ±0.1% of final value 230 µs Adjustment of the output does not significantly affect 630
Quiescent Supply Current ISY No load 1.0 1.6 mA the temperature performance of the device. Typically, 580
TEMP VOLTAGE OUTPUT (mV)

Load Current IL To specified output voltage tolerance 8 21 mA the temperature coefficient change is 0.7ppm/°C for 530
Sink Current IS To specified output voltage tolerance 0.2 0.5 mA
100mV of output adjustment. 480
Short-Circuit Current ISC VO = 0V 30 mA Temperature Voltage Output 430
-60 -40 -20 0 20 40 60 80 100 120 140
Temperature Voltage Output VT (Note 7) 630 mV The REF02 provides a temperature-dependent output TEMPERATURE (°C)
voltage on the TEMP pin. This voltage is proportional to
the absolute temperature, and has a scale factor of Figure 1. REF02 Temperature/Voltage Output vs. Temperature
approximately 2.1mV/°C (Figure 1).
ELECTRICAL CHARACTERISTICS—REF02C Output Voltage = 2.1(T + 273)mV
(VIN = +15V, TA = TMIN to TMAX, IL = 0mA, unless otherwise noted.)
where T = Temperature in °C.
REF02C
PARAMETER SYMBOL CONDITIONS UNITS
MIN TYP MAX

Output Voltage Change with


∆VOT (Note 8) 0.14 0.45 %
Temperature

Output Voltage Temperature


TCVO (Note 9) 20 65 ppm/°C
Coefficient

Change in VO Temperature
Coefficient with Output RP = 10kΩ 0.7 ppm/%
Adjustment

Line Regulation VIN = 8V to 30V (Note 6) 0.011 0.018 %/V


Load Regulation IL = 0 to 5mA (Note 6) 0.008 0.018 %/mA

Temperature Voltage Output


TCVT (Note 7) 2.1 mV/°C
Temperature Coefficient

_______________________________________________________________________________________ 5 6 _______________________________________________________________________________________
+5V, +10V Precision +5V, +10V Precision
Voltage References Voltage References
Typical Operating Characteristics Typical Applications
(TA = +25°C, unless otherwise noted.)
1.1mA +15V
2 2
REF01 OUTPUT WIDEBAND REF02 OUTPUT WIDEBAND
VIN 6 +10V
LINE REGULATION NOISE vs. BANDWIDTH NOISE vs. BANDWIDTH VIN VO
vs. FREQUENCY (0.1Hz TO FREQUENCY INDICATED) (0.1Hz TO FREQUENCY INDICATED) 6
VO +
76 10,000 10,000
VIN = 15V VIN = 15V 10kΩ
VIN = 15V REF01
66 TA = +25°C TA = +25°C TA = +25°C 9V 10kΩ
REF01 5

REF01/02 TOC01
REF01/02 TOC03
TRIM

REF01/02 TOC02
5 GND
56 100kΩ 10.000V +15V
1000 TRIM 4
1000
46 GND 5kΩ OP-07 -10V
9V
4 -15V
-

REF01/REF02
REF01/REF02
36
100 100

LINE REGULATION (dB)


OUTPUT NOISE (µVP-P)

OUTPUT NOISE (µVP-P)


26 Figure 2. Precision Calibration Standard Figure 3. ±10V Reference
16
+15V
6 10 10
10 100 1k 10k 100k 1M 10 100 1k 10k 100k 1M 10 100 1k 10k 100k 1M 2
+15V
FREQUENCY (Hz) FREQUENCY (Hz) FREQUENCY (Hz) 2 VIN 6 VREF 9.09kΩ
VO
NORMALIZED LOAD VIN
6
MAXIMUM LOAD CURRENT REGULATION (∆IL = 10mA) NORMALIZED LINE REGULATION VO REF02 5.11kΩ
vs. TEMPERATURE 5 2
vs. INPUT VOLTAGE vs. TEMPERATURE TRIM 50kΩ 7
35 1.4 1.4 1.5kΩ 6
1.5kΩ OP-07
VIN = 15V REF02 VOUT
1.3 1.3 5.0V ±5% 4
30 3 5 IOUT = + 1mA 3 (10mV/°C)
R TEMP

REF01/02 TOC06
R

REF01/02 TOC04
REF01/02 TOC05
SHORT-CIRCUIT TRIM
1.2 1.2
25 PROTECTION GND *
GND
500mW MAXIMUM 1.1 1.1 4
20 DISSIPATION 4 200kΩ
1.0 1.0 IOUT
15 -15V
0.9 0.9 *UP TO 10 FEET OF SHIELDED
4-CONDUCTOR CABLE.
10 0.8
0.8

MAXIMUM LOAD CURRENT (mA)


LOAD REG (T)/LOAD REG (+25°C)

LOAD REG (T)/LOAD REG (+25°C)


5 0.7 0.7 Figure 4. Current Source Figure 5. Precision Temperature Transducer with
TA = +25°C Remote Sensor
0 0.6 0.6
10 15 20 25 30 -60 -40 -20 0 20 40 60 80 100 120 140 -60 -40 -20 0 20 40 60 80 100 120 140
INPUT VOLTAGE (V) TEMPERATURE (°C) TEMPERATURE (°C)

MAXIMUM LOAD CURRENT QUIESCENT CURRENT OUTPUT CHANGE DUE TO


vs. TEMPERATURE vs. TEMPERATURE THERMAL SHOCK
30 1.3 0.035
VIN = 15V VIN = 15V VIN = 15V
0.030
25 1.2

REF01/02 TOC09

REF01/02 TOC07
REF01/02 TOC08
0.025 T A = TA =
20 1.1 +25°C +75°C
0.020
15 1.0
0.015
10 0.9
0.010

QUIESCENT CURRENT (mA)

MAXIMUM LOAD CURRENT (mA)


5 0.8 0.005 DEVICE IMMERSED

PERCENT CHANGE OUTPUT VOLTAGE (%)


IN +75°C OIL BATH
0 0.7 0
-60 -40 -20 0 20 40 60 80 100 120 140 -60 -40 -20 0 20 40 60 80 100 120 140 -10 0 10 20 30 40 50 60
TEMPERATURE (°C) TEMPERATURE (°C) TIME (s)

_______________________________________________________________________________________ 7 8 _______________________________________________________________________________________
+5V, +10V Precision
Voltage References
Pin Configurations

TOP VIEW

N.C. 1 8 N.C. N.C. 1 8 N.C.

VIN 2 7 N.C. VIN 2 7 N.C.


REF01/ REF01/
N.C./TEMP* 3 REF02 6 VOUT N.C./TEMP* 3 REF02 6 VOUT

GND 4 5 TRIM GDN 4 5 TRIM

REF01/REF02
DIP SO

*NOTE: PIN 3 IS N.C. (NO CONNECTION) ON REF01, TEMP OUTPUT ON REF02.

Ordering Information (continued)


MAX TEMPCO INITIAL ERROR PKG
PART TEMP RANGE PIN-PACKAGE
(ppm/°C) (mV) CODE
REF02EP 0°C to +70°C 8.5 ±15 8 Plastic DIP P8-2
REF02EP+ 0°C to +70°C 8.5 ±15 8 Plastic DIP P8-2
REF02HP 0°C to +70°C 25 ±25 8 Plastic DIP P8-2
REF02HP+ 0°C to +70°C 25 ±25 8 Plastic DIP P8-2
REF02HSA 0°C to +70°C 25 ±25 8 SO S8-2
REF02HSA+ 0°C to +70°C 25 ±25 8 SO S8-2
REF02CP 0°C to +70°C 65 ±50 8 Plastic DIP P8-2
REF02CP+ 0°C to +70°C 65 ±50 8 Plastic DIP P8-2
REF02CSA 0°C to +70°C 65 ±50 8 SO S8-2
REF02CSA+ 0°C to +70°C 65 ±50 8 SO S8-2
REF02CESA -40°C to +85°C 65 ±50 8 SO S8-2
REF02CESA+ -40°C to +85°C 65 ±50 8 SO S8-2
+Denotes a lead-free package.

Revision History Package Information


Pages changed at Rev 7: 1, 9 For the latest package outline information, go to
www.maxim-ic.com/packages.

Maxim cannot assume responsibility for use of any circuitry other than circuitry entirely embodied in a Maxim product. No circuit patent licenses are
implied. Maxim reserves the right to change the circuitry and specifications without notice at any time.

Maxim Integrated Products, 120 San Gabriel Drive, Sunnyvale, CA 94086 408-737-7600 _____________________ 9

© 2007 Maxim Integrated Products is a registered trademark of Maxim Integrated Products, Inc.
D-18 Edit Date: February 12, 2013
Appendix E

MapleSim Tutorials

MapleSim is a simulation environment brought to you by the folks at MapleSoft. It is available on many
computers at Ryerson University, including the computers in the ELE604 labs. The following is a pair of short
tutorials. The first is on how to set up simple electrical system and to produce the underlying characteristic
equations. The second shows you how to create a BJT-driven LED.

E-1
MapleSim  Simple  Sine-­Driven  Resistor  Tutorial   (v.  1.1)           James  A.  Smith  

ELE604  –  Sensors  and  Measurement               January,  2010  

Overview  
System  modeling  and  simulation  is  an  important  process  for  engineering.    It  permits  
you  to  examine  the  effects  that  input  variables  and  component  parameters  have  on  
the  behaviour  of  the  system.    How  does  a  civil  engineer  know  that  the  bridge  she  is  
designing   will   be   able   to   carry   200   passenger   cars?     By   careful   modeling   of   the  
bridge  structure  and  simulation  of  that  model  under  different  test  conditions.    In  the  
same  way,  an  electrical  engineer  should  simulate  a  circuit  to  ensure  that  it  can,  for  
example,  handle  particular  voltage  and  current  levels  (for  safety)  or  to  ensure  that  
the  LED  will  shine  brightly  enough  (in  a  user  interface).  

Here,  you  will  drive  a  resistor  with  an  oscillating  voltage  input  and  will  measure  the  
resulting  current  flow.      While  it  is  a  trivial  circuit  to  understand  intuitively,  the  true  
objective  is  to  introduce  you  to  a  powerful  modeling  and  simulation  tool:  MapleSim  
by  MapleSoft.    In  later  tutorials  you  will  model  more  complex  systems.  

           
The   intended   audience   for   this   tutorial   is   third   year   electrical   engineering  
undergraduate  students  with  little  to  no  background  in  Maple  or  MapleSim,  but  with  
intermediate   background   in   engineering   computer   usage.     Familiarity   with   tools  
such  as  Mathworks  Simulink  or  LTSpice  is  an  asset  but  is  not  required.  

Learning  Objectives  
The  learning  objective  is  to  become  familiar  with  MapleSim  as  a  tool  for  electrical  
modeling.  

Success  Criteria  
The  student  is  to  model  a  sinusoidally  driven  resistor,  creating  documentation  to  
demonstrate  that  the  schematic  was  drawn,  current  and  voltage  were  plotted  and  
system  equations  generated.  

Pre-­‐Tutorial  &  Pre-­‐Requisites  


None.  

Macintosh HD:Users:jasmith:research:Maple:MapleSim:tutorials:simple_sine_drive_resistor_v2.doc  
MapleSim  Simple  Sine-­Driven  Resistor  Tutorial   (v.  1.1)           James  A.  Smith  

ELE604  –  Sensors  and  Measurement               January,  2010  

More  Resources  
 MapleSim  User  Guide  by  MapleSoft.    Available  online:  
http://www.maplesoft.com/support/help/MapleSim/view.aspx?path=Maple
SimUserGuide%2fChapter05#extractingEquations.  

Background  Information  
Here,  you  will  drive  a  resistor  with  an  oscillating  voltage  input  and  will  measure  the  
resulting  current  flow.      While  it  is  a  trivial  circuit  to  understand  intuitively,  the  true  
objective  is  to  introduce  you  to  a  powerful  modeling  and  simulation  tool:  MapleSim  
by  MapleSoft.    In  later  tutorials  you  will  model  more  complex  systems.  

Why   MapleSim?     Because   it   offers   a   unique   combination   of   features.     It   is   multi-­‐


domain,   unlike   products   like   the   Spice   family   (PSpice,   LTSpice,   etc.).     Unlike   other  
multi-­‐domain  products  like  Mathworks’  Simulink,  it  is  also  capable  of  generating  the  
underlying   system   equations.     This   is   a   powerful   feature   that,   for   instance,   can  
permit  further  analysis  in  tools  such  as  Maple,  Mathematica  and  Matlab.      

In  this  tutorial  you  will  be  using  three  different  components  in  this  tutorial  (four,  if  
you  count  the  connecting  wires  between  parts).  

Exploration  
Step  1:  Open  MapleSim  
The  first  step  is  to  ensure  that  you  have  access  to  MapleSim  using  either  a  student  licence  or  
one  of  the  Electrical  and  Computer  Engineering  Department  lab  computers  with  MapleSim  
installed.    Look  for  the  icon  shown  in  Figure  1.  

 
Figure  1  The  MapleSim  icon  (version  4.5),  as  seen  on  a  Macintosh.    Windows  and  Linux  machines  
have  similar  icons.  

Step  2:  Draw  a  circuit  


There   are   four   elements:   sinusoid   source,   resistor,   ground   and   a   probe.     Your   circuit   will,   in  
the  end,  looks  like  Figure  2.  

Macintosh HD:Users:jasmith:research:Maple:MapleSim:tutorials:simple_sine_drive_resistor_v2.doc  
MapleSim  Simple  Sine-­Driven  Resistor  Tutorial   (v.  1.1)           James  A.  Smith  

ELE604  –  Sensors  and  Measurement               January,  2010  

 
Figure  2  The  MapleSim  schematic,  including  a  sinusoidal  input  voltage  (far  left),  a  dual  current  and  
voltage  probe  (middle  left),  resistor  (middle)  and  ground  (bottom  right).  

You   will   need   to   select   the   source,   the   resistor   and   the   ground   from   the   menu   on   the   left  
side   of   the   MapleSim   Window,   as   shown   in   Figure   3.     Drag   them   into   the   main   window.    
You’ll  connect  them  together  shortly.    In  the  mean  time,  place  them  roughly  as  you  see  in  
Figure  2.  

 
Figure  3  Drag  and  drop  the  circuit  elements  from  this  menu.  

Macintosh HD:Users:jasmith:research:Maple:MapleSim:tutorials:simple_sine_drive_resistor_v2.doc  
MapleSim  Simple  Sine-­Driven  Resistor  Tutorial   (v.  1.1)           James  A.  Smith  

ELE604  –  Sensors  and  Measurement               January,  2010  

Beware!     The   sinusoid   source   appears   with   the   positive   (“+”)   port   on   the   left   and   the  
negative  (“-­‐”)  port  on  the  right  when  you  insert  it.    Rotate  it  (using  CTRL-­R  in  Windows  or  
-­R  on  a  Mac)  so  that  it  appears  as  in  Figure  2.  

[Hint:  if  the  symbols  appear  too  small,  use  the  Zoom  feature  in  the  View  menu  to  take  a  close  
look.]  

You  now  need  to  “wire”  the  parts.    Do  this  by  navigating  the  mouse  cursor  near  the  end  of  
one  of  the  parts  (e.g.  the  left  port  on  the  resistor,  as  in  Figure  4).    You’ll  see  the  port  become  
a   green   circle.     Left-­‐click   on   it   to   enable   the   “wire”.     Then,   move   your   cursor   to   the   right-­‐
hand   side   port   of   the   sinusoid   generator.     When   you   encounter   that   port   another   green  
circle   will   appear,   as   in   Figure   5.     Click   again   and   a   wire   will   “bond”   to   it.       Congratulations!    
You  now  have  a  connection  between  the  resistor  and  the  sinusoid  generator.  

 
Figure  4  Select  the  resistor's  port.  

 
Figure  5  Wire  the  resistor  to  the  generator.  

Continue  attaching  components  until  you  have  the  circuit  shown  in  Figure  6.  

 
Figure  6  The  generator,  resistor  and  ground  connected  together.  

Next,  adjust  the  parameters  of  each  component.  Do  this  by  left-­‐clicking  directly  on  
the   component.     For   instance,   if   you   do   this   to   the   sinusoid   generator   a   box   will  
appear,  as  shown  in  Figure  7.    You’ll  also  notice  that  the  parameters  appear  on  the  
right-­‐hand  side  of  the  MapleSim  window.    Any  values  in  grey  are  default  /  guessed  

Macintosh HD:Users:jasmith:research:Maple:MapleSim:tutorials:simple_sine_drive_resistor_v2.doc  
MapleSim  Simple  Sine-­Driven  Resistor  Tutorial   (v.  1.1)           James  A.  Smith  

ELE604  –  Sensors  and  Measurement               January,  2010  

parameters.     You   are   likely   to   want   to   change   these   when   you   make   your   own  
simulations,  but  the  defaults  are  okay  for  now.  

 
Figure  7  You  will  need  to  adjust  the  parameters  of  each  component.    Here,  we  examine  the  
parameters  for  the  sinusoidal  generator.    The  peak  amplitude  (Vh)  is  1  volt,  frequency  (f)  is  1  Hz,  the  
DC  bias  (Vo)  is  0  Volts.  

Set   the   sinusoid   generator   to   have   a   1   volt   peak   amplitude,   no   phase   shift,   1   Hz  
frequency   and   no   voltage   or   time   offset.     Set   the   resistor   to   have   a   1   Ohm   resistance  
(ignore   the   temperature   parameters   and   set   the   initial   conditions   to   “ignore”   for  
both  initial  voltage  and  current  by  selecting  the  “ignore”  icon  for  each).  

 
Figure  8  The  probe  icon.    Use  this  to  measure  characteristics  of  your  system,  like  voltage  and  current  
for  electrical  systems  (it  also  works  to  measure  mechanical  characteristics  if  your  system  contains  
mechanical  elements.).  

Next,   you   need   to   insert   a   probe   (see   Figure   8)   in   order   to   measure   current   and  
voltage   in   your   circuit.   Click   on   the   icon   to   change   your   cursor   to   a   probe.     Navigate  
to  the  wire  between  the  generator  and  the  resistor.    It  will  turn  blue.    Click  on  it  and  
move   the   cursor   upward.     Click   again.     The   probe   is   installed.     In   the   right-­‐hand  
menu,  click  on  the  “current”  checkbox.    Your  circuit  should  look  like  Figure  9.  

Macintosh HD:Users:jasmith:research:Maple:MapleSim:tutorials:simple_sine_drive_resistor_v2.doc  
MapleSim  Simple  Sine-­Driven  Resistor  Tutorial   (v.  1.1)           James  A.  Smith  

ELE604  –  Sensors  and  Measurement               January,  2010  

 
Figure  9  Circuit  with  probe  for  measuring  voltage  and  current.  

You  are  now  ready  to  simulate  the  system!  

Step  3:  Run  the  Simulation  in  MapleSim  


To  run  the  simulation  you  can  click  on  the  “Simulate  the  model”  button,  shown  in  
Figure  10.    The  progress  of  the  simulation  is  shown  at  the  bottom  of  the  MapleSim  
window,  shown  in  Figure  11.  

 
Figure  10  Run  the  simulation  by  clicking  on  the  blue  triangle  near  the  top  of  the  MapleSim  window.  

 
Figure  11  You  can  monitor  progress  of  the  simulation  in  the  bottom  of  the  MapleSim  window.  

When  the  simulation  is  finished  a  plot  window  will  appear,  as  shown  in  Figure  12.    
This  shows  you  the  current  and  voltage,  as  measured  by  the  probe  you  inserted  
earlier.    You  can  modify  the  title  and  x-­‐  and  y-­‐axis  labels  by  double-­‐clicking  on  them.    
You  can  also  export  and  print  these  plots.  

Macintosh HD:Users:jasmith:research:Maple:MapleSim:tutorials:simple_sine_drive_resistor_v2.doc  
MapleSim  Simple  Sine-­Driven  Resistor  Tutorial   (v.  1.1)           James  A.  Smith  

ELE604  –  Sensors  and  Measurement               January,  2010  

 
Figure  12  The  plot  window  showing  the  voltage  and  current  as  measured  by  the  probe.  

If  you  click  near,  but  not  on  the  circuit  elements  in  your  schematic  the  integration  
parameters  for  the  simulation  will  appear  in  the  right-­‐hand  side  of  the  MapleSim  
window,  shown  in  Figure  13.  

 
Figure  13  MapleSim  integration  parameters  for  simulation.    The  details  will  be  discussed  in  a  later  
tutorial.    The  defaults  are  fine  for  this  circuit.  

Step  4:  Export  the  System  Equations  to  Maple  


Here  is  how  to  export  the  equations  into  Maple.    Find  the  “paperclip”  in  the  upper  
left  corner  of  the  application  window,  as  shown  in  Figure  14,  and  then  select  
“Equations”  as  in  Figure  15.  

 
Figure  14  Create  an  "attachment"  

Macintosh HD:Users:jasmith:research:Maple:MapleSim:tutorials:simple_sine_drive_resistor_v2.doc  
MapleSim  Simple  Sine-­Driven  Resistor  Tutorial   (v.  1.1)           James  A.  Smith  

ELE604  –  Sensors  and  Measurement               January,  2010  

 
Figure  15  Select  "equations"  for  the  attachment

An   “Equation   Extraction”   template   will   open   up   in   Maple.     It   will   contain   details  


from  the  MapleSim  model  that  you  are  currently  working  on,  as  shown  in  Figure  16.  

 
Figure  16  The  Maple  "Equation  Extraction"  window.  

The   help   files   at   MapleSoft   related   to   this   can   be   found   at  


http://www.maplesoft.com/support/help/MapleSim/view.aspx?path=MapleSimUserGuide%2fChap
ter05#extractingEquations.    For  convenience,  they’re  included  below  in  Figure  17.  

Macintosh HD:Users:jasmith:research:Maple:MapleSim:tutorials:simple_sine_drive_resistor_v2.doc  
MapleSim  Tutorial  1     James  Andrew  Smith  

ELE604  –  Sensors  and  Measurement     January,  2010  

 
Figure  17  Alternative  and  more  compact  instructions  can  be  found  in  the  official  online  MapleSim  
User  Guide,  an  excerpt  of  which  is  shown  here.  

Click  on  “Main”  in  the  Model  Diagram.    Then,  click  on  “Retrieve  System”  in  “Model  
Input   from   MapleSim”.   In   the   Variable   Management   section,   change   the  
Main.Probe1.i  to  Current  and  the  Main.Probe1.v  to  Voltage.1  

 In  the  “Model  Equations”  section  click  on  “Apply  Variables  in  Variable  Manager”.    
Then  select  the  “System  Equations”  radio  button.    Three  equations  will  appear  on  a  
single  line:  one  for  voltage  and  two  for  current  (opposite  signs  of  one  another),  as  
shown  in  Figure  18.  

 
Figure  18  The  three  equations  for  current  and  voltage  generated  by  the  Maple  Equation  attachment  
to  the  MapleSim  model.    Note  the  sign  difference  between  the  two  current  readings,  “Current(t)”and  
Probe1.p2.i(t)”  

Skill  Exercises  
The  following  are  exercises  to  reinforce  the  material  above  and  to  demonstrate  
more  advanced  skills.    They  are  relatively  straightforward  and  can  be  attempted  
independently.    

 Modify  the  titles  and  labels  in  the  plots.      


                                                                                                               
1  There  is  a  second  current  variable,    Probe1.p2.i(t),  which  has  the  opposite  sign  to  

the  first.    The  signs  correspond  to  the  arrow  shown  on  the  probe  “lead”.  

Macintosh HD:Users:jasmith:research:Maple:MapleSim:tutorials:simple_sine_drive_resistor_v2.doc  
MapleSim  Tutorial  1     James  Andrew  Smith  

ELE604  –  Sensors  and  Measurement     January,  2010  

 In  the  Equation  attachment,  change  the  Probe1.p2.i  variable’s  name  to  reflect  
the  fact  that  it  is  simply  the  negated  version  of  the  other  current  variable.  

 Modify  the  resistor  value  to  permit  more  current  to  flow.    Plot  the  results  and  
then  update  the  Equation  attachment  (hint:  there  is  no  need  to  create  a  new  
attachment;  simply  update  the  old  attachment.)  

Communication  
You  are  to  hand  a  report  document  to  your  TA,  including  a  standard  (and  signed)  
FEAS  cover  sheet,  a  print-­‐out  of  your  MapleSim  schematic  on  one  page,  a  print-­‐out  
of  your  MapleSim  plots  on  another  page  and  a  print-­‐out  of  the  Maple  equation  
generation  pages.    Finally,  include  a  short  writeup  (under  one  page)  outlining  your  
answers  to  the  skill  exercises  listed  above.  

Post-­‐Tutorial  Reflection  
Could  you  simulate  more  complicated  models?    Does  MapleSim  have  the  ability  to  simulate  
transistors,  LEDs  and  Op  Amps?    Since  a  2n3904  BJT  operates  differently  than  a  2n3906  or  a  
2n2219,  where  would  you  find  the  parameters  for  these  components?      

MapleSim  can  also  be  used  to  model  mechanical  systems.    What  kind  of  components  would  
you  need  to  model  an  inverted  pendulum?    What  if  you  wanted  to  attach  a  motor  to  the  
pendulum?    Could  this  be  done?  

Additional  References  
 

 “Principles  of  Linear  Algebra  with  Maple”  by  Kenneth  Shiskowski  and  Karl  Frinkle  
(http://carmine.se.edu/kfrinkle/principlesoflinearalgebrawithmaple/  and  
http://ca.wiley.com/WileyCDA/WileyTitle/productCd-­‐0470637595,descCd-­‐
tableOfContents.html  )    

 “Exploring  Chaos  and  Dynamical  Systems  with  MapleSim”  by  Stephen  Lynch.    
(http://www.doc.mmu.ac.uk/STAFF/S.Lynch/cover1.html  and  
http://www.maplesoft.com/company/publications/articles/view.aspx?SID=19230)  

Macintosh HD:Users:jasmith:research:Maple:MapleSim:tutorials:simple_sine_drive_resistor_v2.doc  
MapleSim  Transistor  –  LED  Tutorial         James  A.  Smith  

Introduction  
Here,   you   are   to   simulate   the   turning   on-­‐and-­‐off   of   an   LED   in   MapleSim.     You   will  
modify  the  parameters  of  the  NPN  BJT  transistor  model  included  in  MapleSim  and  
will   assume   that   the   diode   included   in   MapleSim   is   sufficiently   similar   to   an   LED.      
The  base  of  the  BJT  will  be  driven  by  a  stepping  voltage  source.    This  is  similar  to  
how  the  9s12  microcontroller  will  turn  the  BJT  (and  therefore  the  LED)  on  and  off.  

You  need  to  tune  the  values  of  the  base  and  collector  resistors  so  that  they  permit  
sufficient  (but  not  excessive)  current.  

It   is   assumed   that   you   have   completed   the   first   MapleSim   tutorial,   in   which   you  
were   to   connect   a   resistor   to   a   sine-­‐generator.   This   tutorial   is   slightly   more  
complicated  than  the  previous  tutorial,  however.  

Important  Details  
In   this   tutorial   you   will   be   designing   the   resistor   component   values   to   permit  
sufficient   current   to   drive   the   base   of   the   BJT,   as   well   as   the   LED/diode.     You   will  
need  to  look  up  specifications  for  the  2n3904  BJT  as  well  as  the  LED  to  determine  
what  the  maximum  currents  are  that  they  will  tolerate.    Stay  well  below  those  limits!  

The  simulation  will  require  some  special  attention  to  work  correctly.    For  instance,  
you  will  need  to  tune  the  transistor  parameters  slightly  (they  are  given  below).    As  
well,   you   will   need   to   adjust   the   “integration”   parameters   of   the   simulation.     See  
details  below.    

Step  1:  Draw  the  Circuit  in  MapleSim  


Below   you   will   see   a   figure   outlining   the   basic   layout   of   a   BJT-­‐driven   LED/diode.    
You   need   to   set   it   up   in   a   similar   fashion.     All   of   the   components   are   available   in   the  
MapleSim  menus.    Note  that  the  power  supply  is  five  volts,  as  is  the  stepping  voltage  
provided  by  the  microcontroller.  

 
Figure  1  Example  of  a  suitable  schematic  for  the  design.  

Macintosh HD:Users:jasmith:research:Maple:MapleSim:tutorials:transistor_led_tutorial:transistor_led_tutorial_v1.doc  
MapleSim  Transistor  –  LED  Tutorial         James  A.  Smith  

The  diode  can  be  set  up  to  have  a  “turn-­‐on”  voltage  around  1.6  volts.    What  should  
the   BJT   parameters   be?     These   are   a   little   difficult   to   track   down,   so   they   are  
provided  below  (courtesy  of  Derek  and  Gilbert  at  MapleSoft).  

 
Figure  2  BJT  (2n3904)  characteristics.  

Macintosh HD:Users:jasmith:research:Maple:MapleSim:tutorials:transistor_led_tutorial:transistor_led_tutorial_v1.doc  
MapleSim  Transistor  –  LED  Tutorial         James  A.  Smith  

Step  2:  Run  the  model  


When  you  are  ready,  click  on  the  blue  “Simulate  the  model”  triangle  in  the  upper  left  
corner  of  the  MapleSim  window,  shown  in  Figure  3.    It  will  start  creating  a  compiled  
version  of  the  model.    You  can  watch  the  progress  of  the  simulation  compilation  in  
the   bottom   of   the   application   window,   as   shown   in   Figure   4.     Error   messages   and  
warnings  will  also  appear  here.  

 
Figure  3  Run  the  simulation  by  clicking  on  the  blue  triangle  near  the  top  of  the  MapleSim  window.  

 
Figure  4  You  can  monitor  progress  of  the  simulation  here.  

Integration  Parameters  
There   are   a   number   of   integration   parameters   that   will   need   to   be   tuned.     These  
parameters,  when  set  “properly”  can  improve  the  speed  and  accuracy  of  your  model.    
To  do  this  you  need  to  have  a  moderately  good  understanding  of  how  your  system  
should  behave.  

Macintosh HD:Users:jasmith:research:Maple:MapleSim:tutorials:transistor_led_tutorial:transistor_led_tutorial_v1.doc  
MapleSim  Transistor  –  LED  Tutorial         James  A.  Smith  

 
Figure  5  Integration  parameters  for  the  model,  to  start  with.  

Using  the  Right  Integration  Algorithm  


Because   you   are   feeding   pulses   into   the   base   of   the   transistor   the   system   is  
considered   “stiff”.     This   is   a   mathematical   term   which   can   be   interpreted   to   mean  
that  the  equations  describing  it  switch  very  suddenly.    The  behaviour  of  the  circuit  is  
very  different  when  the  base  is  driven,  versus  when  the  base  is  not  driven.    So,  it’s  
important   to   choose   an   integrating   algorithm   that   understands   that   this   is   “normal”  
and  that  it  can  adapt  when  the  switching  happens.    The  Rosenbrock  integrator  is  a  
“stiff”  integrator  and,  so,  it  is  suitable  for  this  system.    If  your  system  was  driven  by  a  
sinusoid,  you  would  want  to  think  about  using  a  RKF45  (non-­‐stiff)  integrator.1  

Without   getting   into   too   much   detail,   set   the   relative   and   absolute   integration  
tolerances  as  shown  in  Figure  6.  

                                                                                                               
1  For  those  of  you  with  a  Mathworks  Simulink  background,  the  ODE45  integrator  

used  in  Simulink  is  non-­‐stiff,  whereas  the  ODE23s  integrator  is  stiff.  

Macintosh HD:Users:jasmith:research:Maple:MapleSim:tutorials:transistor_led_tutorial:transistor_led_tutorial_v1.doc  
MapleSim  Transistor  –  LED  Tutorial         James  A.  Smith  

 
Figure  6  Integration  parameters  after  some  adjustment.  

Editing  the  Plots  


You  will  need  to  edit  the  plots.    Right-­‐click  on  the  plot  and  rename  the  horizontal  
and  vertical  axes.    Otherwise,  you  can  double-­‐click  on  the  individual  axis  titles  and  
then  edit.  

Reporting  
You  need  to  submit  a  screen-­‐shot  /  print-­‐out  of  your  schematic,  as  well  as  the  
resistor  values  at  the  base  and  collector.    What  is  the  current  which  runs  through  the  
LED/diode?  

When  generating  your  print-­‐outs  remember  that  you  should  display  the  parameter  
names  and  values.    This  can  be  done  from  the  MapleSim  “View”  menu.  

Macintosh HD:Users:jasmith:research:Maple:MapleSim:tutorials:transistor_led_tutorial:transistor_led_tutorial_v1.doc  
Appendix F

Building the Esduino LCD Shield (with driver code)

The following is the second revision of the guide. There are three documents in this portion of the Appendix:

1. the “Building the Esduino ‘Shield’ Board” document. It’s a step-by-step guide.

2. the datasheet for the LCD

3. Sample code for driving the LCD using the Esduino.

Thanks to Ron Wong and Thomas Behan for helping with the material here.

F-1
Esduino  LCD  “Shield”     James  A.  Smith,  Ron  Wong  &  Thomas  Behan  
Rev.  1.1     January  2011  

Building  the  Esduino  LCD  “Shield”  Board  


 

 
Figure  1  Esduino  LCD  "Shield"  Board  

Introduction  
 
This is part of a two-week exercise. In the first week you will demonstrate usage of simulator
tools and will build the LCD board. In the second week you will write a program which
accesses the LCD and displays values from particular points in memory.

This document is designed to step you through the process of constructing the LCD unit.  

Learning  Objectives  &Success  Criteria  


 

These  are  listed  in  the  relevant  part  of  the  Student  Lab  Manual.    Refer  to  it.  

Exploration  
 

You  are  encouraged  to  explore  the  tools  and  parts.    Here  are  some  sample  questions  
you  should  ask  yourself  and  that  you  should  answer:  

 What  is  a  cold  solder  joint?  


 Why  is  eye  protection  important?  
 What  is  the  SPI?  
 What   are   alternative   methods   for   interfacing   an   LCD   to   a   microcontroller?    
(there  are  at  least  two  standard  ways)  
Esduino  LCD  “Shield”     James  A.  Smith,  Ron  Wong  &  Thomas  Behan  
Rev.  1.1     January  2011  

These  types  of  questions  are  examples  of  valid  questions  that  can  be  used  to  assess  
your  achievement  of  the  learning  objectives  for  this  lab  unit.  

Parts  and  Tools  List  


Required  Parts  
1. One  (1)  Technological  Arts  ARPROTO3  (rev  0)  prototyping  board  
2. One  (1)  Electronic  AssemblyLCD  (Three  line,  p/nEA  DOGM163)  
a. Includes  the  LCD  schematic  (see  http://www.lcd-­‐
module.com/eng/pdf/doma/dog-­‐me.pdf).  
3. Four  (4)  Header  Connectors  for  ARPROTO3  
4. Solid  core  22  AWG  wire  (red,  black  and  “coloured”)  

Required  Documents  
1. ELE604  Sensors  and  Measurement  Student  Lab  Manual  by  James  Andrew  
Smith  
2. Electronic  Assembly  Dog  LCD  schematic  /  manual  
3. MC9S12C  Family  /  MC9S12GC  Family  Reference  Manual,  #MC9S12C128  Rev  
01.23  05/2007  by  Freescale  Semiconductor  (available  as  a  free  download  
online)  

Required  Tools  
1. One  (1)  Soldering  Iron  (seeFigure  2)  
2. One  (1)  pair  of  side  cutters  (i.e.  flush  cutters)  (see  Figure  4)  
3. One  (1)  pair  of  needle-­‐nose  pliers  (see  Figure  3)  
4. One  (1)  Fume  hood  (see  Figure  2)  

Recommended  tools  
1. One  (1)  static  strap  
2. One  (1)  solder  sucker  
3. One  (1)  solder  wick  
4. One  (1)  “Third”  or  “Helping”  hand  (see  Figure  5)  

The  fume  hood  and  soldering  iron  are  provided  in  the  lab.    The  required  parts  are  
included   in   your   lab   kit.     The   side   cutters,   pliers   and   recommended   tools   are  
available  at  a  number  of  stores  in  the  city,  including  Creatron  and  Home  Hardware  
on   College   St.     Some   tools   are   also   available   at   Polytechnic   Hardware,   The   Source  
and  Canadian  Tire.  
Esduino  LCD  “Shield”     James  A.  Smith,  Ron  Wong  &  Thomas  Behan  
Rev.  1.1     January  2011  

 
Figure  2  Soldering  Iron  (right)  and  fume  hood  (left)  

 
Figure  3  Needle-­nose  pliers.    Image  courtesy  of  Wikipedia  
(http://en.wikipedia.org/wiki/File:Needle_nose_pliers.jpg)  

 
Figure  4  Side-­  or  Flush-­cutters.    Image  courtesy  of  Wikipedia  
(http://en.wikipedia.org/wiki/File:Side_cutters.jpg)  

 
Esduino  LCD  “Shield”     James  A.  Smith,  Ron  Wong  &  Thomas  Behan  
Rev.  1.1     January  2011  

 
Figure  5  Third-­  or  Helping-­Hand.    This  is  useful  for  holding  circuit  boards  or  wires  while  your  hold  a  
soldering  iron  in  one  hand  and  solder  in  the  other.    Image  courtesy  of  Wikipedia  
(http://en.wikipedia.org/wiki/File:DKHelpingHand.jpg)  

Orientation  
In   this   tutorial,   we   will   refer   to   different   parts   of   the   board   by   compass   direction  
(east,  west,  north,  south).  

           North  

West                        East  

                                     South    

 
Figure  6  Front  of  the  ARPROTO3    prototyping  board.    Note  the  individual  pads.    The  LCD  will  be  mounted  
on  this  side.    The  coloured  sheathing  of  the  wires  will  be  visible  on  this  side,  also.  
Esduino  LCD  “Shield”     James  A.  Smith,  Ron  Wong  &  Thomas  Behan  
Rev.  1.1     January  2011  

 
Figure  7  Rear  of  ARPROTO3  Board.    You  will  do  most  of  your  soldering  on  this  side.  

Steps  
Pre-­‐lab  –  Review  Soldering  Techniques  –  Online!  

There  are  some  very  good  online  guides  to  soldering,  including:  

1. Lady  Ada’s  Soldering  Tutorial  (including  videos  by  Make  Magazine):  


http://www.ladyada.net/learn/soldering/thm.html  
2. “Soldering  Techniques”  by  the  Niagara  College  Technology  Department  
(http://technology.niagarac.on.ca/courses/elnc1236/pdf/Soldering%20Tec
hniques%2010W.pdf)  
3. “Soldering  Safety”  by  Mr.  Jim  Koch  (Ryerson  University):  
http://www.ee.ryerson.ca/~jkoch/soldering/Soldering_safety.html  

 
Figure  8  Video  tutorial  on  soldering  available  at  Lady  Ada's  website  
(http://www.ladyada.net/learn/soldering/thm.html)  

 
Esduino  LCD  “Shield”     James  A.  Smith,  Ron  Wong  &  Thomas  Behan  
Rev.  1.1     January  2011  

Step  0  –  Review  Soldering  Techniques  –  Live!  


 

Mr.   Jim   Koch   will   conduct   a   session   on   soldering   during   the   lab   session.     This   is   a  
vital   skill   for   electrical   engineers!     Pay   attention   to   his   suggestions   and  
recommendations.     Your   TAs   are   also   expert   solderers   and   will   be   able   to   assist   you  
in  the  finer  details.    Bad  soldering  is  virtually  guaranteed  to  lead  to  expensive  and  
time-­‐consuming   fixes   down   the   road.     So   keep   your   mind   open   to   advice   from   the  
experts!  

Step  1  –  Install  the  single-­‐row  headers  


 

Follow  Figs.  7  through  11,  in  order.    The  black  parts  of  the  headers  will  be  placed  on  
the   top   of   the   board.     The   pins   of   the   headers   will   stick   out   the   bottom   of   the   board.    
You’ll  solder  the  pins  from  the  bottom  of  the  board.  

 
Figure  9  Single  row  headers  +  ARPROTO3  board  

Figure  10  Fit  the  headers  on.  


Esduino  LCD  “Shield”     James  A.  Smith,  Ron  Wong  &  Thomas  Behan  
Rev.  1.1     January  2011  

Figure  11  Stack  on  an  existing  protoboard.    This  helps  line  up  the  pins.    Your  TA  or  one  of  your  lab  mates  
may  have  a  spare  board  to  help  you  at  this  stage.  

 
Figure  12  Solder  one  pin  on  each  header  first.    Note  the  iron  on  the  left  and  solder  on  the  right.  Check  
that  the  header  is  still  lined  up  right.    Then  solder  the  remaining  pins.  

 
Figure  13  Done.    Compared  to  the  Esduino.  

 
Esduino  LCD  “Shield”     James  A.  Smith,  Ron  Wong  &  Thomas  Behan  
Rev.  1.1     January  2011  

Step  2.    Test  fit  the  LCD    


 

You  want  to  place  the  LCD  into  the  prototyping  board  from  the  top.    The  pins  will  
stick  out  the  bottom,  where  you  will  eventually  solder  it.    Note  that  one  side  of  the  
LCD   only   has   four   pins.     These   face   the   south   end   of   the   board.     It’s   important   to  
have  empty  space  on  both  the  west  and  north  ends  of  the  boards  to  accommodate  
wires  and  (in  future  labs)  switches  and  LEDs.  

Some  more  details  about  an  ideal  placement  can  be  found  in  Step  10.  

 
Figure  14  Looks  about  right.    The  layout  will  change  a  bit  by  the  end.  

Step  3.  Check  the  LCD  manual  /  schematic.  


 

Yes.     It’s   important.     Remember   the   saying   “measure   twice,   cut   once?”     It   applies  
here,  too,  except  we’d  say  “read  schematic  twice,  solder  once”.  

 
Figure  15    Which  pins  get  connected  to  +5?  
Esduino  LCD  “Shield”     James  A.  Smith,  Ron  Wong  &  Thomas  Behan  
Rev.  1.1     January  2011  

Step  4.  Add  the  +5  and  GND  lines  to  the  South  end  of  the  protoboard  
 

 
Figure  16    Note  how  the  +5  and  GND  

SPI   line   CSB(38)   should   be   wired   to   ground.   Don’t   install   the   other   SPI   lines   (pins  
28,29,  and  39  on  the  LCD)  yet.  

Step  5.  Solder  the  power  lines  on.      


 

 
Figure  17Solder  the  power  wires  on.    The  alligator  clip  is  part  of  the  optional  “third  hand”.  

Step  6.    Clip  the  ends  of  the  wires  off.  


 

The   wires   should   not   be   too   long.   Otherwise   they   will   interfere   with   the   Esduino  
board  that  the  LCD  board  will  eventually  attach  to.  
Esduino  LCD  “Shield”     James  A.  Smith,  Ron  Wong  &  Thomas  Behan  
Rev.  1.1     January  2011  

 
Figure  18Clip  off  the  extra  wire  using  the  "side"  or  "flush"  cutters.    See  the  third  hand  in  the  background?    
It’s  useful!  

Step  7.    Add  the  SPI  communication  lines  


 

An  example  can  be  shown  in  the  figure  below.  

 
Figure  19The  communication  lines  are  connected..  

Step  7.    Recheck  the  schematics.    


 
Esduino  LCD  “Shield”     James  A.  Smith,  Ron  Wong  &  Thomas  Behan  
Rev.  1.1     January  2011  

 
Figure  20Check  the  schematics  again!  

Visually  inspect  all  pins.    Have  your  partner  look  for  cold  solder  joints  (these  are  bad  
joints  that  fail  when  you  least  expect  it  because  the  bond  between  the  solder  and  the  
pins  or  pads  is  not  good).    Check  the  schematics  again!    [It’s  at  this  stage  that  I  found  
two  SPI  lines  shorted  together!    I  fixed  it  prior  to  destroying  my  Esduino!  Phew!  –  Dr.  
Smith]  

Step  8.  DMM  Connectivity  Test  (Beep!)  


Use  the  connectivity  test  feature  of  your  DMM  to  check  for  short-­‐circuits.    Make  sure  
that  your  5  volt  and  GND  lines  are  connected  properly.  

 
Figure  21The  DMM  connectivity  feature  is  important!  

Step  10.    Test  fit  the  LCD.  


 

Check  to  see  that  the  traces  on  the  rear  of  the  board  will  reach  between  your  wires  
and   the   pins   of   the   LCD.     The   bottom   row   of   the   LCD   should   be   the   4th   row   from  
South  on  the  Protoboard.    The  top  row  of  the  LCD  should  be  the  5throw  from  North  
Esduino  LCD  “Shield”     James  A.  Smith,  Ron  Wong  &  Thomas  Behan  
Rev.  1.1     January  2011  

(including  the  single  row  header  row  at  both  North  and  South).    The  East  edge  of  the  
board  should  not  interfere  with  the  drill  hole  on  the  East  edge  of  the  board.  

Step  11.  Solder  the  pins  of  the  LCD  


Be  careful  as  you  solder.    Make  sure  the  solder  flows  properly  to  avoid  cold  solder  
joints.  

Step  12.    Clip  the  ends  of  the  LCD  pins  (on  the  bottom  side  of  the  board)  
 

Keep   the   leads   short   so   that   they   don’t   interfere   with   any   board   that   might   be  
attached  below.  

Step  13.    Recheck  the  schematics!  


Measure  twice  and  cut  once,  as  they  say.  

Step  14.    Check  for  short  circuits  (visually)  


Always  check  for  shorts!  

Step  15.    Check  again  for  shorts  (with  DMM)  


You  can’t  be  too  careful!  

Step  16.  Verify  routing  of  SPI  lines  between  Esduino  and  LCD.  
This   is   a   mechanical   verification   with   your   multimeter.     Attach   the   LCD   board   to   the  
Esduino  (supplied  by  the  TA).    Before  you  attach  the  USB  or  power  to  the  Esduino,  
test  the  connection  between  the  bottom  of  the  Esduino’s  headers  to  the  individual  
LCD   pins   on   the   prototyping   board.     Use   a   multimeter   for   this   test.Your   TA   will  
supervise  this  process.  
Table  1  SPI  pins  on  the  9s12  and  the  LCD.  

LCD   Esduino’s  SPI  pins   MC9S12C    


(located  on  the  “North”   (located  on  chip  in  the  middle  of  
headers)   the  Esduino  board)  
SI  (pin  28)    DO  (D11)   JB3[Default:PM4/MOSI]  (pin  41)  
CLK  (pin  29)    SCK  (D13)   PM5/SCK  (pin  40)  
RS  (pin  39)    OE*  (D9P)   PT3/IOC3/PW3  (pin  4)  
CSB  (pin  38)   GND  (GND)   GND  (GND)  
 

Step  17.  Electrical  /  Software  test  of  the  LCD  


 

Finally,  your  TA  will  power  up  the  Esduino.    He/she  will  then  run  sample  code  
which  will  display  characters  on  your  LCD,  as  shown  in  Figure  22.  If  it  works,  great.    
If  not,  you  will  need  to  debug  the  potential  problems.    Consult  with  your  TA.  

 
Esduino  LCD  “Shield”     James  A.  Smith,  Ron  Wong  &  Thomas  Behan  
Rev.  1.1     January  2011  

 
Figure  22  The  LCD  board  attached  to  the  Esduino.    In  this  case,  we  are  using  a  two-­line  LCD.    You  are  
using  a  three-­line  LCD,  so  the  characters  will  be  a  bit  smaller.  

 
ELE604    
Quick  &  Dirty  LCD  Tutorial  

Ronnie  Wong  
Ryerson  University  
Electrical  and  Computer  Engineering  
January  25,  2011  

 1  
Some  things  to  note...  
•  LCD  Build  Guide:  
– Figure  14:  LCD  placement  is  incorrect.  
– There  is  no  Step  9,  it  jumps  from  Step  8  to  Step  10  
•  1  student  solders,  the  other  should  focus  on  
the  CodeWarrior  assembly  quesSons  (required  
for  write-­‐up)  
•  Soldering:  Remember  the  safety  lessons  given  
by  Jim  Koch  and  Dr.  Smith!!!  

2  
Tip  #  1:  CodeWarrior  
•  The  IDE  is  available  from  Freescale:  
– h\p://www.freescale.com/webapp/sps/site/
prod_summary.jsp?code=CW-­‐HCS12X  
– Or  Google:  “Freescale  Codewarrior  9S12”  
– This  allows  you  to  work  on  your  own  computer  
•  Available  in  ENG307  and  ENG411  (COE538)  

3  
Tip  #2:  Datasheets!  
•  Your  best  friend!  
•  LCD  –  available  from  Jim  Koch’s  ELE604  page  
•  ESDUINO  –  also  available  from  Jim  Koch’s  page  
•  LCD  Build  InstrucSons  –  at  the  end  of  the  lab  
manual  

Where?  Here:  h\p://www.ee.ryerson.ca/


~jkoch/courses/ele604/ELE_604.html  
4  
(ConSnued)  
•  LCD  Quick  Pages:  
– Page  4:  You  should  focus  on:  
•  SI/CLK/RS/CSB  are  not  labeled  
       on  the  Esduino.  These  labels  
       are  specific  to  the  EA  DOG.  
– Page  8:  Focus  on  these  two:  

5  
(ConSnued)  
•  ESDUINO:  
– What  did  you  do  in  your  lab  report?  You  were  
supposed  to  have  done  a  prelim  pin  allocaSon  for  
your  LCD!  
– In  case  you  forgot,  this  page  is  what  you  need:  

Find  it  on  Jim’s  Website!      

6  
(ConSnued)  
•  Dr.  Smith’s  Build  InstrucSons  (i.e.  Student  Guide)  
– Hint:  Appendix  D!  
– Page  125:  “ Table  1:  SPI  Pins  on  the  9S12  and  LCD”  

7  
Tip  #3:  Component  Placement  
•  There  is  more  than  one  way  to  solder  your  LCD  
onto  the  ARPROTO3  board  
– it  depends  on  how  you  place  your  components  
and  wires.  Having  a  general  idea  on  the  size  and  
spacing  of  your  components  can  also  help!  
– Design  and  plan  on  a  napkin  or  paper  will  help  you  
visualize  where  to  place  your  parts  and  more  
importantly:  how  they  will  all  wire  together!  
– REMEMBER:  There  is  limited  space  on  the  shield!  

8  
Tip  #4:  ARPROTO3  Board  Wiring  
•  REMEMBER:  the  ARPROTO3  boards  are  
stackable!  This  allows  you  to  create  mulSple  
boards  (for  different  applicaSons:  LCD/GPS/
Power/etc.)  and  then  stack  them!  

Source:  
h*p://cdn.shopify.com/s/files/1/0045/8932/files/stacked-­‐shields_large.jpg?1280198233  

9  
OK!  I  want  to  design  –  tools?  
•  A  piece  of  paper?  Napkin?  
•  From  Jim  Koch’s  page:  “Prototyping  Shield  3”  

10  
Let  the  Build  Begin…  
•  AAAHHHH!  Where  do  I  begin?  

STEP  1  –  Read  what’s  been  given  to  you!    


  You  have  the  datasheets!    
  You  have  the  build  manual!  

11  
Step  2:  Planning  
•  LCD  Datasheet  (page  4  and  8)  gets  me  this:  
1.  Pins  24  –  26  and  
pins  30  –  37  are  
Sed  to  +5V,  they  
can  be  soldered  on  
the  same  rail  
2.  Pins  23  and  27  are  
GND,  thus  solder  
together  

12  
What’s  next?  
•  Based  on  our  Lab  1  Report  (Ahem!),  we  found  
that  the  SPI  communicaSon  pins  are  also  
located  on  the  J3  connector:  
•  You  can  also  get  this  info  from  the  LCD  build  
instrucSons  in  the  student  guide!  
– Now  match  them!...  (next  page)  

13  
(Cont.)  

14  
Step  3:  Combine  with  the  Shield  

CSB  (GND)  
CLK  
SI  
+5V   RS  
GND  

15  
What  does  this  mean?  Eureka!  
•  Thinking  about  it…each  J1/J2/J3/J4  header  pin  on  
each  shield  that  gets  stacked  on  top  of  one  
another  will  always  get  the  same  analog/digital  
signal  from  that  pin.  
– Note:  if  you  configure  pin  X  (i.e.  PT3)  for  an  App  X  on  
Shield  X,  then  you  cannot  use  pin  X  for  App  Y  on  
Shield  Y  that’s  stacked  onto  it.  You  must  use  another  
pin!!!  ExcepSon:  if  your  App  Y/Shield  Y  circuit  also  
needs  that  same  signal  
•  Power  source:  +5V  and  GND  pins  are  always  
found  on  the  same  pins  per  shield  
16  
Step  4:  Puwng  it  Together!  
Your  objecSve:  To  wire  the  LCD  onto  the  
ARPROTO3  shield.  How?  By  combining…  

17  
Thus…  
Now…its  up  to  you  to  figure  out  
how  to  place  the  component  
and  wires  onto  the  shield.  

Note:  While  laying  out  the  LCD  


and  wires  onto  the  shield,  have  
you  considered  where  you’ll  
place  your  switches  and  LEDs  in  
the  upcoming  Lab???  

18  
References  
J.A.  Smith,  “ELE604  Sensors  and  Measurement  Student  Lab  Manual,”  
Ryerson  University,  Jan  2011.  

Electronic  Assembly,  “DOG  Series  3.3V,”  Jan  2010    


  [Internet:  h\p://www.lcd-­‐module.com/eng/pdf/doma/dog-­‐me.pdf]  

Technological  Arts,  “Esduino,”  Jan  2011,    


[Internet:  h\p://support.technologicalarts.ca/docs/Esduino/TAdocs/Rev1/]  

19  
THE  END…  

GOOD  LUCK!  

20  
ELECTRONIC ASSEMBLY reserves
Issue 1.2010 EA DOG-M the right to change specifications
without prior notice. Printing and
DOG SERIES 3.3V Page 2 typographical errors reserved.

INCL. CONTROLLER ST7036 FOR 4-/8-BIT, SPI (4-WIRE) EA DOG SERIES


With its EA DOG series, ELECTRONIC ASSEMBLY presents the world’s first display series which
will run on 3.3 V systems without auxiliary power. They can, of course be used on traditional 5 V
systems.
Unlike normal LCD modules, you order the display and the corresponding backlight separately. This
EA DOGM163B-A gives you a wealth of possible combinations.
blue
Designed for compact hand-held devices, this modern LCD range provides a number of real benefits
EA LED55x31-W
off ! white with or without backlight:
fo r 1 pc. t
m fla * extremely compact at 55 x 31 mm at the standard font size of 5.57 mm (2 x 16)
available D: 5.8m * ultra-flat at 2.0 mm without backlight or 5.8 mm including LED backlight
LE
with * 4-bit, 8-bit and SPI interface (4-wire)
even EA DOGM081S-A EA DOGM081W-A
+ EA LED55x31-W + EA LED55x31-B * typical power consumption of only 250µA in full operation (LED white backlight as of 3mA)
* easy installation by simply soldering into the board
EA DOGM162E-A
* A whole range of design variants (63) can be supplied as of single units
+ EA LED55x31-G
EA DOGM162W-A * Changing background color
+ EA LED55x31-A
EA DOGM163W-A
+ EA LED55x31-W
SETTING THE CONTRAST
TECHNICAL DATA The contrast on all displays of the EA DOG series can be set with a command. This is done using
* HIGH-CONTRAST LCD SUPERTWIST DISPLAY bits C0 through C5 in the commands "Contrast Set" and "Power/Icon Control/Contrast Set". Generally,
* OPTIONAL LED BACKLIGHT UNITS IN DIFFERENT COLORS the contrast is set once and kept constant across the entire operating temperature range (-20 through
* 1x8, 2x16 AND 3x16 WITH 12.0 mm / 5.6 mm AND 3.6 mm CHARACTER HEIGHT +70°C) thanks to the integrated temperature compensation function.
Even when run at 3.3 V, the displays do not require any additional negative voltage!
* ST 7036 CONTROLLER FOR 4-BIT, 8-BIT AND SPI (4-WIRE) INTERFACE
* POWER SUPPLY +3.3V OR +5V SINGLE SUPPLY (typically 250µA) LED BACKLIGHTS
yellow/green Forwar Current Limiting resistor
* NO ADDITIONAL VOLTAGES REQUIRED 6 different variants are available for individual backlighting: EA LED55x31-G voltage max. @ 3,3 V @5V
* OPERATING TEMPERATURE RANGE -20 THROUGH +70°C white, yellow/green, blue, red, amber and full color.
Connected in parallel 2,2 V 80 mA 14 ohm 35 ohm
* LED BACKLIGHT 3 through 80mA@3.3V or 2 through 40mA@5V For monochrome backlights, 2 separate LED paths are Connected in series 4,4 V 40 mA - 15 ohm
* NO MOUNTING REQUIRED, SIMPLY SOLDER INTO PCB available, which can be switched in parallel or in series to
ideally match the system voltage. This means that all the white Forwar Current Limiting resistor

ORDERING CODE EA LED55x31-W voltage max. @ 3,3 V @5V


backlights can be run either at 5 V or at 3.3 V.
Connected in parallel 3,2 V 60 mA 1,6 ohm 30 ohm
LCD MODULE 1x8 - 11.97mm EA DOGM081x-A Operation of the backlight requires an external series
Connected in series 6,4 V 30 mA - -
LCD MODULE 2x16 - 5.57 mm EA DOGM162x-A resistor for current limiting. This can be calculated from
LCD MODULE 3x16 - 3.65mm EA DOGM163x-A R=U/I; you will find the values in the table. To improve life Limiting resistor
blue Forwar Current
x: B = blue background time it is recommanded to use a current source only. EA LED55x31-B voltage max. @ 3,3 V @5V
E = yellow/green background Connected in parallel 3,2 V 60 mA 1,6 ohm 30 ohm
The operating life of the yellow/green, red and amber
L = yellow/green background (cannot be backlit)
backlights is 100,000 hours and that of the white and blue Connected in series 6,4 V 30 mA - -
S = black background
W = white background backlights much shorter.
amber Forwar Current Limiting resistor
LED BACKLIGHT, WHITE EA LED55X31-W Important: Never operate the backlight directly on a 5 V/ EA LED55x31-A voltage max. @ 3,3 V @5V
LED BACKLIGHT, YELLOW/GREEN 3.3V supply, as this can immediately destroy the LEDs!
EA LED55X31-G Connected in parallel 2,4 V 80 mA 11 ohm 32 ohm

LED BACKLIGHT, BLUE EA LED55X31-B Connected in series 4,8 V 40 mA - 5 ohm


INSTALLATION
LED BACKLIGHT, RED EA LED55X31-R First, the display and the corresponding backlight are
red Forwar Current Limiting resistor
LED BACKLIGHT, AMBER EA LED55X31-A clipped together. The complete unit is then inserted into a EA LED55x31-R voltage max. @ 3,3 V @5V
LED BACKLIGHT, FULL COLOR RGB EA LED55X31-RGB PCB and soldered. Note that the 4 pins for the backlight Connected in parallel 2,1 V 80 mA 15 ohm 36 ohm
must also be soldered from the top. Connected in series 4,2 V 40 mA - 20 ohm
USB TEST BOARD FOR PC (WINDOWS) EA 9780-2USB
Important: There are one or two protective films on the
SOCKET CONNECTOR 4.8 mm HIGH (1x20-PIN, 2.54mm PITCH) EA FL-20P display (top and/or rear side) and one on each backlight. Limiting resistor
Full color Forwar Current
EA LED55x31-RGB voltage max. @3,3 V @5V
Those have to be removed during or after production.
Connected in parallel 4V 125 mA - 3x24 ohm

Zeppelinstr. 19 · D-82205 Gilching · Phone +49-8105-77 80 90 · Fax +49-8105-77 80 99 · www.lcd-module.de · info@lcd-module.de


ELECTRONIC ASSEMBLY reserves ELECTRONIC ASSEMBLY reserves
the right to change specifications EA DOG-M EA DOG-M the right to change specifications
without prior notice. Printing and without prior notice. Printing and
typographical errors reserved. Page 3 Page 4 typographical errors reserved.

5 DIFFERENT TECHNOLOGIES APPLICATION EXAMPLES


As a standard we provide 5 different technologies as STN and FSTN: Different wiring must be used depending on the interface and the power supply. 2 additional capacitors
are required for 3.3 V operation.
Note that the COG technology means that the current capacity of the outputs is limited. Therefore, a
display color display color
optional recommended large load on the bus may cause signal loops and unclean levels. If in doubt, additional pull-down
display type technology readability non with
backlight backlight color resistors (8051) are required or additional waits/NOPs must be incorporated.
backlighted backlighted

readable even
FSTN pos. it's fine with and black on backlight
without black on white white, blue, RGB
transflective without backlight color
backlight

STN pos. readable even black on


backlight unit dark green on yellow/green,
yellow/green without yellow/green or
required yellow/green amber
transmissive backlight amber

STN neg. blue usage only with backlight color on


--- --- white, yellow/green
transmissive backlight blue background

FSTN neg. usage only with backlight color on


--- --- white, RGB
transmissive backlight black background

STN pos. finest readable


no backlight dark green on
yellow/green without --- ---
possible yellow/green
reflective backlight

3 DIFFERENT DISPLAYS
These displays are available for mentioned technologies:

6 DIFFERENT BACKLIGHTS
6 different backlight colors are available to match equipments design as much as possible. The most
effective and brightest one is the white one EA LED55x31-W.

USB-TEST BOARD EA 9780-2USB


For easy startup, a USB test board is available that can be connected to a PC. An USB cable and a
Windows software is supplied with the product. This allows individual text and to be displayed directly
EA LED55x31-W EA LED55x31-G EA LED55x31-B EA LED55x31-R EA LED55x31-A EA LED55x31-RGB on the connected display.
White Yellow/Green Blue Red Amber Full Color
SIMULATION WITH WINDOWS
A simulator window also displays the contents of the display. The software can simulate all the
When you can see black and white pictures only here on this page then you're able to download a displays and colors even without the hardware. You can download the software free from our website:
coloured version from our website http://www.lcd-module.de/eng/pdf/doma/dogme.pdf http://www.lcd-module.de/deu/disk/startdog.zip
ELECTRONIC ASSEMBLY reserves ELECTRONIC ASSEMBLY reserves
the right to change specifications EA DOG-M EA DOG-M the right to change specifications
without prior notice. Printing and without prior notice. Printing and
typographical errors reserved. Page 5 Page 6 typographical errors reserved.

CHARACTER SET TABLE OF COMMAND


The below show character set is alerady built-in. In addition to that you are able to define 8 characters
by your own.

A detailed description for integrated controller ST7036 you can find under
http://www.lcd-module.de/eng/pdf/zubehoer/st7036.pdf
A detailed description for integrated controller ST7036 you can find under
http://www.lcd-module.de/eng/pdf/zubehoer/st7036.pdf
ELECTRONIC ASSEMBLY reserves
the right to change specifications EA DOG-M
without prior notice. Printing and
typographical errors reserved. Page 7 ELECTRONIC ASSEMBLY reserves
EA DOG-M the right to change specifications
Page 8 without prior notice. Printing and
EXAMPLES FOR INITIALISATION typographical errors reserved.

Example of initialisation: 8 bit / 3.3V


EA DOGM081 EA DOGM081
Command RS R/W DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0 Hex Note
Function Set 0 0 0 0 1 1 0 0 0 1 $31 8 bit data length, 1 line, instruction table 1
Bias Set 0 0 0 0 0 1 0 1 0 0 $14 BS: 1/5, 1 line LCD
Power Control 0 0 0 1 0 1 0 1 0 1 $55 booster on, contrast C5, set C4
Follower Control 0 0 0 1 1 0 1 1 0 1 $6D set voltage follower and gain
Contrast Set 0 0 0 1 1 1 1 1 0 0 $7C set contrast C3, C2, C1
Function Set 0 0 0 0 1 1 0 0 0 0 $30 switch back to instruction table 0
Display ON/OFF 0 0 0 0 0 0 1 1 1 1 $0F display on, cursor on, cursor blink
Clear Display 0 0 0 0 0 0 0 0 0 1 $01 delete display, cursor at home
Voltage Booster - (0,1..1uF)
Voltage Booster + (0,1..1uF)
L= Serial Mode, H= Parallel M.
Voltage Booster Output
Voltage Booster Input
Pow er Supply +3,3..5V
Pow er Supply 0V (GND)
Display Data (MSB)
Display Data
Display Data
Display Data
Display Data
Display Data
Display Data
Display Data (LSB)
Enable (falling edge)
L= Write, H=Read
Chip Select
L= Command, H= Data
Reset

Entry Mode Set 0 0 0 0 0 0 0 1 1 0 $06 cursor auto-increment Initialisation for 3.3V


-
-
-
-
L
L
L

H
H

H/ L
H/ L
H/ L
H/ L
H/ L
H/ L
H/ L
H/ L
H/ L
H/ L
H/ L

Example of initialisation: 8 bit / 5V


EA DOGM081

Note:
- LC-displays are not suited
for wave soldering or reflow
soldering. Temperatures
above +80°C may damage
lcd-module.
- Surfaces of display and
backlight are with protection
foils protected against
scratching. Please remove
before use.

Command RS R/W DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0 Hex Note
E

D7
D6
D5
D4
D3
D2
D1
D0
RS

VIN

PSB
R/W

VDD
VSS
CSB

VOUT
RESET

CAP1N
CAP1P

Function Set 0 0 0 0 1 1 0 0 0 1 $31 8 bit data length, 1 line, instruction table 1


Bias Set 0 0 0 0 0 1 1 1 0 0 $1C BS: 1/4, 1 line LCD
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40

Power Control 0 0 0 1 0 1 0 0 0 1 $51 booster off, contrast C5, set C4


Pin Symbol Level Function

Follower Control 0 0 0 1 1 0 1 0 1 0 $6A set voltage follower and gain


Contrast Set 0 0 0 1 1 1 0 1 0 0 $74 set contrast C3, C2, C1
Function Set 0 0 0 0 1 1 0 0 0 0 $30 switch back to instruction table 0
Display ON/OFF 0 0 0 0 0 0 1 1 1 1 $0F display on, cursor on, cursor blink
Clear Display 0 0 0 0 0 0 0 0 0 1 $01 delete display, cursor at home
Entry Mode Set 0 0 0 0 0 0 0 1 1 0 $06 cursor auto-increment Initialisation for 5V
(A1+: LED backlight)
(C1-: LED backlight)
(C2-: LED backlight)
(A2+: LED backlight)

EA DOGM162 Example of initialisation: 8 Bit / 3.3V


EA DOGM162
NC
NC
NC
NC

Command RS R/W DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0 Hex Note
ATTENTION

Function Set 0 0 0 0 1 1 1 0 0 1 $39 8 bit data length, 2 lines, instruction table 1


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

Pin Symbol Function

handling precautions!

Bias Set 0 0 0 0 0 1 0 1 0 0 $14 BS: 1/5, 2 line LCD


Power Control 0 0 0 1 0 1 0 1 0 1 $55 booster on, contrast C5, set C4
Follower Control 0 0 0 1 1 0 1 1 0 1 $6D set voltage follower and gain
Contrast Set 0 0 0 1 1 1 1 0 0 0 $78 set contrast C3, C2, C1
Function Set 0 0 0 0 1 1 1 0 0 0 $38 switch back to instruction table 0
Display ON/OFF 0 0 0 0 0 0 1 1 1 1 $0F display on, cursor on, cursor blink
Clear Display 0 0 0 0 0 0 0 0 0 1 $01 delete display, cursor at home
Entry Mode Set 0 0 0 0 0 0 0 1 1 0 $06 cursor auto-increment Initialisation for 3.3V
Example of initialisation: 8 bit / 5V
EA DOGM162
Command RS R/W DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0 Hex Note
Function Set 0 0 0 0 1 1 1 0 0 1 $39 8 bit data length, 2 lines, instruction table 1
Bias Set 0 0 0 0 0 1 1 1 0 0 $1C BS: 1/4, 2 line LCD
Power Control 0 0 0 1 0 1 0 0 1 0 $52 booster off, contrast C5, set C4
Follower Control 0 0 0 1 1 0 1 0 0 1 $69 set voltage follower and gain
Contrast Set 0 0 0 1 1 1 0 1 0 0 $74 set contrast C3, C2, C1
Function Set 0 0 0 0 1 1 1 0 0 0 $38 switch back to instruction table 0
Display ON/OFF 0 0 0 0 0 0 1 1 1 1 $0F display on, cursor on, cursor blink
Clear Display 0 0 0 0 0 0 0 0 0 1 $01 delete display, cursor at home
Entry Mode Set 0 0 0 0 0 0 0 1 1 0 $06 cursor auto-increment Initialisation for 5V

Example of initialisation: 8 bit / 3.3V


EA DOGM163 EA DOGM163
Befehl RS R/W DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0 Hex Bemerkung
Function Set 0 0 0 0 1 1 1 0 0 1 $39 8 bit data length, 2 lines, instruction table 1
Bias Set 0 0 0 0 0 1 0 1 0 1 $15 BS: 1/5, 3 line LCD
Power Control 0 0 0 1 0 1 0 1 0 1 $55 booster on, contrast C5, set C4
Follower Control 0 0 0 1 1 0 1 1 1 0 $6E set voltage follower and gain
Contrast Set 0 0 0 1 1 1 0 0 1 0 $72 set contrast C3, C2, C1
Function Set 0 0 0 0 1 1 1 0 0 0 $38 switch back to instruction table 0
Display ON/OFF 0 0 0 0 0 0 1 1 1 1 $0F display on, cursor on, cursor blink
Clear Display 0 0 0 0 0 0 0 0 0 1 $01 delete display, cursor at home
Entry Mode Set 0 0 0 0 0 0 0 1 1 0 $06 cursor auto-increment Initialisation for 3.3V

Example of initialisation: 8 bit / 5V


EA DOGM163
Command RS R/W DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0 Hex Note
Function Set 0 0 0 0 1 1 1 0 0 1 $39 8 bit data length, 2 lines, instruction table 1
Bias Set 0 0 0 0 0 1 1 1 0 1 $1D BS: 1/4, 3 line LCD
Power Control 0 0 0 1 0 1 0 0 0 0 $50 booster off, contrast C5, set C4
Note: The 4 LED pins A1, C1, A2 and C2 (or A, R, G, B) must be soldered from the
top to ensure a clean contact.

Follower Control 0 0 0 1 1 0 1 1 0 0 $6C set voltage follower and gain


DIMENSIONS
alle dimensions are
in mm

Contrast Set 0 0 0 1 1 1 1 1 0 0 $7C set contrast C3, C2, C1


Function Set 0 0 0 0 1 1 1 0 0 0 $38 switch back to instruction table 0
Display ON/OFF 0 0 0 0 0 0 1 1 1 1 $0F display on, cursor on, cursor blink
Clear Display 0 0 0 0 0 0 0 0 0 1 $01 delete display, cursor at home
Entry Mode Set 0 0 0 0 0 0 0 1 1 0 $06 cursor auto-increment Initialisation for 5V

Zeppelinstr. 19 · D-82205 Gilching · Phone +49-8105-77 8090 · Fax +49-8105-77 80 99 · www.lcd-module.de · info@lcd-module.de
Listing F.1: Example for driving an Electronic Assembly DOG 3x16 5V SPI Liquid Crystal Display Uses
Assembler and is compatible with Esduino and Codewarrior and contains code numeric and decimal output
(via Mr. Peter Hiscock’s source code from COE538) (tested Dec. 2010)
; ∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗
; ∗ This s t a t i o n e r y s e r v e s as t h e framework f o r a ∗
; ∗ user a p p l i c a t i o n ( s i n g l e f i l e , absolute assembly a p p l i c a t i o n ) ∗
; ∗ For a more c o m p r e h e n s i v e p r o g r a m t h a t ∗
; ∗ d e m o n s t r a t e s t h e more a d v a n c e d f u n c t i o n a l i t y o f t h i s ∗
; ∗ processor , please see the demonstration a p p l i c a t i o n s ∗
; ∗ l o c a t e d in the examples s u b d i r e c t o r y of the ∗
; ∗ F r e e s c a l e C o d e W a r r i o r f o r t h e HC12 Program d i r e c t o r y ∗
; ∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗
; A u t h o r : R o n n i e Wong
; December 1 1 , 2 0 1 0
; Sources :
; 1 . J . V a l v a n o , I n t r o d u c t i o n t o Embedded S y s t e m s : I n t e r f a c i n g t o t h e F r e e s c a l e 9 S12 , 1 s t Ed . , 2010.
; 2 . F r e e s c a l e , MC9S12C F a m i l y MC9S12GC F a m i l y R e f e r e n c e Manual , Rev . 0 1 . 2 3 , May 2 0 0 7 .
; 3 . P e t e r H i s c o c k s , INT2BCD and BCD2ASCII c o n v e r s i o n s u b r o u t i n e s , COE538 − R y e r s o n U n i v e r s i t y 2010.

; export symbols
XDEF Entry , Startup ; e x p o r t ’ Entry ’ symbol
ABSENTRY Entry ; f o r a b s o l u t e a s s e m b l y : mark this as application entry point

; Include d e r i v a t i v e −s p e c i f i c d e f i n i t i o n s
INCLUDE ’ d e r i v a t i v e . inc ’

ROMStart EQU $4000 ; absolute address to p l a c e my c o d e / c o n s t a n t data

; v a r i a b l e / data section

ORG RAMStart
; I n s e r t here your data d e f i n i t i o n .
; i n s e r t rmb and o t h e r v a r i a b l e s h e r e . . .
; −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
; I n t e g e r t o BCD C o n v e r s i o n R o u t i n e ( p o r t e d f r o m P . H i s c o c k s )
; V a r i a b l e s f o r b 1 6 t o d e c . asm and b c d t o a s c . asm s u b r o u t i n e s
bcdbuffer EQU ∗ ; The f o l l o w i n g r e g i s t e r s a r e t h e BCD b u f f e r area
tenthous RMB 1 ; 1 0 , 0 0 0 d i g i t , max s i z e f o r 16 b i t b i n a r y
thousands RMB 1 ; 1 ,000 d i g i t
hundreds RMB 1 ; 100 d i g i t
tens RMB 1 ; 10 d i g i t
units RMB 1 ; 1 digit
bcdspare RMB 10
noblank RMB 1 ; Used i n ’ l e a d i n g z e r o ’ b l a n k i n g b y BCD2ASC
; −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−

; code section
ORG ROMStart

DrSmith FCC ”Dr . Smith ” ; string printout


FCB 0
Ronnie FCC ” Ronnie Wong”
FCB 0
TStark FCC ”Tony S t a r k ”
FCB 0
Esduino FCC ” Esduino ”
FCB 0
Grams FCC ”g”
FCB 0

Entry :
Startup :

LDS #RAMEnd+1 ; initialize the stack pointer

JSR Timer Init


LDAA #$09
STAA DDRT ; PT3 ( $ 0 8 ) and PT0 ( $ 0 1 ) a r e output pins . . .

BSET DDRM,# $38 ; Turn on SPI , e f f e c t i v e l y PM5−PM2


MOVB #$50 , SPICR1 ; SPI C o n t r o l R e g i s t e r 1 , b i t 7 : I n t e r r u p t E n a b l e , b i t 4 : MSTR
MOVB #$00 , SPICR2 ; SPI C o n t r o l R e g i s t e r 2 , b i t [ 7 : 0 ] − D i s a b l e d
;MOVB #$02 , SPIBR ; S e t b a u d r a t e t o 0 . 5 MHz − 500 kHz , d i v i s o r i s 8 ( a s s u m i n g c l o c k o f 4MHz w
MOVB #$05 , SPIBR ; S e t b a u d r a t e t o 375 kHz , d i v i s o r i s 64 ( a s s u m i n g c l o c k o f 24MHz , u s e w i t h M o n i t o r )

JSR LCD Init ; I n i t i a l i z e LCD & Timer


JSR LCD CursorOff ; turn off the cursor

LDX #TStark ; Load S t r i n g o u t p u t into X reg .


JSR LCD OutString ; and o u t p u t it ...

mainLoop :

; BCD C o n v e r s i o n
LDD #3456 ; Digits to print out . . .
JSR int2bcd
JSR bcd2asc
LDX #b c d b u f f e r
JSR LCD OutString ; P r i n t w/ o d e c i m a l

LDX #b c d b u f f e r

F-39 Edit Date: February 12, 2013


JSR LCD OutDecimal ; P r i n t w/ d e c i m a l

JSR LCD CursorOff


loop BRA loop ; loop forever

; −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
; i n s e r t subroutines here . . .
; Timer S u b f u n c t i o n s : 9 S12C32 @ 4MHz
; T h i s t i m e −d e l a y r o u t i n e i s s o f t w a r e d r i v e n
; −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
; E n a b l e TCNT a t 1 u s
Timer Init :
MOVB #$80 , TSCR1 ; E n a b l e TCNT, movb i s an 8− b i t move memory t o memory
;MOVB #$02 , TSCR2 ; S e t TCNT p e r i o d @ 1 u s − 1 m i c r o s e c o n d (@ 4MHz b u s , w i t h o u t M o n i t
MOVB #$05 , TSCR2 ; S e t TCNT p e r i o d @ 1 . 3 3 u s − 1 . 3 3 m i c r o s e c o n d (@ 24MHz b u s , w i t h M o n i t o r )
RTS

; RegD i s t h e t i m e t o w a i t i n u s
; RegD must b e l e s s t h a n 3 2 7 6 7
Timer Wait :
NOP
ADDD TCNT ; End o f w a i t t i m e
wloop CPD TCNT ; S t o p when RegD < TCNT
BPL wloop ; o r i g i n a l by Valvano
RTS

; RegY i s t h e t i m e to wait i n 1ms


Timer Wait1ms :
LDD #1000 ; 1 0 0 0 u s = 1ms . I f SCR2 i s set for 1 . 3 3 us , this is longer . . .
BSR Timer Wait ; Wait 1ms
DEY
BNE Timer Wait1ms
RTS

; LCD S u b f u n c t i o n s : 9 S12C32 @ 4MHz


; −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
; SPI t r a n s m i t / r e c e i v e t o LCD s u b r o u t i n e s
; RegB i s t h e c o d e t o t r a n s m i t
send :
BRCLR SPISR,# $20 , ∗ ; 1 ) w a i t SPTEF
STAA SPIDR ; 2) w r i t e data
BRCLR SPISR,# $80 , ∗ ; 3 ) w a i t SPIF
LDAA SPIDR ; 4 ) r e a d dummy d a t a b y p r o t o c o l , t h e n discard
RTS

; RegA c o n t a i n s t h e command t o b e s e n t
; RS : H/L : L = Command , H = Data
LCD WriteCommand :
BCLR PTT,# $08 ; PT3 = CS = 0 , s e n d command
BSR send ; s e n d LCD command
BSET PTT,# $08 ; PT3 = CS = 1 , t o g g l e b a c k . . .
RTS

; RegA c o n t a i n s t h e d a t a t o b e s e n t
; RS : H/L : L = Command , H = Data
LCD WriteData :
BSET PTT,# $08 ; PT3 = CS = 1 , s e n d d a t a
BSR send ; s e n d LCD d a t a
BCLR PTT,# $08 ; PT3 = CS = 0 , t o g g l e b a c k
RTS
; −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
; LCD command s u b r o u t i n e s
; RegX c o n t a i n s s t r i n g t o b e o u t p u t e d
LCD OutString :
LDAA 1 , x+ ; could a l s o use : ldaa 0 , x − inx afterwards
BEQ done
JSR LCD WriteData
BRA LCD OutString
done RTS

; Prints out decimal p l a c e m e n t . #$2E is decimal .


LCD OutDecimal :
LDY #0 ; initialize counter for decimal s e t −p o i n t
start LDAA 1 , x+
BEQ exitOutDec
JSR LCD WriteData
INY
CPY #3 ; change value here to shift decimal placement
BEQ LCD Decimal
BRA start
LCD Decimal PSHA
LDAA #$2E
JSR LCD WriteData
PULA
BRA start
exitOutDec RTS

; Clears the s c r e e n , homes c u r s o r


LCD Cls :
LDAA #$01
JSR LCD WriteCommand
LDY #30
JSR Timer Wait1ms
RTS

F-40 Edit Date: February 12, 2013


; Turns on t h e cursor
LCD CursorOn :
LDAA #$0F
JSR LCD WriteCommand
LDY #30
JSR Timer Wait1ms
RTS

; Turns o f f t h e cursor
LCD CursorOff :
LDAA #$0C
JSR LCD WriteCommand
LDY #30
JSR Timer Wait1ms
RTS

; Turns o f f d i s p l a y
LCD DisplayOff :
LDAA #$08
JSR LCD WriteCommand
LDY #30
JSR Timer Wait1ms
RTS

LCD ReturnHome :
LDAA #$02
JSR LCD WriteCommand
LDY #5
JSR Timer Wait1ms
RTS

LCD SetPosition :
; i n s e r t code here to set position . . . Revision ’2 ’

LCD WriteAtPos :
; i n s e r t code here to set write position . . . Revision ’2 ’

; This i n i t i a l i s a t i o n sequence is generated b a s e d on t h e EA DOGM081 d a t a s h e e t


LCD Init :
LDY #40 ; Load 40 f o r Timer Wait1ms
JSR Timer Wait1ms ; 40ms d e l a y
LDAA #$31 ; Function Set
JSR LCD WriteCommand ; 8− b i t d a t a l e n g t h , 1 l i n e , i n s t r u c t i o n t a b l e 1 ( s e e datasheet )
LDY #30 ;
JSR Timer Wait1ms ; 30ms d e l a y
LDAA #$1C ; Bias Set
JSR LCD WriteCommand ; 1 / 4 , 1 l i n e LCD
LDY #30 ;
JSR Timer Wait1ms ; 30ms d e l a y
LDAA #$51 ; Power C o n t r o l
JSR LCD WriteCommand ; b o o s t e r o f f , c o n t r a s t C5 , s e t C4
LDY #30 ;
JSR Timer Wait1ms ; 30ms d e l a y
LDAA #$6A ; Follower Control
JSR LCD WriteCommand ; S e t v o l t a g e t o f o l l o w e r and g a i n
LDY #200 ;
JSR Timer Wait1ms ; 200 ms d e l a y
LDAA #$74 ; Contrast Set
JSR LCD WriteCommand ; S e t c o n t r a s t , C3 , C2 , C1
LDY #30 ;
JSR Timer Wait1ms ; 30ms d e l a y
LDAA #$30 ; Function Set
JSR LCD WriteCommand ; switch back to i n s t r u c t i o n t a b l e 0
LDY #30 ;
JSR Timer Wait1ms ; 30ms d e l a y
LDAA #$0F ; D i s p l a y ON/OFF
JSR LCD WriteCommand ; D i s p l a y on , c u r s o r on , c u r s o r b l i n k
LDY #30 ;
JSR Timer Wait1ms ; 30ms d e l a y
LDAA #$01 ; Clear d i s p l a y
JSR LCD WriteCommand ; d e l e t e d i s p l a y , c u r s o r a t home
LDY #5 ;
JSR Timer Wait1ms ; 5ms d e l a y
LDAA #$06 ; E n t r y mode s e t
JSR LCD WriteCommand ; c u r s o r a u t o −i n c r e m e n t
LDY #30 ;
JSR Timer Wait1ms ; 30ms d e l a y
RTS
; −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
; T h i s s e c t i o n i s P . H i s c o c k ’ s BCD R o u t i n e s p o r t e d f r o m t h e EE D e v e l o p m e n t Board
; i n t 2 b c d : c o n v e r t s a 16 b i t b i n a r y number i n . D i n t o BCD d i g i t s
; −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
int2bcd :
XGDX ; s a v e t h e b i n a r y number i n t o . X
LDAA #0
STAA tenthous
STAA thousands
STAA hundreds
STAA tens
STAA units
STAA bcdspare
STAA b c d s p a r e +1

CPX #0 ; check for a zero input


BEQ conexit ; and i f so , e x i t

F-41 Edit Date: February 12, 2013


XGDX ; n o t z e r o , g e t t h e b i n a r y number b a c k t o . D a s d i v i d e n
LDX #10 ;
s e t u p 10 ( D e c i m a l ! ) a s t h e d i v i s o r
IDIV ; d i v i d e : q u o t i e n t i s now i n . X, r e m a i n d e r i n . D
ANDB #$0F ; c l e a r high n i b b l e of remainder
STAB units ; and s t o r e i t
CPX #0 ; i f q u o t i e n t i s zero ,
BEQ conexit ; then e x i t

XGDX ; e l s e swap f i r s t q u o t i e n t back i nto .D


LDX #10 ; and s e t u p f o r a n o t h e r d i v i d e b y 10
IDIV
ANDB #$0F
STAB tens
CPX #0
BEQ conexit

XGDX ; swap q u o t i e n t b a c k i n t o . D
LDX #10 ; and s e t u p f o r a n o t h e r d i v i d e b y 10
IDIV
ANDB #$0F
STAB hundreds
CPX #0
BEQ conexit

XGDX ; swap q u o t i e n t back i n t o .D


LDX #10 ; and s e t u p for another divide b y 10
IDIV
ANDB #$0F
STAB thousands
CPX #0
BEQ conexit

XGDX ; swap quotient back into .D


LDX #10
IDIV
ANDB #$0F
STAB tenthous
conexit RTS ; we ’ r e d o n e the conversion

; bcdtoasc : this routine converts t h e BCD number i n the bcdbuffer into ascii format
bcd2asc :
LDAA #0 ; initialize the blanking flag
STAA noblank

ctthou LDAA tenthous ; check the ’ ten thousands ’ d i g i t


ANDA #$0F ; clear the high nibble
ORAA noblank
BNE notblank1

isblank1 LDAA #’ ’ ; it ’ s a blank


STAA tenthous ; so s t o r e a space
BRA cthou ; and c h e c k t h e ’ thousands ’ digit

notblank1 LDAA tenthous ; get the ten thousands d i g i t


ORAA #$30 ; convert to a s c i i
STAA tenthous
LDAA #$1 ; signal t h a t we h a v e s e e n a non−b l a n k digit
STAA noblank

cthou LDAA thousands ; check the thousands d i g i t for blankness


ANDA #$0F ; clear the high nibble
ORAA noblank ; i f i t s b l a n k and no b l a n k i s s t i l l zero
BNE notblank2

isblank2 LDAA #’ ’ ; thousands d i g i t i s blank


STAA thousands ; so s t o r e a space
BRA c h un s ; and c h e c k the hundreds digit

notblank2 LDAA thousands ; ( similar to ten thousands case )


ORAA #$30
STAA thousands
LDAA #$1
STAA noblank

chuns LDAA hundreds ; check the hundreds d i g i t f o r blankness


ANDA #$0F ; clear the high nibble
ORAA noblank ; i f i t s b l a n k and no−b l a n k i s still zero
BNE notblank3

isblank3 LDAA #’ ’ ; hundreds d i g i t i s blank


STAA hundreds ; so s t o r e a space
BRA ctens ; and c h e c k the tens digit

notblank3 LDAA hundreds ; similar to ten thousands case


ORAA #$30
STAA hundreds
LDAA #$1
STAA noblank

ctens LDAA tens ; check the tens d i g i t for blankness


ANDA #$0F ; clear the high nibble
ORAA noblank ; if its b l a n k and no b l a n k i s s t i l l zero
BNE notblank4

isblank4 LDAA #’ ’ ; tens digit is blank


STAA tens ; so store a space

F-42 Edit Date: February 12, 2013


BRA cunits ; and c h e c k the units digit

notblank4 LDAA tens ; similar to ten thousands case


ORAA #$30
STAA tens
LDAA #$1
STAA noblank

cunits LDAA units ; no b l a n k c h e c k n e c e s s a r y , convert to ascii


ANDA #$0F
ORAA #$30
STAA units
RTS ; we ’ r e d o n e
; −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−

; −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
; i n s e r t i n t e r r u p t routines here . . .

; ∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗
;∗ Interrupt Vectors ∗
; ∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗
ORG $FFFE
DC.W Entry ; Reset Vector

F-43 Edit Date: February 12, 2013


F-44 Edit Date: February 12, 2013
Appendix G

Esduino Schematics and Layout (Rev 1)

The Revision 1 version of the Esduino’s schematics and parts layout are found here.

G-1
[JB4] TX/RX Communications Routing:
Place two shunts in the positions shown Esduino
US = USB-to-SCI (of the MCU) 9S12C-based Arduino-compatible*
When Xbee Option is present: Rev. 1
UX = USB-to-Xbee (for configuring via Host) [JB3]: Digital11 Source
SX = SCI-to-Xbee (for wireless communications) 1-2 (left): PM4
[U4]: Serial Memory [JB2]: Digital10 Source 1-3 (down): PP5 (PAD1)
Footprint for optional 1-2 (left): PT4 1-4 (right): PT5
[J14][J15]: USB2MCU module goes here, SPI memory device. 2-3 (right): PM3
to provide USB interface to host PC; [D2]: User LED [U1]:
or supply your own TTL-level signals (on DIG13) Freescale 9S12C 16-bit microcontroller
to/from Host
[JB8] PS/PM SELECT:

PT3
PT7
PT6
PT2
PT1

PM5
PM2
PAD07
PAD06
DIG1
DIG0

PT0
Select between PS0/PS1
J14 US JB4
GND J3 and PM0/PM1 assignments
[J9][J10]: [Xbee Option]

>
<

D2
+5V

J1
for DIG0 and DIG1 pins

D13
D12
D11
D10
D9P
D8
D7
D4
Plug ADXB here for XBee Interface U4

GND
DTR

SX UX
UX SX
AREF
PT4 PM3 S M
(3V/5V compatible). SPI [J11] BDM IN:
DIG11

PWM D6
PWM D5
<TX US J6 C17
D2 JB2

1 PWM D3
GND J15 DI PM4 PT5

JB8
[J6]: SPI peripheral connector Standard 6-pin Background
RX > ADXB +5 JB3
SPI signals, Output Enable, +5V, J10 Esduino Debug Mode connector for
SCK
PP5
JB1
BDM IN
and Ground are all brought out to www.TechnologicalArts.com advanced debugging use
SS* R5 J11 LOAD
VIN C6
this convenient connector for easy OE* J5 JB6 SW1
USB [SW1 and JB6]:
interfacing to SPI peripherals DO C5 MAN
PB4 R1
G C7
When JB6 set to MAN, use SW1 to
[JB1]: 5V Source Selector PWR PE7 select Serial Monitor mode.
D3 C10
AUTO RUN
PE4
1-2 (lower): 5V from USB Y1 When JB6 set to AUTO, Serial
U1
R6 D1 PA0 R3
2-3 (upper): 5V from U1 via VIN C1 C11
J8 PM0 Monitor mode must be controlled

+
J9 Y2 JB5 PM1
[D1]: Power indicator LED by host via DTR line on serial port.
R2 3V 5V J7 AN7
J12 C16 VDD VRH AR
AN6
C15 C14 JB7
[J7] PB4, PE7,PE4,PA0: C9 [J8] PM0 - PM1:
U3
Four bonus Digital pins. +

RESET
VIN
AN0
AN1
AN2
AN3
AN4
AN5

GND
GND

3V3 5V Two bonus Digital pins;


J2

J4

may be used with an external

SW2
REV. 1 J13
[U3]: 3.3V regulator (800 mA max.) transceiver to implement a
CAN interface.
PAD00
PAD01
PAD02
PAD05

PAD03
PAD04

[J7] AN6 - AN7:


[SW2]: Reset button [JB5]: 3V/5V Operation [J2] AN0 - AN1: Two bonus Analog Inputs;
1-2 (left): 3.3V Six Analog Inputs;
Power Configurations: may be used as digital
2-3 (right): 5V Any of these may be
Instead of deriving 5V to power the board from the USB Host inputs or outputs instead
connection, it can be derived from on-board regulator U1. used as digital inputs
Two different power connections are provided: J12 and J13. or outputs instead
The 2-pin J13 Molex connector is the default, while J12 is an
Order Codes:
optional barrel jack connector (2.1mm center-positive) ESD12C32 (with 9S12C32; surface-mount devices only)
compatible with most common AC-to-DC adapters. If J12 is ESD12C128 (with 9S12C128; surface-mount devices only)
present, and a voltage supply is plugged in, it will ESD12C32-KIT (ESD12C32 plus kit of through-hole parts)
automatically override J13. The applied voltage (VIN) can be ESD12C128-KIT (ESD12C128 plus kit of through-hole parts)
anywhere in the range of 7 to 15V DC. To choose VIN as ESD12C32-UR (fully assembled with 9S12C32, USB2MCU and connectors)
the source of system 5V (via regulator U1), set jumper block ESD12C128-UR (fully assembled with 9S12C128, USB2MCU and connectors)
JB1 to the 2-3 (upper) position. * Footprint and pinout are compatible with
standard Arduino-style shields; Arduino
www.TechnologicalArts.com software environment support pending. JANUARY 2011
A B C D E

VDD VDD 1 2 PE1/IRQ*


C17
VDD C2 100n 1 W1 2 Cut W1 and W2 to isolate interrupts

1
2 1 PE0/XIRQ*
SPI Signals JUMPER1 W2
+5V 100n JUMPER1
J6 9S12C

2
PM2/MISO JB8 DIG0/1 SEL
7
6 VDD PM1/TXCAN
5 PM5/SCK DIG13 PM3/SS* 1 8 PM0/RXCAN
PM3/SS* PM2/MISO 2 CS VCC 7 5 6
4 3 4
3 PT3/IOC3/PW3 DIG9/PWM 3 SO HOLD 6 PM5/SCK ARDUINO 9S12C PS0 PS1 ARDUINO

1
4 PM4/MOSI 4 WP SCK 5 PM4/MOSI J2 1 2 J1 4
2 VSS SI

PP5/PW5
PM0/RXCAN
PM1/TXCAN
PM2/MISO
PM3/SS*
PM4/MOSI
PM5/SCK
PS1
PS0
1 C3 1 AN0 AN0/PAD00 DIG0/RX 1
U4 25LCXXXA 100n 2 AN1 AN1/PAD01 DIG1/TX 2

2
CON7 3 AN2 AN2/PAD02 AN6/PAD06 DIG2 3

48
47
46
45
44
43
42
41
40
39
38
37
5VUSB U1 VDD AN3 AN3/PAD03 PT0/IOC0/PW0
4 DIG3/PWM4
J14 5 AN4 AN4/PAD04 AN7/PAD07 DIG4 5
1 VRH 6 AN5 AN5/PAD05 PT1/IOC1/PW1 DIG5/PWM6

VSSX
VSSA
USB2MCU module PT2/IOC2/PW2

VDDX
2 SEL DIG6/PWM7
attaches to J14 and J15 CON6 PT6/IOC6 DIG7 8

PM3/SS*
1

PS1/TXD
PS0/RXD

PM5/SCK
CON2 JB7

PM2/MISO
PM4/MOSI

PP5/KWP5
D2

PM1/TXCAN
PM0/RXCAN
J15 PT0/IOC0/PW0 1 36 VRH 2 CON8
DTR PT1/IOC1/PW1 PW0/IOC0/PT0 VRH J4
4 2 35 1 2 1 2

1
URX PT2/IOC2/PW2 PW1/IOC1/PT1 VDDA C9 RESET* R7 2K0 J3
3 3 1 L

3
PT3/IOC3/PW3 PW2/IOC2/PT2 3V3 PT7/IOC7 DIG8
2 4 PW3/IOC3/PT3 2 +3V3 1
1 34 AN7/PAD07 100n 3 5V PT3/IOC3/PW3 DIG9/PWM 2

3
PAD07/AN07 +5V
AUTO 5 33 AN6/PAD06 4 GND DIG10/PWM 3
CON4 JB6 VDD1 PAD06/AN06 AN5/PAD05 GND DIG11/PWM
2 6 VSS1 PAD05/AN05 32 5 4
31 AN4/PAD04 6 VIN PM2/MISO DIG12 5
PAD04/AN04 VIN
MAN PT4/IOC4/PW4 7 MC9S12C 30 AN3/PAD03 PM5/SCK DIG13 6

1
PT5/IOC5 PW4/IOC4/PT4 PAD03/AN03 AN2/PAD02 CON6 GND
8 IOC5/PT5 PAD02/AN02 29 7
CUT W3 TO W3 PT6/IOC6 9 28 AN1/PAD01 AREF 8
DISABLE PT7/IOC7 IOC6/PT6 PAD01/AN01 AN0/PAD00 PM4/MOSI
JUMPER1 10 IOC7/PT7 PAD00/AN00 27
AUTO RESET VDD VDD1 J8 PM3/SS* CON8

2
BKGD 11 26 PA0 PM1/TXCAN 1

2
3 MODC/BKGD PA0 3
SW1 PM0/RXCAN 2 VDD +5V
PB4 12 25 PE0/XIRQ*
3
2

RUN LOAD PB4 XIRQ*/PE0 VDDPLL CON2 JB5 selects JB2 JB3

1
1
5V or 3V3 2 1 3 JB3 selects source

3
1
C4 operation of DIG11/PWM
3

XCLKS*/PE7
ECLK/PE4
VSSR
VDDR
RESET*
VDDPLL
XFC
VSSPLL
EXTAL
XTAL
TEST/VPP
IRQ*/PE1
R2 470n J7 JB5

2
1
4

1
1
1
10K C6 C7 C5 AN7/PAD07 1 2

13
14
15
16
17
18
19
20
21
22
23
24
AN6/PAD06 2 JB2 selects source

2
C16 R4 4K7 100n PT4/IOC4/PW4 of DIG10/PWM
2 1

2
2
1

VDD 330p 3n3


A-RST 1 2 CON2 PT5/IOC5

1 2
PP5/PW5
100n VDD
J11 BDM IN VDD R1
3K9 +3V3
2 1 VIN

2
4 3
POWER

1
6 5 PE1/IRQ* 5V out U2 LD1117S IN

1
RESET* 2 3 3
URX PS1 C8 R5 Vout Vin J12
2
1

XDO 1 2 XDI 100n 10K Y1 1

2
8MHz
ADJ

PS0 3 4 UTX +5V R8


2 1

2
2
3

5 6 JB1 237R C13 C12


1

JB4 COM SEL J5 1 2 SW2 2 10n (+5 to +15 VDC)

1
1
2 1 PB4 470n 2
2

R3 10M
BONUS 2 PE7 RESET J13
1

PINS PE4 C10 C11


3

1
1

22p 22p 1

2
2
4 PA0
D3 1N4148 R9 2
2 1 CON4 715R
+3V3 5VUSB
J9 PA0
2

PIN1 1 20 PIN20
PIN2 VCC AD0/DIO0 19 PIN19
2 COM SEL (JB4) Settings:
PIN3 DOUT AD1/DIO1 18 PIN18
3 DIN/CONFIG AD2/DIO2 - for normal operation, jumper 1 to 2, and 5 to 6
PIN4 4 17 PIN17 - for XBee-to-9S12 communication, jumper 2 to 4, and 3 to 5
PIN5 D08 AD3/DIO3 16 PIN16
5 RESET RTS/AD6/DIO6 - for XBee-to-host connection, jumper 1 to 3, and 4 to 6
PIN6 6 15 PIN15 +3V3 +5V Revision Notes:
PIN7 PWM0/RSSI AS/AD5/DIO5 14 PIN14 U3 LD1117S33
7 PWM1 VREF 1 -fixed J9/10 pinout
PIN8 8 13 PIN13 2 3
PIN9 [reserved] ON/SLEEP 12 PIN12 VOUT VIN -added optional SPI EEPROM (U4)
9
1

GND

PIN10 DTR CTS/DIO7 11 PIN11 C15 -improved AREF configuratiion (JB7)


10
1

GND AD4/DIO4 + C14 -added selection jumpers for DIG0/1 connections (JB6)
PWR
1
1

100n
2

ADXB Connector
2

J10 D1 + C1
PIN1 PIN20
PIN2 1 20 PIN19
2

PIN3 2 19 PIN18
3 18 NOTES:
1 PIN4 PIN17 10u 10V TANT 1
1 2

PIN5 4 17 PIN16 This configuration uses modified Serial Monitor www.technologicalarts.com


PIN6 5 16 PIN15 (checks PB4 instead of PP5) R6 support@technologicalarts.com sales@technologicalarts.com
PIN7 6 15 PIN14 2K0 10u 16V TANT
PIN8 7 14 PIN13
- if Load/Run switch not used, host software must use Technological Arts, Inc.
PIN9 8 13 PIN12 DTR to activate serial monitor (or serial monitor Title
2

PIN10 9 12 PIN11
10 11 must implement timeout) Esduino 9S12C MCU Module
(DTR will also initiate AutoReset feature, unless W3 is open) Size Document Number Rev
B FILE: esduino0.dsn 1

Date: Tuesday, December 21, 2010 Sheet 1 of 1


A B C D E
G-4 Edit Date: February 12, 2013
Appendix H

Building Esduino Board

The following is the “build guide” for the Rev. 1 version of the Esduino board. It is similar to the standard
Esduino escept that all through-hole parts have been removed. You will place these components on the board
following the instructions provided here.

H-1
Esduino  Board  (Rev  1)  Build  Guide   Thomas  Behan,  James  Andrew  Smith  &  Ron  Wong  
Document  Version  2     January  2011  

Building  the  Esduino  Board  

 
Figure  1  Esduino  Board  

Introduction  
 
This manual will guide you through the building of the Esduino Board.  

Learning  Objectives  &  Success  Criteria  


 

These  are  listed  in  the  relevant  part  of  the  Student  Lab  Manual.    Refer  to  it.  

Parts  and  Tools  List  


Required  Parts  
1. One  (1)  Technological  Arts  Rev.  1  Esduino12C32  partly  assembled  kit  
(#ESD12C32-­‐KIT).  
 

Required  Documents  
1. ELE604  Sensors  and  Measurement  Student  Lab  Manual  by  James  Andrew  
Smith  
2. MC9S12C  Family  /  MC9S12GC  Family  Reference  Manual,  #MC9S12C128  Rev  
01.23  05/2007  by  Freescale  Semiconductor  (available  as  a  free  download  
online)  
Esduino  Board  (Rev  1)  Build  Guide   Thomas  Behan,  James  Andrew  Smith  &  Ron  Wong  
Document  Version  2     January  2011  
Required  Tools  
1. One  (1)  Soldering  Iron  (seeFigure  2)  
2. One  (1)  pair  of  side  cutters  (i.e.  flush  cutters)  (see  Figure  4)  
3. One  (1)  pair  of  needle-­‐nose  pliers  (see  Figure  3)  
4. One  (1)  Fume  hood  (see  Figure  2)  

Recommended  tools  
1. One  (1)  solder  sucker  
2. One  (1)  solder  wick  
3. One  (1)  “Third”  or  “Helping”  hand  (see  Figure  5)  

The  fume  hood  and  soldering  iron  are  provided  in  the  lab.    The  required  parts  are  
included  in  your  lab  kit.    The  side  cutters,  pliers  and  recommended  tools  are  
available  at  a  number  of  stores  in  the  city,  including  Creatron  and  Home  Hardware  
on  College  St.    Some  tools  are  also  available  at  Polytechnic  Hardware,  The  Source  
and  Canadian  Tire.  

 
Figure  2  Soldering  Iron  (right)  and  fume  hood  (left)  

 
Figure  3  Needle-­nose  pliers.    Image  courtesy  of  Wikipedia  
(http://en.wikipedia.org/wiki/File:Needle_nose_pliers.jpg)  
Esduino  Board  (Rev  1)  Build  Guide   Thomas  Behan,  James  Andrew  Smith  &  Ron  Wong  
Document  Version  2     January  2011  

 
Figure  4  Side-­  or  Flush-­cutters.    Image  courtesy  of  Wikipedia  
(http://en.wikipedia.org/wiki/File:Side_cutters.jpg)  

 
Figure  5  Third-­  or  Helping-­Hand.    This  is  useful  for  holding  circuit  boards  or  wires  while  your  hold  a  
soldering  iron  in  one  hand  and  solder  in  the  other.    Image  courtesy  of  Wikipedia  
(http://en.wikipedia.org/wiki/File:DKHelpingHand.jpg)  

Steps  
Pre-­‐lab  –  Review  Soldering  Techniques  –  Online!  

There  are  some  very  good  online  guides  to  soldering,  including:  

1. Lady  Ada’s  Soldering  Tutorial  (including  videos  by  Make  Magazine):  


http://www.ladyada.net/learn/soldering/thm.html  
2. “Soldering  Techniques”  by  the  Niagara  College  Technology  Department  
(http://technology.niagarac.on.ca/courses/elnc1236/pdf/Soldering%20Tec
hniques%2010W.pdf)  
3. “Soldering  Safety”  by  Mr.  Jim  Koch  (Ryerson  University):  
http://www.ee.ryerson.ca/~jkoch/soldering/Soldering_safety.html  
Esduino  Board  (Rev  1)  Build  Guide   Thomas  Behan,  James  Andrew  Smith  &  Ron  Wong  
Document  Version  2     January  2011  

 
Figure  5  Video  tutorial  on  soldering  available  at  Lady  Ada's  website  
(http://www.ladyada.net/learn/soldering/thm.html)  

Step  0  –  Review  Soldering  Techniques  –  Live!  

Mr.  Jim  Koch  will  conduct  a  session  on  soldering  during  the  lab  session.    This  is  a  
vital  skill  for  electrical  engineers!    Pay  attention  to  his  suggestions  and  
recommendations.    Your  TAs  are  also  expert  solderers  and  will  be  able  to  assist  you  
in  the  finer  details.    Bad  soldering  is  virtually  guaranteed  to  lead  to  expensive  and  
time-­‐consuming  fixes  down  the  road.    So  keep  your  mind  open  to  advice  from  the  
experts!  

Step  1  –  Check  kit  for  all  of  the  parts.  


 

 
Figure  6  Collection  of  parts  with  the  ESD12C32-­KIT.  
Esduino  Board  (Rev  1)  Build  Guide   Thomas  Behan,  James  Andrew  Smith  &  Ron  Wong  
Document  Version  2     January  2011  
Step  2.    Check  the  PCB  for  bad  connections.    

 
 

Figure  7  ESD12C32-­KIT  PCB.  

 
 

You  need  to  look  over  the  board  for  anything  out  of  place.  Spare  scraps  of  solder,  
solder  bubbles,  etc.  Then  gently  poke  each  surface  mount  part  to  see  if  it  moves.  
Parts  that  are  loose  will  need  to  be  fixed  by  your  TA.  

Step  3.  Prepare  to  solder  components  from  smallest  to  largest.  
You  will  need  to  flip  the  board  over  to  solder  all  of  the  parts.  This  means  that  parts  
must  be  held  in  place  by  the  table.  By  starting  with  the  smallest  parts  first,  we  can  
ensure  that  the  parts  do  not  fall  out.  

Step  4.  Find  and  align  the  diode.  


 

 
Figure  8  Diode  Alignment.  

Make  sure  to  orient  the  diode  correctly.  Check  for  the  bar  on  both  the  PCB  and  diode  
on  D3.  
Esduino  Board  (Rev  1)  Build  Guide   Thomas  Behan,  James  Andrew  Smith  &  Ron  Wong  
Document  Version  2     January  2011  
 

Step  5.  Push  the  diode  flush  with  the  board,  bend  the  leads  to  hold  it  in  place.  
 

 
Figure  9  Diode  flush  with  the  PCB.  

Once  you  are  sure  the  diode  has  the  correct  polarity  bend  the  leads  and  slide  it  in  
flush  with  the  board.  Once  completely  flush,  bend  the  leads  to  hold  the  diode  in  
place.  

Step  6.  Solder  the  diode  in  place.  


 

 
Figure  10  Diode  leads  bent  and  ready  to  be  soldered.  

Remember  to  heat  the  lead  and  PCB,  not  the  solder  directly!  Also  do  not  use  too  
much  solder.  De-­‐soldering  is  much  more  difficult  then  soldering,  do  it  right  the  first  
time.  

 
Esduino  Board  (Rev  1)  Build  Guide   Thomas  Behan,  James  Andrew  Smith  &  Ron  Wong  
Document  Version  2     January  2011  
 

Step  7.  Check  solder  joints  and  clip  leads.  


 

 
Figure  11  Correctly  soldered  leads,  one  is  clipped.  

Step  8.  Repeat  for  Crystal  on  Y2.  


 

 
Figure  12  Crystal  oscillator  soldered.  

The  crystal  oscillator  does  not  have  polarity  and  should  be  soldered  in  the  same  way  
as  the  diode.  

 
Esduino  Board  (Rev  1)  Build  Guide   Thomas  Behan,  James  Andrew  Smith  &  Ron  Wong  
Document  Version  2     January  2011  
Step  9.  Add  White  Power  Connector  (J13)  and    Switch  (SW1).  
 

 
Figure  13  White  power  plug  and  Switch  soldered.  

These  two  parts  are  approximately  the  same  height,  and  so  may  be  soldered  
together.    

Step  10.  Solder  male  headers.  


 

 
Figure  14  Place  the  male  headers  on  the  PCB.  

Soldering  the  male  headers  can  be  tricky,  use  the  following  steps  to  make  sure  the  
connections  are  straight,  and  clean:  

1)  Place  all  of  the  male  headers  on  the  PCB.    


Esduino  Board  (Rev  1)  Build  Guide   Thomas  Behan,  James  Andrew  Smith  &  Ron  Wong  
Document  Version  2     January  2011  
2)  Use  a  piece  of  paper  to  hold  the  male  headers  in  place  while  flipping  the  
PCB,  this  will  keep  the  headers  from  falling  out.  

3)  Solder  one  pin  per  header  (called  tacking).  

4)  Flip  the  board  right  side  up  to  make  sure  all  the  headers  are  straight.  With  
only  one  pin  tacked,  they  can  be  fixed  by  hand  without  having  to  de-­‐solder.  

5)  Solder  the  remaining  pins.  

Step  11.  Solder  Female  headers.  Leave  J10,  J14,  and  J15  open  for  the  USB  
Programmer.  
 

 
Figure  15  Place  the  male  headers  on  the  PCB.  

Solder  the  female  headers  using  the  same  techniques  used  in  the  previous  step.  

Step  12.    Add  the  black  power  connector  and  button  (SW2).  
 

 
Figure  16  Bent  leads  of  the  black  power  connector.  

Use  pliers  to  bend  the  leads  of  the  black  power  connector  so  it  is  held  in  place.  This  
will  make  soldering  it  easier.  
Esduino  Board  (Rev  1)  Build  Guide   Thomas  Behan,  James  Andrew  Smith  &  Ron  Wong  
Document  Version  2     January  2011  
Step  13.    Add  USB  Programmer  side  board.  
 

 
Figure  17  Add  USB  side  board.    

Add  the  USB  programmer  side  board.  Notice  that  J10  must  be  left  open  for  the  USB  
programmer  side  board  to  fit.  

Step  14.    Check  for  short  circuits  (visually).  


Always  check  for  shorts!  

Step  15.    Check  for  shorts  with  DMM.  


You  can’t  be  too  careful!  

 
Figure  6  The  DMM  connectivity  feature  is  important!  
Esduino  Board  (Rev  1)  Build  Guide   Thomas  Behan,  James  Andrew  Smith  &  Ron  Wong  
Document  Version  2     January  2011  
Step  16.    Left  over  parts.  

 
Figure  19  Left  over  parts.  

You  should  have  a  few  left  over  parts.  These  were  left  off  so  that  the  USB  side  
programmer  and  be  soldered  directly  to  the  board.  

Step  17.    Place  the  jumpers.  


The  board  is  now  finished.  The  jumpers  should  now  be  placed  according  to  the  
desired  usage  of  the  board.  Check  the  Esduino  overview  diagram  to  see  what  
settings  are  right  for  you!  

 
Figure  20  Finished  Esduino  Board  with  jumpers.  

Step  18.    Programming  the  bootloader  onto  the  9s12  


The  microcontroller  chip  is  effectively  blank  at  this  point  and  will  not  “boot  up”1.    
You  will  need  to  add  a  piece  of  software  to  it  to  allow  it  to  connect  to  Codewarrior  
via  the  USB  cable.    To  do  this  your  Teaching  Assistant  will  need  the  following:  

                                                                                                               
1  Booting,  boot  up,  and  bootstrap  effectively  mean  “a  self-­‐sustaining  process  that  

proceeds  without  external  help”  (http://en.wikipedia.org/wiki/Bootstrapping).    In  


our  specific  case,  the  code  that  runs  the  “serial  monitor”  program  and  permits  the  
9s12  Esduino  board  to  communicate  with  Codewarrior  on  your  PC  is  a  “bootstrap”  
program  because  it  engages  automatically  without  help  from  you.    What  does  a  
Esduino  Board  (Rev  1)  Build  Guide   Thomas  Behan,  James  Andrew  Smith  &  Ron  Wong  
Document  Version  2     January  2011  
 The  Serial  Monitor  program  
 Codewarrior  for  the  HCS12  
 A  Background  Debug  Module  (BDM)  cable  (see  Figure  7)  

 
Figure  7  Background  Debugger  Module  (BDM)  for  the  Esduino.    Also  known  as  a  BDM  cable  or  BDM  
"pod"  (p/n  USBDMLT)  .    Photo  courtesy  of  Technological  Arts.  

Here  are  the  steps  to  installing  the  serial  monitor  “bootstrap”  code.  2  Your  TA  will  be  
happy  to  do  this  for  you.  

1. Go  to  Technological  Arts  resource  page  to  get  the  USBDMLT  drivers:  
http://support.technologicalarts.ca/docs/USBDMLT/  
a. Download  the  USBDMLT  CODE  WARRIOR  IDE  SETUP  FILES.zip  
zip  file  
2. Go  to  Technological  Arts  Esduino  page  to  get  the  abs  files  at  
http://support.technologicalarts.ca/docs/Esduino/Code/  
a. Save  the  ESD12C32_Serial_Monitor.abs  file    
3. Unzip  the  USBDMLT  file  to  your  local  directory  and  plug  in  the  BDM  cable  
pod  (see  Figure  7)  into  the  USB  port  of  your  PC  
4. Install  the  USB  driver  in  your  extracted  USBDMLT  file  folder  under  
"USB_Driver"  
5. Run  the  files  "Install  Codewarrior  Files"  and  "Install  Codewarrior  Debug  Files."  
(Also  found  in  the  extracted  folder)  
6. In  the  "Utilities"  subfolder,  run  "Test_USBDM."  It  should  detect  with  "1  
Found"....exit.  
7. Insert  the  BDM’s  six-­‐pin  connector  into  the  BDM  port  of  the  Esduino.    Ensure  

                                                                                                                                                                                                                                                                                                                                         
bootstrap  look  like?    Check  out  a  pair  of  Blundstone  boots  
(http://www.blundstone.ca/).  
2  More  instructions  on  the  BDM  can  be  found  here:    

http://www.technologicalarts.ca/catalog/product_info.php?cPath=50_55&products
_id=572&osCsid=9c08084a090017f8ca2351ce628d51ea  (click  on  the  "Resources"  
tab  for  instructions  on  setup)
Esduino  Board  (Rev  1)  Build  Guide   Thomas  Behan,  James  Andrew  Smith  &  Ron  Wong  
Document  Version  2     January  2011  
that  you  line  up  the  pins  correctly  (there  are  two  ways  to  do  it;  one  is  right  
and  one  is  wrong!)    Refer  to  Figure  8.  
8. Inside  the  Freescale  program  folder  in  your  C  directory...C:\Program  
Files\Freescale\Codewarrior  for  S12(X)  V5.X,  run  the  program  hiwave.exe  
(Its  basically  the  serial  monitor  without  the  Codewarrior  IDE).  
9. Select  the  link  type  as  TBDML...and  select  the  MC9S12C32  chip  variant.  
10. Use  the  Load  option  to  get  your  abs  file  into  the  unit.    
11. You’re  done!  
 

 
Figure  8  BDM  connection  to  the  Esduino.    Note  the  white  square  on  the  J11  port.    Make  sure  that  the  red  
wire  on  the  BDM  lines  up  with  it  and  that  the  plastic  flange  is  beside  it  as  well.  
Appendix I

Serial Communication to PC for data logging (with


quick-start code)

I.1 Setup
You will want to set up your Esduino board to communicate with a desktop or laptop PC in order to log the
data and manipulate it in Matlab or maybe Labview. Here, we assume that you are using Windows on the PC.
This has been tested using the following:

1. MacBook Pro running Codewarrior 5.x on a Parallels virtual machine (Windows XP). Used to compile
the code and transfer it to an Esduino, Rev 1.

2. P & E Micro Multilink Universal BDM

3. Dell Windows XP desktop PC, running RealTerm (http://realterm.sourceforge.net/), connected to


the Esduino via the USB adapter

4. Example code by Valvano: http://users.ece.utexas.edu/~valvano/Starterfiles/SCI_9S12.zip

5. Matlab 2011a on the Dell PC.

• For simple example, refer to http://www.mathworks.com/help/techdoc/matlab_external/f92576.


html.
• For advanced examples, refer to Matlab Instrument Control Toolbox here: http://www.mathworks.
com/products/instrument/hardware/serial.html

This is different that the typical lab setup for students (e.g. Windows XP under VMWare virtual machine
with Linux host) and 9s12’s built-in serial monitor (rather than the BDM).
To get this to work, I created a new project in Codewarrior and replaced the main.c file contents with
the content’s of Valvano’s file. I also imported the SCI.C and SCI.H files, then ran Make a few times before
downloading it via the BDM cable.

I.2 To-Do
How to alternate between the Esduino’s Serial Monitor mode (“Load”?) and running the serial communication
to the PC (“Run”?), as this is more typical of the student setup.

I-1
I.3 Serial Communication Code & Test
I.3.1 Test first using RealTerm
RealTerm (http://realterm.sourceforge.net/) is the most capable serial terminal program for Windows.
It’s much better than HyperTerm, and it’s free! Use it to test out the serial output from your Esduino first.
The Esduino serial code (see Listing I.1 and the complete files at http://users.ece.utexas.edu/~valvano/
Starterfiles/SCI_9S12.zip) is configured for 19200 baud, as is RealTerm in Fig. I.1.

Figure I.1: RealTerm is set up for 19200 baud. Use the Windows Device Manager (right) to identify the correct
COM port that RealTerm is to use (COM 8 in this case, but it will likely be different on your computer!)

I-2 Edit Date: February 12, 2013


Listing I.1: The main component of the serial / SCI code that permits communication between the Esduino
and the PC for data logging
// f i l e n a m e ∗∗∗∗∗∗∗∗ Main . C ∗∗∗∗∗∗∗∗∗∗∗∗∗∗
// Example main p r o g r a m f o r SCI 9 S12C32 g a d l f y e x a m p l e
// 9 S12C32 SCI c o n n e c t e d t o PC com p o r t
// d o e s n o t r u n i n BOOT mode , o n l y i n RUN mode

// This example accompanies the books


// ” Embedded M i c r o c o m p u t e r S y s t e m s : R e a l Time I n t e r f a c i n g ” ,
// Thomsen , c o p y r i g h t ( c ) 2 0 0 6 ,
// ” I n t r o d u c t i o n t o Embedded M i c r o c o m p u t e r S y s t e m s :
// M o t o r o l a 6 8 1 1 and 6 8 1 2 S i m u l a t i o n ” , B r o o k s−C o l e , c o p y r i g h t ( c ) 2002 ,
// J o n a t h a n W. V a l v a n o 3 / 1 7 / 0 7

// You may u s e , e d i t , r u n o r d i s t r i b u t e t h i s file


// as l o ng as t h e above c o p y r i g h t n o t i c e s remain

// how t o r u n p r o g r a m s t h a t u s e t h e SCI p o r t
// 1 ) c o n n e c t 9 S12C32 t o PC ’ s COM p o r t ,
// s e t 9 S12C32 t o BOOT mode
// r e s e t 9 S12C32
// 2 ) e x e c u t e P r o j e c t −>Debug ( c o m p i l e s and d o w n l o a d s c o d e t o 9 S12C32 )
// 3 ) q u i t MW d e b u g g e r o n c e p r o g r a m m i n g c o m p l e t e
// q u i t t i n g t h e d e b u g g e r w i l l r e l e a s e t h e COM p o r t
// 4) s t a r t a t e r m i n a l program ( l i k e HyperTerminal )
// s p e c i f y p r o p e r COM p o r t , 1 9 2 0 0 b i t s / s e c , no f l o w c o n t r o l
// 5 ) s e t t o RUN mode and h i t r e s e t
// 6 ) when done , q u i t t e r m i n a l p r o g r a m
// q u i t t i n g t h e t e r m i n a l p r o g r a m w i l l r e l e a s e t h e COM p o r t
// s e t 9 S12C32 t o BOOT mode
// r e s e t 9 S12C32

#include <h i d e f . h> /∗ common d e f i n e s and m a c r o s ∗/


#include <mc9s12c32 . h> /∗ d e r i v a t i v e i n f o r m a t i o n ∗/
#include ” SCI . h”

#pragma LINK INFO DERIVATIVE ” mc9s12c32 ”

//−−−−−−−−−−−−−−−−−−−−−OutCRLF−−−−−−−−−−−−−−−−−−−−−
// O u t p u t a CR, LF t o SCI t o g o t o a new l i n e
// I n p u t : none
// O u t p u t : none
// t o g g l e PortT b i t 0 e a c h t i m e , d e b u g g i n g p r o f i l e
void OutCRLF( void ) {
SCI OutChar (CR ) ;
SCI OutChar ( LF ) ;
PTT ˆ= 0 x01 ; // t o g g l e b i t 0
}

char s t r i n g [ 2 0 ] ; // g l o b a l t o a s s i s t i n d e b u g g i n g
unsigned short n ;
void main ( void ) {
DDRT |= 0 x03 ; // PortT b i t s 1 , 0 a r e o u t p u t t o LED
SCI Init (19200); // f a s t e s t s t a n d a r d b a u d r a t e on r u n mode 9 S12C32

S C I O u t S t r i n g ( ” TechArts S12C32 , SCI demo 3 / 1 7 / 0 7 −JWV” ) ; OutCRLF ( ) ;


for ( ; ; ) {
PTT ˆ= 0 x02 ; // t o g g l e b i t 1
SCI OutString ( ” I n S t r i n g : ” ) ;
SCI InString ( string , 1 9 ) ;
S C I O u t S t r i n g ( ” O u t S t r i n g=” ) ; S C I O u t S t r i n g ( s t r i n g ) ; OutCRLF ( ) ;

S C I O u t S t r i n g ( ” InUDec : ” ) ; n=SCI InUDec ( ) ;


S C I O u t S t r i n g ( ” OutUDec=” ) ; SCI OutUDec ( n ) ; OutCRLF ( ) ;

S C I O u t S t r i n g ( ” InUHex : ” ) ; n=SCI InUHex ( ) ;


S C I O u t S t r i n g ( ” OutUHex=” ) ; SCI OutUHex ( n ) ; OutCRLF ( ) ;
}

I-3 Edit Date: February 12, 2013


I.3.2 Test using Matlab
Matlab is very capable at data processing. For this reason it will be important to transfer data from your
Esduino to Matlab. The Mathworks provides a good guide for getting started with Serial Input/Output in
Matlab here: http://www.mathworks.com/help/techdoc/matlab_external/f92576.html.
The following is a transcript of the commands used in Matlab to obtain serial data from the Esduino.

>> a=serial(’COM8’); % Use Device Manager (Windows) to verify this port. Assign to ‘a’
>> set(a,’BaudRate’,19200); % Set the speed to match the code running on Esduino.
>> fopen(a); % Open the ‘‘file’’ for ‘a’.
>> a % Report what is going on with this ‘file’

Serial Port Object : Serial-COM8

Communication Settings
Port: COM8
BaudRate: 19200
Terminator: ’LF’

Communication State
Status: open
RecordStatus: off

Read/Write State
TransferStatus: idle
BytesAvailable: 10
ValuesReceived: 40
ValuesSent: 0

>> out=fscanf(a); % Wait for serial data to arrive. (waits for a Carriage Return?).
>> fclose(a) % close the ‘a’ file
>> delete(a) % delete the ‘a’ file
>> clear a % clear the variable, too.
>> out % What did Matlab capture on the serial port? It’s stored in ‘out’

out =

TechArts S12C32, SCI demo 3/17/07 -JWV

I-4 Edit Date: February 12, 2013


Figure I.2: Matlab is set up for 19200 baud. Use the Windows Device Manager (right) to identify the correct
COM port that Matab is to use (COM 8 in this case, but it will likely be different on your computer!)

I-5 Edit Date: February 12, 2013


I-6 Edit Date: February 12, 2013
Appendix J

Esduino Schematics and Layout (Rev 1)

The Revision 1 version of the Esduino’s schematics and parts layout are found here.

J-1
[JB4] TX/RX Communications Routing:
Place two shunts in the positions shown Esduino
US = USB-to-SCI (of the MCU) 9S12C-based Arduino-compatible*
When Xbee Option is present: Rev. 1
UX = USB-to-Xbee (for configuring via Host) [JB3]: Digital11 Source
SX = SCI-to-Xbee (for wireless communications) 1-2 (left): PM4
[U4]: Serial Memory [JB2]: Digital10 Source 1-3 (down): PP5 (PAD1)
Footprint for optional 1-2 (left): PT4 1-4 (right): PT5
[J14][J15]: USB2MCU module goes here, SPI memory device. 2-3 (right): PM3
to provide USB interface to host PC; [D2]: User LED [U1]:
or supply your own TTL-level signals (on DIG13) Freescale 9S12C 16-bit microcontroller
to/from Host
[JB8] PS/PM SELECT:

PT3
PT7
PT6
PT2
PT1

PM5
PM2
PAD07
PAD06
DIG1
DIG0

PT0
Select between PS0/PS1
J14 US JB4
GND J3 and PM0/PM1 assignments
[J9][J10]: [Xbee Option]

>
<

D2
+5V

J1
for DIG0 and DIG1 pins

D13
D12
D11
D10
D9P
D8
D7
D4
Plug ADXB here for XBee Interface U4

GND
DTR

SX UX
UX SX
AREF
PT4 PM3 S M
(3V/5V compatible). SPI [J11] BDM IN:
DIG11

PWM D6
PWM D5
<TX US J6 C17
D2 JB2

1 PWM D3
GND J15 DI PM4 PT5

JB8
[J6]: SPI peripheral connector Standard 6-pin Background
RX > ADXB +5 JB3
SPI signals, Output Enable, +5V, J10 Esduino Debug Mode connector for
SCK
PP5
JB1
BDM IN
and Ground are all brought out to www.TechnologicalArts.com advanced debugging use
SS* R5 J11 LOAD
VIN C6
this convenient connector for easy OE* J5 JB6 SW1
USB [SW1 and JB6]:
interfacing to SPI peripherals DO C5 MAN
PB4 R1
G C7
When JB6 set to MAN, use SW1 to
[JB1]: 5V Source Selector PWR PE7 select Serial Monitor mode.
D3 C10
AUTO RUN
PE4
1-2 (lower): 5V from USB Y1 When JB6 set to AUTO, Serial
U1
R6 D1 PA0 R3
2-3 (upper): 5V from U1 via VIN C1 C11
J8 PM0 Monitor mode must be controlled

+
J9 Y2 JB5 PM1
[D1]: Power indicator LED by host via DTR line on serial port.
R2 3V 5V J7 AN7
J12 C16 VDD VRH AR
AN6
C15 C14 JB7
[J7] PB4, PE7,PE4,PA0: C9 [J8] PM0 - PM1:
U3
Four bonus Digital pins. +

RESET
VIN
AN0
AN1
AN2
AN3
AN4
AN5

GND
GND

3V3 5V Two bonus Digital pins;


J2

J4

may be used with an external

SW2
REV. 1 J13
[U3]: 3.3V regulator (800 mA max.) transceiver to implement a
CAN interface.
PAD00
PAD01
PAD02
PAD05

PAD03
PAD04

[J7] AN6 - AN7:


[SW2]: Reset button [JB5]: 3V/5V Operation [J2] AN0 - AN1: Two bonus Analog Inputs;
1-2 (left): 3.3V Six Analog Inputs;
Power Configurations: may be used as digital
2-3 (right): 5V Any of these may be
Instead of deriving 5V to power the board from the USB Host inputs or outputs instead
connection, it can be derived from on-board regulator U1. used as digital inputs
Two different power connections are provided: J12 and J13. or outputs instead
The 2-pin J13 Molex connector is the default, while J12 is an
Order Codes:
optional barrel jack connector (2.1mm center-positive) ESD12C32 (with 9S12C32; surface-mount devices only)
compatible with most common AC-to-DC adapters. If J12 is ESD12C128 (with 9S12C128; surface-mount devices only)
present, and a voltage supply is plugged in, it will ESD12C32-KIT (ESD12C32 plus kit of through-hole parts)
automatically override J13. The applied voltage (VIN) can be ESD12C128-KIT (ESD12C128 plus kit of through-hole parts)
anywhere in the range of 7 to 15V DC. To choose VIN as ESD12C32-UR (fully assembled with 9S12C32, USB2MCU and connectors)
the source of system 5V (via regulator U1), set jumper block ESD12C128-UR (fully assembled with 9S12C128, USB2MCU and connectors)
JB1 to the 2-3 (upper) position. * Footprint and pinout are compatible with
standard Arduino-style shields; Arduino
www.TechnologicalArts.com software environment support pending. JANUARY 2011
A B C D E

VDD VDD 1 2 PE1/IRQ*


C17
VDD C2 100n 1 W1 2 Cut W1 and W2 to isolate interrupts

1
2 1 PE0/XIRQ*
SPI Signals JUMPER1 W2
+5V 100n JUMPER1
J6 9S12C

2
PM2/MISO JB8 DIG0/1 SEL
7
6 VDD PM1/TXCAN
5 PM5/SCK DIG13 PM3/SS* 1 8 PM0/RXCAN
PM3/SS* PM2/MISO 2 CS VCC 7 5 6
4 3 4
3 PT3/IOC3/PW3 DIG9/PWM 3 SO HOLD 6 PM5/SCK ARDUINO 9S12C PS0 PS1 ARDUINO

1
4 PM4/MOSI 4 WP SCK 5 PM4/MOSI J2 1 2 J1 4
2 VSS SI

PP5/PW5
PM0/RXCAN
PM1/TXCAN
PM2/MISO
PM3/SS*
PM4/MOSI
PM5/SCK
PS1
PS0
1 C3 1 AN0 AN0/PAD00 DIG0/RX 1
U4 25LCXXXA 100n 2 AN1 AN1/PAD01 DIG1/TX 2

2
CON7 3 AN2 AN2/PAD02 AN6/PAD06 DIG2 3

48
47
46
45
44
43
42
41
40
39
38
37
5VUSB U1 VDD AN3 AN3/PAD03 PT0/IOC0/PW0
4 DIG3/PWM4
J14 5 AN4 AN4/PAD04 AN7/PAD07 DIG4 5
1 VRH 6 AN5 AN5/PAD05 PT1/IOC1/PW1 DIG5/PWM6

VSSX
VSSA
USB2MCU module PT2/IOC2/PW2

VDDX
2 SEL DIG6/PWM7
attaches to J14 and J15 CON6 PT6/IOC6 DIG7 8

PM3/SS*
1

PS1/TXD
PS0/RXD

PM5/SCK
CON2 JB7

PM2/MISO
PM4/MOSI

PP5/KWP5
D2

PM1/TXCAN
PM0/RXCAN
J15 PT0/IOC0/PW0 1 36 VRH 2 CON8
DTR PT1/IOC1/PW1 PW0/IOC0/PT0 VRH J4
4 2 35 1 2 1 2

1
URX PT2/IOC2/PW2 PW1/IOC1/PT1 VDDA C9 RESET* R7 2K0 J3
3 3 1 L

3
PT3/IOC3/PW3 PW2/IOC2/PT2 3V3 PT7/IOC7 DIG8
2 4 PW3/IOC3/PT3 2 +3V3 1
1 34 AN7/PAD07 100n 3 5V PT3/IOC3/PW3 DIG9/PWM 2

3
PAD07/AN07 +5V
AUTO 5 33 AN6/PAD06 4 GND DIG10/PWM 3
CON4 JB6 VDD1 PAD06/AN06 AN5/PAD05 GND DIG11/PWM
2 6 VSS1 PAD05/AN05 32 5 4
31 AN4/PAD04 6 VIN PM2/MISO DIG12 5
PAD04/AN04 VIN
MAN PT4/IOC4/PW4 7 MC9S12C 30 AN3/PAD03 PM5/SCK DIG13 6

1
PT5/IOC5 PW4/IOC4/PT4 PAD03/AN03 AN2/PAD02 CON6 GND
8 IOC5/PT5 PAD02/AN02 29 7
CUT W3 TO W3 PT6/IOC6 9 28 AN1/PAD01 AREF 8
DISABLE PT7/IOC7 IOC6/PT6 PAD01/AN01 AN0/PAD00 PM4/MOSI
JUMPER1 10 IOC7/PT7 PAD00/AN00 27
AUTO RESET VDD VDD1 J8 PM3/SS* CON8

2
BKGD 11 26 PA0 PM1/TXCAN 1

2
3 MODC/BKGD PA0 3
SW1 PM0/RXCAN 2 VDD +5V
PB4 12 25 PE0/XIRQ*
3
2

RUN LOAD PB4 XIRQ*/PE0 VDDPLL CON2 JB5 selects JB2 JB3

1
1
5V or 3V3 2 1 3 JB3 selects source

3
1
C4 operation of DIG11/PWM
3

XCLKS*/PE7
ECLK/PE4
VSSR
VDDR
RESET*
VDDPLL
XFC
VSSPLL
EXTAL
XTAL
TEST/VPP
IRQ*/PE1
R2 470n J7 JB5

2
1
4

1
1
1
10K C6 C7 C5 AN7/PAD07 1 2

13
14
15
16
17
18
19
20
21
22
23
24
AN6/PAD06 2 JB2 selects source

2
C16 R4 4K7 100n PT4/IOC4/PW4 of DIG10/PWM
2 1

2
2
1

VDD 330p 3n3


A-RST 1 2 CON2 PT5/IOC5

1 2
PP5/PW5
100n VDD
J11 BDM IN VDD R1
3K9 +3V3
2 1 VIN

2
4 3
POWER

1
6 5 PE1/IRQ* 5V out U2 LD1117S IN

1
RESET* 2 3 3
URX PS1 C8 R5 Vout Vin J12
2
1

XDO 1 2 XDI 100n 10K Y1 1

2
8MHz
ADJ

PS0 3 4 UTX +5V R8


2 1

2
2
3

5 6 JB1 237R C13 C12


1

JB4 COM SEL J5 1 2 SW2 2 10n (+5 to +15 VDC)

1
1
2 1 PB4 470n 2
2

R3 10M
BONUS 2 PE7 RESET J13
1

PINS PE4 C10 C11


3

1
1

22p 22p 1

2
2
4 PA0
D3 1N4148 R9 2
2 1 CON4 715R
+3V3 5VUSB
J9 PA0
2

PIN1 1 20 PIN20
PIN2 VCC AD0/DIO0 19 PIN19
2 COM SEL (JB4) Settings:
PIN3 DOUT AD1/DIO1 18 PIN18
3 DIN/CONFIG AD2/DIO2 - for normal operation, jumper 1 to 2, and 5 to 6
PIN4 4 17 PIN17 - for XBee-to-9S12 communication, jumper 2 to 4, and 3 to 5
PIN5 D08 AD3/DIO3 16 PIN16
5 RESET RTS/AD6/DIO6 - for XBee-to-host connection, jumper 1 to 3, and 4 to 6
PIN6 6 15 PIN15 +3V3 +5V Revision Notes:
PIN7 PWM0/RSSI AS/AD5/DIO5 14 PIN14 U3 LD1117S33
7 PWM1 VREF 1 -fixed J9/10 pinout
PIN8 8 13 PIN13 2 3
PIN9 [reserved] ON/SLEEP 12 PIN12 VOUT VIN -added optional SPI EEPROM (U4)
9
1

GND

PIN10 DTR CTS/DIO7 11 PIN11 C15 -improved AREF configuratiion (JB7)


10
1

GND AD4/DIO4 + C14 -added selection jumpers for DIG0/1 connections (JB6)
PWR
1
1

100n
2

ADXB Connector
2

J10 D1 + C1
PIN1 PIN20
PIN2 1 20 PIN19
2

PIN3 2 19 PIN18
3 18 NOTES:
1 PIN4 PIN17 10u 10V TANT 1
1 2

PIN5 4 17 PIN16 This configuration uses modified Serial Monitor www.technologicalarts.com


PIN6 5 16 PIN15 (checks PB4 instead of PP5) R6 support@technologicalarts.com sales@technologicalarts.com
PIN7 6 15 PIN14 2K0 10u 16V TANT
PIN8 7 14 PIN13
- if Load/Run switch not used, host software must use Technological Arts, Inc.
PIN9 8 13 PIN12 DTR to activate serial monitor (or serial monitor Title
2

PIN10 9 12 PIN11
10 11 must implement timeout) Esduino 9S12C MCU Module
(DTR will also initiate AutoReset feature, unless W3 is open) Size Document Number Rev
B FILE: esduino0.dsn 1

Date: Tuesday, December 21, 2010 Sheet 1 of 1


A B C D E
J-4 Edit Date: February 12, 2013
Appendix K

Load Cell Usage

Since the beam load cell from Futek is proprietary, no detailed information (e.g. GF, material parameters, # of
working bridges, etc.) is provided. As such, there is no point in calculating the expected bridge voltage signal
proportional to the applied load.
However, if you note in the specifications, Futek provides the nominal output sensitivity of 1mv/Volt. What
this means is that if you use 10 Volt d.c. reference voltage to drive the bridge, the nominal bridge output will
be 10 mv for the rated full load of 1 LB (or 1.2 LB max. allowed). Therefore, with this information you can
figure out the gain of the IA required to give you the output of 0 to 5Volts (into your A/D) for load of 0 to 1
LB. You may then fine tune the gain of the IA if necessary.
Also, it is important that you connect the ”+” and ”-” terminals of the bridge to the corresponding terminals
of your IA to get the desired positive voltage output under load; and also properly balance the bridge to get
zero voltage output under no -load condition (refer to the chapter on the load cell labs).

K-1



  

 
 

 


 

    !"#$ %&#
'( )% *  #

!
% +
,"
#

  ( % ("  -.'/((


% ( 0 -.1$ (
( %%% (
 (  $  2 (( 
/(
( 
 ( (
%3(
% 45  
% ( ( #

'  
 (
 %(
%  (/%
( ( ( % ( ( %   

(#
%
( ((
 %(
%
%(
%
#

5  
% ("
 (    

( %  (
6(7
% "%

0" % ( 14

!# '  6%$7
( %
 
%(  % 
$

((
"%  "  '/((
% ( 
-( (% ( (3(8
5 (

$%
 / #
&# 5  
% (
% ("(  %%

(
/%


("  '/((
% ( 7
 ( (*% ( #
9# 5  
% (,
("% ( % (
 ( %" %
  2
% (  ( (% % %(
 (
  %(
%:
(
%#
;# ,(<%=3  %" "% (*% (  
( $  
(
(%%

( % ($ 


% ( (

 "   2 ( ( 

( % (( 
% (( % %

((%% (  
#

&
  

*(   %
(( "%# 
( "% (!

(
( ($0#&1# %  //%$
 %9

( %/(  (
" (
   
#

>%  //%*  

  
"(  (  "%#
(  

 (( (
    #5
% 

(

((     
(   
/% 
% # %;#

,  ( (*  

9
, 

% 
(4 
%  
% ( (   (%
#

,  !4)

>%!2#
(%#5
%&89!
,  &4)

>%&2#
(%#5
%?8@&
,  94)

>%;2#
(%#5
%!!8!&&
,  ;4)

>%@2#
(%#5
%!?8!@&
, 
%
%( 

 
% #  
%%$
 %
(
 %
( #% ((  ('( #

,   %*  

 %@$
 +
 % ( %#    (/ !A*
( 
"#

 , % (* %

;
(( (
  %" (
 "((
$ %B#

)(( (( (

 !   "

C ,  ) D 


E-  (0C-*18-  (0, 1E (0)18 (0F%(1


,( ((( (
  
  +
%(%%
 ( 
(
% (#'( '#

?
#$$ %#

 C(>%%


& '
!#  %% 
(
% 88
 % ( % (#
&# 
 $%((( (
%
#
9# 3(%% %/( /%(
( ($( %
(
%  % (( ((
(
 (#
;# 
%% %G(( (%%#
?# (
%
" ( 
   % ( (( #
@# '/ 

/ %(

((
#
B# 

"%
 (%/(  / 
%
#
#  %%( %(/ %(( #
# '/  % %
 % (( (
(%%  % (#
!#
% 
(
 %
("( 
% % (& #

& '
!# *( %//%% % 
(
(%
#
&# *( %( #
9# *( %% ( " "% 

/("#
;# *(   (/ #
?# *( % /% %  %(#
@# *(  (%
/%#
B# *( /%
(
%% (( ($( (% (
 (#-/(/% G /%

(
(
%#
# *( % ( % %%(#
# *( 

(
% 
%(% (  #
!#*( 
("( 
%
(
%
 ;8( %"
#

@
#$$ %
 *  0G  14*( %  (>*/%
(%# #

B
#$$ %

( ) $*(+,  )$)!

)!-.$ //   0$ ,,1  / 2


)    /. /2

( ) $32


4   5  %
( 
 (  ($ (( 

" % 
% %%% /%#*(  %(
 ( %  %( ( 
% #*( %  ( % #,
 %(
 %  ( % # 


8(  ( (%

%
%  "  (0  4/6,$2


K-10 Edit Date: February 12, 2013
Appendix L

MEMSIC 2125

L-1
! !
MXD2125G/H/M/N SPECIFICATIONS T"15@GI1J1LD@!R!)+q&E![CC1A1I5D?7L!\!;!g!GLA1@@!7D>1IB?@1!L7D1F]!S((E!S([!\!+3;S!GLA1@@!
Improved, Ultra Low Noise 7D>1IB?@1!@N1C?8?1FU
!

r3 g Dual Axis Accelerometer with MXD2125G/H MXD2125M/N


Parameter Conditions Min Typ Max Min Typ Max Units
Digital Outputs $#.$M0!%.4^=! #5C>![H?@! ! ! ! ! ! ! !
!!!"15@GI1J1LD!05L61*! r:3; r:3; g
!!!.7LA?L15I?DO! _1@D!8?D!@DI5?6>D!A?L1 ! ;3+! ! ! ;3+! ! Q!78!`$
MXD2125G/H !!![A?6LJ1LD!#II7I)! '!$1L@7I!D7!a!$1L@7I ! r*3;! ! ! r*3;! ! F16I11@
!!!=I5L@21I@1!$1L@?D?2?DO:! ! ! r)3;! !! ! r)3;! ! Q!!
$#.$%=%S%=a! #5C>![H?@! ! ! ! ! ! ! !
MXD2125M/N !!!$1L@?D?2?DOE!(?6?D5A!MGDNGD@!5D! ! **3b *)3+! *:3)! **3b *)3+! *:3) Q!FGDO!
N?L@!! COCA1-6
!!(M^='!5LF!(M^=aZ!&>5L61!
FEATURES Sck Internal Tem perature 721I!=1JN1I5DGI1!! ! P*; ! cb! P)+! ! cb! Q!
Resolution better than 1 milli-g O scillator Sensor
Tout
(optional) d#0M!g!_%[$!Y#S#Y! #5C>![H?@! ! ! ! ! ! ! !
Dual axis accelerometer fabricated on a monolithic CMOS IC !!!;!g!M88@1DZ! P;3* ;3;! c;3*! P;3* ;3;! c;3* g
Voltage
On chip mixed mode signal processing R eference
Vref
C LK !!!;!g!(GDO!&OCA1Z! ! Zb39 +;! +*3:! Zb39 +;! +*3: Q!FGDO!
No moving parts COCA1!
C ontinous
50,000 g shock survival rating H eater Self Test
!!!;!g!M88@1D!721I!=1JN1I5DGI1! '!8I7J!)+q&! ! r*3+! ! ! r*3+! ! Jg-q&
Control
17 Hz bandwidth expandable to >160 Hz _5@1F!7L!*)3+Q-6! r;3;)! r;3;)! Q-q&!
! !
3.0V to 5.25V single supply continuous operation .M%$#!4#0`M0"[.&#! ! ! ! ! ! !
X axis LPF A/D D out X
Continuous self test !!!.7?@1!(1L@?DOE!IJ@! ! ;3)! ;3Z! ;3)! ;3Z! Jg- Hz
Independent axis programmability (special order) Factory Adjust
`0#e^#.&a!0#$4M.$#! ! ! ! ! ! ! ! !
Compensated for Sensitivity over temperature O ffset & G ain !!!:F_!_5LFB?FD>!! ! *+! *9! f! *+! *9! *f! /X!
Ultra low initial Zero-g Offset =#"4#0[=^0#!M^=4^=! ! ! ! ! ! ! ! !
Y axis LPF A/D D out Y !!!=7GD!S7AD561! ! *3*+ *3)+! *3:+! *3*+ *3)+! *3:+ S!
!
2-AX IS
APPLICATIONS ! SENSO R
!!!$1L@?D?2?DO! ! Z3g +3;! +3Z! Z3g! +3;! +3Z! JS-qh
Automotive – Vehicle Security/Vehicle stability control/ Vdd Gnd Vda
SMY=[,#!0#`#0#.&#! ! ! ! ! ! ! ! ! !
Headlight Angle Control/Tilt Sensing !!!S018! R:3;SP+3)+S!@GNNAO )3Z )3+! )3g+! )3Z! )3+! )3g+ S!
!!!&>5L61!721I!=1JN1I5DGI1! ! ! ;3*! ! ! ;3*! ! JS-q&
Security – Gas Line/Elevator/Fatigue Sensing
!!!&GII1LD!(I?21!&5N5K?A?DO! $7GIC1! ! ! *;;! ! ! *;; P[!
Information Appliances – Computer Peripherals/PDA’s/Mouse MXD2125G/H/M/N FUNCTIONAL BLOCK DIAGRAM $#Y`!=#$=!! ! ! ! ! ! ! ! !
Smart Pens/Cell Phones
!!!&7LD?LG7G@!S7AD561!5D!(M^='E!! R+3;S!$GNNAOE!7GDNGD! ! ! !! ! ! !! !
Gaming – Joystick/RF Interface/Menu Selection/Tilt Sensing !!!(M^=a!GLF1I!`5?AGI1! I5?A@!D7! !! +3;! !! +3;! S!
GPS!<!electronic Compass tilt Correction @GNNAO!27AD561!
Consumer – LCD projectors, pedometers, blood pressure !!!&7LD?LG7G@!S7AD561!5D!(M^='E! R:3;S!$GNNAOE!7GDNGD! ! :3;! !! ! :3;! !! !
Monitor, digital cameras !!!(M^=a!GLF1I!`5?AGI1! I5?A@!D7! !! !! S!
@GNNAO!27AD561!
GENERAL DESCRIPTION (M^='!5LF!(M^=a!M^=4^=$! ! ! ! ! ! ! ! !
=>1!"'()*)+,-/-"-.!NI72?F1@!DB7!F?6?D5A!7GDNGD@!D>5D! !!!.7IJ5A!MGDNGD!05L61! MGDNGD!/?6>! Z3b ! ! Z3b! ! ! S!
=>1!"'()*)+,-/-"-.!?@!5!A7B!C7@DE!FG5A!5H?@! MGDNGD!Y7B! ! ;3)! ! ;3)! S!
5CC1A1I7J1D1I!85KI?C5D1F!7L!5!@D5LF5IFE!@GKJ?CI7L!&"M$! 5I1!@1D!D7!+;Q!FGDO!COCA1!5D!X1I7!6!5CC1A1I5D?7L3!!=>1!
!!!!MGDNGD!`I1VG1LCO! "'()*)+,-"! f+! *;;! *;+! f+! *;;! *;+ /X!
NI7C1@@3!!%D!?@!5!C7JNA1D1!@1L@?L6!@O@D1J!B?D>!7LPC>?N! 7GDNGD@!5I1!F?6?D5A!B?D>!FGDO!COCA1@!TI5D?7!78!NGA@1!B?FD>!D7! "'()*)+/-.! :b; Z;;! Z);! :b; Z;;! Z); /X!
J?H1F!J7F1!@?6L5A!NI7C1@@?L63!!=>1!"'()*)+,-/-"-.! N1I?7FU!D>5D!5I1!NI7N7ID?7L5A!D7!5CC1A1I5D?7L3!!=>1!FGDO! !!!&GII1LD!! $7GIC1!7I!@?LWE!R! !! ! *;;! !! ! *;;! P[!
J15@GI1@!5CC1A1I5D?7L!B?D>!5!8GAAP@C5A1!I5L61!78!r:!g!5LF!5! COCA1!7GDNGD@!C5L!K1!F?I1CDAO!?LD1I85C1F!D7!5!J?CI7P :3;SP+3)+S!@GNNAO
@1L@?D?2?DO!78!*)3+Q-6!R+S!5D!)+q&3!!%D!C5L!J15@GI1!K7D>! NI7C1@@7I3! !!!0?@1-`5AA!=?J1! :3;!D7!+3)+S!@GNNAO f;! *;;! **;! f;! *;;! **; L$!
FOL5J?C!5CC1A1I5D?7L!T1363!2?KI5D?7LU!5LF!@D5D?C!5CC1A1I5D?7L! The typical noise floor is 0.2 mg/ Hz allowing signals !!!=GILPML!=?J1+! R+3;S!$GNNAO! ! *g;! ! ! *g;! ! J$!
R:3;S!$GNNAO! ! :;;! ! :;;! J$!
T1363!6I52?DOU3! below 1 milli-g to be resolved at 1 Hz bandwidth.!!=>1!
4Mi#0!$^44Ya! ! ! ! ! ! ! ! !
=>1!"'()*)+,-/-"-.!F1@?6L!?@!K5@1F!7L!>15D! "'()*)+,-/-"-.!?@!N5CW561F!?L!5!>1IJ1D?C5AAO!@15A1F! !!!MN1I5D?L6!S7AD561!05L61! ! :3; ! +3)+! :3;! ! +3)+ S!
C7L21CD?7L!5LF!I1VG?I1@!L7!@7A?F!NI778!J5@@3!!=>?@! Y&&!@GI85C1!J7GLD!N5CW561!T+!JJ!H!+!JJ!H!)!JJ!>1?6>DU! !!!$GNNAO!&GII1LD! R!+3;S! )3+ :3*! :3f! )3+! :3*! :3f! J[!
1A?J?L5D1@!@D?CD?7L!5LF!N5ID?CA1!NI7KA1J@!5@@7C?5D1F!B?D>! 5LF!?@!7N1I5D?7L5A!721I!5!PZ;q&!D7!*;+q&T"-.U!5LF!;q&!D7! !!!$GNNAO!&GII1LD! R!:3;S! :3; :3b! Z3g! :3;! :3b! Z3g! J[!
C7JN1D?D?21!F12?C1@!5LF!NI72?F1@!@>7CW!@GI2?25A!78!+;E;;;! 9;q&T,-/U!D1JN1I5DGI1!I5L613! =#"4#0[=^0#!0[.,#! ! ! ! ! ! ! ! !
g,!A15F?L6!D7!@?6L?8?C5LDAO!A7B1I!85?AGI1!I5D1!5LF!A7B1I!A7@@! !!!MN1I5D?L6!05L61! ! ;! ! c9;! PZ;! ! c*;+ q&!
FG1!D7!>5LFA?L6!FGI?L6!5@@1JKAO3! NOTES 7N1I5D1F!5D!:3;S!?L!NI7FGCD?7LE!D>1O!C5L!K1!DI?JJ1F!5D!D>1!85CD7IO!@N1C?8?C5AAO!87I!
* D>?@!A7B1I!@GNNAO!27AD561!7N1I5D?7LE!?L!B>?C>!C5@1!D>1!@1L@?D?2?DO!5LF!X1I7!g!K?5@!
! !!,G5I5LD11F!KO!J15@GI1J1LD!78!?L?D?5A!788@1D!5LF!@1L@?D?2?DO3!
A121A!@N1C?8?C5D?7L@!7L!D>?@!N561!B?AA!K1!J1D3!!4A15@1!C7LD5CD!D>1!85CD7IO!87I!@N1C?5AAO!
)
Information furnished by MEMSIC is believed to be accurate and reliable. ”MEMSIC, Inc. !![A?6LJ1LD!1II7I!?@!@N1C?8?1F!5@!D>1!5L6A1!K1DB11L!D>1!DIG1!5LF!?LF?C5D1F!5H?@!78! DI?JJ1F!F12?C1@!87I!A7B!@GNNAO!27AD561!7N1I5D?7L3!
@1L@?D?2?DO3! +!
However, no responsibility is assumed by MEMSIC for its use, nor for any 800 Turnpike St., Suite 202, North Andover, MA 01845 !MGDNGD!@1DDA1F!D7!B?D>?L!r*9J63
:
infringements of patents or other rights of third parties which may result from !!=I5L@21I@1!@1L@?D?2?DO!?@!D>1!5A61KI5?C!@GJ!78!D>1!5A?6LJ1LD!5LF!D>1!?L>1I1LD!
its use. No license is granted by implication or otherwise under any patent or
Tel: 978.738.0900 Fax: 978.738.0196 @1L@?D?2?DO!1II7I@3!!!
patent rights of MEMSIC. www.memsic.com
Z!
!=>1!F12?C1!7N1I5D1@!721I!5!:3;S!D7!+3)+S!@GNNAO!I5L613!!4A15@1!L7D1!D>5D!@1L@?D?2?DO!
5LF!X1I7!g!K?5@!A121A!B?AA!K1!@A?6>DAO!F?881I1LD!5D!:3;S!7N1I5D?7L3!`7I!F12?C1@!D7!K1!
"#"$%&!"'()*)+,-"-.-/!0123#! 4561!*!78!9! :-)+-);;+!
! "#"$%&!"'()*)+,-"-.-/!0123#! 4561!)!78!9! :-)+-);;+!
! !
ABSOLUTE MAXIMUM RATINGS* Note: =>1!"#"$%&!A767l@!5II7B!?LF?C5D1@!D>1!c'!@1L@?L6!
$GNNAO!S7AD561!TS((E!S([U!jjjjjj333P;3+!D7!c93;S! F?I1CD?7L!78!D>1!F12?C13!!=>1!ca!@1L@?L6!F?I1CD?7L!?@!I7D5D1F!f;°
$D7I561!=1JN1I5DGI1!! jjj3jjjjPg+q&!D7!c*+;q&! 5B5O!8I7J!D>1!!c'!F?I1CD?7L!87AA7B?L6!D>1!I?6>DP>5LF!IGA13!$J5AA!
[CC1A1I5D?7L!jjjjjjjjjjjjjj33+;E;;;!g! C?ICA1!?LF?C5D1@!N?L!7L1T*U3! MXD2125G/H/M/N PIN DESCRIPTIONS DISCUSSION OF TILT APPLICATIONS AND
! VDD!<!=>?@!?@!D>1!@GNNAO!?LNGD!87I!D>1!F?6?D5A!C?ICG?D@!5LF! RESOLUTION
k$DI1@@1@!5K721!D>7@1!A?@D1F!GLF1I![K@7AGD1!"5H?JGJ!05D?L6@!J5O!C5G@1!N1IJ5L1LD!
F5J561!D7!D>1!F12?C13!!=>?@!?@!5!@DI1@@!I5D?L6!7LAO]!D>1!8GLCD?7L5A!7N1I5D?7L!78!D>1! !!!!!!!!!!!!!!!!!! D>1!@1L@7I!>15D1I!?L!D>1!5CC1A1I7J1D1I3!!=>1!(&!27AD561!
Tilt Applications:!!ML1!78!D>1!J7@D!N7NGA5I!5NNA?C5D?7L@!78!
F12?C1!5D!D>1@1!7I!5LO!7D>1I!C7LF?D?7L@!5K721!D>7@1!?LF?C5D1F!?L!D>1!7N1I5D?7L5A! @>7GAF!K1!K1DB11L!:3;!5LF!+3)+!27AD@3!!0181I!D7!D>1!@1CD?7L!
@1CD?7L@!78!D>?@!@N1C?8?C5D?7L!?@!L7D!?JNA?1F3!!#HN7@GI1!D7!5K@7AGD1!J5H?JGJ!I5D?L6! D>1!"#"$%&!5CC1A1I7J1D1I!NI7FGCD!A?L1!?@!?L!
7L!4&_!A5O7GD!5LF!85KI?C5D?7L!@G661@D?7L@!87I!6G?F5LC1!7L!
C7LF?D?7L@!87I!1HD1LF1F!N1I?7F@!J5O!5881CD!F12?C1!I1A?5K?A?DO3! D?AD-?LCA?L5D?7L!J15@GI1J1LD3!![L!5CC1A1I7J1D1I!G@1@!D>1!
1HD1IL5A!N5ID@!5LF!C7LL1CD?7L@!I1C7JJ1LF1F3!
87IC1!78!6I52?DO!5@!5L!?LNGD!D7!F1D1IJ?L1!D>1!?LCA?L5D?7L!
Pin Description: LCC-8 Package !
5L6A1!78!5L!7Kn1CD3!
4?L! .5J1! (1@CI?ND?7L! VDA!<!=>?@!?@!D>1!N7B1I!@GNNAO!?LNGD!87I!D>1!5L5A76!
!
5JNA?8?1I@!?L!D>1!5CC1A1I7J1D1I3!!S([!@>7GAF!5AB5O@!K1!
*! =M^=! =1JN1I5DGI1!T[L5A76!S7AD561U! [!"#"$%&!5CC1A1I7J1D1I!?@!J7@D!@1L@?D?21!D7!C>5L61@!?L!
C7LL1CD1F!D7!S((3!!0181I!D7!D>1!@1CD?7L!7L!4&_!A5O7GD!5LF!
)! (M^=a! aP[H?@![CC1A1I5D?7L!(?6?D5A!$?6L5A N7@?D?7LE!7I!D?ADE!B>1L!D>1!5CC1A1I7J1D1Il@!@1L@?D?21!5H?@!?@!
85KI?C5D?7L!@G661@D?7L@!87I!6G?F5LC1!7L!1HD1IL5A!N5ID@!5LF!
:! ,LF! ,I7GLF! N1IN1LF?CGA5I!D7!D>1!87IC1!78!6I52?DOE!7I!N5I5AA1A!D7!D>1!
C7LL1CD?7L@!I1C7JJ1LF1F3!
Z! S([! [L5A76!$GNNAO!S7AD561! #5ID>l@!@GI85C13!!$?J?A5IAOE!B>1L!D>1!5CC1A1I7J1D1Il@!5H?@!?@!
!
+! (M^='! 'P[H?@![CC1A1I5D?7L!(?6?D5A!$?6L5A N5I5AA1A!D7!D>1!87IC1!78!6I52?DO!TN1IN1LF?CGA5I!D7!D>1!#5ID>l@!
Gnd!<!=>?@!?@!D>1!6I7GLF!N?L!87I!D>1!5CC1A1I7J1D1I3!
g! SI18! )3+S!0181I1LC1! @GI85C1UE!?D!?@!A15@D!@1L@?D?21!D7!C>5L61@!?L!D?AD3!!!
!
9! $CW! MND?7L5A!#HD1IL5A!&A7CW! !
THEORY OF OPERATION DOUTX!<!=>?@!N?L!?@!D>1!F?6?D5A!7GDNGD!78!D>1!HP5H?@!
b! S((! (?6?D5A!$GNNAO!S7AD561! =5KA1!*!5LF!`?6GI1!)!>1AN!?AAG@DI5D1!D>1!7GDNGD!C>5L61@!?L!
=>1!"#"$%&!F12?C1!?@!5!C7JNA1D1!FG5AP5H?@!5CC1A1I5D?7L! 5CC1A1I5D?7L!@1L@7I3!%D!?@!85CD7IO!NI76I5JJ5KA1!D7!*;;!/X!
D>1!'P!5LF!aP5H1@!5@!D>1!GL?D!?@!D?AD1F!8I7J!cf;q!D7!;q3!!
J15@GI1J1LD!@O@D1J!85KI?C5D1F!7L!5!J7L7A?D>?C!&"M$!%&! 7I!Z;;!/X3!!=>1!G@1I!@>7GAF!1L@GI1!D>1!A75F!?JN1F5LC1!?@!
.7D?C1!D>5D!B>1L!7L1!5H?@!>5@!5!@J5AA!C>5L61!?L!7GDNGD!N1I!
Ordering Guide NI7C1@@3!!=>1!F12?C1!7N1I5D?7L!?@!K5@1F!7L!>15D!DI5L@81I!KO! @G88?C?1LDAO!>?6>!5@!D7!L7D!@7GIC1-@?LW!m*;;P[!DON?C5A3!!
F16I11!78!D?AD!T?L!JgUE!D>1!@1C7LF!5H?@!>5@!5!A5I61!C>5L61!?L!
L5DGI5A!C7L21CD?7L!5LF!7N1I5D1@!A?W1!7D>1I!5CC1A1I7J1D1I@! i>?A1!D>1!@1L@?D?2?DO!78!D>?@!5H?@!>5@!K11L!NI76I5JJ1F!5D!
Model Package Style Digital Temperature 7GDNGD!N1I!F16I11!78!D?AD3!!=>1!C7JNA1J1LD5IO!L5DGI1!78!
>52?L6!5!NI778!J5@@3!!=>1!NI778!J5@@!?L!D>1!"#"$%&! D>1!85CD7IO!D7!K1!D>1!@5J1!5@!D>1!@1L@?D?2?DO!87I!D>1!OP5H?@E!
Output Range D>1@1!DB7!@?6L5A@!N1IJ?D@!A7B!C7@D!5CCGI5D1!D?AD!@1L@?L6!D7!
@1L@7I!?@!5!65@3!!! D>1!5CC1A1I7J1D1I!C5L!K1!NI76I5JJ1F!87I!L7LP1VG5A!
"'()*)+,Y! Y&&b!!!!!!!!! *;;!/X! ;!D7!9;q&! K1!5C>?121F!B?D>!D>1!"#"$%&!F12?C1!TI181I1LC1!
07/$!C7JNA?5LD!
! @1L@?D?2?D?1@!7L!D>1!HP!5LF!OP5H1@3!!&7LD5CD!D>1!85CD7IO!87I!
5NNA?C5D?7L!L7D1![.P;;"'P;;9U3!!
[!@?L6A1!>15D!@7GIC1E!C1LD1I1F!?L!D>1!@?A?C7L!C>?N!?@! 5FF?D?7L5A!?L87IJ5D?7L3!
"'()*)+,`! Y&&bE!4KP8I11! *;;!/X! ;!D7!9;q&! !
@G@N1LF1F!5CI7@@!5!C52?DO3!!#VG5AAO!@N5C1F! !
! ! X
"'()*)+/Y! Y&&b!!!!!!!!! Z;;/X! ;!D7!9;q&! 5AGJ?LGJ-N7AO@?A?C7L!D>1IJ7N?A1@!T6I7GN@!78! DOUTY!<!=>?@!N?L!?@!D>1!F?6?D5A!7GDNGD!78!D>1!OP5H?@!
07/$!C7JNA?5LD! +900
D>1IJ7C7GNA1@U!5I1!A7C5D1F!1VG?F?@D5LDAO!7L!5AA!87GI!@?F1@!78! 5CC1A1I5D?7L!@1L@7I3!%D!?@!85CD7IO!NI76I5JJ5KA1!D7!*;;!/X!
"'()*)+/`! Y&&bE!4KP8I11! Z;;/X! ;!D7!9;q&! D>1!>15D!@7GIC1!TFG5A!5H?@U3!!^LF1I!X1I7!5CC1A1I5D?7LE!5! 7I!Z;;!/X3!!=>1!G@1I!@>7GAF!1L@GI1!D>1!A75F!?JN1F5LC1!?@! gravity

"'()*)+"Y! Y&&b!!!!!!!!! D1JN1I5DGI1!6I5F?1LD!?@!@OJJ1DI?C5A!5K7GD!D>1!>15D!@7GIC1E! @G88?C?1LDAO!>?6>!5@!D7!L7D!@7GIC1-@?LW!m*;;P[!DON?C5A3!! 00


*;;!/X! PZ;!D7!*;+q!
M E M SIC

07/$!C7JNA?5LD! @7!D>5D!D>1!D1JN1I5DGI1!?@!D>1!@5J1!5D!5AA!87GI!D>1IJ7N?A1@E! i>?A1!D>1!@1L@?D?2?DO!78!D>?@!5H?@!>5@!K11L!NI76I5JJ1F!5D!


"'()*)+"`! Y&&bE!4KP8I11! C5G@?L6!D>1J!D7!7GDNGD!D>1!@5J1!27AD5613!!! D>1!85CD7IO!D7!K1!D>1!@5J1!5@!D>1!@1L@?D?2?DO!87I!D>1!HP5H?@E!
*;;!/X! PZ;!D7!*;+q! Y
! D>1!5CC1A1I7J1D1I!C5L!K1!NI76I5JJ1F!87I!L7LP1VG5A! Top View
"'()*)+.Y! Y&&b!!!!!!!!! Z;;!/X! PZ;!D7!*;+q! !
[CC1A1I5D?7L!?L!5LO!F?I1CD?7L!B?AA!F?@DGIK!D>1!D1JN1I5DGI1! @1L@?D?2?D?1@!7L!D>1!HP!5LF!OP5H1@3!!&7LD5CD!D>1!85CD7IO!87I!
07/$!C7JNA?5LD! Figure 2: Accelerometer Position Relative to Gravity
NI78?A1E!FG1!D7!8I11!C7L21CD?7L!>15D!DI5L@81IE!C5G@?L6!?D!D7!K1! 5FF?D?7L5A!?L87IJ5D?7L3!
"'()*)+.`! Y&&bE!4KP8I11! Z;;!/X! PZ;!D7!*;+q! !
5@OJJ1DI?C5A3!!=>1!D1JN1I5DGI1E!5LF!>1LC1!27AD561!7GDNGD! !
[AA!!N5ID@!5I1!@>?NN1F!?L!D5N1!5LF!I11A!N5CW56?L63!! 78!D>1!87GI!D>1IJ7N?A1@!B?AA!D>1L!K1!F?881I1LD3!!=>1! TOUT <!=>?@!N?L!?@!D>1!KG881I1F!7GDNGD!78!D>1!D1JN1I5DGI1! ! 'P[H?@! aP[H?@!
Caution: #$(!T1A1CDI7@D5D?C!F?@C>5I61U!@1L@?D?21!F12?C13! F?881I1LD?5A!27AD561!5D!D>1!D>1IJ7N?A1!7GDNGD@!?@!F?I1CDAO! @1L@7I3!!=>1!5L5A76!27AD561!5D!=M^=!?@!5L!?LF?C5D?7L!78!D>1! 'P[H?@! ! ! ! !
NI7N7ID?7L5A!D7!D>1!5CC1A1I5D?7L3!!=>1I1!5I1!DB7!?F1LD?C5A! F?1!D1JN1I5DGI13!!=>?@!27AD561!?@!G@18GA!5@!5!F?881I1LD?5A! MI?1LD5D?7L! ! &>5L61! ! &>5L61!
5CC1A1I5D?7L!@?6L5A!N5D>@!7L!D>1!5CC1A1I7J1D1IE!7L1!D7! J15@GI1J1LD!78!D1JN1I5DGI1!8I7J!5JK?1LD!5LF!L7D!5@!5L! =7!#5ID>l@! '!MGDNGD N1I!F163! a!MGDNGD N1I!F163!
! J15@GI1!5CC1A1I5D?7L!?L!D>1!HP5H?@!5LF!7L1!D7!J15@GI1! 5K@7AGD1!J15@GI1J1LD!78!D1JN1I5DGI13!!! $GI85C1! TgU! 78!D?AD! TgU! 78!D?AD!
! 5CC1A1I5D?7L!?L!D>1!OP5H?@3!!4A15@1!2?@?D!D>1!"#"$%&! ! TF163U! TJgU! TJgU!
8 B1K@?D1!5D!BBB3J1J@?C3C7J!87I!5!N?CDGI1-6I5N>?C! Sck!<!=>1!@D5LF5IF!NI7FGCD!?@!F1A?21I1F!B?D>!5L!?LD1IL5A! f;! *3;;;! ! ;3*+! ;3;;;! ! *93Z+!
F1@CI?ND?7L!78!D>1!8I11!C7L21CD?7L!>15D!DI5L@81I!NI?LC?NA13! CA7CW!7ND?7L!Tb;;W/XU3!!This pin should be grounded b+! ;3ffg! ! *3:9! ;3;b9! ! *93:9!
1 7
! when operating with the internal clock.!![L!1HD1IL5A! b;! ;3fb+! ! )3bb! ;3*9Z! ! *93*g!
X +g
! CA7CW!7ND?7L!C5L!K1!@N1C?5A!7IF1I1F!8I7J!D>1!85CD7IO! 9;! ;3fZ;! ! +3bg! ;3:Z)! ! *g3:+!
2 6 g;! ;3bgg! ! b3+f! ;3+;;! ! *+3;Z!
5AA7B?L6!D>1!G@1I!D7!?LNGD!5!CA7CW!@?6L5A!K1DB11L!Z;;W/X!
Z+! ;39;9! ! *)3):! ;39;9! ! *)3):!
[LF!*3g"/X!

M E M S IC
3 5 :;! ;3+;;! ! *+3;Z! ;3bgg! ! b3+f!
! );! ;3:Z)! ! *g3:+! ;3fZ;! ! +3bg!
4
Vref!<![!I181I1LC1!27AD561!?@!525?A5KA1!8I7J!D>?@!N?L3!!%D!?@! *;! ;3*9Z! ! *93*g! ;3fb+! ! )3bb!
Y +g @1D!5D!)3+;S!DON?C5A!5LF!>5@!*;;P[!78!FI?21!C5N5K?A?DO3! +! ;3;b9! ! *93:9! ;3ffg! ! *3:9!
;! ;3;;;! ! *93Z+! *3;;;! ! ;3*+!
Top View
! Table 1: Changes in Tilt for X- and Y-Axes
!
!

"#"$%&!"'()*)+,-"-.-/!0123#! 4561!:!78!9! :-)+-);;+! "#"$%&!"'()*)+,-"-.-/!0123#! 4561!Z!78!9! :-)+-);;+!


! !
Resolutiono!!=>1!5CC1A1I7J1D1I!I1@7AGD?7L!?@!A?J?D1F!KO! POWER SUPPLY NOISE REJECTION PCB LAYOUT AND FABRICATION SUGGESTIONS!
T2
L7?@13!=>1!7GDNGD!L7?@1!B?AA!25IO!B?D>!D>1!J15@GI1J1LD! =B7! C5N5C?D7I@! 5LF! 5! I1@?@D7I! 5I1! I1C7JJ1LF1F! 87I! K1@D! *3! =>1!$CW!N?L!@>7GAF!K1!6I7GLF1F!D7!J?L?J?X1!L7?@13!
K5LFB?FD>3!i?D>!D>1!I1FGCD?7L!78!D>1!K5LFB?FD>E!KO! I1n1CD?7L!78!N7B1I!@GNNAO!L7?@1!TI181I1LC1!`?6GI1!+!K1A7BU3! )3! Y?K1I5A!G@1!78!C1I5J?C!KON5@@!C5N5C?D7I@!?@!
5NNAO?L6!5L!1HD1IL5A!A7B!N5@@!8?AD1IE!D>1!7GDNGD!L7?@1!FI7N@3! =>1!C5N5C?D7I@!@>7GAF!K1!A7C5D1F!5@!CA7@1!5@!N7@@?KA1!D7!D>1! I1C7JJ1LF1F3!
01FGCD?7L!78!K5LFB?FD>!B?AA!?JNI721!D>1!@?6L5A!D7!L7?@1! T1 F12?C1! @GNNAO! N?L@! TS([E! S((U3! =>1! C5N5C?D7I! A15F! A1L6D>! :3! 07KG@D!A7B!?LFGCD5LC1!6I7GLF!B?I?L6!@>7GAF!K1!G@1F3!
I5D?7!5LF!D>1!I1@7AGD?7L3!=>1!7GDNGD!L7?@1!@C5A1@!F?I1CDAO! @>7GAF!K1!5@!@>7ID!5@!N7@@?KA1E!5LF!@GI85C1!J7GLD!C5N5C?D7I@!! Z3! &5I1!@>7GAF!K1!D5W1L!D7!1L@GI1!D>1I1!?@!pD>1IJ5A!
B?D>!D>1!@VG5I1!I77D!78!D>1!J15@GI1J1LD!K5LFB?FD>3!=>1! ! 5I1! NI181II1F3! `7I! DON?C5A! 5NNA?C5D?7L@E! C5N5C?D7I@! &*! 5LF! @OJJ1DIOq!7L!D>1!4&_!?JJ1F?5D1AO!@GII7GLF?L6!D>1!
J5H?JGJ!5JNA?DGF1!78!D>1!L7?@1E!?D@!N15WP!D7P!N15W!25AG1E! A (g)= (T1/T2 - 0.5)/12.5% &)!C5L!K1!C1I5J?C!;3*!r`E!5LF!D>1!I1@?@D7I!0!C5L!K1!*;!ȍ3!! "#"$%&!F12?C1!5LF!D>5D!D>1I1!?@!L7!@?6L?8?C5LD!>15D!
5NNI7H?J5D1AO!F18?L1@!D>1!B7I@D!C5@1!I1@7AGD?7L!78!D>1! 0g = 50% Duty Cycle ! @7GIC1!L15IKO3!
T2= 2.5ms or 10ms (factory programmable)
J15@GI1J1LD3!i?D>!5!@?JNA1!0&!A7B!N5@@!8?AD1IE!D>1!IJ@! V SUPPLY +3! [!J1D5A!6I7GLF!NA5L1!@>7GAF!K1!5FF1F!F?I1CDAO!K1L15D>!
L7?@1!?@!C5ACGA5D1F!5@!87AA7B@o! Figure 3: Typical output Duty C ycle D>1!"#"$%&!F12?C13!!=>1!@?X1!78!D>1!NA5L1!@>7GAF!K1!
! @?J?A5I!D7!D>1!"#"$%&!F12?C1l@!877DNI?LD!5LF!K1!5@!
CHOOSING T2 AND COUNTER FREQUENCY D>?CW!5@!N7@@?KA13!
.7?@1!TJ6!IJ@U!\!.7?@1TJ6- Hz U!k! T BandwidthT HzU k*3gU DESIGN TRADE-OFFS
C1 R C2 g3! S?5@!C5L!K1!5FF1F!@OJJ1DI?C5AAO!5I7GLF!D>1!6I7GLF!
! =>1!L7?@1!A121A!?@!7L1!F1D1IJ?L5LD!78!5CC1A1I7J1D1I! NA5L13!!S?5@!?LCI15@1!D>1IJ5A!?@7A5D?7L!78!D>1!F12?C1!
=>1!N15WPD7PN15W!L7?@1!?@!5NNI7H?J5D1AO!1VG5A!D7!g3g!D?J1@! I1@7AGD?7L3!!=>1!@1C7LF!I1A5D1@!D7!D>1!J15@GI1J1LD! 8I7J!D>1!I1@D!78!D>1!4&_3!
D>1!IJ@!25AG1!T87I!5L!521I561!GLC1ID5?LDO!78!;3*QU3! I1@7AGD?7L!78!D>1!C7GLD1I!B>1L!F1C7F?L6!D>1!FGDO!COCA1! !
! VDA VDD
7GDNGD3!!=>1!5CDG5A!I1@7AGD?7L!78!D>1!5CC1A1I5D?7L!@?6L5A!?@! !
DIGITAL INTERFACE A?J?D1F!KO!D>1!D?J1!I1@7AGD?7L!78!D>1!C7GLD?L6!F12?C1@!G@1F! MEMSIC
Accelerometer
!
=>1!"'()*)+,-/-"-.!?@!15@?AO!?LD1I85C1F!B?D>!A7B!C7@D! D7!F1C7F1!D>1!FGDO!COCA13!!=>1!85@D1I!D>1!C7GLD1I!CA7CWE!D>1! ! !
J?CI7C7LDI7AA1I@3!!`7I!D>1!F?6?D5A!7GDNGD!5CC1A1I7J1D1IE!7L1! >?6>1I!D>1!I1@7AGD?7L!78!D>1!FGDO!COCA1!5LF!D>1!@>7ID1I!D>1! !
Figure 5: Power Supply Noise Rejection
F?6?D5A!?LNGD!N7ID!?@!I1VG?I1F!D7!I15F!7L1!5CC1A1I7J1D1I! =)!N1I?7F!C5L!K1!87I!5!6?21L!I1@7AGD?7L3!!=5KA1!)!@>7B@! !
7GDNGD3!`7I!D>1!5L5A76!7GDNGD!5CC1A1I7J1D1IE!J5LO!A7B!C7@D! @7J1!78!D>1!DI5F1P788@3!!%D!?@!?JN7ID5LD!D7!L7D1!D>5D!D>?@!?@!D>1! !
J?CI7C7LDI7AA1I@!5I1!525?A5KA1!D7F5O!D>5D!815DGI1!?LD16I5D1F! I1@7AGD?7L!FG1!D7!D>1!J?CI7NI7C1@@7I@l!C7GLD1I3!!%D!?@! !
[-(!T5L5A76!D7!F?6?D5A!C7L21ID1I@U!B?D>!I1@7AGD?7L@!I5L6?L6! NI7K5KA1!D>5D!D>1!5CC1A1I7J1D1Il@!L7?@1!8A77I!J5O!@1D!D>1! !
8I7J!b!D7!*)!K?D@3! A7B1I!A?J?D!7L!D>1!I1@7AGD?7L3! !
!! ! !
%L!J5LO!5NNA?C5D?7L@!D>1!J?CI7C7LDI7AA1I!NI72?F1@!5L! ! ! &7GLD1IP! ! ! ! !
!
1881CD?21!5NNI75C>!87I!D>1!D1JN1I5DGI1!C7JN1L@5D?7L!78!D>1! ! "#"$%& &A7CW! &7GLD@ ! 01@7P !
!
@1L@?D?2?DO!5LF!D>1!X1I7!g!788@1D3!$N1C?8?C!C7F1!@1DE!I181I1LC1! ! $5JNA1! 05D1! 41I!=) &7GLD@ AGD?7L
=)!TJ@U 05D1! T"/XU! &OCA1! N1I!g! TJgU !
F1@?6L@E!5LF!5NNA?C5D?7L@!L7D1@!5I1!525?A5KA1!8I7J!D>1! !
85CD7IO3!!=>1!87AA7B?L6!N5I5J1D1I@!JG@D!K1!C7L@?F1I1F!?L!5! ! )3+! Z;;! ! )3;! ! +;;; ! g)+! *3g!
! )3+! Z;;! ! *3;! ! )+;; !:*)3+! :3)! !
F?6?D5A!?LD1I85C1o! !
! )3+! Z;;! ! ;3+! ! *)+; !*+g3:! g3Z!
!
! *;3;! *;;! ! )3;! ! );;;; )+;;! ;3Z!
Resolutiono!@J5AA1@D!F1D1CD5KA1!C>5L61!?L!?LNGD!5CC1A1I5D?7L!
! *;3;! *;;! ! *3;! ! *;;;; ! *)+;! ;3b!
Bandwidtho!F1D1CD5KA1!5CC1A1I5D?7L@!?L!5!6?21L!N1I?7F!78!
! *;3;! *;;! ! ;3+! ! +;;; ! g)+! *3g!
D?J1!
Acquisition Timeo!D>1!FGI5D?7L!78!D>1!J15@GI1J1LD!78!D>1! Table 2: Trade-Offs Between Microcontroller Counter Rate and
5CC1A1I5D?7L!@?6L5A! T2 Period.
!
! CONVERTING THE DIGITAL OUTPUT TO AN
DUTY CYCLE DEFINITION ANALOG OUTPUT
=>1!"'()*)+,-/-"-.!>5@!DB7!4i"!FGDO!COCA1!7GDNGD@! =>1!4i"!7GDNGD!C5L!K1!15@?AO!C7L21ID1F!?LD7!5L!5L5A76!
THEOU3!=>1!5CC1A1I5D?7L!?@!NI7N7ID?7L5A!D7!D>1!I5D?7!=*-=)3!! 7GDNGD!KO!?LD16I5D?7L3![!@?JNA1!0&!8?AD1I!C5L!F7!D>1!
=>1!X1I7!g!7GDNGD!?@!@1D!D7!+;Q!FGDO!COCA1!5LF!D>1! C7L21I@?7L3!.7D1!D>5D!D>5D!D>1!?JN1F5LC1!78!D>1!C?ICG?D!
@1L@?D?2?DO!@C5A1!85CD7I!?@!@1D!D7!*)3+Q!FGDO!COCA1!C>5L61! 87AA7B?L6!D>1!?LD16I5D7I!JG@D!K1!JGC>!>?6>1I!D>5L!D>1!
N1I!g3!!=>1@1!L7J?L5A!25AG1@!5I1!5881CD1F!KO!D>1!?L?D?5A! ?JN1F5LC1!78!D>1!0&!8?AD1I3!0181I1LC1!8?6GI1!Z!87I!5L!
D7A1I5LC1!78!D>1!F12?C1!?LCAGF?L6!X1I7!g!788@1D!1II7I!5LF! 1H5JNA13!
@1L@?D?2?DO!1II7I3!!=>?@!F12?C1!?@!7881I1F!8I7J!D>1!85CD7IO! !
NI76I5JJ1F!D7!1?D>1I!5!*;J@!N1I?7F!T*;;!/XU!7I!5!)3+J@! 10K
N1I?7F!TZ;;/XU3!!! DOUT AOUT
!
=*! ! Y1L6D>!78!D>1!p7Lq!N7ID?7L!78!D>1!COCA13! MEMSIC 1uF
Accel.
=)!T41I?7FU! Y1L6D>!78!D>1!D7D5A!COCA13!
(GDO!&OCA1! 05D?7!78!D>1!p;Lq!D?J1!T=*U!78!D>1!COCA1!D7! !
D>1!D7D5A!COCA1!T=)U3!(18?L1F!5@!=*-=)3! Figure 4: Converting the digital output to an analog voltage
4GA@1!B?FD>! =?J1!N1I?7F!78!D>1!p7Lq!NGA@13!(18?L1F!5@!
=*3!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

"#"$%&!"'()*)+,-"-.-/!0123#! 4561!+!78!9! :-)+-);;+! "#"$%&!"'()*)+,-"-.-/!0123#! 4561!g!78!9! :-)+-);;+!


!
LCC-8 PACKAGE DRAWING
!
!

! Fig 6: Hermetically Sealed Package Outline

"#"$%&!"'()*)+,-"-.-/!0123#! 4561!9!78!9! :-)+-);;+!


Web Site: www.parallax.com Office: (916) 624-8333
Forums: forums.parallax.com Fax: (916) 624-8003
Sales: sales@parallax.com Sales: (888) 512-1024
Technical: support@parallax.com Tech Support: (888) 997-8267

Memsic 2125 Dual-Axis Accelerometer (#28017)


The Memsic 2125 is a low-cost thermal accelerometer capable of measuring tilt, collision, static and
dynamic acceleration, rotation, and vibration with a range of ±3 g on two axes. Memsic provides the
2125 IC in a surface-mount format. Parallax mounts the circuit on a tiny PCB providing all I/O
connections so it can easily be inserted on a breadboard or through-hole prototype area.

Features
y Measures ±3 g on each axis
y Simple pulse output of g-force for each axis
y Convenient 6-pin 0.1” spacing DIP module
y Analog output of temperature (TOut pin)
y Fully temperature compensated over 0 to 70 °C
operating temperature range

Key Specifications Application Ideas


y Power Requirements: 3.3 to 5 VDC; y Dual-axis tilt and acceleration sensing
< 5 mA supply current for autonomous robot navigation
y Communication: TTL/CMOS y R/C tilt controller or autopilot
compatible 100 Hz PWM output signal y Tilt-sensing Human Interface Device
with duty cycle proportional to
acceleration
y Motion/lack-of-motion sensor for
alarm system
y Dimensions: 0.42 x 0.42 x 0.45 in
y Single-axis rotational angle and
(10.7 x 10.7 x 11.8 mm)
position sensing
y Operating temperature: 32 to 158 °F
(0 to 70 °C)

Theory of Operation
The MX2125 has a chamber of gas with a
heating element in the center and four
temperature sensors around its edge.
When the accelerometer is level, the hot
gas pocket rises to the top-center of the
chamber, and all the sensors will measure
the same temperature.

By tilting the accelerometer, the hot gas will collect closer to some of temperature sensors. By
comparing the sensor temperatures, both static acceleration (gravity and tilt) and dynamic acceleration
(like taking a ride in a car) can be detected. The MX2125 converts the temperature measurements into
signals (pulse durations) that are easy for microcontrollers to measure and decipher.

Copyright © Parallax Inc. Memsic 2125 Dual-Axis Accelerometer (#28017) v2.0 1/29/2009 Page 1 of 3
Pin Definitions
For Memsic MXD2125GL pin ratings, see the manufacturer’s datasheet posted on the 28017 product page
at www.parallax.com.

Pin Name Function


1 Tout Temperature Out
2 Yout Y-axis PWM output
3 GND Ground -> 0 V
4 GND Ground -> 0 V
5 Xout X-axis PWM output
6 VDD Input voltage: +3.3 to +5 VDC

Communication Protocol
Each axis has a 100 Hz PWM duty cycle output in which acceleration
is proportional to the ratio tHx/Tx. In practice, we have found that
Tx is consistent so reliable results can be achieved by measuring
only the duration of tHx. This is easy to accomplish with the BASIC
Stamp PULSIN command or with the Propeller chip’s counter
modules.

With Vdd = 5V, 50% duty cycle corresponds to 0 g, but this will vary
with each individual unit within a range of 48.7% to 51.3%. This
zero offset may be different when using Vdd = 3.3 V. See the
manufacturer’s datasheet for details.

Example Circuit
The example schematic and wiring diagram below are for the BASIC Stamp and Board of Education.

The program below, SimpleTilt.bs2, simply measures the pulse width, that is, the duration of tHx, for
each axis. The raw values are displayed in the BASIC Stamp Editor’s Debug Terminal. If you run the
program, then tilt the accelerometer, you should see the values for each axis change.

Copyright © Parallax Inc. Memsic 2125 Dual-Axis Accelerometer (#28017) v2.0 1/29/2009 Page 2 of 3
' Smart Sensors and Applications - SimpleTilt.bs2
' Measure room temperature tilt.

'{$STAMP BS2}
'{$PBASIC 2.5}

x VAR Word
y VAR Word

DEBUG CLS

DO

PULSIN 6, 1, x
PULSIN 7, 1, y

DEBUG HOME, DEC4 ? X, DEC4 ? Y

PAUSE 100

LOOP

Programming Resources and Downloads


BASIC Stamp
y Smart Sensors and Applications — The BASIC Stamp example above is taken from the Stamps in
Class text Smart Sensors and Applications, which features several chapters specific to the Memsic
Dual-Axis Accelerometer. Topics include output scaling and offset, measuring vertical rotation, tilt-
controlled video gaming basics, data logging g-force during a skateboard trick, and data logging
acceleration on an RC car. The book and sample code can be downloaded from the 28029 product
page at http://www.parallax.com

y Boe-Bot Robot Projects with the Memsic 2125 Accelerometer — The following projects with
source code are posted under the Stamps in Class Mini-Projects sticky-thread in the Stamps in Class
Forum at http://forums.parallax.com:
o Boe-Bot Robot Navigation with Accelerometer Incline Sensing
o A Tilt Radio Controller for Your Boe-Bot
y The Memsic 2125 Demo Kit BASIC Stamp Source Code — this source code contains conditional
compile directives that allow it to be used with the BS2, BS2e, BS2sx, BS2p, and BS2pe.

Propeller Objects
Several Memsic 2125 Accelerometer code objects and applications
for the Propeller chip are available in the Propeller Object Exchange
(http://obex.parallax.com).

Below is a photograph of the high-speed Memsic MXD2125


Accelerometer Demo in action. This application “provides a high
speed assembly driver, and separate-cog and same-cog Spin
versions of the MXD2125 Dual Axis Accelerometer. The high speed
version displays the data on a television as a 3D wireframe plane
with normal vector.

Copyright © Parallax Inc. Memsic 2125 Dual-Axis Accelerometer (#28017) v2.0 1/29/2009 Page 3 of 3
Appendix M

Debugging: Serial Monitor vs. DBUG12

M-1
http://www.evbplus.com/Code_Warrior_hcs12.html

Back to main page

CodeWarrior is a very powerful and professional IDE. The main feature of CodeWarrior IDE is the
source level debugger in assembler and C. CodeWarrior Special Edition is a wonderful gift from
Freescale to all of us and it's free for educational use. What's more, by CodeWarrior supporting
serial monitor, they have made it very affordable to support CodeWarrior for the OEM.

Freescale has invested millions of dollar into CodeWarrior and the current versions work very well.
What's more, Freescale knows they will never sell enough copies of CodeWarrior to make back
what they have invested. They did it to drive chip sales.

As a software developer, the first thing you look at is available tools and what it will cost.
There are many companies making MCU chips these days and for the most part they all have
about the same features at a similar price. Special Edition CodeWarrior sets Freescale apart from
others. There is no any MCU chip maker offers you a such first class C source level
debugger free of charge.

CodeWarrior IDE does not work with D-Bug12, but it works with serial monitor. Before Freescale
created the serial monitor a BDM is needed as an interface between the PC and HCS12. Freescale
created the serial monitor for working with CodeWarrior to eliminate the cost of a BDM.

Now a student can use the serial monitor with CodeWarrior to debug his programs and in fact,
many universities have been using the serial monitor with CodeWarrior without a BDM in their
classrooms.

Without spending money on a BDM, a student will be able to spend his savings on purchasing a
more advanced trainer, like the Dragon12-Plus board with many on-board peripherals. Purchasing
an EVB board that comes with a BDM at a reasonable price, most likely leaves the student with an
EVB of only limited functionality.

Some universities use D-Bug12 monitor first, then replace the D-Bug12 monitor with serial
monitor to be used with CodeWarrior IDE. In this case, a school laboratory only needs to have
one BDM or use one Dragon12 board as a BDM POD, to program all students' boards with serial
monitor.

To replace bootloader and D-Bug12 monitor with serial monitor, you need a BDM or a BDM POD to
perform the task. The procedure to program the on-chip flash memory is provided at:
www.evbplus.com/TinyBDM_9s12/TinyBDM_9s12.html

Some universities use CodeWarrior IDE only. In this case, we pre-load the on-chip flash memory
with serial monitor.

A quick check of monitor type on your board:

For the Dragon12 and Dragon12 Plus boards:

If your board is pre-installed with D-Bug12 monitor, the Port B LED indicators will light up from left to right one
at a time and the speaker will chirp once when the board is turned on. If the chirp is too soft you can remove the
sticker on the speaker to increase the volume.

Wytec Evaluation Boards: EVBplus


http://www.evbplus.com/Code_Warrior_hcs12.html

If you ordered the board with serial monitor for Code Warrior, it would be pre-installed with serial monitor and a
factory test program. The state of the left switch of the 2-position DIP switch (S7) is tested by the serial monitor
for selecting RUN or LOAD mode during power up or reset, and the Port B LED indicators will light up from right
to left one at a time and the speaker will chirp once to indicate that the serial monitor is functioning.

If the left switch is placed in "LOAD" mode (in the "low" position) the monitor will wait for a command from PC.

If the left switch is placed in "RUN" mode (in the "up" position) the LED indicators will light up again from left to
right to indicate that the program execution is diverted to the user code.

Code Warrior communicates with serial monitor only in LOAD mode and so in order to interface with Code
Warrior you have to reset the left switch in the “low “position. The Port B LED indicators will light up from right to
left one at a time and the speaker will chirp once when the board is turned on.

If the serial monitor is not installed or erased by a BDM, the LED indicators will not light up one at a time during
power up or reset.

For the MiniDragon+ and MiniDragon Plus2 boards:

If your board is pre-installed with D-Bug12 monitor, it will display the diagnostic code “E-4-3” on the 7-segment
LED and the speaker will chirp once when the board is turned on. The code character "E" stands for EVB mode.

If you ordered the board with serial monitor for Code Warrior, it would be pre-installed with serial monitor and a
factory test program. The state of the left switch of the 2-position DIP switch (S7) is tested by the serial monitor
for selecting RUN or LOAD mode during power up or reset.

If the left switch is placed in "LOAD" mode (in the "low" position) the monitor will display the diagnostic code
“S-4-3” on the 7-segment LED and the speaker will chirp once and then wait for a command from PC.

If the left switch is placed in "RUN" mode (in the "up" position) the monitor will display the diagnostic code
“U-4-3” on the 7-segment LED and the speaker will chirp once to indicate that the program execution is diverted
to the user code.

The code character "U" stands for running a User program and the code character "S" is displayed as the
number "5" and stands for Serial monitor.

Code Warrior communicates with serial monitor only in LOAD mode and so in order to interface with Code
Warrior you have to reset the left switch in the “low “position. It will display the diagnostic code “5-4-3” on the
7-segment LED and the speaker will chirp once when the board is turned on

If the serial monitor is not installed or erased by a BDM, the LED indicators will not light up one at a time during
power up or reset.

Useful links for learning Code Warrior:

Wytec Evaluation Boards: EVBplus


http://www.evbplus.com/Code_Warrior_hcs12.html

Finally, the first book written exclusively for the CodeWarrior has
arrived.

Dr. Richard Haskell and Dr. Darrin Hanna have completed a new book for learning to program
in C using CodeWarrior. The book includes sample programs tested on our Dragon12-Plus and
the MiniDragon-Plus2 boards. The CodeWarrior itself can be daunting, but their book will make it
easy for you to learn what you need to get your project up and running quickly.
You can find a description of the book at this website: http://www.lbebooks.com/index.htm

The CodeWarrior stationery file for the Dragon12-Plus and MiniDragon-Plus2 can be used in two
new books "Learning by example using C - Programming the Dragon12-Plus using CodeWarrior"
and "Learning by example using C - Programming the MiniDragon-Plus2 using CodeWarrior". The
books are written by professors Richard Haskell and Darrin Hanna at Oakland University.

Instructions of how to download Code Warrior from Freescale's web site and CodeWarrior
tutorial can be found at Professor Paterno's web site:
http://web.njit.edu/~paterno/ECET310/T3-CodeWarrior%20Simulator.pdf

The CodeWarrior project setup procedure can be found at Professor Jeff Sumey's web site:
http://www.aet.cup.edu/~jsumey/cet360/cwintro/cwintro.html

The Code Warrior tutorial: http://www.microdigitaled.com/HCS12/HCS12_books.htm

The most resourceful “CodeWarrior for the Dragon12 trainer” web site:
http://www.mecheng.adelaide.edu.au/robotics/wpage.php?wpage_id=56

The mechanical engineering of University of Adelaide in Australia is awesome. Here you can see
what their students have achieved in so many great projects:
http://www.mecheng.adelaide.edu.au/news/

Following is the web site for downloading the free CodeWarrior:


http://www.freescale.com/webapp/sps/site/overview.jsp?nodeId=01272600610BF1
Special edition version 5.1 for HCS12(X) ( Classic, Windows hosted )
Special edition version 6.3 for RS08/HC(S)08 and CF V1 ( Classic, Windows hosted )

Wytec Evaluation Boards: EVBplus


http://www.evbplus.com/Code_Warrior_hcs12.html

The size of either file is quite large. It will take a few hours to download, so you should first save it
on your hard drive in case you need to install it in another PC.

Following is the web site for downloading the CodeWarrior full edition for a 30-day free evaluation:
http://www.freescale.com/webapp/sps/site/overview.jsp?nodeId=01272600612247

Wytec Evaluation Boards: EVBplus


M-6 Edit Date: February 12, 2013
Appendix N

The HC12 Serial Debugger

N-1
13
HCS12 Serial Monitor
Connection
This section provides information about debugging with the CodeWarrior IDE and the
HCS12 Serial Monitor connection.

Serial Monitor Technical Considerations


When the debugger runs the HCS12 Serial Monitor connection, it can communicate and
debug hardware running the HCS12 Serial Monitor in full compliance with the Freescale
Application Note AN2548 specifications, and AN2548SW1 and AN2548SW2 software.
Refer to this Application Note for communication hardware requirements.

CodeWarrior IDE and Serial Monitor


Connection
You can access the HCS12 Serial Monitor connection in two different ways when using
Codewarrior IDE. You either:
• Use the Stationary Wizard at the start of the project to set the connection, or
• Set the connection from within an existing project.
These paths are explained in the Debugger Interface chapter of this manual.

HCS12 Serial Monitor Interface


Follow these steps to use the HCS12 Serial Monitor connection:
1. Run the CodeWarrior IDE with the shortcut created in the program group.
2. Create a project (see the Debugger Interface chapter of this manual).
3. Choose Project > Make and Project > Debug to start the debugger.
Debugger Main window opens.

HC(S)12(X) Debugger Manual 401


HCS12 Serial Monitor Connection
HCS12 Serial Monitor Interface

Figure 13.1 Debugger Main Window - Component Menu

4. In the debugger main window, choose Component > Set Connection to select another
connection.

Figure 13.2 Set Connection Dialog Box - HCS12 Serial Monitor Selection

5. Select HC12 as Processor, then HCS12 Serial Monitor as connection in the Set
Connection dialog box.
6. Click the OK button.
The Monitor Setup dialog box appears.
7. In the Monitor Setup dialog box Monitor Communication tab, choose the correct Host
serial communication port if necessary.

402 HC(S)12(X) Debugger Manual


HCS12 Serial Monitor Connection
HCS12 Serial Monitor Interface

Figure 13.3 Monitor Setup Window - Monitor Communication Tab

8. Press the OK button.


The HCS12 Serial Monitor connection reads the device silicon ID and opens the
Derivative Selection dialog box. The device silicon ID can match several derivatives.
9. Select the derivative that matches your hardware in the Derivative Selection dialog
box.
If debugger is aware about PARTID returned by the connected derivative then you can
filter derivative list by PARTID.

Figure 13.4 Set Derivative Dialog Box

If debugger has no information about PARTID returned by the connected derivative


then CPU specific derivative list is used.

HC(S)12(X) Debugger Manual 403


HCS12 Serial Monitor Connection
HCS12 Serial Monitor Interface

Figure 13.5 Set Directive Dialog Box

10. Press the OK button.


The Monitor Setup dialog box opens again.
11. Click on the Vector Table Mirroring tab.

NOTE We recommend that you use the Vector Table Mirroring feature. Otherwise,
you cannot program vectors as captured or protect them from erasure or
overwriting by the HCS12 Serial Monitor.

Figure 13.6 Monitor Setup Dialog Box - Vector Table Mirroring Tab

12. To enable this feature, check the Enable Vector Table Mirroring checkbox.

404 HC(S)12(X) Debugger Manual


HCS12 Serial Monitor Connection
HCS12 Serial Monitor Interface

Figure 13.7 Monitor Setup Dialog Box - Vector Table Mirroring Tab

13. Click Auto Detect to make the debugger search for the vector table address and
vectors reserved by the HCS12 Serial Monitor.
14. Once automatic detection succeeds, press OK to start debugging.

MONITOR-HCS12 Menu Options


Once you set the HCS12 Serial Monitor connection, MONITOR-HCS12 appears in the
Debugger menu, as shown below.

Figure 13.8 MONITOR-HCS12 Menu Options

HC(S)12(X) Debugger Manual 405


HCS12 Serial Monitor Connection
HCS12 Serial Monitor Interface

Table 13.1 MONITOR-HCS12 Menu Options

Menu Entry Description

Load Displays Load Executable File dialog box (see Load Executable File
Window).

Reset Resets connection hardware and software.

Setup Displays Setup dialog box.

Communication Displays Monitor Setup dialog box, containing Monitor


Communication tab and Load Options tab.
• In Monitor Communication tab (Figure 13.9), set or modify
current serial communication from HOST Serial
Communication Port list box.
Check Show Monitor TX/RX to report all low-level
communication frames between host computer and HCS12
Serial Monitor in Command Line window.
• In Load Options tab (Figure 13.10), use checkbox to
enable or disable automatic erase of Flash memory on
loading.

Command Files Opens Connection Command Files dialog box. Each tab allows
access to a different set of connection command files:
\cmd\HCS12_Serial_Monitor_startup.cmd
\cmd\HCS12_Serial_Monitor_reset.cmd
\cmd\HCS12_Serial_Monitor_preload.cmd
\cmd\HCS12_Serial_Monitor_postload.cmd

Debugging Opens Debugging Memory Map dialog box for target MCU (see
Memory Map Debugging Memory Map).

Trigger Module Opens Trigger Module Settings dialog (see HCS12 On-Chip DBG
Settings Module or HCS12X On-Chip DBG Module).

Bus Trace Opens Trace component window within the main window (see
HCS12 On-Chip DBG Module or HCS12X On-Chip DBG Module).

406 HC(S)12(X) Debugger Manual


HCS12 Serial Monitor Connection
HCS12 Serial Monitor Interface

Figure 13.9 Monitor Setup Dialog Box - Monitor Communication Tab

Figure 13.10 Monitor Setup Dialog Box - Load Options Tab

HC(S)12(X) Debugger Manual 407


HCS12 Serial Monitor Connection
HCS12 Serial Monitor Interface

408 HC(S)12(X) Debugger Manual


N-10 Edit Date: February 12, 2013
Appendix O

9s12 Resource List & Codewarrior Programming


“Short Courses”

There are a number of good books to use for reference.

1. Freescale Compiler Tools Manual (C programming with Codewarrior): [5]

2. Freescale Assembler Tools Manual (Assembler with Codewarrior): [2]

3. MC9s12C User Manual: [3]

4. University-grade courseware from Freescale http://www.freescale.com/webapp/search/Serp.jsp?QueryText=


mc9s12c&assetIdResult=&fsrch=1&sessionChecker=Z5SSMztRfjSZgMCW8s3RBm5HNmNdYnsZpxjsTFpJpTb230ncv
21-1829371026%211291038001264&attempt=1&showCustomCollateral=false&RELEVANCE=true&Documentation
Documentation%2F310JFPZ20JCX%60%60University+Courseware&fromTrng=false&showAllCategories=
false&fromMobile=false&isResult=false&isFromFlex=false&isTree=false&pageSize=25&fromASP=
false&isAdvanceSearch=false&getTree=false&fromPSP=false&lastQueryText=mc9s12c&SelectedAsset=
Documentation&iteration=1&assetLocked=false&assetLockedForNavigation=false&fromCust=false&getFi
false&fromDAP=false&fromWebPages=false&getResult=false&isComparison=false

5.

O-1
http://wiki.mdmsolutions.org/index.php/9s12c32MemoryMap

9s12c32MemoryMap Md m S o lu tio n sWik i


HomePage
RecentChanges

Ed itin g
Edit this page
CREDITS
In fo rm a tio n
Last edited on February 18,
These notes were sent to me by Eric Engler, in 2007
discussion of BinLoad. For more information, PageHistory
PageInfo
please see his website.
S ea rc h
Notes on the 9S12C32
Memory Map
LikePages
Although written for the 32K flash 9S12C32, these notes are
helpful in understanding the basic 9S12 memory paging mechanism
and many of these notes apply to other 9S12 devices, also.
User info

$0000: control register block. Although you can re-map these


registers to live at a different address, most people
leave them here so zero page addressing can be used to
address the control registers that live in the lowest
256 addresses.

$3800: 2K of RAM: 3800 - 3fff


SP should be set to $4000, so it uses the top part of RAM

NOTE: AN2548 says the stack needs 35 bytes of storage for its
own use. This is often misunderstood - they are NOT
asking us to reserve the top 35 bytes for use by the
SerMon, but rather they are going to use the same
stack used by the end-user program, and the max no.
of bytes the SerMon will put on the stack is 35 bytes.
So it's safe to allocate the stack starting from the
higest avail. RAM location (SP must start one byte
higher than the top of RAM - typically $4000).

NOTE: Unlike d-bug12, there is no pseudo vector table in


RAM. The pseudo vector table goes into flash at
$f780 - f7ff.

$4000: 16K fixed flash block (PPAGE block $3E). This is where user
programs will often go. This is not shared with any other
function (the $c000 block is shared with vectors and the
SerMon itself)

$8000: 16K page window. This is a mirror of the flash at 4000 if


PPAGE holds $3e (which is the case in run mode). This can
also mirror the $c000 block if PPAGE holds 3f,but there's

MdmSolutionsWiki - 9 s12 c32 MemoryMap


http://wiki.mdmsolutions.org/index.php/9s12c32MemoryMap

not much value in doing it this way.

The bane of all newbies to the C32 family is this hole


between the two 16K blocks: the $4000 and $c000 blocks are
separated by this $8000 page window. People who compile C
programs want one big contiguous space of flash memory to
hold their text (program code) segment, since it's difficult
to break up their output code into two separate flash ranges.
This isn't a big concern for Assembly language developers
because they can easily design their memory usage to straddle
this window.

Karl Lunt solved this "hole in the middle" problem by making


use of the mirroring of the $4000 block at $8000 at runtime.
The user program gets "org'd" at $8000 during assembly/compile
time, and his binload program burns it into two separate
regions ($4000 and $c000). He remaps the lower 16K of .s19
records for flash burning purposes so those records are
burned into the $4000 block (instead of the $8000 block as
requested by the .s19 records). All internal address
references in the user program are based on the runtime
contiguous block of nearly 30K ($8000 - f77f). This is how
he eliminates the hole between the two 16K blocks of flash.

Karl's trick will probably work during execution in the debug


mode (with the serial monitor active), but Pluto would have
to ensure that PPAGE holds $3e when it runs a program. And
the user program would be org'd at $8000 and the pseudo
vectors would have to point into the range of $8000 - f77f.

$c000: 16K fixed flash block (PPAGE block $3F)


There's almost 14K of flash for user programs: $c000 - f77f.
The upper 128 bytes of this 14K is for pseudo vector table:
$f780 - f7ff. The highest 2K of flash is reserved for the
serial monitor: $f800 - $ffff

The 64K addressing range is called the logical address range (this is
the address range used by the PC/SP/IX/IY, etc). The type of address
that uses the PPAGE addressing scheme to reference flash blocks using
their native internal address is called a physical address.

A physical address is always required when programming flash, since


there can be a lot more flash than can be addressed with 64K (at least,
in some higher-end MCU's other than the 9s12C32). Freescale's internal
flash programming code always requires physical addresses. A physical
address is 20 bits long, so you'll see 5 hex digits in a physical
address. Since 20 bits is not an even multiple of 8 bits, you'll often
see a 24 bit address, just to make it line up on byte boundaries but
upper 4 bits isn't used (prior to the S12X, anyway).

I don't want to confuse anyone here, but I should mention that there's
two types of physical address schemes. The "paged" scheme simply uses
the PPAGE value as the high order byte. This means there's a gap
between $ffff (highest 64K address) and $3d0000 (lowest paged address).
A user program gets burned into flash from $3d0000 to $3dffff, and then
from $3f0000 to $3fffff. The CodeWarrior tool chain uses this scheme.

The "linear" scheme uses an equivalent address that builds up from the
64K range, and has no hole. The D-bug12 bootloader and the P&E tools
use this scheme. With this model you can just keep incrementing the

MdmSolutionsWiki - 9 s12 c32 MemoryMap


http://wiki.mdmsolutions.org/index.php/9s12c32MemoryMap

address one byte at a time from $00000 to $fffff (less than this,
depending on how much flash your chip has), with no holes in the middle.
Many modern debuggers and flash burning programs that run on the PC can
translate a paged address file on the fly, or the SRecCvt program can be
used to translate a paged .s19 file to a linear .s19 file. Why would
you want to translate? Because the CodeWarrior chain (and possibly
others) will generate paged addresses and you may need linear addresses
for use with the bootloader, or P&E tools, etc. P&E has their own
translation program called logtophy (logical to physical). Sometimes
people will use a different extension for a linear file: I've seen .s2
in some cases, but there is no widely used convention for this, so you
can't be sure which scheme is in use if you see a file with an .s19
extension.

The memory window at $8000 seems unimportant on the C32 since you can
directly address the entire 32K of flash using logical 64K addresses at
runtime (aside from the case of programming flash, as mentioned above).
However, you can still use the memory window and there can be a benefit
in using it. If you store $3E in the PPAGE register at address $0030,
then the $4000 block of flash will also be seen at $8000. Similarly, if
you store $3F in the PPAGE register, then the $C000 block will also be
visible at $8000. Of course, since these 2 flash blocks are also fixed,
you'll continue to see them at $4000 or $C000. The window at $8000, in
effect, results a 16K hole between the two fixed blocks of flash, but
you can use Karl's trick as mentioned above to treat this as one big
block of 30K.

Startup Code
One important factor that needs to be considered when you have a program
in flash that will run upon startup (switch in Run position): you must
have some initialization code to configure a few things before the main
program runs. You have to map the control registers and RAM, and then
set SP at the top of RAM. You should also set the PLL frequency. If
you're using gcc, the startup code has to be patched. I have a complete
demo project in my EmbeddedGNU Windows IDE, including the modified gcc
startup code. There's also code for the reset vector so your program
will execute upon powerup. You can use my code even if you don't want
to use my IDE. Be sure to look at the help file for some more info on
the C32.

Serial Monitor Notes


We have some vectors at the top of our usable flash range in the area
just below $F800. This is our own vector table that we define.
Interrupts are handled first by the serial monitor (which has firmware
hooks just below $ffff), and then flow is directed to our own vectors
(just below $f800) so our code can handle the interrupts.

However, the serial interupt is dedicated for use by the serial monitor
if running in boot mode (monitor mode). It uses these interrupts to let
it steal some MCU clock cycles so it can execute our debug commands and
send back the results. This is an invasive style of debugging because
the timer in the MCU still ticks away while the serial monitor is
running - this can cause trouble if our program is using the timer for
its purposes. It's a reasonable trade-off to make in order to get
low-cost debugging over the serial port. In cases where we need less

MdmSolutionsWiki - 9 s12 c32 MemoryMap


http://wiki.mdmsolutions.org/index.php/9s12c32MemoryMap

invasive debugging, we need to use a BDM device. While in active BDM


mode to execute debug commands, the timer is temporarily halted. This
makes it easier to debug programs that are aware of the passage of time.
But even this isn't perfect if you're interacting with high speed
external devices that can't be halted - like Ethernet on the NE64, for
example.

If we run in boot mode then the serial monitor, while still present in
flash, is not actually active. However, the vectors just below $f800
are still used in the boot mode because we're not allowed to modify the
protected flash range where the serial monitor lives ($f800 - $ffff).
How does the C32 MCU know that it's supposed to use our vectors and not
the serial monitor vectors if we're running in the boot mode? Because
the serial monitor has firmware vectors in place that will trap all of
the interrupts, and it will direct those interrupts to the new vector
table if the serial monitor is not active. Even the serial port
interrupt, normally used only by the serial monitor in program mode, is
redirected to our own vector table in boot mode.

To make our lives easier, if we code interrupt vectors at an ORG in


the $ffxx memory block, the serial monitor routines automatically
remap our own addresses to the $f7xx range when we program the flash.
So as far as our source code is concerned, it looks like we're putting
our vectors right over the top of the serial monitor vectors. This is
"by design" - they wanted it to look like our program will have
complete control, and this is really the case in boot mode.

Notice: "Array to string conversion" (...repeated 9 times)

MdmSolutionsWiki - 9 s12 c32 MemoryMap


The following are useful “short courses” offered by Freescale for learning about the HCS12 / 9s12.

O-6 Edit Date: February 12, 2013


Reading this Document

Answers provided to the Instructor assume that the reader is using Freescale HCS12C Family Student Learning Kit,
and CodeWarrior development software.

This short course has been created using an adapted version of the Process Oriented Guided Inquiry Learning (POGIL)
method. For more information visit www.pogil.org

Laboratory Short Course

Introduction to CodeWarrior™ –
Simulating the Microcontroller in
Assembly Language

www.freescale.com/universityprograms

Freescale™ and the Freescale logo are trademarks of Freescale Semiconductor, Inc.
All other product or service names are the property of their respective owners
© Freescale Semiconductor, Inc. 2006.
Document Number: LABS12CINTRO03S /REV 1 Freescale Semiconductor LABS12CINTRO03S, Rev 1 1
Page 3: Check the language support you want (Assembly) and click Next.
Overview
Page 4: Check Relocatable Assembly.
A laboratory experience is vital for us to be able to start programming the microcontroller and to be able to really understand how it
works and to apply it in embedded system designs. This module shows the student how to enter an assembly language program in Page 5: Check Full Chip Simulation and P&E Multilink/Cyclone Pro and click Finish.
the CodeWarrior® integrated development environment and then to simulate its execution using the True-Time simulator/debugger. In the Project Manager Window

4. Switch to the Full Chip Simulation for debugging by clicking the pull down arrow and selecting Full Chip Simulation. (This
Learning Objectives does not use the hardware for debugging. If you want to actually use the HCS12 hardware, choose P&E Multilink Cyclone
In this module we introduce you to the CodeWarrior® programming environment. We will see how to start the system and enter a Pro.)
program to be run with the debugger. In the next module we will give you a program and you will start to learn to use the HCS12
instruction set by modifying if to change how it operates.

Success Criteria
At the end of this module you will be able to assemble a program and to run and debug it with the CodeWarrior simulator/debugger.

Prerequisites
You must know about the HCS12 instruction set and the memory addressing modes available. You do not have to know the
instruction set in detail. The following lab modules will help you learn that.

More Resources and Further Information 5. Create listing files by opening the Simulator Settings panel by clicking the icon shown above.
Cady, Fredrick M., Software and Hardware Engineering: Assembly and C Programming for the Freescale HCS12
a. Click on + next to Target in the Target Settings.
Microcontroller, 2nd edition. (New York: Oxford University Press, Inc., 2008). Chapter 5 An Assembler Program, Chapter 6 The
Linker, Chapter 7 The HCS12 Instruction Set. b. Highlight Assembler for HC12 and in that panel click on Options.

Smart Linker, Metrowerks Corporation, Austin, TX, 2003. (i) Check Generate a listing file.

Debug (DBG) Module V1 Block User Guide, S12DBGV1/D, Freescale Semiconductor, 2003. (ii) Check Object File Format. Choose ELF/DWARF 2.0 Object File Format.

MC9S12C128 Data Sheet: Covers MC9S12C Family and MC9S12GC Family, Freescale Semiconductor, Austin, Texas, 2005. (iii) Click OK.

Montañez, E. and Ruggles, S., MCUSLK_CSM12C32 - Getting Started with the Microcontroller Student Learning Kit c. Click OK.
(MCUSLK), Freescale Semiconductor, Austin, Texas, 2005.
6. Open the Sources folder (click on the + if it is not open).
Sibigtroth, J. M., CPU12RM/AD rev. 3 – CPU12 Reference Manual, Freescale Semiconductor, Austin, Texas, 2002.
7. Double click on main.asm and enter the following code after the comment
Williams, J., AN2548SW1 – CodeWarrior Project Software files for AN2548/D, Freescale Semiconductor, Austin, Texas, 2003.
; Your program code goes here.
Debugger HCS12 Onchip DBG Module User Interface, Metrowerks, 2003.
; Your program code goes here
; Initialize I/O
Using the CodeWarrior® Simulator main_loop:
; DO
1. Launch the CodeWarrior IDE. nop ; A "no operation" operation
a. From the Windows desktop, click Start > Programs > Freescale CodeWarrior > CW for HC12 Vx.x > CodeWarrior IDE. ldx #ConstData ; Initialize X with an address
ldab #$02 ; Initialize a counter with data
2. Create New Project. ; Load and store data in a loop
a. From the IDE main menu bar, select File > New. New window appears.
loop:
ldaa 0,x ; Get the data
b. Highlight HC(S)12 New Project Wizard. staa VarData ; Store it in RAM
ldaa 2,x ; Get another byte
c. Enter a Project Name that makes sense to you (like lab_x).
staa VarData+1 ; Store it
d. Enter a Location for the project. This should be on a drive or in a directory where you want to keep your HCS12 projects. inx ; Increment the pointer
decb ; Decrement the counter
e. Click OK. bne loop ; Loop until B = 0
3. In the New Project Wizard nop
; Forever
Page 2: Select MC9S12C32 (or your derivative) as the derivative you want to use and click Next. bra main_loop

Freescale Semiconductor LABS12CINTRO03S, Rev 1 2 Freescale Semiconductor LABS12CINTRO03S, Rev 1 3


;************************************************************** a. Click on the Add New Text File icon:
MyConst:SECTION
; Place constant data here
ConstData: DC.B $0a,$0b,$11,10
;**************************************************************
MyData: SECTION
; Place variable data here
VarData: DS.B 2 ; Two bytes of storage
b. Edit the file.
8. Save it to whatever name you want: File > Save As. (Make sure you give it an .asm filename, or you can just use the main.asm
file if you want.) c. File > Save As (use .asm as the extension for assembler files).
d. Add it to the project: Project > Add *.asm to the project. In Add Files check both Full Chip Simulation and P&E Multilink
9. Check to make sure debugging information is going to be generated. Cyclone Pro.
a. In the Project Manager Files window, check to see that there is a • in the rightmost column under the bug icon. e. Assemble/Compile it: Project > Compile.

13. View the linker parameter file.


a. Click the + next to Prm and double click the Full_Chip_Simulation_linker.prm file to open it in the editor.

Explore 2.

The linker parameter file allows us to locate the various parts of the program in the proper sort of memory. For example, all code
and constant data must be in ROM and variable data and the stack in RAM.

1. Look at the SEGMENTS portion.


10. Assemble the file to check for errors:
a. What memory locations are used for RAM?
a. Click on Project > Compile.
b. Where memory locations are used for ROM?
b. Correct any errors.
2. Look at the PLACEMENT portion. A variety of default placement options are included. We are interested in where the
DEFAULT_ROM (code and constant data SECTIONS in our assembly program) and the DEFAULT_RAM (variable data
SECTION) will be located.
11. Have a look at your list file.
a. In what memory locations will the code and constants be located?
a. File > Open and position to the bin folder in your project and open the .lst file.
b. In what memory locations will the variable data be located?
Explore 1.
Stimulate 2.
1. How many bytes are in the program and constant data?
1. What change would you make to the linker parameter file if the target hardware had RAM in memory locations $1000 - $1FFF
2. You cannot tell from this listing in what memory locations the VarData variable bytes will be located. Why not? (0x1000 – 0x1FFF)?
3. What op code (in hexadecimal) is generated for a nop instruction? 2. What change would you make to the linker parameter file if you wanted to locate the code and constants in memory starting at
$4000 (0x4000)?
4. Do any of the labels in the program generate any code bytes?

Stimulate 1. 14. Make the project.


1. Why does the instruction ldx ConstData assemble to CExx xx? a. Project > Make or click on the icon
2. What are the four bytes (in hexadecimal) assembled as constant data bytes by the assembler directive DC.B?

3. In the ConstData why does DC.B produce different data bytes for $10 and 10?

b. Correct any linking errors.

15. Inspect the Linker Map file.


a. Click the + on Linker Map and open Full_Chip_Simulation.map.

Explore 3.
In future lab exercises you may wish to add other source files to your project. Here is how you do that.
STARTUP SECTION
12. Add other source files to the relocatable files in the project:

Freescale Semiconductor LABS12CINTRO03S, Rev 1 4 Freescale Semiconductor LABS12CINTRO03S, Rev 1 5


1. What is the starting address of the program? 2. Click the Green Start/Continue Arrow or click Run > Start/Continue. The program should run to your breakpoint and stop.
(Note: A breakpoint stops the program before it executes that statement.)
SECTION-ALLOCATION SECTION
3. Now, step through your program one assembly language statement at a time by clicking on the single-step button or pressing
2. What number base is used to tell you the size of the various sections?
F11 until you reach the nop instruction
3. How many bytes of ROM are used by this program? at the beginning of the program again.
(We will see what the LDS instruction is
4. How many bytes of RAM are used by this program?
all about later.)
OBJECT-ALLOCATION SECTION
4. At each step inspect the Register window to see what is happening to the registers. Try to predict what will happen at each
5. What is the memory address of the label main_loop? step BEFORE you click on the step button.
6. What is the memory address of the label loop? Stimulate 3.
7. In what memory locations would you find MyData? 1. Under what circumstances does it make sense to run and debug your programs in the simulator?

2. When would you want to run and debug your programs using the hardware debugger?
16. Run the program without the PBMCUSLK using the CodeWarrior True-Time Simulator.
Skill Exercise 1
a. Make sure Full_Chip_Simulation is shown in the Project Manager pull down window as shown in step 4 above.
1. Double click on each of the register boxes in the Register window and enter a value of zero for each register. You won't be
b. Launch the True-Time Simulator by Project > Debug, F5, or clicking on the icon
able to change the CCR.
2. Press the Reset Target button (or type control-R) to return the program to the initial reset state.

3. Single-step through the program and complete a table showing the result of each instruction. The CCR (Condition Code
Register) bits NZVC are shown bold when the bit is set.
If a loader warning appears click OK.
Instruction D A B IX IY PC SP NZVC
c. If Simulator is not the debug target, click on Component > Set Target and chose Simulator Target Interface and click
OK. Reset state 0000 00 00 0000 0000 C000 FFFE 0000

d. If your program has not been loaded, or you want to reload it, click Simulator > Load and load bin\simulator.abs. lds
#__SEG_END_SSTACK
e. You can use all the features of the simulator on the code.
nop
Explore 4.
ldx #ConstData
After the simulator has been launched, have a look at the display:
ldab #$02
1. The Source window shows your source program.
ldaa 0,x
2. The Assembly window shows the program as it looks in memory. Right Click in the Assembly window and check Display
Code to make your display show the code in the memory locations $C000 - $C01A. Right Click again and check Display staa VarData
Symbolic to show symbolic instead of decimal addresses.
ldaa 2,x
3. The Registers window shows the current status/contents of all registers.
staa VarData+1
4. The Data window will show the current value of constant and variable data in your program. Click on the +ConstData to show
inx
the four constant data bytes. Right Click on ConstData and select FORMAT ALL Hex. Click on the +VarData to show the two
variable bytes. decb
5. The Procedure window shows what procedure you are currently in and the Command window allows you to enter bne loop
simulator/debugger commands.
ldaa 0,x
6. The Memory window allows the display of memory contents. Right Click in the Memory window and select Address . . . and
in the Display Address window enter C000. staa VarData

a. What is displayed here? ldaa 2,x

7. Try resizing any of the windows. staa VarData+1


inx
Run the Program in the Simulator decb
Explore 5.
bne loop
1. In the Source window position the cursor pointer over the nop instruction and Right Click and select Set Breakpoint.

Freescale Semiconductor LABS12CINTRO03S, Rev 1 6 Freescale Semiconductor LABS12CINTRO03S, Rev 1 7


nop
bra main_loop
Revision History
Communication
1. As you step through your program explain to your lab instructor what you see on the screen. In particular, explain what is Revision Comments Author
happening to each register and to the condition code register as you step through your program. What questions do you have?
0 Initial Release Fred Cady
1 Conversion to CodeWarrior 4.6 Fred Cady
Reflection on Learning
1. For the program entered and stepped through, list any instructions that you are not sure how they work. Compare your list with
your lab partner's and if you understand something that he or she does not, explain it so that they understand. If there are still
instructions you are not sure of, ask your laboratory instructor to explain them to you.

Freescale Semiconductor LABS12CINTRO03S, Rev 1 8 Freescale Semiconductor LABS12CINTRO03S, Rev 1 9


How to Reach Us:
Home Page:
www.freescale.com Information in this document is provided solely to enable system and software
implementers to use Freescale Semiconductor products. There are no express or
implied copyright license granted hereunder to design or fabricate any integrated
Web Support: circuits or integrated circuits based on the information in this document.
http://www.freescale.com/support Freescale Semiconductor reserves the right to make changes without further notice to
any products herein. Freescale Semiconductor makes no warranty, representation or
USA/Europe or Locations Not Listed: guarantee regarding the suitability of its products for any particular purpose, nor does
Freescale Semiconductor, Inc. Freescale Semiconductor assume any liability arising out of the application or use of
Technical Information Center, EL516 any product or circuit, and specifically disclaims any and all liability, including without
2100 East Elliot Road limitation consequential or incidental damages. “Typical” parameters which may be
Tempe, Arizona 85284 provided in Freescale Semiconductor data sheets and/or specifications can and do
+1-800-521-6274 or +1-480-768-2130 vary in different applications and actual performance may vary over time. All operating
www.freescale.com/support parameters, including “Typicals” must be validated for each customer application by
customer’s technical experts. Freescale Semiconductor does not convey any license
under its patent rights nor the rights of others. Freescale Semiconductor products are
Europe, Middle East, and Africa: not designed, intended, or authorized for use as components in systems intended for
Freescale Halbleiter Deutschland GmbH surgical implant into the body, or other applications intended to support or sustain life,
Technical Information Center or for any other application in which the failure of the Freescale Semiconductor
Schatzbogen 7 product could create a situation where personal injury or death may occur. Should
81829 Muenchen, Germany Buyer purchase or use Freescale Semiconductor products for any such unintended or
+44 1296 380 456 (English) unauthorized application, Buyer shall indemnify and hold Freescale Semiconductor
+46 8 52200080 (English) and its officers, employees, subsidiaries, affiliates, and distributors harmless against
+49 89 92103 559 (German) all claims, costs, damages, and expenses, and reasonable attorney fees arising out
+33 1 69 35 48 48 (French) of, directly or indirectly, any claim of personal injury or death associated with such
www.freescale.com/support unintended or unauthorized use, even if such claim alleges that Freescale
Semiconductor was negligent regarding the design or manufacture of the part.

Japan:
Freescale Semiconductor Japan Ltd.
Headquarters
ARCO Tower 15F
1-8-1, Shimo-Meguro, Meguro-ku,
Tokyo 153-0064
Japan
0120 191014 or +81 3 5437 9125
support.japan@freescale.com

Asia/Pacific:
Freescale Semiconductor Hong Kong Ltd.
Technical Information Center
2 Dai King Street
Tai Po Industrial Estate
Tai Po, N.T., Hong Kong
+800 2666 8080
support.asia@freescale.com

For Literature Requests Only:


Freescale Semiconductor Literature Distribution
Center
P.O. Box 5405
Denver, Colorado 80217
1-800-441-2447 or 303-675-2140
Fax: 303-675-2150
LDCForFreescaleSemiconductor@hibbertgroup.com

Freescale™ and the Freescale logo are trademarks of Freescale Semiconductor, Inc. All other
product or service names are the property of their respective owners. ARM is the registered
trademark of ARM Limited. ARM9, ARM11, and ARML210™ are the trademarks of ARM Limited.
Java and all other Java-based marks are trademarks or registered trademarks of Sun
Microsystems, Inc. in the U.S. and other countries. The “PowerPC” name is a trademark of IBM
Corp. and used under license.
© Freescale Semiconductor, Inc. 2006.
Document Number: LABS12CINTRO03S /REV 1
Appendix P

Codewarrior and C Example

P-1
What's New with the 9S12? 10-11-28 11:30 AM

What is so Special About the M68DKIT912C32?


Items in this section:

1. Introduction
2. Creating a new CodeWarrior Project for you M68DKIT912C32
3. Understanding how the on-chip serial monitor interacts with CodeWarrior
4. Configuring Processor Expert to be compatible with the serial monitor
5. Adding functions to our user application
6. Reviewing our code
7. Compile, Link, and Debug
8. Running the application
9. Review of what we accomplished
10. Cut to the chase - Use the custom stationery

Well let me tell you. There is tightly coded serial resident monitor that is included on every
M68MOD912C32 module. This enables you, through the CodeWarrior interface, to access virtually all
debugging features of the 9S12, through a standard serial cable. In other words, using CodeWarrior v3.0
Special Edition, and your M68DKIT912C32, you can begin writing your application. As you become more
familiar to the tools and your application becomes more sophisticated, you can upgrade to more feature rich
tools as required.

The serial resident monitor is described in detail in Application Note 2548 which include the associated
software files. You really do not need the software unless you are going to port the debugger to a different
family of devices (e.g. DP256).

Let's go step by step setting our M68DKIT912C32. Before we start, you should already have CodeWarrior
v3.0 installed on your machine. If you do not, do it now. It is a standard Windows installation procedure.
If you do not own a copy, you may download the Special Edition version at no charge. Follow the step by
step installation wizard and licensing instructions. OK, let's continue.
back to the top

Launch CodeWarrior and select File/New.

Highlight HC(S)12 New Project Wizard and provide a project name. I used my_project
my_project. You will also

http://www.futureerc.com/9s12resource/M68DM912C32/9S12_Improvements.htm Page 1 of 22
What's New with the 9S12? 10-11-28 11:30 AM

need to set a path location where you want your project to be created. This should be your working
directory. The next step is to select the device type.

Select the MC9S12C32. This is the device that is used on the M68MOD912C32 module. Hit next.

Now you need to select the language you will use to program your application. I have selected C for this
example. You can see you also have the options to program in Assembly or C++. You can also select all or
any combination of these. Hit next.

http://www.futureerc.com/9s12resource/M68DM912C32/9S12_Improvements.htm Page 2 of 22
What's New with the 9S12? 10-11-28 11:30 AM

The wizard will ask you if you wish to use Processor Expert. Processor Expert is a tool that combines
easy-to-use component based application creation with an expert knowledge system. Functionality of CPU
and on-chip peripherals as well as higher levels of specific applications are encapsulated into components
called Embedded Beans. This powerful tool frees up developers from the long effort of learning bits and
bytes of new peripherals and how to properly set them up to implement the desired functions. It allows the
developer to describe how built-in peripherals and their hardware environment will be used and
automatically generates the code to properly initialize, write to and read these peripherals. This tool
dramatically saves the time to learn about a new device and the time to correct mistakes and help
concentrate on the real part of the application, the added value of a project.

Select yes and hit next.

CodeWarrior v3.0 now has support for an add on product call PC-lint from Gimpel Software. Without
going into too much detail, PC-lint finds quirks, idiosyncrasies, glitches and bugs in C and C++ programs.
The purpose of such analysis is to determine potential problems in such programs before integration or
porting, or to reveal unusual constructs that may be a source of subtle and, yet, undetected errors. Because it
looks across several modules rather than just one, it can determine things that a compiler cannot. It is
normally much fussier about many details than a compiler wants to be. If you want to know more about this

http://www.futureerc.com/9s12resource/M68DM912C32/9S12_Improvements.htm Page 3 of 22
What's New with the 9S12? 10-11-28 11:30 AM

tool you should go directly to Gimpel Software. Enough of that.

For this example, you should select no and hit next.

Now I think this part is really cool. The fact that you can have full IEEE compliance on float and double
variables on a 16-bit processor is neat. That is why I use it. Does it make my code larger - YES. Do I
really need this type of precision for this example - NO. But like you, I am an engineer and I think it is
neat. If you think you are going to be short of code space, and you don't need the precision, then by all
means disable it. OK, hit next please.

Now this may be one of the more important parts of the configuration wizard. This is where we select
which targets we want to support in our application. If you are not sure what a target it, think of it like a
configuration. The "Metrowerks Full Chip Simulator" is the default selection. As you would expect, that
is a simulator that does not require hardware for debugging. I think that is always a good one to include so
I would keep it. Also, let's select the "Motorola Serial Monitor Hardware Debugging" target. Do you
remember how we talked about Application Note 2548 above? Well that is the same serial monitor that is
on your M68MOD912C32 module.

http://www.futureerc.com/9s12resource/M68DM912C32/9S12_Improvements.htm Page 4 of 22
What's New with the 9S12? 10-11-28 11:30 AM

However, here is the catch!


If you are using CodeWarrior v3.0 Special Edition, you are not only restricted by an 8K compile limit, but
also a 32 file project limit. In other words, you can not have more than 32 files in your working project
(and that is not just source and header files). So let's keep the example lean on targets right now because
most of you are probably starting out with Special Edition. Hit finish.

Let the tool work for a little while. It is pulling all of the necessary files together that are required to create
your project as you specified it in the wizard. When it is completed, you will see something like the
following:

back to the top

You have successfully created a project using the New Project Wizard. "Well that's great!", you say, "Now
what?" Hmmmm... Good question. Now we need to turn this project into something useful. Let's take a
step back and see what we actually have to work with. Our M68MOD912C32 module is plugged into a
M68DM912C32 docking module. The M68DM912C32 has two LEDs and two user switches. At the very
least, we should be able to do something with those, right? Well, the schematic of the M68DM912C32 can
be downloaded here. If we just want to take a peak at the schematic we can see that the LEDs are connect
to PT0 and PT1.

http://www.futureerc.com/9s12resource/M68DM912C32/9S12_Improvements.htm Page 5 of 22
What's New with the 9S12? 10-11-28 11:30 AM

If you are like me, you like immediate gratification - just to make sure you have everything hooked up
correctly. You just want to blink the LEDs, right? Well like Uncle Albert always said, "...with great power
comes great responsibility" (for all of you Spiderman fans out there). No seriously, we have to do a few
things up front to make sure that the Processor Expert utility is configured properly with the monitor that is
already on our board.

Remember, the serial monitor is really just a separate program that is already programmed into the FLASH
of the 9S12C32. When the part comes out of reset, the PC follows the reset vector to the monitor program.
From there, the monitor decides if it should stay in the monitor program and perform a certain function (e.g.
like pass the contents of memory to the debugger so it can be displayed for you) or just load the user's reset
vector (i.e. start of your program) and pass control to the main application. The main things we have to
make sure of are:

1. Change the build target to the serial monitor


2. We have selected the 48-pin package of the 9S12C32 device
3. The have re-mapped the RAM in the way the serial monitor expects us to (remember, the serial
monitor uses resources of the microcontroller)
4. We have set the bus speed to 24 MHz so that serial communication is still at 115, 200

Change the build target to the serial monitor

http://www.futureerc.com/9s12resource/M68DM912C32/9S12_Improvements.htm Page 6 of 22
What's New with the 9S12? 10-11-28 11:30 AM

Go to the build target pull down menu and change it from "Simulator" to "Monitor".
back to the top

Select the 48-Pin 9S12C32 Device


Click on the Processor Expert Tab in the project manager window. Then double-click on the "48-pin"
configuration icon under the configurations folder. This is telling Processor Expert the specific processor
type you are using. Remember different devices in the same family have different packages and memory
configurations. It is our job to tell Processor Expert which one we are using.

You will see a green check mark disappear from the 80-pin configuration and appear at the 48-pin
configuration. You will also notice that the graphical representation of the device in the target CPU window
will change from the 80-pin version to the 48-pin version.

Re-Map the RAM

http://www.futureerc.com/9s12resource/M68DM912C32/9S12_Improvements.htm Page 7 of 22
What's New with the 9S12? 10-11-28 11:30 AM

The 9S12C32 has 2K of on-chip RAM. Like all 9S12 devices, the memory resources are able to be
relocated throughout the memory map. The designer of the serial monitor had to make certain assumptions
of where this memory was going to exist because the monitor supports all 9S12 families spanning from 32K
all the way to 512K devices. You need to make sure that your RAM is relocated so that it ends with
location $3FFF
$3FFF. Since the 9S12C32 device has 2K, we need to relocate the memory to a starting address
$3800
$3800. In other words, 2K of RAM ($800$800) starting at location $3800 will finish at location $3FFF
$3FFF.

So, double-click the Cpu:MC9S12C32C_48 bean in the project window

in order to open the bean inspector window for that particular bean. You should see the following on the
right hand side of your screen:

http://www.futureerc.com/9s12resource/M68DM912C32/9S12_Improvements.htm Page 8 of 22
What's New with the 9S12? 10-11-28 11:30 AM

Go to the "Internal RAM Mapping" field of the properties tap and change the $0800 to $3800. Click on
the build options tap because we have to make a change there as well.

http://www.futureerc.com/9s12resource/M68DM912C32/9S12_Improvements.htm Page 9 of 22
What's New with the 9S12? 10-11-28 11:30 AM

In fact, you see that Processor Expert has already identified an inconsistency in our configuration (as
indicated by the red exclamation points). Change the RAM address to $3800 to match what we did on the
previous tab. Also, change the value of the "Memory Model" field to small. This should resolve all of the
red exclamation point into green check marks.

http://www.futureerc.com/9s12resource/M68DM912C32/9S12_Improvements.htm Page 10 of 22
What's New with the 9S12? 10-11-28 11:30 AM

Set the Bus Speed to 24 MHz


Click back to the properties tap on the same bean inspector window. We need to make a few changes here
to make sure the clocks specified match what is on the M68MOD912C32 module. The entire schematic of
the module can be downloaded here. What we are looking for is the speed of the crystal, which is 8 MHz.
We need to make that change, as well as requesting the PLL to bump the bus speed up to 24 MHz so that
our application matches that of the monitor.

http://www.futureerc.com/9s12resource/M68DM912C32/9S12_Improvements.htm Page 11 of 22
What's New with the 9S12? 10-11-28 11:30 AM

back to the top

Well that is it. You have done it. We have now given Processor Expert sufficient information regarding the
device that we are using (48-pin C32, already has a serial monitor installed, etc...) so that it can generate
code accordingly. Speaking of code, we haven't written any application code to do anything yet. We
haven't been blinking any LEDs. Where is our immediate gratification!

No problem, let's do that now. This is what I propose. We use one of the PWM outputs that is connected to
LED0 to modulate the brightness of the LED. Let's say every 20 msec we will update the duty cycle. So
what do we need to accomplish this? We need a function to initialize and update the PWM. We also need
a function to create a 20 msec time-base in order for us to perform our update. Boy, I am glad we have
Processor Expert!

First, let's add the PWM bean to our project. Expand the folders in the Bean Selector window to reveal the
PWM bean. The order you expand the folders is first expand CPU internal peripherals folder
and then expand the timer folder under that. You should see the PWM
bean as in the selection below:

http://www.futureerc.com/9s12resource/M68DM912C32/9S12_Improvements.htm Page 12 of 22
What's New with the 9S12? 10-11-28 11:30 AM

Double-click the PWM bean and it will be added to your project. You will be asked if you want to add the
bean to all configurations for which you can reply yes and check "don't ask me again" so the box doesn't
keep popping up while we build our project.

You will see that the bean has been added to your project but the red explanation marks indicate that we
need to configure something or provide additional information for Processor Expert to be able to generate
code. It is telling us we need to set a PWM period and an initial on or off time. In addition, we need to
confirm that the correct PWM output (namely PT0) so we are directing the signal to the correct LED. If you
click the PWM period field you will see the following pop-up box:

http://www.futureerc.com/9s12resource/M68DM912C32/9S12_Improvements.htm Page 13 of 22
What's New with the 9S12? 10-11-28 11:30 AM

This is a graphical tool that let's you define your PWM period. If I type in 20 msec, and a 5% error
allowed, Processor Expert tell us that it can achieve 19.040 msec which is close enough for what we are
doing. I confirm the selection with an OK and go the the Starting pulse width field.

http://www.futureerc.com/9s12resource/M68DM912C32/9S12_Improvements.htm Page 14 of 22
What's New with the 9S12? 10-11-28 11:30 AM

Now we have less choices here because some pre-scalars and timebases have already been assumed from
our previous selection. If we move our mouse over the the closest values text in the possible settings
section, we can simply select from the pull down list. I chose 74.667 usec because it was my first option.
This means the very first PWM cycle will be on (or off, depending on polarity settings) for 74.667 usec and
then be the opposite polarity for the remaining 19.040 msec. Click OK to confirm that setting.

Another thing I like about this interface is that we can name our beans to something meaningful instead of
the default names. For example, in this specific case, the bean name defaulted to PWM6. That is fine but it
really doesn't mean anything to me at the application level. Let's call it, LED_D2; at least that matches the
schematic! It is in fact connected to PT0 so the output pin selection is correct. You should see something
like this when you are done:

As a side note, if your view does not look like this, make sure that you have the "Advanced" button
selected. This changes the number of fields you can view. The view buttons are located in the lower left

hand corner of the window.

OK, now that we have added the PWM functionality, let's add the time-base that we will use for our update
frequency. Go back to the Bean Selector window to reveal the Timer Interrupt bean. The order you expand
the folders is again to expand CPU internal peripherals folder and then expand the
timer folder under that. You should see the Timer Interrupt bean as in the selection below:

http://www.futureerc.com/9s12resource/M68DM912C32/9S12_Improvements.htm Page 15 of 22
What's New with the 9S12? 10-11-28 11:30 AM

Double-click this bean and add it into your project. Once again, we will see some red exclamation marks
indicating that Processor Expert needs additional information from us. Just as we did before, select the
period field and enter a value of 20 msec. I also renamed the bean to something more meaningful to the
application, TI1_20ms. You should see something like this:

I want to take this opportunity to show you something really cool about Processor Expert. The reason why
we have gone to the trouble of creating a periodic interrupt of 20 msec is because we want to execute a
piece of code every 20 msec, namely, updating the PWM duty cycle. That implies interrupt service routine
and things of that nature, right? Well, Processor Expert handles all of that for you automatically. It creates
a C file called Events.c
Events.c. In this file are all of the functions that are included in the scope of the event
handler (i.e. interrupt vectors). In other words, Processor Expert generates all of the necessary function calls
associated with the events. All you need to do is add you code within the 'brackets' of the function. Pretty
cool, huh? If it doesn't make sense quite yet, it will.

http://www.futureerc.com/9s12resource/M68DM912C32/9S12_Improvements.htm Page 16 of 22
What's New with the 9S12? 10-11-28 11:30 AM

In the picture above, I clicked the "Events" view of the Bean Inspector. There you can see that there is
going to be an event procedure (i.e. function call) named TI1_20ms_OnInterrupt() and it is going
to be included in the file Events.c
Events.c. OK, enough of that, when you see the code it will be entirely clear.
back to the top

Well let's review what we have done:

1. Set up the CPU, clock speed, and RAM to accommodate serial monitor on the 9S12C32 device
2. Created a PWM function to control the brightness of LED_D2
3. Created a 20 msec time-base interrupt

What about that gratification? LET'S BLINK THE LED!!!

Go to the Processor Expert pull-down and select "Code Design 'my_project'".

This is going to generate all of the necessary files based upon the inputs we gave Processor Expert. Once
that is compete, click the files tab so you can see all of the file that Processor Expert created for us. You
may also need to expand the "Generate Code" folder and the "User Modules" folder.

http://www.futureerc.com/9s12resource/M68DM912C32/9S12_Improvements.htm Page 17 of 22
What's New with the 9S12? 10-11-28 11:30 AM

As a general rule of thumb, do not modify the files in the "Generate Code" folder. Let this be the working
folder for Processor Expert. Your working directory should be the "User Modules" folder. Your main()
routine is contained in my_project.c
my_project.c. All of the interrupt handler functions are contained in
Events.c
Events.c.

Double-click the Events.c file to open it in the editor. Scroll down to the function (line 53) You will
see the following function handler:

The comments indicate where we should write the code we want to be executed each time the event
TI1_20ms_OnInterrupt() is called. Namely, we want to update the PWM duty cycle. If we open
the LED_D2.c file, we can see all of the functions that Processor Expert created for us.

http://www.futureerc.com/9s12resource/M68DM912C32/9S12_Improvements.htm Page 18 of 22
What's New with the 9S12? 10-11-28 11:30 AM

The one I think is the easiest to use is the LED_D2_SetRatio16()


LED_D2_SetRatio16(). Basically you pass a 16-bit
number to the function. It scales it to represent a duty cycle of 0% - 100%. If you passed it 655 that would
be equivalent to 1%. If you passed it 32,767 that would be equivalent to 50% and so on. You probably see
where we are going with this. We are going to call this function from within the function of
TI1_20ms_OnInterrupt(). Go back to Events.c and write the following code within the
function call of TI1_20ms_OnInterrupt() .

void TI1_20ms_OnInterrupt(void)
{
/* Write your code here ... */
static word x;
LED_D2_SetRatio16(x); /* Update the new PWM duty cycle. */
x+=500; /* Add 500 to the last value of x. */
}

You can copy and paste the text here directly if you would like. When you are done, your file should look
like the following:

http://www.futureerc.com/9s12resource/M68DM912C32/9S12_Improvements.htm Page 19 of 22
What's New with the 9S12? 10-11-28 11:30 AM

back to the top

All right, it is gratification time. Make sure that your M68DKIT912C32 is has power and is connected to
the serial port of your PC. Also make sure you don't have any other programs running that may currently be
connected to the serial port (like a Palm Pilot sync or something like that). make sure that the little switch
on your M68MOD912C32 module is in the "boot" position and then hit the reset button in the middle of the
board.

Click the debug button on the project manager button console.

This will compile, link, and launch the debugger. The debugger will negotiate with your serial monitor,
erase the FLASH in the 9S12C32, and download the executable file we just created. If this operation is
successful you will see the following:

http://www.futureerc.com/9s12resource/M68DM912C32/9S12_Improvements.htm Page 20 of 22
What's New with the 9S12? 10-11-28 11:30 AM

back to the top

Click the green "GO" button and your program will execute on your M68DKIT912C32. LED_D2
should periodically change from bright to dim and then back to bright again. There should be a little
gratification there, right?
back to the top

Let's review what we have accomplished.

1. We created a project using CodeWarrior.


2. We modified the CPU bean to be compatible with the on-board serial monitor (memory map, bus
speed, etc).
3. We used Processor Expert to create application code to dim an LED.
4. We compiled and downloaded that code into our development board.
5. We ran our code.

Not too bad. I wanted you to have a chance to make all of these adjustments so you could understand all of
the pieces of the puzzle. It is like learning how to drive a car with a standard transmission so that you are
able to appreciate the automatic one (thanks Dad!). OK, we understand it now so we don't really want to
have to perform all of these steps every time we want to create a new application using the

http://www.futureerc.com/9s12resource/M68DM912C32/9S12_Improvements.htm Page 21 of 22
What's New with the 9S12? 10-11-28 11:30 AM

M68DKIT912C32 with the serial monitor. Well, luckily we do not have to. We can copy the project that
we have and place it in the "Stationery" folder within the CodeWarrior Installation. That way, the next time
we have a project we can use the stationery and it will already be configured for us.
back to the top

Give me stationery that has already been created please.

I have created a piece of default stationery specifically for your M68DKIT912C32. It has I/O defined for
the LEDs and the two switch buttons. It has a periodic 20 msec interrupt event. Every 20 msec it updates
the PWM output duty cycle to an LED so it appears to get brighter, brighter, brighter, and then dimmer,
dimmer, dimmer. Also, every 20 msec it polls the state of SW3, if it is pressed, it turns on the other LED. If
it is not, the LED remains off. All of the functionality is within the Events.c. file so the user can write
all of your own code. You can remove the code in the Events.c file as well, I just put it in there so you
would know that your program was working OK.

Download the stationery file here.

You will need to unzip the file into the Stationery directory shown in the figure below:

You have completed this tutorial and this section. Good Luck!
back to the top

back to the main page

http://www.futureerc.com/9s12resource/M68DM912C32/9S12_Improvements.htm Page 22 of 22
P-24 Edit Date: February 12, 2013
Appendix Q

Code Example Blinking an LED on PM5

Listing Q.1: Example for blinking an LED on PM5 based on Timer Overflow. Uses Assembler and is compatible
with Esduino and Codewarrior (tested Nov. 2010). Modified from code found at www.microdigitaled.com
; ∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗
; ∗ This s t a t i o n e r y s e r v e s as t h e framework f o r a ∗
; ∗ user a p p l i c a t i o n ( s i n g l e f i l e , absolute assembly a p p l i c a t i o n ) ∗
; ∗ For a more c o m p r e h e n s i v e p r o g r a m t h a t ∗
; ∗ d e m o n s t r a t e s t h e more a d v a n c e d f u n c t i o n a l i t y o f t h i s ∗
; ∗ processor , please see the demonstration a p p l i c a t i o n s ∗
; ∗ l o c a t e d in the examples s u b d i r e c t o r y of the ∗
; ∗ F r e e s c a l e C o d e W a r r i o r f o r t h e HC12 Program d i r e c t o r y ∗
; ∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗
;
; − − − − − − − − − − − − − − − − − − − − − − − − − − − −
; This code m o d i f i e d from t h e o r i g i n a l f i l e , Timer Overflow AssemProg . t x t
; f o u n d a t h t t p : / / www . m i c r o d i g i t a l e d . com/HCS12/ Hardware / Dragon12 / C o d e w a r r i o r a s m
; There a r e o t h e r e x a m p l e s o f A s s e m b l e r code w r i t t e n t o work w i t h
; C o d e w a r r i o r ( i . e . p r o b a b l y assume t h e u s e o f t h e S e r i a l M o n i t o r and
; n o t DBUG−12 o r a BDM m o d u l e ) .
;
; James S m i t h ; Nov . 2 0 1 0 .
; − − − − − − − − − − − − − − − − − − − − − − − − − − − −

; export symbols
XDEF Entry , Startup ; e x p o r t ’ Entry ’ symbol
ABSENTRY Entry ; for a b s o l u t e a s s e m b l y : mark t h i s as application entry point

; I n c l u d e d e r i v a t i v e −s p e c i f i c d e f i n i t i o n s
INCLUDE ’ mc9s12c32 . i n c ’

ROMStart EQU $4000 ; absolute address to p l a c e my c o d e / c o n s t a n t data

; v a r i a b l e / data section

ifdef HCS12 SERIALMON


ORG $3FFF − (RAMEnd − RAMStart )
else
ORG RAMStart
endif
; Insert here your data definition .
Counter DS .W 1 ; not necessary f o r now .
FiboRes DS .W 1 ; not necessary f o r now .

; code section
ORG ROMStart

; Include d e v i c e i n i t i a l i z a t i o n code
; INCLUDE ’ MCUInit . i n c ’

Entry :
Startup :
; remap t h e RAM &amp ; EEPROM h e r e . S e e EB386 . p d f
ifdef HCS12 SERIALMON
; s e t r e g i s t e r s at $0000
CLR $11 ; INITRG= $ 0
; s e t ram t o end a t $3FFF
LDAB #$39
STAB $10 ; INITRM= $ 3 9

; s e t eeprom t o end a t $0FFF


LDAA #$9
STAA $12 ; INITEE= $ 9

LDS #$3FFF+1 ; S e e EB386 . p d f , initialize the stack pointer


else

Q-1
LDS #RAMEnd+1 ; initialize the stack pointer
endif

; Call generated Device Initialization function


; CALL MCU init
mainLoop :
; Make P o r t M’ s PM5 on LED o u t p u t .
MOVB #%00100000 ,DDRM ; make PM5 o u t p u t ( f o r d r i v i n g on−b o a r d LED D2 )
CLR PTM ; e n s u r e LED i s o f f

;−−−−−−−T o g g l i n g t h e LED c o n n e c t e d t o PORTM ( on PM5)

LDAA #$80
STAA TSCR1
LDAA #$04 ; P r e s c a l e r =16 ( Try 0−7 v a l u e s t o s e e c h a n g e s on LEDs )
STAA TSCR2
LDAA #0
OVER BSET TFLG2,%10000000 ; c l e a r t h e Timer o v e r f l o w f l a g ( w r i t i n g HIGH c l e a r s i t )
H1 BRCLR TFLG2 , mTFLG2 TOF, H1 ; w a i t f o r Timer O v e r f l o w
INCA ; keep adding the o v e r f l o w s
STAA PTM ; and dump i t on PORTM t o s e e PTM o r PTIM?
BRA OVER

; ∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗
;∗ Interrupt Vectors ∗
; ∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗
ORG $FFFE
DC.W Entry ; R e s e t V e c t o r . CPU w a k e s h e r e and i t is sent to start of the code at $4000

Listing Q.2: Example for blinking an LED on PM5 based an Interrupt Service Routine linked to RTI. Uses
Assembler and is compatible with Esduino and Codewarrior (tested Nov. 2010). Modified from [12] example
11-18.
; ∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗
; ∗ This s t a t i o n e r y s e r v e s as t h e framework f o r a ∗
; ∗ user a p p l i c a t i o n ( s i n g l e f i l e , absolute assembly a p p l i c a t i o n ) ∗
; ∗ For a more c o m p r e h e n s i v e p r o g r a m t h a t ∗
; ∗ d e m o n s t r a t e s t h e more a d v a n c e d f u n c t i o n a l i t y o f t h i s ∗
; ∗ processor , please see the demonstration a p p l i c a t i o n s ∗
; ∗ l o c a t e d in the examples s u b d i r e c t o r y of the ∗
; ∗ F r e e s c a l e C o d e W a r r i o r f o r t h e HC12 Program d i r e c t o r y ∗
; ∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗
;
; − − − − − − − − − − − − − − − − − − − − − − − − − − − −
; T h i s c o d e i s an a d a p t i o n o f Example 11−18 f r o m t h e t e x t
; ”HCS12 M i c r o c o n t r o l l e r and Embedded S y s t e m s : U s i n g A s s e m b l y
; and C w i t h C o d e W a r r i o r b y Mazadi and C a u s e y .
;
; James S m i t h ; Nov . 2 0 1 0 .
; − − − − − − − − − − − − − − − − − − − − − − − − − − − −

; export symbols
XDEF Entry , Startup ; e x p o r t ’ Entry ’ symbol
ABSENTRY Entry ; f o r a b s o l u t e a s s e m b l y : mark this as application entry point

; − − − − − − − −
; I n c l u d e d e r i v a t i v e −s p e c i f i c d e f i n i t i o n s
INCLUDE ’ mc9s12c32 . i n c ’

ROMStart EQU $4000 ; absolute address to p l a c e my c o d e / c o n s t a n t data

; − − − − − − − −
; v a r i a b l e / data s e c t i o n

ifdef HCS12 SERIALMON


ORG $3FFF − (RAMEnd − RAMStart )
else
ORG RAMStart
endif
; I n s e r t here your data d e f i n i t i o n .
; The i s t h e ’ ’ S c r a t c h Pad ’ ’ w h e r e v a r i a b l e s a r e m a n i p u l a t e d .
; I t w i l l s t a r t a t $ 3 9 1 0 ( i . e . s o m e w h e r e i n t h e 2 k o f RAM) on t h e Esduino .
ORG $ 3 9 1 0 ; S t a r t o f v a r i a b l e s p a c e i n RAM.
TEMP DC. B 1
COUNT DC. B 1

; − − − − − − − −
; code s e c t i o n
ORG ROMStart
Entry :
Startup :
; −−−−−−−−−−−−−−−−−−−−− don ’ t t o u c h a n y t h i n g BELOW h e r e −−−−−−−−−−−−−−−−−−−−−
; vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
; remap t h e RAM & EEPROM h e r e . S e e EB386 . p d f
i f d e f HCS12 SERIALMON
; s e t r e g i s t e r s at $0000
CLR $11 ; INITRG= $ 0
; s e t ram t o end a t $3FFF
LDAB #$39
STAB $10 ; INITRM= $ 3 9

Q-2 Edit Date: February 12, 2013


; s e t eeprom t o end a t $0FFF
LDAA #$9
STAA $12 ; INITEE= $ 9

LDS #$3FFF+1 ; S e e EB386 . p d f , initialize the stack pointer


else
LDS #RAMEnd+1 ; initialize the stack pointer
endif
; ˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆ
; −−−−−−−−−−−−−−−−−−−−− don ’ t t o u c h a n y t h i n g ABOVE h e r e −−−−−−−−−−−−−−−−−−−−−

; Interrupts e t −up f o r t h e ” ReTurn f r o m I n t e r r u p t ” ( RTI )


BSET CRGINT,%10000000
LDAA #%01111111 ; l o n g e s t RTI i s a b o u t 0 . 1 3 s e c Change t h i s number t o see toggling rate f o r RTI
STAA RTICTL
CLR TEMP
CLR COUNT
; Make P o r t M’ s PM5 on LED o u t p u t .
MOVB #%00100000 ,DDRM ; make PM5 o u t p u t ( f o r d r i v i n g on−b o a r d LED D2 )
CLR PTM ; e n s u r e LED i s o f f
CLI ; unmask t h e i n t e r r u p t s i n t h e CCR ; ENABLE INTERRUPTS GLOBALLY
mainLoop :
HERE BRA HERE ; k e e p l o o p i n g u n t i l i n t e r r u p t e d b y RTI .

; −− I n t e r r u p t S e r v i c e R o u t i n e ( ISR ) f o r RTI t o t u n on PortM . 5 (PM5)


; t h e p r o g r a m comes h e r e b e c a u s e t h e RTI was a c t i v a t e d .
RTI ISR
INC COUNT ; increment the count
LDAA COUNT ; A = COUNT
CMPA #8 ; i s i t ˜2 s e c ? ( 8 x 0 . 2 6 2 1 4 4 s e c )
BNE OVER ; i f n o t c l e a r RTIF and r e t u r n
LDAA TEMP ; get the l a s t value
EORA #%00100000 ; t o g g l e b i t 5 on P o r t M
STAA TEMP ; s t o r e t h e new v a l u e
STAA PTM ; d i s p l a y on P o r t M
CLR COUNT
OVER BSET CRGFLG, %10000000 ; c l e a r RTIF
RTI ; r e t u r n from i n t e r r u p t

; ∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗
;∗ Interrupt Vectors ∗
; ∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗
ORG $FFF0 ; V e c t o r t a b l e l o c a t i o n f o r RTI i n t e r u p t
DC.W RTI ISR

ORG $FFFE
DC.W Entry ; Reset V e c t o r . CPU w a k e s h e r e and it is sent to start of the code at $4000

Q.1 Installation of the 9s12 bootloader


Here are the steps towards placing a new bootloader on the 9s12c32 Esduino:1

1. Unplug power to your Esduino.

2. Connect the BDM programmer (also known as a “debugger”), such as that shown in Fig. Q.1.

(a) Use either the Tech. Arts or Wytec open-source BDM (USBDM) or the P&E Multilink.2
(b) The red line on the BDM cable should be closest to Pin 1 on the six-pin BDM port of the Esduino.
Pin 1 is demarked with a small white square on the PCB, beside “J1”.
(c) Connect the USB port on the BDM programmer to the USB port on your “’host” computer.

3. Power-up the Esduino

4. Start a new Code Warrior project using the built-in template. Any project will do. Just make sure to
select the correct chip.

5. Once the project is created, change the debugger from “Full Chip Simulation” to your choice of debugger
hardware:
1
Initial version of these instructions were written by Thomas Behan in Winter 2011. James Smith updated them in December
2011.
2
The P&E Multilink is the easiest to set up because the drivers for it come with Codewarrior.

Q-3 Edit Date: February 12, 2013


Figure Q.1: A P&E Multilink BDM programmer, connected to the Esduino’s BDM port. One side of the BDM
programmer has a USB port to connect to the PC and the other side has a flat six-wire cable to connect to the
Esduino.

(a) If you are using the hardware debugger from Technological Arts or Wytec, choose TBDML. You will
have had to install the open source drivers for this device ahead of time, though.
(b) If you have the P & E Multilink debugger, then choose it instead.3

6. Click the green arrow to compile/install the project.

7. Click through the pop-up windows that follow until you get to the Hi-Wave “True-Time Simulator and
Real-Time Debugger” window. For instance:

(a) If you’re using the USBDM, in the USBDM configuration popup window, use the defaults.
(b) Click ‘ok’ to the “Loading new application...” warning.
(c) Click ‘ok’ to the “Debugger is going to errase...” warning.

8. The original, dummy project has now been programmed into the Esduino.
3
The P&E debugger costs two to three times as much (about $120 with shipping) as the others but it is much easier to install!

Q-4 Edit Date: February 12, 2013


9. Now we will overwrite that program with the bootloader.

(a) Select “Load” from the appropriate drop-down menu in the Hi-Wave window:
i. ‘HC12MultilinkCyclonePro’ for the P&E Multilink
ii. ‘TBDML’ if you are using the Technological Arts or Wytec debugger hardware
(b) Browse your computer’s files, and select the file: “ESD12C32 Serial Monitor.abs”.
i. You can download the file from http://support.technologicalarts.ca/docs/Esduino/Code/
SerialMonitor/UseWithHiwave/
(c) Once the file is selected, click on “Load” (not any other ‘advanced’ option)
(d) Click ok to the “Debugger is going to mass erase...” warning.

10. The bootloader is now loaded.

Now, unplug power to the Esduino, then unplug the BDM hardware. Connect a USB cable between your
computer and the small USB port on the Esduino. Power up the Esduino. Fire-up Codewarrior and download
code via the HCS12 Serial Monitor option.

Q.1.1 Problems with a “locked” processor


If you can’t reflash the serial bootloader because Hiwave complains about a “locked” processor, then you should
either:

1. Use the USBDM’s “HCS12 programmer.exe utility that is provided in the Utilities folder of the USBDM
project.” (Carl Barnes; Tech. Arts), or

2. use unsecure 12 available from the P&E micro website.

Q.2 Coding hints


This is a work-in-progress and will need some updating.

BDM Hardware vs. Serial Monitor The Esduino comes with a serial monitor that resides in its memory.
For general programming and testing, this is sufficient for connecting your Esduino to your PC. However,
a BDM cable is a better, more fool-proof way of getting code onto the Esduino. Technological Arts and
Wytec sell “cheap” BDM cables (less than $50) that require the use of open-source drivers. Some people
(like Dr. Smith) have trouble installing the drivers. An alternative is the $120 Multilink BDM from P&E.
After two months of evaluation, it’s fair to say that it’s the easiest way to get code onto the Esduino.

Memory (Assembler Programming) “one problem everyone is having is the RAMStart is defined differ-
ently depending on if the HCS12 SERIALMON symbol is defined or not. If defined the stack is started
at $3FFF+1, if not at $0FFF, which seems to cause problems on the real board but not the simulator”.
(courtesy of Anthony Bailey)

Q-5 Edit Date: February 12, 2013


Q-6 Edit Date: February 12, 2013
Appendix R

IEEE Formatting for Report Writing

The following documents, originally written for students in BME100, will aid you in following the required
IEEE format.

R-1
Download the Template from the
BME 100 webpage. Don’t make the
document from scratch!

Write your
name in the Using the IEEE Template
“header” Write
here Student ID
Title is 24 pt Times New Roman TNR font
in the
header
A subtitle which narrows the Here
scope of your project is good!

Student ID
Introduce your topic here. Put and Full
your “Thesis statement” here. Name here.

Headings are in capital letters and


numbered with Roman Numerals, Figures, drawings, etc.
in 10 pt TNR font. need to be cited (with
the [#]) if you did not
do them yourself.

Add an “Acknowledgements” section if


you got help on your project.

References, based on the


Table captions are on the top. If Refworks output, are in 8pt
you copy or modify someone’s Times New Roman font.
table, you need to cite it (with
the [#]).
BME 100 IEEE Standard citation formatting May 2010

Introduction

You are expected to use standard formatting for both your articles and for the referencing/citations. We use
IEEE (Institute of Electrical and Electronics Engineers) formatting because IEEE is the world’s largest
professional organization and you are very likely to read and write IEEE documents in your professional
(real-world!) careers.

RefWorks: The Right Tool!

Luckily, the Library’s RefWorks system can output to IEEE standard. You need to set this up:

Set up RefWorks to output to IEEE standard format


1. Login to RefWorks (via the Universityʼs Library website)
2. Click on the "Bibliography" box near the top and centre of the window (about 2cm from the top and 10cm
from the left)
3. Click on the "Output Style" dropdown menu and select "Access Output Style Manager..." (at the bottom of
the list).
4.The Output Style Manager page will open.
5. In the left-hand list, choose IEEE - Institute of Electrical Engineers. Click on "Add to Favourites" below.
6. Click on the "Go back to previous page"
7. Now you should be able to format citations in the IEEE format.

As you gather articles into RefWorks you can then automatically output the references to your word
processor document.

Warning! Sometimes RefWorks cuts off parts of the citation (like location of the conference, part of the
conference name and journal number). If so, you are responsible for adding it back in!!

Example

When writing your text, you will need to add citations to tell the reader where you got your information
from. Here is an example

Example Paper With References in IEEE Format


I. Introduction

It was found that the interaction between the feet and the “muddy icky ground” [1] was an intractable
problem in the development of the system. Luckily, Poulakakis et al. were able to overcome this with
bounding. [2] The citations are numbered in order of usage and we make sure to add quotation marks
around text taken directly from the original paper. When there are more than two authors in a paper we
only list the first author followed by the Latin expression “et al.”

II. Conclusions

In the references, note that the first reference [1] is a Journal article (IEEE Transactions on
Instrumentation and Measurement), the second reference [2] is a conference paper and the third reference
[3] is a web link (URL).

References

[1] S. Nabulsi, J. F. Sarria, H. Montes and M. A. Armada, "High-Resolution Indirect Feet–Ground


Interaction Measurement for Hydraulic-Legged Robots," Instrumentation and Measurement, IEEE
Transactions on, vol. 58, no. 2, pp. 3396-3404, 2009.

[2] I. Poulakakis, J. A. Smith and M. Buchler, "Experimentally validated bounding models for the scout
II quadrupedal robot," in Robotics and Automation, 2004. Proceedings. ICRA '04. 2004 IEEE
International Conference on Robotics and Automation, Boston, USA, 2004, pp. 2595-2600 Vol.3.

[3] J. Smith, "A Study on Procrastinating Professors," BME100 Online Resources, October 2001
[Online]. Available:. BME100 Online Resources, http://www.ee.ryerson.ca/~jasmith/tado/bme100
[Accessed: May 2, 2010]

Macintosh HD:Users:jasmith:Teaching:Ryerson:BME100:2010_Summer:Citation_Standard.doc
Version 1
Refworks Update on IEEE Citation/Referencing

Some things to be watch out for…


! The Word export function in Refworks may not always output the correct IEEE format
! Errors are prone to happen when using the “Refworks” auto fill button feature from online resources.
Although this function populates most of the fields for you, it’s not perfect and it cannot be relied upon.
You’ll quickly discover the errors when you export your references out into Word format.

Here are some examples:

EXAMPLE 1:

[4] R. J. Wong and L. B. Ong, "On being careful with some features while referencing," Journal of Rons Documents,
vol. 5, pp. 45, May 2010, 2010.

As you can see, we’ve got a few mistakes here…


** Make sure the range of pages is displayed (unless it really is only one page)
** May 2010, 2010 is a result from the following field information

Believe it or not, some online resource’s Refworks function will auto fill in both fields with the publication
year so it’s up to you to double check for inconsistencies!

EXAMPLE 2:

[4] R. J. Wong and L. B. Ong, "On being careful with some features while referencing," Journal of Rons Documents,
vol. 5, pp. 45-49, May, 2010.

Again, another mistake even though we’ve corrected our following field information

As you can see, there’s a comma in between May and 2010. Unfortunately, there’s no way around this so
you’ll have to delete the comma yourself.
=*$".6(%
9'154,%=*$".6%
O73%'%5)&Q"O`52%)("352*Q"
"
"
?(%&'$%+,&'-*%'+#%6@*78>%6??8>%$&A7%+(&$*%')#%-*%'$*%/+0$>%
%3.),-*"%'9"
"
]9"T5'*&A"777"
"
!"""#$%&'&%()#
<*4$'74,%=*$".6(%>*7%$.%?@%
*&+,-#./%0-# OP,'$/1QA"OP,'$/1Q"53-"OP,'$/1Q"
"
"
P9P9"K%)3*"53-"89R9"S$*<51-"
!"#$%&"'(%)*'+,%-.,(% "
#$%&" &'()*" +,%-*" ./0*1&" ./22/3)(4,&*-" .5&*&" 6/1"
.%'5'%/3&" ,&%3+" '$*" 7888" .%'5'%/3" &(&'*29" " :*1'5%3" 7888"
<*4$'74,%=*$".6(%>A.6,%$"#1%?@%
&*.'%/3&" $50*" &)%+$')(" -%66*1*3'" .%'5'%/3" &'()*&;" <)*5&*"
.$*.=" >%'$" (/,1" %3&'1,.'/1" 53-" '$*" 1*6*1*3.*&" 5'" '$*" *3-" "#$%&'$%()*#&%+,&'-*.#%/+0$%(-11-2$3%45%6$&%+1787"
/6"'$%&"+,%-*"6/1"2/1*"%36/125'%/39" OP,'$/1Q"*'"5)9"
"
"
T9"S2%'$"*'"5)9"
&,/$%0'$#$'.1(% "
?&*" '$*" 1*6*1*3.*" 3,2@*1" %3&'*5-" /6" '$*" %'*2" -*'5%)&" 6/1"
.%'5'%/3&9" " 76" (/," 51*" 1*6*11%3+" '/" &*0*15)" 1*6*1*3.*&A"
%3.),-*" *5.$" 3,2@*1*-" 1*6*1*3.*" ,&*-A" ,&%3+" 153+*&" 9'154,%B+'$.6%
>$*3"5<<)%.5@)*9""?&*"*34-5&$*&"6/1"'$*"153+*"&*<515'/19" 9" :33%6;378%+(&$*%&'$%$3)&-*.#%/+0$"
" K9"S2%'$A"8-9"
#$*" -5'5" 51*" &,<</1'*-" %3" B!C!!DEA" @,'" $50*" @**3" "
F,*&'%/3*-"%3"2/1*"1*.*3'"&',-%*&"B!A"DE9""73"B!GEA"6/1" <*4$'74,%B+'$.6(%
*H52<)*A" <%+&" >*1*" 1*</1'*-" '/" @*" 5@)*" '/" 6)(I" J)-"
:33%6;3#78%+(&$*%&'$%$3)&-*#.%/+0$#"
K.L/35)-A" $/>*0*1A" 3/'*-" '$5'" '$*" <%+&" $5-" @**3"
'$1/>3"%3'/"'$*"5%19"BME" ]9"Y//$"53-":9"a/@%3A"8-&9"
" 76" '$*1*" 51*" 2/1*" '$53" '$1**" *-%'/1&A" ,&*" '$*" 6%1&'"
$3)&-*.#%/+0$%(-11-2$3%45%6$&%+178"
]9"Y//$"*'"5)9A"8-&9"
2'34'.56#7"8%9,:$'.1%
85.$"1*6*1*3.*"%&"<1*.*-*-"@("5"1*6*1*3.*"3,2@*19""#$*"
1*6*1*3.*"3,2@*1"%&",&*-">$*1*"'$*"5,'$/1">/,)-",&,5))(" C4#:,(%#1+%C*34'(",6(%
@*",&*-"%3"/'$*1".%'5'%/3"6/125'&9"
O:%'(QA"OY1/0%3.*ZS'5'*"P@@1*0%5'%/3Q;"OY,@)%&$*1Q"
"
"
76"5"@//="%&"<,@)%&$*-"%3"&*0*15)".%'%*&A".$//&*"'$*"6%1&'"
),1,6#4%;*4,(% .%'(")%&'*-9"
J2%'"53("<51'&"/6"5".%'5'%/3"'$5'"51*"3/'"5<<)%.5@)*9" "#$% &'$% +44*$<)+&$3% (-*0% -(% &'$% =,41)#'$*.#% /+0$>% )(%
?&*" 5@@1*0%5'*-" 6/12&" /6" ./2<53(" 53-" N/,135)" 505%)5@)*9"
352*&"%6"</&&%@)*9" "
?&*" '$*" 5@@1*0%5'*-" 6/12" /6" '$*" 2/3'$" >$*1*" [/@/=*3A"V\;"]%)*("
1*F,%1*-9" "
"
76" '$*" <)5.*" /6" <,@)%.5'%/3" %&" >*))4=3/>3A" (/," /3)("
3**-"'$*"352*"/6"'$*"<)5.*"U*9+9"V*>"W/1=X9"
"
^/3-/3;"S<1%3+*14_*1)5+"
"

!" G"
" I.*61#4%>C#7,6%G.6A#$@%
76" '$*" <)5.*" /6" <,@)%.5'%/3" %&" /,'&%-*" '$*" ?SA" %3.),-*"
'$*"./,3'1(9" BObQE" B:,&'-*C>%6BD)&1$C>8%!O#0)'+K%A"0/)9"ObQA"3/9"ObQA"
" OK/3'$QA"OW*51QA"<<9"O&'51'"bQ4O*3-"bQ9"
"
:52@1%-+*A"83+)53-;":52@1%-+*"?"Y" "
"
?&*"'$*"&'53-51-"5@@1*0%5'%/3"/6"'$*"N/,135)"352*"%6"%'"
$5&"/3*9"
0'$#$'.1(%G.6%C6'1$%9.*6:,(% "
BME" W7%T,#'>%6:#%U$%K+5%D')/G>8%F@2.J,K+',-1A"0/)9"
2..F%
!fMA"3/9"!A"\,)("!hceA"<<9"!C!4!Cg9"
"BObQE" OP,'$/1QA"!"##$%A"ObQ'$"*-9"OY)5.*Q;"OY,@)%&$*1QA"
OW*51Q9" BfE" K7@7%X.K+'-/5>%F7%J-1)&)>%Y7%H1-/)3)#%$&%+17%
" 6Q,&,*$%X=&)A+1%E$&2-*G#>8%O7.N-5@,G+P2.F21@7A"
" 0/)9"GcA"3/9"!GA"L*.9"GCCMA"<<9"cMgc4cMhM9"
B!E" L9"89"d3,'$A"90'E+*2',+K.JK5#)-,@*3A"G3-" "
*-9"a*5-%3+A"KP;"P--%&/34]*&)*(A"!hfD9"

BGE" R9"P9"J&%6A"8-9A"M3-'5.,@2.4'5-'22)-'5. 9$#1+#6+%


N-,2)+,0)29"^/3-/3;"a/,')*-+*A"GCCM9"
" BObQE" !F-,K2%A"OS'53-51-&"@/-(Q"S'53-51-"OS'53-51-"
3,2@*1QA"OL5'*Q9"
"
D$,A%'1%#%E#65,6%2..F% "
J2%'"'$*"-5'*"%6"%'"%&"%3.),-*-"%3"'$*"&'53-51-"3,2@*19"
BObQE" B:,&'-*C>%6BD)&1$C>8%)/%!"##$%A"ObQ'$"*-9"OP,'$/1QA" "
OY)5.*Q;"OY,@)%&$*1QA"OW*51QA"<<9"O&'51'"bQ4O*3-"
BgE" &'(#)*+,-#'.=)#1233-'5D.Q#K0*2.+'E.9-K2.
bQ9"
" /,)01,0)2.#(.6RHSTU.(#).&'(#)*+,-#'.
" &',2)1@+'52A"7SJ"S'53-51-"hMMC;!hgg9"
BDE" E7%F1+*G$%+/3%H7%I-21$#>%6J+&$/&%?/(-*0+&)-/>8%
BhE" &'(#)*+,-#'.F21@'#K#5;BF2K21#**0'-1+,-#'3.
%3"&'(#)*+,-#'./#0)123.-'.4'5-'22)-'5A"c'$"*-9"
J'E.&'(#)*+,-#'.4I1@+'52."2,G22'./;3,2*3H
I7:7%K+AL$-3%+/3%@7%F-*1$&&>%;37>%KM/A'$/>%
N#1+K.+'E.U2,)#:#K-,+'.J)2+.V2,G#)$3B/:21-(-1.
T*1253(;"d9"T9"S5,1A"GCCe9"
S2W0-)2*2',3B=+),.XXD.C-)2K233.NJV.U2E-0*.
"
J11233.6#',)#K.YUJ6L.+'E.=@;3-1+K.N+;2).Y=8ZL.
0.1G,6,1:,HC6.:,,+'15% /:21-(-1+,-#'3A"7888"S'53-51-"gCG9!!4!hhf9"
`/1"./36*1*3.*&"/1"<1/.**-%3+&A"5@@1*0%5'*"'$*"'%')*9"
76"'$*"'%')*"./3'5%3&"'$*"(*51A"/2%'"%'"56'*1"'$*"<,@)%&$*19" "
"
BcE" K7%E$$*)/AN%+/3%J7%3$%O*$$(>%6P-2%&-%:)3%E-/4
$N=$*&#>8%)/%!"#$%&'()*+,-)&./0&123&-4'&./0&
6#'(7.80*+'.9+1,#)3.-'.6#*:0,-'5./;3,2*39" &,:"1':#4%;,7.6$%
V*>"W/1=;"P:KA"<<9"!Me4!f!9" BObQE" B:,&'-*C>%6BD)&1$C>8%BF-0=+/5CS%BJ1+A$C>%I$=7%
56178&!"#$993:2;7&#<&=>9&'()*+,-)&./0&123& ObQA"OW*51Q9"
-4'&./0&-#2<9"92$9&#2&4?@12&A1$=#"7&:2& "
"
6#*:0,-'5./;3,2*3<"
B!CE" V9"P&/=53A"_9"S$/,<"53-"K9"]5%-3*1A"
BeE" \9"[51'2533A"P9"L*"P3+*)%"53-"P9"S,'.)%66*A" 6X=&)0)#&)A%(+)*%$NA'+/R$%-(%3)R)&+1%#)R/+&,*$#>8%
6Q*+0)/R%&'$%"#$*%;N=$*)$/A$S%?/(-*0+&)-/% 7RK;"i,1%.$A"S>%'j*1)53-A"a*<9"ai"GhfDA"!hhf9"
T)+#$#%-/%U$4#)&$%V,+1)&5%@,3R$0$/&>8%)/%=)#17.
>?,@./&A68&.6#'(7.80*+'.9+1,#)3.-'.
"
6#*:0,-'5./;3,2*3A"V*>"W/1=;"P:KA"GCCg9"
BC+3D.=)#122E-'53.#(.,@2.FG2',;H/-I,@.J''0+K.
/&A68&.6#'(2)2'12.#'.80*+'.9+1,#)3.-'.
6#*:0,-'5./;3,2*3L"
"

D" c"
&",('(H-'((,6$#$'.1% 0'$#$'.1(%G.6%B4,:$6.1':%9.*6:,(%
BObQE" B:,&'-*C>%6BD)&1$C>8%BY$R*$$C%&'$#)#>%
!,3%('$,%
OL*<51'2*3'QA"O?3%0*1&%'(QA"OY)5.*QA"OW*51Q9"
"BObQE" OP,'$/1QA"!F-,K2%A"OS%'*QA"O:1*5'%/3"-5'*Q9"
BObQE" B:,&'-*C>%6BD)&1$C8>%BY$R*$$C%3)##$*&+&)-/>% BJ3)%3*E9"P05%)5@)*;"OS%'*"352*QA"O?a^Q"
OL*<51'2*3'QA"O?3%0*1&%'(QA"OY)5.*QA"OW*51Q9" BP..*&&*-;"OL5'*QE9"
P05%)5@)*;"OS%'*"352*QA"O]*@"&%'*Q"BP..*&&*-" "
OL5'*QE9" "
" "B!DE" 7888":/2<,'*1"S/.%*'(A"&444.6#*:0,2)./#1-H
" 2,;./,;K2.A0-E2A"7888":/2<,'*1"S/.%*'(A"V/09"
?&*" '$*" ./11*.'" '(<*" 6/1" '$*" <5<*1" U'$*&%&A" GCCg9"BJ3)%3*E9"P05%)5@)*;"$''<;ZZ
-%&&*1'5'%/3X9"
>>>9./2<,'*19/1+Z5,'$/1Z"
?&*" '$*" 5@@1*0%5'*-" 6/12" /6" '$*" -*<51'2*3'" 53-"
,/)<$*#)&57%%?(%&'$%,/)<$*#)&5.#%/+0$%)/A1,3$#%&'$%#&+&$% &'()*Z.&4&'()*9$'2"BP..*&&*-;"GD"\539"GCChE9"
/1"<1/0%3.*"'$5'"%'"%&"%3A"/2%'"'$*"&'5'*Z<1/0%3.*"352*" "
61/2"'$*"<)5.*9"
76" (/," 6/,3-" '$*" '$*&%&" /1" -%&&*1'5'%/3" %3" 53" /3)%3*"
-5'5@5&*A"+%0*"'$*"-5'5@5&*"%36/125'%/3"5&">*))9" BO2..F%
"
BObQE" OP,'$/1QA"!F-,K2%A"OY)5.*Q;"OY,@)%&$*1QA"OW*51Q9"B84
B!!E" Z7%L),>%6:%L-A+1%F-0=+*)#-/%:1R-*)&'0%(-*%WL[?% @//=E9"P05%)5@)*;"OL5'5@5&*"352*QA"O?a^Q"
F)*A,)&%W$*)()A+&)-/>8%K7F-0=7[A7%&'$#)#>%D"E[>% BP..*&&*-;"OL5'*QE9"
[5)%65HA"VSA"!hhD9"
"
"
B!GE" ;7:7%[1-+&>%6F+#$%[&,3)$#%-(%D$A'/)A+1%I$=-*&%
]1%'%3+"L*0*)/<2*3'"P2/3+"S',-*3'"83+%4 B!cE" P9_9"P$/"53-"\9L9"?))253A"F@2.F@2#);.#(.
/$$*#>8%J'7Y7%3)##$*&+&)-/>%KAO)11%"/)<$*#)&5>% =+)3-'5[.F)+'3K+,-#'[.+'E.6#*:-K-'5A"
K-/&*\+1>%VF>%]^^_7%:<+)1+41$S%J*-V,$#&%Y)#` 83+)*>//-":)%66&A"V\;"Y1*3'%.*4[5))A"!hfG9"B84
&*1'5'%/3&"53-"#$*&*&A"$''<;ZZ @//=E9"P05%)5@)*;"P:K"L%+%'5)"^%@151(A"$''<;ZZ
>>>9<1/F,*&'9./2"BP..*&&*-"GC"`*@9"GCChE9" </1'5)95.29/1+Z"BP..*&&*-;"DC"\539"GCChE9"
" "

=6$':4,%.6%I.*61#4%
BObQE" OP,'$/1QA"O#%')*QA"!O#0)'+K%A"0/)9"ObQA"3/9"ObQA"
OL5'*QA"<<9"O&'51'"bQ4O*3-"bQ9"BJ3)%3*E"P05%)5@)*;"
OL5'5@5&*"352*QA"O?a^Q"BP..*&&*-;"OL5'*QE9"
"
J17*34'(",+%-.:*A,1$% "
L/" 3/'" %3.),-*" ,3<,@)%&$*-" -/.,2*3'&" %3" '$*" B!eE" 6I-AG%:/A'-*#%H$$=%cT-+&.%Q*-0%Q1-+&)/R>8%
@%@)%/+15<$(9""J3)("1*6*1"'/"'$*"-/.,2*3'"%3"'*H'9" 6-P-K.4'57A"0/)9"McA"3/9"!GA"L*.9"!hhcA"<9"!!9"
D1$,6K',L(M%,$:N% BJ3)%3*E9"P05%)5@)*;"P.5-*2%."S*51.$"Y1*2%*1A"
$''<;ZZ>*@9*@&./$/&'9./2"BP..*&&*-;"!C"`*@9"
UOP,'$/1QA"<1%05'*"./22,3%.5'%/39"OK/3'$Q"OW*51Q9X"
GCChE9"
"
"
E,$$,6(M%,$:N% "
aB:,&'-*C>%6BD)&1$C8>%,/=,41)#'$37b" 76" '$*" 51'%.)*" $5&" 5" LJ7" UL%+%'5)" J@N*.'" 7-*3'%6%*1X" /1"
" [L^" U[53-)*" S(&'*2" 7-*3'%6%*1X" 1*6*1*3.*A" ,&*" %'"
" %3&'*5-"/6"'$*"?a^"/6"'$*"-5'5@5&*9"
J)-"K.L/35)-"$5-"5"6512">%'$"051%/,&")%0*&'/.="UJ)-" "
KAY-/+13>%6K5%L)($8>%,/=,41)#'$37b" B!ME" @7%K+#-/>%6F-00$/&#%A-/#)3$*$3%'+*0(,1>8%
" J6U./&A684."0KK2,-'A"0/)9"DeA"3/9"GA"\,3*"
GCCDA"<<9"!GC4!GG9"BJ3)%3*E9"P05%)5@)*;"P:K"
L%+%'5)"^%@151(A"-/%;!C9!!ceZfgGhc!9fgGhhM"
BP..*&&*-;"DC"\539"GCChE9"
"

e" M"
P$",6%J(,G*4%;,G,6,1:,(%
#$*1*" 51*" /'$*1" '(<*&" /6" 25'*1%5)&" '$5'" $50*" 3/'" @**3" &#34,%.G%0.1$,1$(%
./0*1*-"%3"'$%&"F,%.="+,%-*9""Y)*5&*"1*6*1"'/"'$*"6/))/>%3+"
!"#$%&"'(%)*'+,%-.,(%!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!%R%
6/1"2/1*"%36/125'%/3"U@/)-*-"1*6*1*3.*&"51*"<1*6*11*-X;"
" &,/$%0'$#$'.1(%!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!%R%
Q=RS% DBBBM%!"""#$%&'()*+#,%-.*)/#,)/0*#1(.2*M% 2'34'.56#7"8%9,:$'.1%!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!%R%
DBBB%0.A7*$,6%9.:',$8M%T.KN%UVVWN%QP14'1,SN%%
T*3*15)"a,)*&"ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd"!"
=K#'4#34,X%DBBB%0.A7*$,6%9.:',$8M%%
"$$7XHHLLLN:.A7*$,6N.65H#*$".6H($84,H% P,'$/1&"dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd"G"
:(O($84,N"$A%Q=::,((,+X%?V%I#1N%UVVYSN% S%3+)*"P,'$/1"dddddddddddddddddddddddddddddddddddddddddddddddddddddddddd"G"
K,)'%<)*"P,'$/1&"U,<"'/"DX"dddddddddddddddddddddddddddddddddddddddd"G"
Q=US% <*6+.:"%J1'K,6('$8M%3%4#)%#$.)*#5*6*+*7-*8#!# K,)'%<)*"P,'$/1&"U2/1*"'$53"DX"ddddddddddddddddddddddddddddddd"G"
!"""#,)/0*9%QP14'1,SN%=K#'4#34,X%<*6+.:"%% 8-%'/1&"ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd"G"
J1'K,6('$8M%"$$7XHHLLL4'3NA*6+.:"N,+*N#*H Y)5.*&"53-"Y,@)%&$*1&"dddddddddddddddddddddddddddddddddddddddddddddddd"G"
G'1+H:'$#$'.1H',,,N"$A4%Q=::,((,+X%?V%I#1N%
0'$#$'.1(%G.6%C6'1$%9.*6:,(%!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!%?%
UVVYSN%
R//="dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd"D"
BPDE" 7888A"&444.4E-,#)-+K./,;K2.U+'0+K7"BJ3)%3*E9"" 7'*2"%3"5"^51+*1"R//="ddddddddddddddddddddddddddddddddddddddddddddddddd"D"
P05%)5@)*;"7888A"$''<;ZZ>>>9%***9/1+Z</1'5)Z
:/36*1*3.*ZY1/.**-%3+"dddddddddddddddddddddddddddddddddddddddddd"D"
.2&k-/.&k%</1'5)&Z%</1'5)&Z<,@)%.5'%/3&Z5,'$/1&Z
'153&N3)Z&'()*253,5)9<-6"" \/,135)"UY5<*1"6/125'X"dddddddddddddddddddddddddddddddddddddddddddddddd"c"
BP..*&&*-;"DC"\539"GCChE9" S'53-51-"ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd"c"
#*.$3%.5)"a*</1'"ddddddddddddddddddddddddddddddddddddddddddddddddddddddddd"c"
BPcE" K9:9#9"]%)&/3A"&/&.O#0)'+K.F-,K2.J\\)2P-+,-#'3A"
#$*&%&ZL%&&*1'5'%/3"ddddddddddddddddddddddddddddddddddddddddddddddddddddd"e"
\539"GCC!9"BJ3)%3*E9"P05%)5@)*;""
$''<;ZZ>>>9*629)**-&95.9,=Zl251=Z7S75@@1Z"" ?3<,@)%&$*-"L/.,2*3'"dddddddddddddddddddddddddddddddddddddddddddddd"e"
BP..*&&*-;"DC"\539"GCChE9" 73'*10%*>&A"*'.9"dddddddddddddddddddddddddddddddddddddddddddddddddddddddd"e"
^*''*1&A"*'.9"ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd"e"
BPeE" JKK.F@+,.OJ/D.O#0)'+K.J\\)2P-+,-#'./#0)123A"
0'$#$'.1(%G.6%B4,:$6.1':%9.*6:,(%!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!%]%
P@@1*0%5'%/3&9./29"BJ3)%3*E9"P05%)5@)*;""
$''<;ZZ>>>95@@1*0%5'%/3&9./2ZN5&95&<"" ]*@"&%'*"dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd"M"
BP..*&&*-;"DC"\539"GCChE9" 84R//="dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd"M"
P1'%.)*"/1"\/,135)"ddddddddddddddddddddddddddddddddddddddddddddddddddddddddd"M"
BPME" 7888A">]]^.&444./,+'E+)E3./,;K2.U+'0+K9"
BJ3)%3*E9"P05%)5@)*;"7888A"$''<;ZZ P$",6%J(,G*4%;,G,6,1:,(%!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!%^%
&'53-51-&9%***9/1+Z+,%-*&Z&'()*Z"
GCChkS'()*kK53,5)9<-6""
BP..*&&*-;"e"`*@9"GCChE9"
<.6,%Z,47[%
#$*1*"%&"%36/125'%/3"%3"BPD!PeE"'$5'".53"@*"$*)<6,)" >$*3" "
,&%3+"5@@1*0%5'%/3&A"53-"%36/125'%/3"%3"BPME"'$5'"%&",&*6,)" L%-" (/," =3/>" '$5'" '$*1*" %&" &/2*/3*" 5'" '$*" E'36#68" >%'$"
%3">/1-".$/%.*A"<,3.',5'%/3"53-"&'()%3+;" &<*.%5)%j*-"%36/125'%/3"&=%))&"%3"(/,1"51*5"/6"&',-(m""
" "
#$%&" %&" (/,1" 9*3\,:$% 97,:'#4'($A" 53-" $*Z&$*" %&" $*1*" '/"
&87," 9.*6:,"
",47%8.*%5,$%#%3,$$,6%*1+,6($#1+'15%.G%$",%6,(.*6:,(%
P@@1*0%5'%/3&",&*-"%3" BPDA"<<9"!D4!cE" 8.*%1,,+%$.%(*::,,+"5'"L5)$/,&%*"?3%0*1&%'(9"
1*6*1*3.*&" "
#/"6%3-"/,'">$/"(/,1"&,@N*.'"&<*.%5)%&'"%&A"/1"6/1"$*)<">%'$"
7888"#153&5.'%/3&A"\/,135)&" BPDA"<<9"!e4!gE" '$%&"53-"/'$*1"-5'5@5&*&A"./3'5.'"5"E'36#6'#1;"
"
53-"^*''*1&"5@@1*0%5'%/3&"
V/347888"N/,135)"5@@1*0%5'%/3&" BPc!PeE" D1-"`)//1A"S*H'/3"^%@151(" Y$/3*;"hCG4chc4DhMe"
!DMC"R511%3+'/3"S'1**'" 8425%);"S*H'/39^%@151(o-5)9.5"
]/1-".$/%.*"53-",&5+*" BPMA"<<9"GD4GhE" Y9J9"R/H"!CCC"
[5)%65HA"VS"
" :535-5"RD\"Gnc"
"

f" N+3,.0:E+,2E.U+)1@.>]]^.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy