Railway Foundation - PowerPoint PPT Presentation

About This Presentation
Title:

Railway Foundation

Description:

Title: Railway Foundation Author: Alan Goude Last modified by: Alan Goude Created Date: 10/2/2005 10:59:15 AM Document presentation format: On-screen Show – PowerPoint PPT presentation

Number of Views:292
Avg rating:3.0/5.0
Slides: 18
Provided by: AlanG75
Category:

less

Transcript and Presenter's Notes

Title: Railway Foundation


1
Railway Foundation
  • Electronic, Electrical and Processor Engineering

2
Microprocessor Systems
  • Four main components
  • Microprocessor
  • Memory
  • Inputs
  • Outputs
  • Memory
  • ROM types program and fixed data
  • RAM (Read Write) Data variables

3
Microprocessor
  • Circuit is driven by a clock signal
  • The microprocessor has internal registers.
  • The action performed is determined by a set of
    binary instructions stored in ROM
  • A reset starts the microprocessor at a
    predetermined point in the program (usually
    location 0)

4
Inputs Outputs
  • Normally Digital I/O ( two levels 0 1)
  • Normally parallel i.e grouped 8bit Ports
  • What about analogue signals?
  • Analogue to Digital Converter (ADC)
  • Digital to Analogue Converter (DAC)
  • Other devices include hardware timers and
    counters
  • Digital data can also be in a serial format (e.g.
    RS232, RS 485 are serial standards)

5
Microcontrollers
  • Integration of all required components onto one
    chip.
  • Many manufacturers Microchip, Freescale, Intel,
    Infineon, Philips, ARM etc. producing different
    microprocessors
  • Many microcontrollers with same microprocessor
    but differ in other components.
  • Used in embedded products.

6
Programming
  • Can be done different levels
  • Object (machine) binary code
  • Assembly language
  • High level language ( e.g. C language)
  • Internal architecture
  • Memory Map
  • Programmers Model different for programming at
    different levels

7
An example machine instruction
EXAMPLES Machine code 0110111100001000 means
move the value from W reg. to file register
00001000 i.e 8
Assembly Count EQU 8 MOVWF Count A program
called an assembler converts it to the binary
object code.
8
An Assembler program
Program Line Numbers
00050 Constants 00051 LED equ 3
LED bit 3 on PORTB 00053 Reset
vector 00054 This code will
start executing when a reset occurs.
00055 000000 00056 ORG
0x0000 00057 00058 Start of
main program 000000 00059
Start 000000 9693 00060 bcf
TRISB,LED Set PortB bit 3 as an o/p 000002
9681 00061 bcf PORTB,LED set
LED off 000004 00062 Loop
while(1) 000004 8681 00063
bsf PORTB,LED turn led on 000006
9681 00064 bcf PORTB,LED
turn led off 000008 D7FD 00065 bra
Loop endwhile
ROM location
Comments Begin with
Assembly instructions
Object code in HEX format
Labels
9
C Programming
  • Portable
  • High level Abstract
  • Standard constructs
  • Variables various data types
  • Selection ( if statements)
  • Loops (while, for, do)
  • Standard operations (-/)
  • Logical and bit-wise operations (AND OR XOR etc.)

10
Simple C outline
  • Selection - two types
  • if (comparison is true ) Do this once
  • if (comparison is true ) Do this
    onceelse do this once
  • Example if (x 9)

Loops while (comparison is true ) KEEP Doing
this Example while ( y lt 10)
Comparisons- is equal to ! is not equal
to gt is greater than lt is less than gt is greater
or equal to lt is less than or equal to
Defining variables unsigned char i //8 bit
valueint x // 16 bit signedunsigned int y //
16 bit value
Misc. // starts a commenti // increment by
onei-- // decrement by one // logical
AND // logical OR
Assignment() and operators(-/) x 9i 7y
x/4 (5i) //integer division!
11
Practical approach
  • Treat as a programmable digital device
  • Choose device based on number and types of input
    and outputs
  • Write program-
  • Define inputs and outputs
  • Read input data, process data and generate
    outputs
  • Requires C language and knowledge of
    microcontroller specific features.

12
Microchip PIC 18F452 C18 C Compiler
  • Access to Special Function Registers by
    include ltp18f452.hgt
  • Defines names for all component parts.
  • Example PORTB an 8 bit digital I/O Port
  • TRISB - Port B direction register (0 output, 1
    input)
  • PORTB - all 8 bits
  • PORTBbits.RBx - individual bits where x is bit
    number (numbering starts at 0)

13
What does this do?
  • //PortA is 7 bits
  • TRISA 15
  • TRISB 0
  • PORTBbits.RB0 0
  • while(1)
  • while( PORTAbits.RA4 0)
  • while( PORTAbits.RA4 1)
  • PORTBbits.RB0 1
  • while( PORTAbits.RA4 0)
  • while( PORTAbits.RA4 1)

14
Analogue to Digital Converter(ADC)
  • n bits determines resolution
  • Reference voltage sets the input range
  • Often have an analogue multiplexer to allow
    several input channels to a single ADC

15
Example 8 bit ADC
  • Reference voltages of 0v and 5v
  • Input voltage range 5v 0v 5v
  • Number of digital values (steps) 2n 28 256
  • NOTE Values range from 0 to 255
  • Resolution Reference voltage range
  • 5 / 256
  • 0.01953125 volts 19.53125mV

Number of digital values
16
Remember max. digital value 255. Max.
convertible input 255 x resolution in volts
255 x 0.01953125 0.01953125 4.98046875 V
Digital value
255
Input voltage
0
4.98046875Volts
0
17
Digital Conversion
Digital value
3
2
0.05859375
1
0.0390625
Analogue Input voltage
0
0.01953125
Write a Comment
User Comments (0)
About PowerShow.com