Computer Interfacing - Serial Communication

advertisement
Digital Electronics and Computer
Interfacing
Tim Mewes
7. Computer Interfacing – Serial
communication
7 Serial communication
In serial communication data is send one bit at a
time
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
RS-232 (recommended standard 232) 1969:
defines
• signal levels (up to 25V)
• signal rate (Baud or bits/s)
• connectors DB-25 (recommended)
however DE-9 is most 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
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 further data follows line remains high
Digital Electronics and Computer Interfacing
4
7.1 Serial communication via RS-232
Thus before communication can take place sender
and receiver need to “decide” on:
• Transmission speed (baud rate)
• Number of data bits typically 8
• Parity (none, even or odd)
• Number of stop bits (1 or 2)
• Flow control “handshaking” (none, hardware,
software (XON/XOFF))
Check the manual of the device!
Digital Electronics and Computer Interfacing
5
7.1 Serial communication in LabVIEW
Write command
Check manual
Configure port first
• VISA resource name: COM1/COM2
• baud rate (9600 or 2400, 4800, 7200 etc.)
• data bits (8 or 7 are most 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
• Check that LabVIEW settings match those in manual
• flow control is often source of problems in particular
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
Minimal 3-wire
connection
Minimal 5-wire
connection
with flow control
Digital Electronics and Computer Interfacing
7
Download