Digital Electronics and Computer Interfacing 7. Computer Interfacing – Serial communication

advertisement
Digital Electronics and Computer
Interfacing
Ti Mewes
Tim
M
7. Computer Interfacing – Serial
communication
7 Serial communication
In serial communication data is send one bit at a
time
ti
Advantages compared to parallel communication:
• less cables required
• Signal delay between cables not an issue
• crosstalk between cables not an issue
Main disadvantages:
• Speed
• Getting it to work…
Digital Electronics and Computer Interfacing
2
7 1 Serial communication via RS-232
7.1
RS 232
RS-232 (recommended standard 232) 1969:
d fi
defines
• signal levels (up to 25V)
• signal rate (Baud or bits/s)
• connectors DB-25 (recommended)
h
however
DE
DE-9
9 iis mostt common
Does not define:
• Character encoding (ASCII)
• actual transmission rate
• start/stop bits, data bits, parity
Digital Electronics and Computer Interfacing
3
7 1 Serial communication via RS-232
7.1
RS 232
Communication:
Here:
• 1 start bit (signals the receiver that data follows)
• 8 data bits
• no parity bit (used to check for incorrect
transmission, could be even or odd)
• 1 stop bit (indicates that data transmission is over)
if no ffurther
th data
d t follows
f ll
liline remains
i hi
high
h
Digital Electronics and Computer Interfacing
4
7 1 Serial communication via RS-232
7.1
RS 232
Thus before communication can take place sender
and receiver need to “decide” on:
• Transmission speed (baud rate)
• Number
N b off d
data
t bit
bits ttypically
i ll 8
• Parity (none, even or odd)
• Number of stop bits (1 or 2)
• Flow control “handshaking” (none, hardware,
software
ft
(XON/XOFF))
Check the manual of the device!
Digital Electronics and Computer Interfacing
5
7 1 Serial communication in LabVIEW
7.1
Write command
Check manual
Configure port first
• VISA resource name: COM1/COM2
• baud rate (9600 or 2400, 4800, 7200 etc.)
• data
d t bits
bit (8 or 7 are mostt common))
• parity (none most common)
• stop bits (1, 1.5 or 2)
• flow control ((none most common))
Wait – if needed
Read response
Check manual
End session
what to expect
Cleanup!
Digital Electronics and Computer Interfacing
6
7 2 Serial communication problems
7.2
• Check that LabVIEW settings match those in manual
problems in p
particular
• flow control is often source of p
hardware flow control – it is just not implemented reliably
in many devices
• PIN assignment differs between DTE (Data Terminal Equipment)
and DCE (Data Circuit-terminating Equipment)
• PIN assignment
i
t
Minimal 3-wire
connection
Minimal 5-wire
connection
with flow control
Digital Electronics and Computer Interfacing
7
Download