Sunteți pe pagina 1din 31

Microcontroller Talk CRES-ARC

8/12/2006

microcontrollers_cres_arc.ppt

Topics To Touch On

History of microcontrollers What are microcontrollers How you can work with microcontrollers Overview of the W8ZPF Voter ID project

8/12/2006

microcontrollers_cres_arc.ppt

History Of Microcontrollers

Microprocessors came before Microcontrollers


November 1971

April of 1972

Intel introduced the world's first single chip microprocessor, the Intel 4004 First 8-bit microprocessor appeared on the market under a name 8008 8080 became available Addressed 64Kb of memory, had 75 instructions, and cost $360

April of 1974

MOS Technology - WESCON exhibit ( 1975)


a pivotal event in the history of microprocessors Announced the 6501 and 6502 at $25 each
microcontrollers_cres_arc.ppt 3

8/12/2006

What Are Microcontrollers?

Microprocessor Microcontroller what's the diff? Microprocessors can not stand alone

instruction decoder, ALU, address/data/ctl. busses, timing logic, (CPU) Has no capability to interact with the outside world

memory, I/O ports, UARTS, etc. must be added to make it useful

Microcontrollers are small computing systems on a single chip


Central Processing Unit (CPU) Program memory Random Access Memory (RAM) EEPROM - Electrically Erasable Programmable Read Only Memory A variety of peripheral devices

USARTs, Timer/Counters, ADC, DAC, I/O Ports, CANs, SPIs, etc., etc.
microcontrollers_cres_arc.ppt 4

8/12/2006

What Are Microcontrollers?


So, whats all the excitement about?

They are inexpensive- even in single pieces You can design complex functionality in a small package Microcontrollers can be viewed as a universal building block There are a lot of free tools to work with Microcontrollers And The thing I like the best - Next Slide!

8/12/2006

microcontrollers_cres_arc.ppt

What Are Microcontrollers?

8/12/2006

microcontrollers_cres_arc.ppt

What Are Microcontrollers?


Microchip 16F88 DIP Package

$3.90 each single unit price

8/12/2006

microcontrollers_cres_arc.ppt

What Are Microcontrollers? 16F88 INTERNAL VIEW


(Harvard Architecture)

Has 35 instructions Datasheet 214 pages

8/12/2006

microcontrollers_cres_arc.ppt

What Are Microcontrollers?


ATMEL ATmega8 DIP Package

$4.50 Each single unit price

8/12/2006

microcontrollers_cres_arc.ppt

What Are Microcontrollers? Atmega8 INTERNAL VIEW


(Harvard Architecture)

Has 130 instructions Datasheet 302 pages

8/12/2006

microcontrollers_cres_arc.ppt

10

How you can work with microcontrollers

So whats the catch?


If you are new to software development

You need to think in a new paradigm Start small and learn the basics first You can work with microcontrollers on a couple of levels Walk before you attempt to run

8/12/2006

microcontrollers_cres_arc.ppt

11

How you can work with microcontrollers


Ok So What Do Microcontrollers Do?
Well out of the box it does nothing! But you can make it do fantastic things

Just add software

8/12/2006

microcontrollers_cres_arc.ppt

12

How you can work with microcontrollers


How To Get Started

Select a controller family


Based on your goals Availability of free stuff Not a trivial task for the beginner You need a way to load programs

set-up a development environment


Then are you ready to start!


microcontrollers_cres_arc.ppt 13

8/12/2006

The W8ZPF Voter Controller

A real project

What are we trying to accomplish Interface to the repeater system Microcontroller Selection Development Environment Software Design The Final Board (observations)
microcontrollers_cres_arc.ppt 14

8/12/2006

The W8ZPF Voter Controller


What are we trying to accomplish?

Identify how each receiver participated in relaying signals to the main transmitter during a key down session Accommodate up to 3 receivers in the design Use existing repeater interfaces/signals

8/12/2006

microcontrollers_cres_arc.ppt

15

The W8ZPF Voter Controller


Simplified Interface Diagram
Current Voter Card CORE (H) RX1 Voted (^) RX1(H) RX2 (H) RX3 (H) RX1 Dominant (^) Sample every 100ms When CORE is active RX1 Dominant (^) RX1 Dominant (^) Calculate output when CORE goes inactive
< 90% of the time Low Pitch CW ID (M/R)** (DOMINANT) *Controller remembers last transition ** ACTUALLY 88.8 %

New Voter Microcontroller

Current Repeater Controller *

CD ID (M/R)

RX2 Voted (^) RX3 Voted (^)


=>90% of the time High Pitch CW ID (M/R) (VOTED)**

Inputs, Outputs, & Transformation


8/12/2006 microcontrollers_cres_arc.ppt 16

The W8ZPF Voter Controller


INTERFACE FOR THE VOTER CONTROLLER PROJECT

CORE LINE
Ignore RX inputs

Active

Idle

Accumulate Data (100ms)

1 or 0

Output lines retain previous data until core goes active again

RX1 RX3 output lines (active high)


All output lines are cleared after core goes active for debounce time.

