Presentation is loading. Please wait.

Presentation is loading. Please wait.

Training program: Mechanic - electrotechnician Program name: Digital processing - microprocessors III. class Microcontrollers Elaborated by: Vlastimil.

Similar presentations


Presentation on theme: "Training program: Mechanic - electrotechnician Program name: Digital processing - microprocessors III. class Microcontrollers Elaborated by: Vlastimil."— Presentation transcript:

1

2 Training program: Mechanic - electrotechnician Program name: Digital processing - microprocessors III. class Microcontrollers Elaborated by: Vlastimil Vlček Projekt Anglicky v odborných předmětech, CZ.1.07/1.3.09/04.0002 je spolufinancován Evropským sociálním fondem a státním rozpočtem České republiky.

3 How does a microcontroller work? Unlike the classic hardware solution by means of standard digital circuits, the required function of an electronic device is carried out by means of a program which is saved in a dedicated area of the memory of a microcontroller. After the program is launched, the microcontroller reads the first instruction, decodes it and carries it out. Immediately afterwards, the program will do the same with the second instruction, then the third, fourth etc. This is therefore referred to as a sequence of instructions, forming a definite functional unit which performs a particular activity. Program run is controlled by an internal source of clock frequency. Instructions are carried out individually, at one moment it is possible to carry out only one instruction, it is therefore not possible to carry out two or more instructions at the same time. Everything, however, occurs many times per second, so the result is a seemingly continuous action.

4 Procedure for creating applications with microcontrollers Assignment Design of an electric circuit diagram Assembling a functional model of the design prototype Design of the program block diagram Writing the source text of the program Translation into the machine code of a microcontroller, elimination of syntactic errors Debugging of individual parts of the program (possible software simulation), debugging on a functional model (function check, testing) Writing a finished, debugged code in the program memory of a microcontroller

5 Development environment Development environment is a complex of means for assembling and debugging of a program in the target application. ICD (In Circuit Debugger) is a method of program debugging directly inside the chip of a microcontroller (in its program memory).

6 Main principles of designing a device with microcontrollers. Careful design and check of a circuit diagram. Careful construction of a functional model (thorough check of the printed circuit, measuring the components, high-quality soldering, not to use soldering pastes and other preparations, only clean colophony!). Fit the important parts of the program source text with notes to make it comprehensible even after a longer time. In longer programs use the principles of structured programming, debug the individual functional blocks separately and call them by means of subroutines. Thus the main program block can be short and clear and both the structure and the function of the program are obvious at first sight.

7 An example of designing a simple device controlled by a microcontroller. Design an electronic device in which a light emitting diode (LED) is switched on after pressing the button. The LED diode must remain on while the button is pressed; when the button is released, the diode must switch off. Implement the device by means of the PIC16F883 microcontroller. The function of the device must be implemented with the help of software.

8 Circuit diagram design

9 Block diagram

10 Corresponding code in an assembler list F=inhx8m, P=16F84A, R=hex, N=0 __config 0x3FF9 ;Definition of special function regist ers Portaequ0x05 portb equ0x06 trisa equ0x85 trisb equ0x86 Status equ0x03 #defineTLRB0;the button is on a zero bit of the B port #defineLEDRA0;the LED diode is on a zero bit of the A port org0 ;Port inicialization bankseltrisa;bank selection movlw b'00001111' ;setup of ports movwf trisa movlw b'00000000' movwf trisb bankselporta;bank selection bsfLED;the LED diode switching off ;The beginning of the main program back btfscTL;button test. Is it pressed? gotoback;no -> we read again bcfLED;yes -> switch on the LED diode! zp1btfssTL;button test. Is it already released? gotozp1;no -> we read again bsfLED;yes -> switch off the LED diode! goto back end

11 Clear presentation of the function of the whole assignment Clear view of the division of a problem into individual parts Universality of the solution – independence on a particular programming language (knowledge of a particular programming language is not necessary at this moment) Easy portability between various development systems and programming languages (there is no programming code yet) In more complicated tasks, it is possible to make detailed drawings of individual main functional units, they describe a certain part of the program in a more detailed way. A certain limit must not be, however, exceeded, otherwise the main advantage of a block diagram – clearness – will disappear. The purpose of a block diagram

12 Summary of the subject matter What is the task of a program in a microcontroller? What is the task and purpose of a block diagram? Can any text editor (e.g. MS-Word) be used for writing the source text of a program?

13 Summary of the subject matter Is it possible for a microcontroller to process several instructions at the same time? What springs to your mind when you hear the term “development environment”?

14  Datasheet Microchip PIC16F882/883/884/886/887 DS41291E (http://www.microchip.com)  Jiří Hrbáček: Mikrořadiče PIC16CXX a vývojový kit PICSTART (BEN – technická literatura, Praha 2001 3. dotisk 4. vydání) References


Download ppt "Training program: Mechanic - electrotechnician Program name: Digital processing - microprocessors III. class Microcontrollers Elaborated by: Vlastimil."

Similar presentations


Ads by Google