Upload
sarabjit-singh
View
214
Download
0
Embed Size (px)
Citation preview
8/2/2019 2006 08 N9CX Uproc Talk
1/31
8/12/2006 microcontrollers_cres_arc.ppt 1
Microcontroller Talk CRES-ARC
8/2/2019 2006 08 N9CX Uproc Talk
2/31
8/12/2006 microcontrollers_cres_arc.ppt 2
Topics To Touch On
History of microcontrollers
What are microcontrollers
How you can work with microcontrollers
Overview of the W8ZPF Voter IDproject
8/2/2019 2006 08 N9CX Uproc Talk
3/31
8/12/2006 microcontrollers_cres_arc.ppt 3
History Of Microcontrollers Microprocessors came before Microcontrollers
November 1971
Intel introduced the world's first single chip microprocessor, the Intel4004
April of 1972 First 8-bit microprocessor appeared on the market under a name 8008
April of 1974 8080 became available
Addressed 64Kb of memory, had 75 instructions, and cost $360
MOS Technology - WESCON exhibit ( 1975) a pivotal event in the history of microprocessors Announced the 6501 and 6502 at $25 each
8/2/2019 2006 08 N9CX Uproc Talk
4/31
8/12/2006 microcontrollers_cres_arc.ppt 4
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.
8/2/2019 2006 08 N9CX Uproc Talk
5/31
8/12/2006 microcontrollers_cres_arc.ppt 5
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 offree tools to work with
Microcontrollers
And The thing I like the best - Next Slide!
8/2/2019 2006 08 N9CX Uproc Talk
6/31
8/12/2006 microcontrollers_cres_arc.ppt 6
What Are Microcontrollers?
8/2/2019 2006 08 N9CX Uproc Talk
7/31
8/12/2006 microcontrollers_cres_arc.ppt 7
What Are Microcontrollers?
Microchip 16F88 DIP Package
$3.90 each single unit price
8/2/2019 2006 08 N9CX Uproc Talk
8/31
8/12/2006 microcontrollers_cres_arc.ppt 8
16F88 INTERNAL VIEW
What Are Microcontrollers?
(Harvard Architecture)
Has 35 instructionsDatasheet 214 pages
8/2/2019 2006 08 N9CX Uproc Talk
9/31
8/12/2006 microcontrollers_cres_arc.ppt 9
What Are Microcontrollers?
ATMEL ATmega8 DIP Package
$4.50 Each single unit price
8/2/2019 2006 08 N9CX Uproc Talk
10/31
8/12/2006 microcontrollers_cres_arc.ppt 10
Atmega8 INTERNAL VIEW(Harvard Architecture)
What Are Microcontrollers?
Has 130 instructionsDatasheet 302 pages
8/2/2019 2006 08 N9CX Uproc Talk
11/31
8/12/2006 microcontrollers_cres_arc.ppt 11
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/2/2019 2006 08 N9CX Uproc Talk
12/31
8/12/2006 microcontrollers_cres_arc.ppt 12
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/2/2019 2006 08 N9CX Uproc Talk
13/31
8/12/2006 microcontrollers_cres_arc.ppt 13
How you can work with microcontrollers
How To Get Started
Select a controller family
Based on your goals
Availability of free stuff
set-up a development environment
Not a trivial task for the beginner
You need a way to load programs
Then are you ready to start!
8/2/2019 2006 08 N9CX Uproc Talk
14/31
8/12/2006 microcontrollers_cres_arc.ppt 14
The W8ZPF Voter ControllerA real project
What are we trying to accomplish
Interface to the repeater system
Microcontroller Selection
Development Environment
Software Design
The Final Board (observations)
8/2/2019 2006 08 N9CX Uproc Talk
15/31
8/12/2006 microcontrollers_cres_arc.ppt 15
The W8ZPF Voter ControllerWhat are we trying to accomplish?
Identify how each receiver participated inrelaying signals to the main transmitterduring a key down session
Accommodate up to 3 receivers in thedesign
Use existing repeater interfaces/signals
8/2/2019 2006 08 N9CX Uproc Talk
16/31
8/12/2006 microcontrollers_cres_arc.ppt 16
The W8ZPF Voter ControllerSimplified Interface Diagram
Current VoterCard
New VoterMicrocontroller
Current RepeaterController
CORE (H)
RX1(H)
RX2 (H)
RX3 (H)
RX1 Voted (^)
RX2 Voted (^)
RX3 Voted (^)
RX1 Dominant (^)
RX1 Dominant (^)
RX1 Dominant (^)
=>90% of the timeHigh Pitch CW ID (M/R)(VOTED)**
< 90% of the timeLow Pitch CW ID (M/R)**
(DOMINANT)
Inputs, Outputs, & Transformation
CD ID (M/R)
*Controller remembers last transition
** ACTUALLY 88.8 %
*
Sample every 100ms
When CORE is active
Calculate output whenCORE goes inactive
8/2/2019 2006 08 N9CX Uproc Talk
17/31
8/12/2006 microcontrollers_cres_arc.ppt 17
The W8ZPF Voter ControllerINTERFACE FOR THE VOTER CONTROLLER PROJECT
RX1 RX3 output lines (active high)
CORE LINE
1 or 0 Output lines retain previous datauntil core goes active again
All output lines are clearedafter core goes active fordebounce time.
Version 1.0 - wje
There are 6 output lines3 -> rx1 - rx3 voted3-> rx1 - rx3 dominant
Active Idle
AccumulateData (100ms)Ignore RX inputs
8/2/2019 2006 08 N9CX Uproc Talk
18/31
8/12/2006 microcontrollers_cres_arc.ppt 18
The W8ZPF Voter ControllerMicrocontroller 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/2/2019 2006 08 N9CX Uproc Talk
19/31
8/12/2006 microcontrollers_cres_arc.ppt 19
The W8ZPF Voter ControllerThe 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/2/2019 2006 08 N9CX Uproc Talk
20/31
8/12/2006 microcontrollers_cres_arc.ppt 20
The W8ZPF Voter ControllerThe 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
Generally faster to develop SW using a compiler However, a not significant issue for this project
8/2/2019 2006 08 N9CX Uproc Talk
21/31
8/12/2006 microcontrollers_cres_arc.ppt 21
The W8ZPF Voter ControllerThe development environment
ATmega8Development board(Spark Fun)
LINUX environment(FC3 FC5)
Serial port(program flash memory)
This is what it physically looks like
Final board
8/2/2019 2006 08 N9CX Uproc Talk
22/31
8/12/2006 microcontrollers_cres_arc.ppt 22
The W8ZPF Voter ControllerVoter ID Board Schematic
8/2/2019 2006 08 N9CX Uproc Talk
23/31
8/12/2006 microcontrollers_cres_arc.ppt 23
The W8ZPF Voter ControllerThe Microcontroller Board
8/2/2019 2006 08 N9CX Uproc Talk
24/31
8/12/2006 microcontrollers_cres_arc.ppt 24
The W8ZPF Voter ControllerThe 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/2/2019 2006 08 N9CX Uproc Talk
25/31
8/12/2006 microcontrollers_cres_arc.ppt 25
The W8ZPF Voter ControllerThe Software Design How does one start?
VARIOUS SOFTWARE STRATEGIES
8/2/2019 2006 08 N9CX Uproc Talk
26/31
8/12/2006 microcontrollers_cres_arc.ppt 26
The W8ZPF Voter ControllerThe Software Design (STATE MACHINE)
BackgroundProcessing
ForegroundProcessing
Background Responsibilities- Debounce inputs- Watch core line- Determine when new
state exists- Maintain count for each Rx
Foreground Responsibilities- HW initialization- Call action routines on
state changes- Processes RX data onkey-up
- Signals main controllerregarding RX usage(sets output lines)
New state
Call routineTo handle theState change
Go to sleep
100 MS interrupt
Return from interruptWakes-up foreground
HW
Run Backgroundprocess
States are:STARTUPIDLECOUNTING
8/2/2019 2006 08 N9CX Uproc Talk
27/31
8/12/2006 microcontrollers_cres_arc.ppt 27
The W8ZPF Voter ControllerThe 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
8/2/2019 2006 08 N9CX Uproc Talk
28/31
8/12/2006 microcontrollers_cres_arc.ppt 28
The W8ZPF Voter ControllerThe 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/2/2019 2006 08 N9CX Uproc Talk
29/31
8/12/2006 microcontrollers_cres_arc.ppt 29
The W8ZPF Voter Controllermain.h file variable declarations
#ifdef LOCAL #define LOCAL#define EXTERN #include main.h#else#define EXTERN extern
#endif
enum { NO, YES };
enum { STARTUP, COUNTING, IDLE };
EXTERN unsigned char state;EXTERN unsigned char new_state;EXTERN int16_t rx1_count;EXTERN int16_t rx2_count;EXTERN int16_t rx3_count;
8/2/2019 2006 08 N9CX Uproc Talk
30/31
8/12/2006 microcontrollers_cres_arc.ppt 30
The W8ZPF Voter ControllerThis 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 changerx1_count = 0;rx2_count = 0;rx3_count = 0;
//clear all "voted" output lines to the repeaterPORTB &= ~(_BV(PB0));
PORTB &= ~(_BV(PB1));PORTB &= ~(_BV(PB2));
//clear all "dominant" output lines to the repeaterPORTD &= ~(_BV(PD5));PORTD &= ~(_BV(PD6));PORTD &= ~(_BV(PD7));break;
case IDLE:/*
Calculate results, set outputlines accordingly**** This is long & will not show details here ****/break;
case STARTUP:// Do initialization herebreak;
}sei();}sleep_mode();}
Fragment of code from main.c
8/2/2019 2006 08 N9CX Uproc Talk
31/31
8/12/2006 microcontrollers cres arc ppt 31
The W8ZPF Voter Controller
THE END !!