MIKROPROCESORY PRO VÝKONOVÉ SYSTÉMY. Speciální obvody a jejich programování v C 2. díl. České vysoké učení technické Fakulta elektrotechnická

Podobné dokumenty
MIKROPROCESORY PRO VÝKONOVÉ SYSTÉMY. Speciální obvody a jejich programování v C 2. díl

MIKROPROCESORY PRO VÝKONOVÉ SYSTÉMY. Stručný úvod do programování v jazyce C 2.díl. České vysoké učení technické Fakulta elektrotechnická

GUIDELINES FOR CONNECTION TO FTP SERVER TO TRANSFER PRINTING DATA

Tento materiál byl vytvořen v rámci projektu Operačního programu Vzdělávání pro konkurenceschopnost.

Introduction to MS Dynamics NAV

MIKROPROCESORY PRO VÝKONOVÉ SYSTÉMY. Stručný úvod do programování v jazyce C 1.díl. České vysoké učení technické Fakulta elektrotechnická

MIKROPROCESORY PRO VÝKONOVÉ SYSTÉMY. Systém přerušení. České vysoké učení technické Fakulta elektrotechnická

By David Cameron VE7LTD

DC circuits with a single source

USER'S MANUAL FAN MOTOR DRIVER FMD-02

UPM3 Hybrid Návod na ovládání Čerpadlo UPM3 Hybrid 2-5 Instruction Manual UPM3 Hybrid Circulation Pump 6-9

User manual SŘHV Online WEB interface for CUSTOMERS June 2017 version 14 VÍTKOVICE STEEL, a.s. vitkovicesteel.com

2. Entity, Architecture, Process

1 INTRODUCTION 2 TESTING HARDWARE

Gymnázium, Brno, Slovanské nám. 7 WORKBOOK. Mathematics. Teacher: Student:

Transportation Problem

Radiova meteoricka detekc nı stanice RMDS01A

2N LiftIP. IO Extender. Communicator for Lifts. Version

Základy digitální techniky

Gymnázium a Střední odborná škola, Rokycany, Mládežníků 1115

MIKROPROCESORY PRO VÝKONOVÉ SYSTÉMY. Special HW pheripheries and their programming in C 1. díl. České vysoké učení technické Fakulta elektrotechnická

WL-5480USB. Quick Setup Guide

WORKSHEET 1: LINEAR EQUATION 1

Střední průmyslová škola strojnická Olomouc, tř.17. listopadu 49

dspic33: Přerušení, čítače a Change Notification

Standard VGA (Video Graphics Array)

Litosil - application

VY_32_INOVACE_06_Předpřítomný čas_03. Škola: Základní škola Slušovice, okres Zlín, příspěvková organizace

Chapter 7: Process Synchronization

USING VIDEO IN PRE-SET AND IN-SET TEACHER TRAINING

POSLECH. Cinema or TV tonight (a dialogue between Susan and David about their plans for tonight)

CHAPTER 5 MODIFIED MINKOWSKI FRACTAL ANTENNA

PC/104, PC/104-Plus. 196 ept GmbH I Tel. +49 (0) / I Fax +49 (0) / I I

DATA SHEET. BC516 PNP Darlington transistor. technický list DISCRETE SEMICONDUCTORS Apr 23. Product specification Supersedes data of 1997 Apr 16

Připojení internetového modulu econet300 Do regulátoru ecomax 810P3-L TOUCH.

