Robotix Tutorial 8

1,535 views

Published on

Published in: Business, Technology
  • Be the first to comment

  • Be the first to like this

Robotix Tutorial 8

  1. 1. 31 st Jan to 1 st Feb 2008 TECHNOLOGY ROBOTICS SOCIETY Indian Institute of Technology, Kharagpur
  2. 2. Computer Control Parallel & Serial Port Communication
  3. 3. PC Parallel Port - Features <ul><li>Commonly known as the printer port </li></ul><ul><li>25 pin D-Type connector </li></ul><ul><li>It has 12 digital output pins, 5 digital input pins </li></ul><ul><li>Pins operate at the TTL voltage level i.e. 0 – 5V </li></ul><ul><li>Port identified by a base address in the computer I/O memory space </li></ul>
  4. 4. PC Parallel Port – Pin Layout
  5. 5. PC Parallel Port – I/O Registers <ul><li>Most PC’s have 378 Hex base address </li></ul><ul><li>8 output pins are accessed via the DATA port (Base address) </li></ul><ul><li>4 output pins are accessed via the CONTROL port (Base address + 2) </li></ul><ul><li>5 input pins are accessed via the STATUS port (Base address + 1) </li></ul>
  6. 6. PC Parallel Port – I/O Registers <ul><li>- marked bits in register byte are unused </li></ul>
  7. 7. 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); }
  8. 8. PC Serial Port - Features <ul><li>Most commonly 9 pin D-Type connector. 25 pin D-Type is rare </li></ul><ul><li>Pins operate at -25 to + 25 voltage levels </li></ul><ul><li>Data transmitted as a bit sequence </li></ul><ul><li>Known as the EIA RS232C port or simply RS232 </li></ul>
  9. 9. EIA RS232C Specifications <ul><li>Logic 0 is between +3 to +25 volts </li></ul><ul><li>Logic 1 is between -3 to -25 volts </li></ul><ul><li>-3 to +3 volts region is undefined </li></ul><ul><li>Maximum data rate of 19,600 bps </li></ul>
  10. 10. Serial Port vs. Parallel Port <ul><li>Serial cables can be much longer that Parallel cables </li></ul><ul><ul><li>50V swing compared to 5V swing </li></ul></ul><ul><li>Null Modem Configuration just needs 3 core cable compared to 19 core parallel port cable </li></ul><ul><li>Serial suited for wireless transmission </li></ul><ul><li>Microcontrollers just need two pins (RXD & TXD) for communication </li></ul>
  11. 11. Null Modem Configuration <ul><li>Pin 3 Transmit Data </li></ul><ul><li>Pin 2 Receive Data </li></ul><ul><li>Pin 5 Signal Ground </li></ul><ul><li>Pin 4, 6, 1 shorted together </li></ul><ul><li>Pin 7, 8 shorted together </li></ul>
  12. 12. RS-232 Waveforms <ul><li>Asynchronous Communication i.e. separate clock at both ends </li></ul><ul><li>Frame synchronization done by the start / stop bit </li></ul><ul><li>Line is kept logic 1 when idle. Start bit is logic 0 </li></ul><ul><li>Bit order from LSB to MSB </li></ul>
  13. 13. RS-232 Level Converters <ul><li>For using the RS232 data, digital devices need TTL/CMOS voltage levels </li></ul><ul><li>Level conversion is done using IC MAX232 / DS232 </li></ul>
  14. 14. RS-232 frame decoding <ul><li>The decoding of the bit sequence frame is done by computer hardware </li></ul><ul><li>When communicating with robots, decoding done by onboard microcontroller </li></ul><ul><li>Microcontroller Serial communication interface is known as UART (Universal Asynchronous Receiver Transmitter) </li></ul>
  15. 15. Accessing Serial Port - VB <ul><li>MSComm Control 6.0 is used for serial port communication </li></ul>
  16. 16. MSComm Control Properties
  17. 17. MSComm Control Properties <ul><li>Com Port identification number </li></ul><ul><li>Settings: Baud Rate, Parity Check, Data Bits, Stop Bits </li></ul><ul><li>Hand Shaking Method : Xon/Xoff for null-modem configuration </li></ul>
  18. 18. MSComm Control Properties
  19. 19. MSComm Control Properties <ul><li>InBufferSize : Input buffer size </li></ul><ul><li>OutBufferSize : Output buffer size </li></ul><ul><li>RThreshhold : Receive size for interrupt generation </li></ul><ul><li>SThreshhold : Min. transmit size </li></ul><ul><li>InputLen : Number of bytes to be picked up from the input buffer </li></ul><ul><li>EOFEnable : Search for EOF character </li></ul>
  20. 20. MSComm Control Properties
  21. 21. MSComm Control Properties <ul><li>ParityReplace : Parity Error replacement character </li></ul><ul><li>NullDiscard : Null characters sent to the receive buffer or not </li></ul><ul><li>RTSEnable : Request to Send enable </li></ul><ul><li>DTREnable : Data Terminal Ready </li></ul>
  22. 22. Example Code <ul><li>‘ Receive Data </li></ul><ul><li>Private Sub CommunicationTerminal_OnComm() </li></ul><ul><li>Dim InputBuffer As String </li></ul><ul><li>If CommunicationTerminal.CommEvent = comEvReceive Then </li></ul><ul><li>InputBuffer = CommunicationTerminal.Input </li></ul><ul><li>End If </li></ul><ul><li>‘ Use InputBuffer as per requirement </li></ul><ul><li>End Sub </li></ul><ul><li>‘ Transmit Data </li></ul><ul><li>If CommunicationTerminal.PortOpen = True Then </li></ul><ul><li>CommunicationTerminal.Output = “Hello” </li></ul><ul><li>End If </li></ul>

×