Top Banner
31 st Jan to 1 st Feb 2008 TECHNOLOGY ROBOTICS SOCIETY Indian Institute of Technology, Kharagpur
22

Robotix Tutorial 8

Jan 29, 2018

Download

Business

ankuredkie
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Robotix Tutorial 8

31st Jan to 1st Feb 2008

TECHNOLOGY ROBOTICS SOCIETYIndian Institute of Technology, Kharagpur

Page 2: Robotix Tutorial 8

Computer Control

Parallel & Serial Port Communication

Page 3: Robotix Tutorial 8

PC Parallel Port - Features Commonly known as the printer port 25 pin D-Type connector It has 12 digital output pins, 5 digital input pins Pins operate at the TTL voltage level i.e. 0 – 5V Port identified by a base address in the computer

I/O memory space

Page 4: Robotix Tutorial 8

PC Parallel Port – Pin Layout

Page 5: Robotix Tutorial 8

PC Parallel Port – I/O Registers Most PC’s have 378 Hex base address 8 output pins are accessed via the DATA port (Base

address) 4 output pins are accessed via the CONTROL port

(Base address + 2) 5 input pins are accessed via the STATUS port (Base

address + 1)

Page 6: Robotix Tutorial 8

PC Parallel Port – I/O Registers

- marked bits in register byte are unused

Page 7: Robotix Tutorial 8

Accessing Parallel Port – VC ++#include <conio.h>

#define Data 0x378 // Base address#define Status 0x379 // Base address + 1#define Control 0x37a // Base address + 2

int main () {unsigned char Bits;Bits = 0b11001010;_outp(Data, Bits); /* output data */Bits = _inp(Status);/* input data */ return (0);}

Page 8: Robotix Tutorial 8

PC Serial Port - Features Most commonly 9 pin D-Type connector. 25 pin D-

Type is rare Pins operate at -25 to + 25 voltage levels Data transmitted as a bit sequence Known as the EIA RS232C port or simply RS232

Page 9: Robotix Tutorial 8

EIA RS232C Specifications Logic 0 is between +3 to +25 volts Logic 1 is between -3 to -25 volts -3 to +3 volts region is undefined Maximum data rate of 19,600 bps

Page 10: Robotix Tutorial 8

Serial Port vs. Parallel Port Serial cables can be much longer that Parallel cables

50V swing compared to 5V swing Null Modem Configuration just needs 3 core cable

compared to 19 core parallel port cable Serial suited for wireless transmission Microcontrollers just need two pins (RXD & TXD) for

communication

Page 11: Robotix Tutorial 8

Null Modem Configuration Pin 3 Transmit Data Pin 2 Receive Data Pin 5 Signal Ground Pin 4, 6, 1 shorted together Pin 7, 8 shorted together

Page 12: Robotix Tutorial 8

RS-232 Waveforms

Asynchronous Communication i.e. separate clock at both ends Frame synchronization done by the start / stop bit Line is kept logic 1 when idle. Start bit is logic 0 Bit order from LSB to MSB

Page 13: Robotix Tutorial 8

RS-232 Level Converters For using the RS232 data,

digital devices need TTL/CMOS voltage levels

Level conversion is done using IC MAX232 / DS232

Page 14: Robotix Tutorial 8

RS-232 frame decoding The decoding of the bit sequence frame is done by

computer hardware When communicating with robots, decoding done by

onboard microcontroller Microcontroller Serial communication interface is

known as UART (Universal Asynchronous Receiver Transmitter)

Page 15: Robotix Tutorial 8

Accessing Serial Port - VB MSComm Control 6.0 is used for serial port

communication

Page 16: Robotix Tutorial 8

MSComm Control Properties

Page 17: Robotix Tutorial 8

MSComm Control Properties Com Port identification number Settings: Baud Rate, Parity Check, Data Bits, Stop

Bits Hand Shaking Method : Xon/Xoff for null-modem

configuration

Page 18: Robotix Tutorial 8

MSComm Control Properties

Page 19: Robotix Tutorial 8

MSComm Control Properties InBufferSize : Input buffer size OutBufferSize : Output buffer size RThreshhold : Receive size for interrupt generation SThreshhold : Min. transmit size InputLen : Number of bytes to be picked up from the

input buffer EOFEnable : Search for EOF character

Page 20: Robotix Tutorial 8

MSComm Control Properties

Page 21: Robotix Tutorial 8

MSComm Control Properties ParityReplace : Parity Error replacement character NullDiscard : Null characters sent to the receive

buffer or not RTSEnable : Request to Send enable DTREnable : Data Terminal Ready

Page 22: Robotix Tutorial 8

Example Code‘ Receive Data

Private Sub CommunicationTerminal_OnComm()

Dim InputBuffer As String

If CommunicationTerminal.CommEvent = comEvReceive Then

InputBuffer = CommunicationTerminal.Input

End If

‘ Use InputBuffer as per requirement

End Sub

‘ Transmit Data

If CommunicationTerminal.PortOpen = True Then

CommunicationTerminal.Output = “Hello”

End If