





































Estude fácil! Tem muito documento disponível na Docsity
Ganhe pontos ajudando outros esrudantes ou compre um plano Premium
Esta página não é visível na pré-visualização
Não perca as partes importantes!






































P M R 2 3 1 0 - L A B O R A T Ó R I O
39
Objetivo
Resumo
Experiência
40
Procedimento experimental
°
42
C> o d0 16 (liga o driver e prepara para andar p/ esquerda) C> o d0 1e (dispara o movimento para a esquerda) C> o d0 96 (liga o driver e prepara para andar p/ direita) C> o d0 9e (dispara o movimento para a direita)
C> o c3 90 (programa porta A para entrada e porta B para saída)
C> i c0 (lê o valor da porta A do 8255) DATA = DF (o valor lido é indicado depois do =) C>
43
int s1; // variável para status do sensor 1 out (0xc3, 0x90); // programa o 8255 com a porta A para // entrada s1 = in(0xc0) & 0x01; // lê o sensor 1 (bit menos // significativo) e aplica a máscara // (00000001)b para isolar o bit if (s1 == 0) { // se for igual a zero é porque // detectou . . . }
PMR2310 – Microprocessadores aplicados à automação 21
O acionamento do motor de passo é feito através da programação de um 8254 (Timer Programável) presente na
interface com motor de passo. A Figura 22 mostra o diagrama de blocos deste módulo. Conforme esta figura o
Timer 0 deve ser programado para reduzir a freqüência do clock do sistema (SYSCLOCK = 3,072 MHz) para
uma freqüência 2 vezes maior que a velocidade máxima de movimentação do motor de passo. A saída do Timer
0 é ligada diretamente ao clock do Timer 1 com o qual pode-se ajustar a freqüência de acionamento do motor de
passo, ou seja, a taxa de passos por segundo. Através da variação desta freqüência durante o movimento, o motor
pode ser acelerado ou desacelerado. O Timer 2 em conjunto com o flip-flop e com as portas lógicas permite a
definição do número de pulsos que deverá ser enviado para o motor.
Os outros comandos para a interface são dados através do registrador de comandos. Os comandos disponíveis
são os seguintes:
A Figura 23 mostra o significado dos bits do registrador de controle.
CLR
&
Via de dados do sistema
DIREÇÃO
ENABLE
8254
SYSRESET (^) &
gate gate gate Vcc CLOLK
CLK Q
D Q
SYSCLOCK (clock do sistema)
Driver de potência (L298)
Controlador de motor de passo (L297)
Registrador de controle
Timer 0 (modo 3)
Timer 1 (modo 3)
Timer 2 (modo 5)
Vcc
Motor de passo
Figura 22. Diagrama de blocos do módulo de controle de motor de passo
22 versão de 14/02/
Este módulo possui dois pontos de teste para verificação dos sinais com o osciloscópio. O ponto TP1 é o sinal de
seleção do 82C54 (Timers programáveis) e o ponto TP2 é o terra para conexão do terra do osciloscópio.
Os jumpers JP1 a JP4 configuram o tipo de módulo processador, se 8085 ou se 68HC11, Tabela XIV, enquanto
que os jumpers JP5 a JP8 configuram as faixas de endereços de acesso do módulo, Tabela XV. A Figura 24
mostra a posição dos jumpers na placa do módulo.
Tabela XIV. Configuração do tipo de microprocessador/ microcontrolador
microprocessador/microcontrolador JP1 JP2 JP3 JP
8085 ON OFF ON OFF
8052 ou 68HC11 OFF ON OFF ON
Tabela XV. Configuração das faixas de endereços de I/O
Faixa de endereços JP5 JP6 JP7 JP
C0H - CFH ON OFF OFF OFF
D0H - DFH OFF ON OFF OFF
E0H - EFH OFF OFF ON OFF
F0H - FFH OFF OFF OFF ON
A função de cada endereço é determinada pelos bits A0 a A3 de endereço adicionalmente aos bits A4 a A
determinados pelos jumpers JP5 a JP8. A Tabela XVI mostra a função de cada endereço na interface. O
registrador de controle da interface está no endereço n0H (onde n pode ser C, D, E ou F dependendo dos jumpers
JP5 a JP8) enquanto que o timer 8254 ocupa os endereços n4H a n7H (onde n pode ser C, D, E ou F dependendo
dos jumpers JP5 a JP8).
DIR x x CLR DISP EN GT1 H/F
D6 D5 D4 D3 D2 D1 D
Endereço: n0H*
D
Modo Half ou Full step 0 – Full step 1 – Half step
Gate do Timer 1 0 – para Timer 1 – habilita Timer
Habilita Driver do motor 0 – desabilita driver 1 – habilita driver
Dispara movimento quando em HIGH, deve retornar para LOW pelo menos um ciclo de clock antes de ser redisparado
Direção de rotação do motor 0 – sentido horário 1 – sentido anti-horário
Limpa o flip-flop de contagem de pulsos 0 – limpa o flip-flop 1 – permite a contagem
Figura 23. Palavra de controle da interface com motor de passo
24 versão de 14/02/
A Figura 25 apresenta o procedimento para
inicialização da interface.
Para iniciar o movimento deve-se escrever no
registrador de controle o bit D3=HIGH. Após a
escrita deste bit no registrador de controle o motor
de passo inicia o movimento com a freqüência
programada no Timer 1 com o número de pulsos
programado no Timer 2. O bit D3 do registrador
de controle deve retornar para LOW antes de
disparar o movimento do motor de passo
novamente.
O movimento do motor de passo é independente
de qualquer comando por software, uma vez
iniciado o movimento o mesmo é interrompido se ocorrer uma das situações abaixo:
A direção do movimento pode ser invertida com o motor em movimento através da escrita no registrador de
comando. Setando o bit D7=LOW o motor move-se em sentido horário, com D7=HIGH o motor move-se em
sentido anti-horário.
Para se determinar se o movimento do motor de passo chegou ao fim pode-se ler o valor do Timer 2 e verificar
duas situações:
A Figura 26 mostra as conexões entre o módulo de motor de passo, os outros módulos do kit, a fonte de
alimentação e o sistema de posicionamento.
Inicio
limpa o flip-flop de contagem de pulsos (bit D4)
habilita o driver do motor de passo (bit D2)
reseta o bit de disparo do movimento (bit D3)
programa o modo do Timer 0
programa o modo do Timer 2
programa o modo do Timer 1
programa a constante de redução de freq. do Timer 0
programa a constante de velocidade do Timer
programa a constante de número de pulsos do Timer 2
Fim
Figura 25. Procedimento de inicialização da interface
PMR2310 – Microprocessadores aplicados à automação 25
Figure 26. Conexões do Módulo do Motor de Passo com os outros mídulos do sistema
Table 1. Pin Description
Symbol Pin Number^ Type Name and Function Dip PLCC PA3–0 1–4 2–5 I/O PORT A, PINS 0–3: Lower nibble of an 8-bit data output latch/ buffer and an 8-bit data input latch. RD 5 6 I READ CONTROL: This input is low during CPU read operations. CS 6 7 I CHIP SELECT: A low on this input enables the 82C55A to respond to RD and WR signals. RD and WR are ignored otherwise. GND 7 8 System Ground A (^) 1–0 8–9 9–10 I ADDRESS: These input signals, in conjunction RD and WR, control the selection of one of the three ports or the control word registers. A 1 A 0 RD WR CS Input Operation (Read) 0 0 0 1 0 Port A - Data Bus 0 1 0 1 0 Port B - Data Bus 1 0 0 1 0 Port C - Data Bus 1 1 0 1 0 Control Word - Data Bus Output Operation (Write) 0 0 1 0 0 Data Bus - Port A 0 1 1 0 0 Data Bus - Port B 1 0 1 0 0 Data Bus - Port C 1 1 1 0 0 Data Bus - Control Disable Function X X X X 1 Data Bus - 3 - State X X 1 1 0 Data Bus - 3 - State PC (^) 7–4 10–13 11,13–15 I/O PORT C, PINS 4–7: Upper nibble of an 8-bit data output latch/ buffer and an 8-bit data input buffer (no latch for input). This port can be divided into two 4-bit ports under the mode control. Each 4-bit port contains a 4-bit latch and it can be used for the control signal outputs and status signal inputs in conjunction with ports A and B. PC (^) 0–3 14–17 16–19 I/O PORT C, PINS 0–3: Lower nibble of Port C. PB0-7 18–25 20–22, I/O PORT B, PINS 0–7: An 8-bit data output latch/buffer and an 8- 24–28 bit data input buffer. V (^) CC 26 29 SYSTEM POWER: a^ 5V Power Supply. D (^) 7–0 27–34 30–33, I/O DATA BUS: Bi-directional, tri-state data bus lines, connected to 35–38 system data bus. RESET 35 39 I RESET: A high on this input clears the control register and all ports are set to the input mode. WR 36 40 I WRITE CONTROL: This input is low during CPU write operations. PA7–4 37–40 41–44 I/O PORT A, PINS 4–7: Upper nibble of an 8-bit data output latch/ buffer and an 8-bit data input latch. NC 1, 12, No Connect 23, 34
2
82C55A FUNCTIONAL DESCRIPTION
General
The 82C55A is a programmable peripheral interface device designed for use in Intel microcomputer sys- tems. Its function is that of a general purpose I/O component to interface peripheral equipment to the microcomputer system bus. The functional configu- ration of the 82C55A is programmed by the system software so that normally no external logic is neces- sary to interface peripheral devices or structures.
Data Bus Buffer
This 3-state bidirectional 8-bit buffer is used to inter- face the 82C55A to the system data bus. Data is transmitted or received by the buffer upon execution of input or output instructions by the CPU. Control words and status information are also transferred through the data bus buffer.
Read/Write and Control Logic
The function of this block is to manage all of the internal and external transfers of both Data and Control or Status words. It accepts inputs from the CPU Address and Control busses and in turn, issues commands to both of the Control Groups.
Group A and Group B Controls
The functional configuration of each port is pro- grammed by the systems software. In essence, the CPU ‘‘outputs’’ a control word to the 82C55A. The control word contains information such as ‘‘mode’’, ‘‘bit set’’, ‘‘bit reset’’, etc., that initializes the func- tional configuration of the 82C55A.
Each of the Control blocks (Group A and Group B) accepts ‘‘commands’’ from the Read/Write Control Logic, receives ‘‘control words’’ from the internal data bus and issues the proper commands to its as- sociated ports.
Control Group A - Port A and Port C upper (C7–C4) Control Group B - Port B and Port C lower (C3–C0)
The control word register can be both written and read as shown in the address decode table in the pin descriptions. Figure 6 shows the control word format for both Read and Write operations. When the control word is read, bit D7 will always be a logic ‘‘1’’, as this implies control word mode information.
Ports A, B, and C
The 82C55A contains three 8-bit ports (A, B, and C). All can be configured in a wide variety of functional characteristics by the system software but each has its own special features or ‘‘personality’’ to further enhance the power and flexibility of the 82C55A.
Port A. One 8-bit data output latch/buffer and one 8-bit input latch buffer. Both ‘‘pull-up’’ and ‘‘pull- down’’ bus hold devices are present on Port A.
Port B. One 8-bit data input/output latch/buffer. Only ‘‘pull-up’’ bus hold devices are present on Port B.
Port C. One 8-bit data output latch/buffer and one 8-bit data input buffer (no latch for input). This port can be divided into two 4-bit ports under the mode control. Each 4-bit port contains a 4-bit latch and it can be used for the control signal outputs and status signal inputs in conjunction with ports A and B. Only ‘‘pull-up’’ bus hold devices are present on Port C.
See Figure 4 for the bus-hold circuit configuration for Port A, B, and C.
3
82C55A OPERATIONAL DESCRIPTION
Mode Selection
There are three basic modes of operation that can be selected by the system software:
Mode 0 – Basic input/output Mode 1 – Strobed Input/output Mode 2 – Bi-directional Bus
When the reset input goes ‘‘high’’ all ports will be set to the input mode with all 24 port lines held at a logic ‘‘one’’ level by the internal bus hold devices (see Figure 4 Note). After the reset is removed the 82C55A can remain in the input mode with no addi- tional initialization required. This eliminates the need for pullup or pulldown devices in ‘‘all CMOS’’ de- signs. During the execution of the system program, any of the other modes may be selected by using a single output instruction. This allows a single 82C55A to service a variety of peripheral devices with a simple software maintenance routine.
The modes for Port A and Port B can be separately defined, while Port C is divided into two portions as required by the Port A and Port B definitions. All of the output registers, including the status flip-flops, will be reset whenever the mode is changed. Modes may be combined so that their functional definition can be ‘‘tailored’’ to almost any I/O structure. For instance; Group B can be programmed in Mode 0 to monitor simple switch closings or display computa- tional results, Group A could be programmed in Mode 1 to monitor a keyboard or tape reader on an interrupt-driven basis.
231256–
Figure 5. Basic Mode Definitions and Bus Interface
231256–
Figure 6. Mode Definition Format
The mode definitions and possible mode combina- tions may seem confusing at first but after a cursory review of the complete device operation a simple, logical I/O approach will surface. The design of the 82C55A has taken into account things such as effi- cient PC board layout, control signal definition vs PC layout and complete functional flexibility to support almost any peripheral device with no external logic. Such design represents the maximum use of the available pins.
Single Bit Set/Reset Feature
Any of the eight bits of Port C can be Set or Reset using a single OUTput instruction. This feature re- duces software requirements in Control-based appli- cations.
When Port C is being used as status/control for Port A or B, these bits can be set or reset by using the Bit Set/Reset operation just as if they were data output ports.
5
231256–
Figure 7. Bit Set/Reset Format
Interrupt Control Functions
When the 82C55A is programmed to operate in mode 1 or mode 2, control signals are provided that can be used as interrupt request inputs to the CPU. The interrupt request signals, generated from port C, can be inhibited or enabled by setting or resetting the associated INTE flip-flop, using the bit set/reset function of port C.
This function allows the Programmer to disallow or allow a specific I/O device to interrupt the CPU with- out affecting any other device in the interrupt struc- ture.
INTE flip-flop definition:
(BIT-SET)–INTE is SET–Interrupt enable (BIT-RESET)–INTE is RESET–Interrupt disable
Note: All Mask flip-flops are automatically reset during mode selection and device Reset.
6
MODE 0 Port Definition
A B GROUP A GROUP B
D 4 D 3 D 1 D 0 PORT A
PORT C (^) › PORT B
PORT C (UPPER) (LOWER) 0 0 0 0 OUTPUT OUTPUT 0 OUTPUT OUTPUT 0 0 0 1 OUTPUT OUTPUT 1 OUTPUT INPUT 0 0 1 0 OUTPUT OUTPUT 2 INPUT OUTPUT 0 0 1 1 OUTPUT OUTPUT 3 INPUT INPUT 0 1 0 0 OUTPUT INPUT 4 OUTPUT OUTPUT 0 1 0 1 OUTPUT INPUT 5 OUTPUT INPUT 0 1 1 0 OUTPUT INPUT 6 INPUT OUTPUT 0 1 1 1 OUTPUT INPUT 7 INPUT INPUT 1 0 0 0 INPUT OUTPUT 8 OUTPUT OUTPUT 1 0 0 1 INPUT OUTPUT 9 OUTPUT INPUT 1 0 1 0 INPUT OUTPUT 10 INPUT OUTPUT 1 0 1 1 INPUT OUTPUT 11 INPUT INPUT 1 1 0 0 INPUT INPUT 12 OUTPUT OUTPUT 1 1 0 1 INPUT INPUT 13 OUTPUT INPUT 1 1 1 0 INPUT INPUT 14 INPUT OUTPUT 1 1 1 1 INPUT INPUT 15 INPUT INPUT
MODE 0 Configurations
231256–
8
MODE 0 Configurations (Continued)
231256–
9