Paralelní port PC

Transkript

Paralelní port PC
Komunikace zabudovaných systém z PC
●
Způsoby komunikace zabudováních systému z PC
●
Sběrnice pro přenos dat interní a externí ;
●
Sériově sběrnice RS232,SPI,I2C,1-Wire,CAN,USB;
.
●
Paralelní port PC. GPIB sběrnice;
●
Sběrnice ISA,PCI,SCSI,VME;
●
Příklady programovaní LPT,COM,USB;
V. Kushpil (ÚJF AVCR)
Způsoby komunikace zabudováních
systému ZS z PC
●
Realizace přenosu dat ZS a PC
drátové nebo bezdrátové přípojení
drátové linky nebo radio vlny, světlo, magnetické pole ...
●
Způsob přenosu dat
sériový bit za bitem nebo paralelní přenos několik
.
bitu najednou
linky RS232, CAN, I2C, 1Wire... nebo LPT, GPIB, SCSI...
●
Způsob kontroly a uspořádáni dat při přenosu
protokoly RS232-HANDSHAKE, CAN-KINGDOM, I2Cmaster/slave, 1-Wire... nebo LPT-SPP/EPP, GPIB-talker
/listner, SCSI...
V. Kushpil (ÚJF AVCR)
Sběrnice pro přenos dat interní a externí
Interní sběrnice (ISA, PCI, SCSI,VME)
dovoluj provádět paralelní přenos dat na male vzdáleností
(Lmax < 0.5m)
(rychlost od 5 MByte/sec)
.
Externí sběrnice (RS232,I2C,USB,CENTRONIX)
dovoluj provádět sériový nebo paralelní přenos dat na velké vzdáleností
(Lmax > 1m)
(rychlost od 110 Byte/sec)
V. Kushpil (ÚJF AVCR)
Sběrnice pro přenos dat interní a externí
.
V. Kushpil (ÚJF AVCR)
Sériově sběrnice
V. Kushpil (ÚJF AVCR)
Sériově sběrnice
RS232 rychlost od 110bit/sec, do 110 Kbit/sec,
Lmax 12m (2-8 wires), (single net bus)
SPI rychlost 110Kbit/sec, (multi net bus)
Lmax do 1m (4 wires)
I2C rychlost do 3.4 Mbit/sec, (multi net bus)
Lmax 100m (2 wires)
1-Wire rychlost do /sec, (multi net bus)
Lmax 750m (1 wires)
CAN rychlost do 1Mbit/sec, (multi net bus)
Lmax 10 Km (1-2 wires)
USB rychlost do 480Mbit/sec, (multi net bus)
Lmax 25m (2 wires)
V. Kushpil (ÚJF AVCR)
Sériově sběrnice
V. Kushpil (ÚJF AVCR)
Sériová sběrnice RS232
Sběrnice kategorie USART (Universal Asynchronous Receiver Transmitter)
Standart vznik v 60 letech. Je velice dobře podporován jak na HARDWARE
tak na SOFTWARE úrovně Maximum rychlosti přenosu dat 1MHz
Asynchronni znamená že není pulzy synchronizace datového toku.
T.z. že o časovém rozdíleni dat musí TRANSEIVER a RESEJVER dohodnut
před začátkem přenosu. Pro kontrolu a synchronizace datového toku
jsou použita START,STOP,PARITY bity.
V. Kushpil (ÚJF AVCR)
Sériová sběrnice RS232
V. Kushpil (ÚJF AVCR)
Sériová sběrnice SPI (Motorola)
Serial Peripheral Interface (SPI)
is a 4-wire full-duplex synchronous serial data link:
–SCLK: Serial Clock
–MOSI: Master Out Slave In -Data from Master to Slave
–MISO: Master In Slave Out -Data from Slave to Master
–SS: Slave Select
V. Kushpil (ÚJF AVCR)
Sériová sběrnice I2C (Philips)
(Inter-IC) Originally, bus defined by Philips providing a simple way to
talk between IC’s by using a minimum number of pins.
A set of specifications to build a simple universal bus guaranteeing
compatibility of parts (ICs) from different manufacturers:
–Simple Hardware standards
–Simple Software protocol standard
•No specific wiring or connectors -most often it’s just PCB tracks
•Has become a recognised standard throughout our industry and is
used now by ALL major IC manufacturers.
V. Kushpil (ÚJF AVCR)
Sériová sběrnice 1-Wire
Dallas Semiconductor/Maxim provides a technology called
1-Wire®, that uses a single wire (plus ground) to accomplish both
communication and power transmission.
A single bus master can feed multiple slaves over a single twisted-pair
cable.
An important aspect of this technology is that every slave has a
globally unique digital address.
Data on the 1-Wire net is transferred by time slots. For example, to
write a logic one to a slave, the master pulls the bus low for 15μs or
less. To write a logic zero, the master pulls the bus low for at least 60μs
to provide timing margin for worst-case conditions. A system clock is
not required, as each 1-Wire part is self-clocked by its own internal
oscillator synchronized to the falling edge of the master.
V. Kushpil (ÚJF AVCR)
Sériová sběrnice CAN (Bosch)
CAN (Controller Area Network)
•Proposed by Bosch for industrial applications)
•Relatively complex coding of the messages
•Relatively accurate and (usually) fixed timing
•All modules participate in every communication
•Content-oriented (message) addressing scheme
V. Kushpil (ÚJF AVCR)
Sériová sběrnice CAN (2)
V. Kushpil (ÚJF AVCR)
Sériová sběrnice USB
USB (Universal Serial Bus)
•Originally a standard for connecting PCs to peripherals
•Defined by Intel, Microsoft, …
•Intended to replace the large number of legacy ports in the PC
•Single master (= Host) system with up to 127 peripherals
•Simple plug and play; no need to open the PC
•Standardized plugs, ports, cables
•Has over 99% penetration on all new PCs
•Adapting to new requirements for flexibility of Host function
–New Hardware/Software allows dynamic exchanging
of Host/Slave roles
–PC is no longer the only system Host. Can be a camera
or a printer
V. Kushpil (ÚJF AVCR)
Paralelní port PC
V. Kushpil (ÚJF AVCR)
Paralelní port PC (2)
PORTA
PORTB
PORTC
Data port
Status port
Control port
Data port:
●
It includes pin 2 to pin 9
with pin names Data-0 to
Data- 9
●
It is usually for data
output according to old
“standard parallel port”
standard.
Address
Bit no.
7
Pin
Name
Data 7
Pin
Number
Pin 9
Base +0
(e.g.
0×378)
6
Data 6
Pin 8
5
Data 5
Pin 7
4
Data 4
Pin 6
3
Data 3
Pin 5
2
Data 2
Pin 4
1
Data 1
Pin 3
0
Data 0
Pin 2
V. Kushpil (ÚJF AVCR)
Paralelní port PC (3)
PORTB Status Port
Status port is an
input only port i.e.
Data can’t be output
on this port but it can
only be read.
Address
Base +1
(eg 0×379)
Bit
no.
7
Pin Name
Pin Number
Busy
Pin 11 (hardware
inverted)
6
Ack
Pin 10
5
Paper Out
Pin 12
4
Select
Pin 13
3
Error
Pin 15
2
Irq
-
1
Reserved
-
0
Reserved
-
V. Kushpil (ÚJF AVCR)
Paralelní port PC (3)
PORTC Control port
Control port is a read /
write port. For printer
purposes it is write
only port.
Address
Base +2
(eg
0×37A or
37AH)
Bit
no.
7
Pin Name
Unused
-
6
Unused
-
5
Enable bi-
Pin Number
-
directional
4
Enable Irq Via
-
Ack-line
3
Select printer
Pin 17
(Hardware Inv.)
2
Initialize
printer
Pin 16
1
Auto line feed
Pin 14
(Hardware Inv.)
0
strobe
Pin 1
(Hardware Inv.)
V. Kushpil (ÚJF AVCR)
Paralelní port PC (4)
How to access parallel port pins in the software.
Parallel port is assigned a unique I/O address which is generally among
the following:
1) 378h
(mostly the case)
2) 278h
(normally found when there are more than one parallel ports)
2)3BCh
(Rare case)
How to know the port address on your pc
• Restart your computer go into BIOS. Then see the address of the port
there.
• If it is set auto hen there are two options:
1) Explicitly assign an address in the BIOS.
2) Check the address in Windows by going to
Control panel System Device Manager  PortsPrinter portProperties
Resources Input/Output Range.
V. Kushpil (ÚJF AVCR)
Paralelní port PC (5)
•
These days starting from PC’s equipped with Pentium processors, the parallel ports
have Bi-directional read/write facility.
•
Bi-directional means that you can read byte (8 bits) from parallel port which
•
traditionally was an output only port in the old PC’s.
In order to check whether your port is configured for it, restart your PC and go into
BIOS see the portion related to the parts. You will find port address as well as its
type, usually the options are as follows
SPP
Bidirectional
standard parallel port not bidirectional
standard parallel port with bidirectional facility
EPP
Enhanced Parallel port
ECP
Extended Capabilities parallel port
To accomplish data in through data port you should:
1. set your port to bi-directional, EPP or ECP.
2. write a 1 in bit 5 of control port.
V. Kushpil (ÚJF AVCR)
Paralelní port PC (6)
SPP (CENTRONIX) standard handshake mode
V. Kushpil (ÚJF AVCR)
Paralelní port PC (7)
EPP (Enhanced Parallel Port) handshake
Write
Read
V. Kushpil (ÚJF AVCR)
GPIB sběrnice
The GPIB (General Purpose Interface Bus) has become the
worldwide standard for connecting instruments to computers.
Invented in the 1960s by Hewlett Packard and originally designated
as HPIB, the bus specification was eventually adopted by a wide
variety of both instrument and computer manufacturers.
The original specification was documented and sanctioned by the
Institute of Electrical and Electronic Engineers as IEEE-488.
V. Kushpil (ÚJF AVCR)
GPIB sběrnice (2)
V. Kushpil (ÚJF AVCR)
GPIB sběrnice (3)
V. Kushpil (ÚJF AVCR)
GPIB sběrnice (4)
V. Kushpil (ÚJF AVCR)
GPIB sběrnice (5)
V. Kushpil (ÚJF AVCR)
Sběrnice ISA,PCI,SCSI,VME
Sběrnice ISA (Industry Standard Architecture) je počítačová sběrnice pro
rozšiřující karty, která byla vyvinuta firmou IBM v roce 1981.
Sběrnice ISA obsahovala adresovou část, která měla šířku 24 bitů a dokázala
tedy adresovat až 16 MB paměti. Kromě paměti bylo možné obsluhovat
maximálně 65535 vstupně/výstupních portů pomocí šestnáctibitové I/O
sběrnice. Datová část sběrnice měla šířku 16 bitů.
Blokový přenos dat byl na počátku řešen tak, že řízení sběrnice převzalo
externí zařízení. Později se využilo čtyř až osmi DMA kanálů.
Přenos dat probíhal přes synchronní protokol a oscilátor měl časovou
základnu 70 ns, což odpovídá taktovací frekvenci 14,285 MHz.
Postupem času však byla na trhu ISA používající jednu z 5 základních
frekvencí - 4,77 MHz, 8 MHz, 10 MHz, 12 MHz a 16 MHz.
V současné době se nové základní desky obsahující ISA sloty nevyrábějí
a operační systém Windows Vista jí už standardně nepodporuje.
V. Kushpil (ÚJF AVCR)
Sběrnice ISA,PCI,SCSI,VME
Sběrnice PCI je počítačová sběrnice pro připojení periferií k základní desce,
která není omezená na platformu osobních počítačů PC. Používá paralelní
přenos dat (šířka 32 nebo 64 bitů) a je orientovaná na přenos zpráv místo
přímé komunikace (anglicky message passing). Od zbytku systému je
oddělena pomocí PCI mostů, které zprostředkovávají komunikaci s
připojenými kartami. V jednom počítači je jedna nebo i více nezávislých
PCI sběrnic.
V. Kushpil (ÚJF AVCR)
Sběrnice ISA,PCI,SCSI,VME
V. Kushpil (ÚJF AVCR)
Sběrnice ISA,PCI,SCSI,VME
Sběrnice SCSI (Small Computer System Interface) je standardní rozhraní a sada
příkazů pro výměnu dat mezi externími nebo interními počítačovými zařízeními a
počítačovou sběrnicí. SCSI se vyslovuje „skazi“. SCSI se obvykle používá pro
připojení pevných disků nebo magnetopáskových jednotek. Pomocí SCSI lze
připojit i jiná zařízení např. skenery, jednotky CD-ROM nebo DVD. SCSI se nyní
nejčastěji používá u výkonných pracovních stanic nebo serverů. Servery
využívající RAID mají téměř vždy disky připojené pomocí SCSI.
V. Kushpil (ÚJF AVCR)
Sběrnice ISA,PCI,SCSI,VME
SCSI is an acronym for Small Computer Systems Interface. It is an ANSI standard that has become
one of the leading I/O buses in the computer industry. The foundation of the SCSI standard was laid
by Shugart Associates (the same guys that gave the world the first mini floppy disks) when they
introduced the SASI bus (Shugart Associates Standard Interface).
After some time an industry effort was started to come to a more strict standard allowing devices
from different vendors to work together. This effort was recognized in the ANSI SCSI-1 standard.
The SCSI-1 standard (approximately 1985) is rapidly becoming obsolete. The current standard is
SCSI-2 (see Further reading), with SCSI-3 on the drawing boards.
V. Kushpil (ÚJF AVCR)
Sběrnice ISA,PCI,SCSI,VME
V. Kushpil (ÚJF AVCR)
Příklady programovaní LPT,COM,USB
V. Kushpil (ÚJF AVCR)
Příklady programovaní LPT
V. Kushpil (ÚJF AVCR)
Příklady programovaní COM
V. Kushpil (ÚJF AVCR)
Příklad programovaní USB
V. Kushpil (ÚJF AVCR)