1 / 13

Microcontroller Programming for Technical Subjects

This program teaches students how microcontrollers work and how to design and program devices using microcontrollers in technical subjects. It covers circuit design, code writing, debugging, and development environments. Suitable for English-language teaching in technical subjects.

colligan
Download Presentation

Microcontroller Programming for Technical Subjects

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Anglicky v odborných předmětech"Support of teaching technical subjects in English“ Výukový program: Mechanik - elektrotechnik Název programu: Číslicová technika - mikroprocesory III. ročník, Mikrořadiče Vypracoval: 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.

  2. 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 aprogram which is saved in a dedicated areaof 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 asequence 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.

  3. 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

  4. Development environment Development environment is a complex of means for assembling and debugging of aprogram 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).

  5. 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 usesoldering 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 theprogram are obvious at first sight.

  6. 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 thePIC16F883 microcontroller. The function of the device must be implemented with the help of software.

  7. Circuit diagram design

  8. Block diagram

  9. Corresponding code in an assembler list F=inhx8m, P=16F84A, R=hex, N=0 __ config 0x3FF9 ;Definition of special function registers Porta equ 0x05 portb equ 0x06 trisa equ 0x85 trisb equ 0x86 Status equ 0x03 #define TL RB0 ;the button is on a zero bit of the B port #define LED RA0 ;the LED diode is on a zero bit of the A port org 0 ;Port inicialization banksel trisa ;bank selection movlw b'00001111' ;setup of ports movwf trisa movlw b'00000000' movwf trisb banksel porta ;bank selection bsf LED ;the LED diode switching off ;The beginning of the main program back btfsc TL ;button test. Is it pressed? goto back ;no -> we read again bcf LED ;yes -> switch on the LEDdiode! zp1 btfss TL ;button test. Is it already released? goto zp1 ;no -> we read again bsf LED ;yes -> switch off the LED diode! goto back end

  10. The purpose of a block diagram • 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.

  11. 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?

  12. 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”?

  13. References • DatasheetMicrochip 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í)

More Related