POPIS TUN TAP. Vysvetlivky: Modre - překlad Cervene - nejasnosti Zelene -poznamky. (Chci si ujasnit o kterem bloku z toho schematu se mluvi.

Next line show use of paragraf symbol. It should be kept with the following number. Jak může státní zástupce věc odložit zmiňuje 159a.

Automatika na dávkování chemie automatic dosing

2N Voice Alarm Station

Digital Electronics. Jaroslav Bernkopf. 17 October 2008

dat 2017 Dostupný z Licence Creative Commons Uveďte autora-zachovejte licenci 4.0 Mezinárodní

Transformers. Produkt: Zavádění cizojazyčné terminologie do výuky odborných předmětů a do laboratorních cvičení


Měřič výkonu 1μW - 1kW. Power Meter 1μW - 1kW

Compression of a Dictionary

Škola: Střední škola obchodní, České Budějovice, Husova 9. Inovace a zkvalitnění výuky prostřednictvím ICT

External ROM 128KB For Sinclair ZX Spectrum

TechoLED H A N D B O O K

EU peníze středním školám digitální učební materiál

CHAIN TRANSMISSIONS AND WHEELS


1, Žáci dostanou 5 klíčových slov a snaží se na jejich základě odhadnout, o čem bude následující cvičení.

Mechanika Teplice, výrobní družstvo, závod Děčín TACHOGRAFY. Číslo Servisní Informace Mechanika:

Aktivita CLIL Chemie III.

Vánoční sety Christmas sets

Arduino Data Logger Shield

Využití hybridní metody vícekriteriálního rozhodování za nejistoty. Michal Koláček, Markéta Matulová

PRAVIDLA ZPRACOVÁNÍ STANDARDNÍCH ELEKTRONICKÝCH ZAHRANIČNÍCH PLATEBNÍCH PŘÍKAZŮ STANDARD ELECTRONIC FOREIGN PAYMENT ORDERS PROCESSING RULES

4Ever H A N D B O O K

Progressive loyalty V1.0. Copyright 2017 TALENTHUT

SPECIFICATION FOR ALDER LED

Uživatelská příručka. Xperia P TV Dock DK21

Arduino Ethernet Shield W5100 R3

Jak importovat profily do Cura (Windows a

Střední průmyslová škola strojnická Olomouc, tř.17. listopadu 49

Czech Republic. EDUCAnet. Střední odborná škola Pardubice, s.r.o.

ROLZ-2. Portable AV/Conference Center. Assembly Instructions

EXACT DS OFFICE. The best lens for office work

Výukový materiál zpracovaný v rámci operačního programu Vzdělávání pro konkurenceschopnost

Klepnutím lze upravit styl předlohy. nadpisů. nadpisů.

Microchip. PICmicro Microcontrollers

2N LiftIP. Voice Alarm Station. Communicator for Lifts. Version

Tabulka 1 Stav členské základny SK Praga Vysočany k roku 2015 Tabulka 2 Výše členských příspěvků v SK Praga Vysočany Tabulka 3 Přehled finanční

Co je uvnitř - senzory a přístrojová technika v NXT robotech. Pavel Ripka katedra měření ČVUT

UŽIVATELSKÁ PŘÍRUČKA

H2shop.cz. english česky

obal manuálu, asi něco podobného jako u LC 100 asi by to chtělo lepší obrázek!!! FYTOSCOPE FS130 Instruction Guide

USER'S MANUAL FAN MOTOR DRIVER FMD-01, FMD-03

Střední škola obchodní, České Budějovice, Husova 9, VY_INOVACE_ANJ_741. Škola: Střední škola obchodní, České Budějovice, Husova 9

ALFA UP H A N D B O O K

FIRE INVESTIGATION. Střední průmyslová škola Hranice. Mgr. Radka Vorlová. 19_Fire investigation CZ.1.07/1.5.00/

Číslo projektu: CZ.1.07/1.5.00/ Název projektu: Inovace a individualizace výuky

1 st International School Ostrava-mezinárodní gymnázium, s.r.o. Gregorova 2582/3, Ostrava. IZO: Forma vzdělávání: denní

PAINTING SCHEMES CATALOGUE 2012

Digital Control of Electric Drives. Vektorové řízení asynchronních motorů. České vysoké učení technické Fakulta elektrotechnická

Database systems. Normal forms

Aplikace Embedded systémů v Mechatronice. Michal Bastl A2/713a

1. Maple - verze. 2. Maple - prostredi. Document Mode vs. Worksheet Mode

TKGA3. Pera a klíny. Projekt "Podpora výuky v cizích jazycích na SPŠT"

Just write down your most recent and important education. Remember that sometimes less is more some people may be considered overqualified.

PITSTOP VY_22_INOVACE_26

Utilita L32 LogSync v

LOGBOOK. Blahopřejeme, našli jste to! Nezapomeňte. Prosím vyvarujte se downtrade

Theme 6. Money Grammar: word order; questions

WYSIWYG EDITOR PRO XML FORM

Čipové karty Lekařská informatika

Číslo materiálu: VY 32 INOVACE 29/18. Číslo projektu: CZ.1.07/1.4.00/

Fourth School Year PISTON MACHINES AND PISTON COMPRESSORS

VOŠ, SPŠ automobilní a technická. Mgr. Marie Šíchová. At the railway station

MIKROPROCESORY PRO VÝKONOVÉ SYSTÉMY. Systémová struktura počítače

Transkript:

MIKROPROCESORY PRO VÝKONOVÉ SYSTÉMY Speciální obvody a jejich programování v C 2. díl České vysoké učení technické Fakulta elektrotechnická Ver.1.10 J. Zděnek, 2017

Compare Unit The following three screens illustrate a different configurations of Compare Unit, which is often used, for example, to generate PWM modulation for a three-phase asynchronous motor. The principle of this unit (following picture): The Up-down Counter counts from zero to the continuously adjustable maximum value and then automatically starts the decrement back to zero. It generates the so-called carrier wave (Carrier Wave) The unit contains two digital comparators that compare the state of the bidirectional counter with the contents of the programmable comparator registers. If the event of a match, the unit generates a logical 0 level if the counter counts up or the logical level 1 if the counter is sweeping down (subtracts). The so-called modulation wave (Modulation Wave) The output value is further adjusted (delayed) so that the output that generates the complementary signal for the transistors of one inverter leg is not triggered at the same time (Dead Time) When changing the counting direction of the counter (zero, max), the unit sets an interrupt request and the new content of the corresponding comparator registrs are loaded. A1B14MIS Mikroprocesory pro výkonové systémy 09 2

Compare Unit A1B14MIS Mikroprocesory pro výkonové systémy 09 3

Compare Unit second config The following screen shows the block diagram of a Compare Unit config for one leg. The comparator has three such branches for generating a total of six output pulses for three three-phase full bridge transistors for supplying a three-phase asynchronous motor (Induction Motor) The two-way counter is common to all three branches. Phase shift of pulses of individual branches (for motor power supply) is done by the software by correct filling all six comparator registers (generation of modulation wave. The overall block diagram of the compare unit for generating six PWM outputs with short-circuit protection as the Dead Timer circuit is shown in the second following screen. Output PWM signals from a microcontroller can not directly power up transistors (voltage levels, pulse potential, desired current). Thus, a transformation element called Transistor Driver is inserted between the outputs of the PWM modulator from the microcontroller and the transistors. A1B14MIS Mikroprocesory pro výkonové systémy 09 4

Compare Unit - single chanel A1B14MIS Mikroprocesory pro výkonové systémy 09 5

Compare Unit general view Carrier Wave Code (Kód nosné vlny) Int Žádost o obsluhu Driver (Budič tranzistorů Clock (Takt) Up-Down Counter (Obousměrný čítač) + Compare Unit1 Společná reference Dead Time & Output Logic Compare Unit2 Dead Time & Output Logic + + Induction Machine (Třífázový asynchronní motor) Compare Unit3 Dead Time & Output Logic A1B14MIS Mikroprocesory pro výkonové systémy 09 6

I/O ports The ports of the PIC18F87J11 microcontroller (and the like) can be controlled (read or written) either directly by the software or hardware input or output (eg Capture Unit or Compare Unit,...). The ports are eight-bits wide and are designed to allow any combination of input and output configuration for standard ports, only input (analogue or digital) can be set for the analog input ports. After resetting, all ports (their bits) are set as inputs (in order to avoid electrical conflict with external hardware). The default block diagram of standard port is follows: Each standard port includes: Direction register Output register Input register Control logic for proper write or port bit read A1B14MIS Mikroprocesory pro výkonové systémy 09 7

I/O pin Read of port value LATCH Write to pin register LATCH or PORT Write to direction register LATCH (1=Input, 0=Output) Read of pin state PORT Pin I/O based on TRISx value Input port register A1B14MIS Mikroprocesory pro výkonové systémy 09 8

Port acces controll For a given standard port, the output or input is selected by writing to the appropriate bit register (TRIS): Output - Write in the TRIS bit 0 (mnemo: 0 resembles O) The input to the TRIS bit is written 1 (mnemo: 1 resembles I) If the port is handled by HW (eg Capture / Compare Unit), it is also necessary to enter a programmable value for the I / O in the direction register. After the RESET microcontroller are in TRIS 1 (all Input) By writing to the register (LAT or PORT - the same register) the corresponding values are written to the LATCH registrer. If the relevant TRIS registry bit is set to output (0 - Output), the values from the LATCH register appear on the output pin. The value from the output register is read by reading the LAT. The pin value of the microcontroller is read by reading PORT. Thus, the value of the LATCH output register may be other than the pin of the microcontroller if the bit is not set to output, or the external hardware holds a pin other than LATCH. A1B14MIS Mikroprocesory pro výkonové systémy 09 9

Example: 2x interrupt, 2 interrupt levels The following example demonstrates the use of the PIC18F87J11 microcontroller priority system, which has two levels (higher and lower priority) Interrupt requests generate two timers (TMR0 and TMR1) to set the corresponding request for xif (Interrupt Flag). Interrupt Flag sets the appropriate interrupt source (here any of the timers) in the harware. Interrupt Flag must be reset in ISR by programmer. The xif reset in this example is done at the beginning of the ISR, but the reset can be located anywhere in the ISR. The interrupt level is blocked in the hardware before the next request until the ISR completes. The application processing itself is simulated in this example by incrementing the x and y variables in the corresponding ISRs. The interrupt enable (GIEH, GIEL) must always be placed in the program as the last one after initialization and setting of all other registers and bits used. A1B14MIS Mikroprocesory pro výkonové systémy 09 10

Example: 2x interrupt, 2 interrupt levels A1B14MIS Mikroprocesory pro výkonové systémy 09 11

Example: 2x interrupt, 2 interrupt levels A1B14MIS Mikroprocesory pro výkonové systémy 09 12

Example: 2x interrupt, 2 interrupt levels A1B14MIS Mikroprocesory pro výkonové systémy 09 13

Example: 1x interrupt, 2 interrupt sources The following example illustrates a situation where multiple interrupt requests are connected to one level (for example, because we want to use 4 interrupt request sources and the PIC18F87J11 microcontroller has only two priority levels. In the example, the TMR0 and TMR1 timers are connected to a higher interrupt priority level, the lower level is not used (its Interrupt Enable Flag IE ie PIE1bits.TMR1IE = 0 (ie FALSE). In ISR at the higher level, xif from each timer is tested and sw flags t0int, t1int are set accordingly. At the same time, it is shown how to transfer the calculation from ISR to background loop. Why to do that? This microcontroller has a small hw stack and it is not appropriate in ISR to build extensive user programs and call functions. The interrupt enable bits (GIEH, GIEL) must always be placed in the program as the last one after initialization and setting of all other registers and bits used. Both GIEH and GIEL flags must be set to 1 (TRUE) even if one of two interrupt priority levels is not used. A1B14MIS Mikroprocesory pro výkonové systémy 09 14

Example: 1x interrupt, 2 interrupt sources A1B14MIS Mikroprocesory pro výkonové systémy 09 15

Example: 1x interrupt, 2 interrupt sources A1B14MIS Mikroprocesory pro výkonové systémy 09 16

Example: 1x interrupt, 2 interrupt sources A1B14MIS Mikroprocesory pro výkonové systémy 09 17

Example: 1x interrupt, 2 interrupt sources A1B14MIS Mikroprocesory pro výkonové systémy 09 18

Example: Capture Unit period measurement The following two screens resemble the Capture Unit block diagram and the timing of its Let's recall the purpose of the Capture Unit. The unit allows to remove the delay from the actual event arrival time (input impulse signal edge), by reading the reference timer in the ISR (the actual edge arrival time is stored in the Capture Register). This eliminates unacceptable errors when measuring high frequency signals (ie a short period). To program the Capture Unit, an input signal is required. In hardware we need to connect it to the input. However, it is preferable to debug the MPLAB Simulator program, where an input signal generator is available A1B14MIS Mikroprocesory pro výkonové systémy 09 19

Example: Capture Unit period measurement A1B14MIS Mikroprocesory pro výkonové systémy 09 20

Example: Capture Unit period measurement A1B14MIS Mikroprocesory pro výkonové systémy 09 21

Example: Capture Unit period measurement To debug the Capture Unit, an input signal is required. In hardware, we need to connect it to the input of the microcontroller. However, the program can be debugged in the MPLAB Simulator, where an input signal generator named Stimulus In the MPLAB menu, we find it in "Debugger-> Stimulus". Stimulus has several modes to generate the input signal to inputs in the Simulator. In the following screen, a Capture Unit program is used to debug the input signal timing from the processor clock. The input of the Capture Unit 1 is pin RC2. The start-up stimulus waits for 1000 steps (it's optional), and then every 500 steps generates the edge, ie the period of the generated signal is 1000 steps (see next screen). This is followed by a Capture Unit program with Timer1 reference timer. For this example, it is not necessary to monitor the timer overflow, its connection to the lower level of the interrupt is only demonstrative. The variable period must have the same dimension (here 16 bits) as the Capture Register to make the modulo 16 run correctly (the preposition for the example above is that the timer overflows only once (not multiple times) when measuring longer periods. A1B14MIS Mikroprocesory pro výkonové systémy 09 22

Example: Capture Unit period measurement A1B14MIS Mikroprocesory pro výkonové systémy 09 23

Example: Capture Unit period measurement A1B14MIS Mikroprocesory pro výkonové systémy 09 24

Example: Capture Unit period measurement A1B14MIS Mikroprocesory pro výkonové systémy 09 25

Example: Capture Unit period measurement A1B14MIS Mikroprocesory pro výkonové systémy 09 26

Example: Capture Unit period measurement Two 8 bit variables into one 16bit A1B14MIS Mikroprocesory pro výkonové systémy 09 27

Example: Capture Unit period measurement The following screen shows in the "Watch" window that the measured period using the Capture Unit and the input from the Stimulus signal generator is exactly the expected 1000 steps of the processor clock, independent of the timer reference timer 1 from which the time information is taken from the Capture Register. The "Watch" window is in the "View-> Watch" menu. A1B14MIS Mikroprocesory pro výkonové systémy 09 28

Example: Capture Unit period measurement A1B14MIS Mikroprocesory pro výkonové systémy 09 29

Example: Compare Unit PWM generation The following two screens resemble a Compare Unit block diagram and time diagram when using it. Recall the purpose of the Compare Unit. The unit allows to eliminate the delay between the required signal edge generating time and the actual edge time if the edge was generated by the software in the ISR. Compare Unit allows you to pre-program the type and time (calculated in the reference timer code) of the future generated edges in advance in the ISR. The desired future edge time is programmed into the Compare Register and the type of future edge (ascending, descending) into the Event Register. In this way, the Compare Unit together with the software generates an output signal (PWM) exactly in relation to the stepping of the reference timer. Let's also recall (and from the following example, it is clear) that the Compare Unit itself does not know anything, the software must be serviced. For debugging with the Compare Unit, we use the simulator in MPLAB and the Viewed Simulator Logic Analyzer. When tuning in hardware, you need to use the best digital oscilloscope to view the generated signal. A1B14MIS Mikroprocesory pro výkonové systémy 09 30

Compare Unit A1B14MIS Mikroprocesory pro výkonové systémy 09 31

Compare Unit principle A1B14MIS Mikroprocesory pro výkonové systémy 09 32

Example: Compare Unit PWM generation The following example (somewhat longer) demonstrates the use of the Compare Unit. Both levels of interrupt are used. Compare Unit in this example generates PWM with fixed period and variable active PWM (log 1). The Timer1 is reference timer for the Compare Unit. The ISR in the higher priority programes the time and type (upward, downward) of next generated edges. The active part of the PWM (i.e., log 1) is swept in a lower priority ISR that responds to the Timer0 overflow. PWM has Dead Time at both ends of the generated period. In this example, note: Program Structures (Few Functions) Appropriate Program Flags (Software Flags) using structure type structure (structure "status"). Symbolic choice of program constants. Initialize timers and Compare Unit. ISR structures in both priority layers. A1B14MIS Mikroprocesory pro výkonové systémy 09 33

Example: Compare Unit PWM generation A1B14MIS Mikroprocesory pro výkonové systémy 09 34

Example: Compare Unit PWM generation A1B14MIS Mikroprocesory pro výkonové systémy 09 35

Example: Compare Unit PWM generation A1B14MIS Mikroprocesory pro výkonové systémy 09 36

Example: Compare Unit PWM generation A1B14MIS Mikroprocesory pro výkonové systémy 09 37

Example: Compare Unit PWM generation A1B14MIS Mikroprocesory pro výkonové systémy 09 38

Example: Compare Unit PWM generation A1B14MIS Mikroprocesory pro výkonové systémy 09 39

Example: Compare Unit PWM generation A1B14MIS Mikroprocesory pro výkonové systémy 09 40

Example: Compare Unit PWM generation A1B14MIS Mikroprocesory pro výkonové systémy 09 41

Example: Compare Unit PWM generation A1B14MIS Mikroprocesory pro výkonové systémy 09 42

Example: Compare Unit PWM generation A1B14MIS Mikroprocesory pro výkonové systémy 09 43

Example: Compare Unit PWM generation The following screen shows the MPLAB (SIM) simulator and the Simulator Logic Analyzer (MPLAB) logic analyzer. The top screen captures the generated fixed period of PWM (10000) timer steps, and the active part of the PWM (Duty Cycle) is just over 50%. The bottom screen then shows the time difference between the PWM edge generated by the Compare Unit (ie, hardware) and the edge-generated software (RD0 output), see ISR for interrupt processing from Compare Unit ie void CCP1_int (void). In actual use, the active part of the PWM (log 1) will be controlled, for example, by a man-operated sensor or better from the controller output. A1B14MIS Mikroprocesory pro výkonové systémy 09 44

Example: Compare Unit PWM generation A1B14MIS Mikroprocesory pro výkonové systémy 09 45

MIKROPROCESORY PRO VÝKONOVÉ SYSTÉMY Speciální obvody a jejich programování v C 2. díl KONEC České vysoké učení technické Fakulta elektrotechnická