There are 6 output lines 3 -> rx1 - rx3 voted 3-> rx1 - rx3 dominant microcontrollers_cres_arc.ppt 17

Version 1.0 - wje

8/12/2006

The W8ZPF Voter Controller


Microcontroller Selection

Looked at 2 controllers For This Project


Microchip 16F88 Atmel Atmega8

Basic software structure was implemented using both Either would have done the job

So how did I choose?

8/12/2006

microcontrollers_cres_arc.ppt

18

The W8ZPF Voter Controller


The development environment

16F88 Microchip microcontroller

(initial choice)

MPLAB

Free environment for assembly language Create, Edit, Assemble, Link, Load, & emulate programs I use it on Windows 2K I have used it for several projects works well No limitations on usage

8/12/2006

microcontrollers_cres_arc.ppt

19

The W8ZPF Voter Controller


The development environment

ATmega8 microcontroller

(final choice)

Open Software Foundation tool-set


GNU C compiler, assembler, linker Make utility Avrdude program loader

Runs on Linux (Unix) & Windows Wanted experience with this environment

Atmega8 is more compiler friendly However, a not significant issue for this project

Generally faster to develop SW using a compiler

8/12/2006

microcontrollers_cres_arc.ppt

20

The W8ZPF Voter Controller


The development environment
This is what it physically looks like Serial port ATmega8 Development board
(Spark Fun)

(program flash memory)

LINUX environment
(FC3 FC5)

Final board

8/12/2006

microcontrollers_cres_arc.ppt

21

The W8ZPF Voter Controller


Voter ID Board Schematic

8/12/2006

microcontrollers_cres_arc.ppt

22

The W8ZPF Voter Controller


The Microcontroller Board

8/12/2006

microcontrollers_cres_arc.ppt

23

The W8ZPF Voter Controller


The Software Design

This is where it gets a bit philosophical I think of it in these terms


Software is a solution to a problem Must understand the problem first Then think about strategies to solve it

8/12/2006

microcontrollers_cres_arc.ppt

24

The W8ZPF Voter Controller


The Software Design How does one start?

VARIOUS SOFTWARE STRATEGIES


8/12/2006 microcontrollers_cres_arc.ppt 25

The W8ZPF Voter Controller


The Software Design
(STATE MACHINE)
HW
100 MS interrupt Run Background process

States are: STARTUP IDLE COUNTING

Background Processing

Return from interrupt

Foreground Responsibilities - HW initialization


- Call action routines on state changes - Processes RX data on key-up - Signals main controller regarding RX usage (sets output lines)

Wakes-up foreground

Background Responsibilities - Debounce inputs


- Watch core line - Determine when new state exists - Maintain count for each Rx

Foreground Processing

New state

Call routine To handle the State change


Go to sleep

8/12/2006

microcontrollers_cres_arc.ppt

26

The W8ZPF Voter Controller


The Software Design
(STATE MACHINE)

Source File Statistics


main.c 155 lines main.h 17 lines init_timer1.c 30 lines init_io.c 103 lines interrupt.c 118 lines Makefile 328 lines
microcontrollers_cres_arc.ppt 27

8/12/2006

The W8ZPF Voter Controller


The Software Design
(STATE MACHINE)

More Statistics (Decimal)


RESOURCE

USED/AVAILABLE

Text size 1462/8K Bytes (program instructions/tables, etc) Data size 37/512 Bytes (variables) TOTAL 1499 Bytes (5DBh) Used

512 Bytes of EEPROM none used

8/12/2006

microcontrollers_cres_arc.ppt

28

The W8ZPF Voter Controller


main.h file variable declarations
#ifdef LOCAL #define EXTERN #else #define EXTERN extern #endif
enum { NO, YES }; enum { STARTUP, COUNTING, IDLE }; EXTERN EXTERN EXTERN EXTERN EXTERN unsigned char state; unsigned char new_state; int16_t rx1_count; int16_t rx2_count; int16_t rx3_count;
8/12/2006 microcontrollers_cres_arc.ppt 29

#define LOCAL #include main.h

The W8ZPF Voter Controller


This is the main loop (part of it anyway) of the foreground state machine code
while(1){ if(new_state == YES ){ new_state = NO; cli(); switch(state){ case COUNTING: // clear out old receiver counts on this state change rx1_count = 0; rx2_count = 0; rx3_count = 0; //clear all "voted" output lines to the repeater PORTB &= ~(_BV(PB0)); PORTB &= ~(_BV(PB1)); PORTB &= ~(_BV(PB2)); //clear all "dominant" output lines to the repeater PORTD &= ~(_BV(PD5)); PORTD &= ~(_BV(PD6)); PORTD &= ~(_BV(PD7)); break; case IDLE: /* Calculate results, set output lines accordingly **** This is long & will not show details here *** */ break; case STARTUP: // Do initialization here break; } sei(); } sleep_mode(); }

Fragment of code from main.c

8/12/2006

microcontrollers_cres_arc.ppt

30

The W8ZPF Voter Controller

THE END !!

8/12/2006

microcontrollers_cres_arc.ppt

31

S-ar putea să vă placă și