Wednesday, March 20, 2013

Hyper Terminal using MAX 485


Good evening,

If you want to learn how to run a keyboard and PC with a microcontroller by using the MAX 485. I did a small project (Hyper Terminal using MAX 485). In which the data can be transmitted to the PC through the serial port.

The block diagram of hyper terminal using MAX 485 is given below.


For this we are using a PIC 16F877A with a 4 MHz crystal for oscillating and MAX 485, Since the MAX 485 is to be communicating with the PC, The serial port operates at 12 V, which will fry our MAX 485. To fix this problem we are using MAX 232 as a level convertor. The input of the RS 232 must be TTL or C MOS, so we are using two MAX 485’s. Output Of first MAX 485 is differential output, which is converted to TTL output by using another MAX 485. The signal is feed to PC through the RS 232

The schematic of the Hyper Terminal using MAX 485 is shown below:


The full part list of above circuit is given below:
  •  PIC16F877A                                              
  •  4Mhz crystal                              
  • DB9 connector(female)          
  • DB Hood                               
  • MAX232                              
  • MAX485                                   2                               
  • Capacitor(.01uf)                         2               
  • Capacitor (22pf)                         2
  • Capacitor   (1uf)                         4
  • Capacitor (10uf)                         2
  • Resistors (4.7K)                         7 




UART:

Pic 16F877A has UART (Universal Asynchronous Receiver Transmitter) is one of the basic interfaces which provide a simple and reliable communication between one controller to another controller or between a controller and PC.

Interfacing UART with PIC16F877A

Now we want to display a text in PC from PIC16F877A by using UART module. In PIC16F877A contains a single serial interface that is UART. The Transmitter pins send the data into PC and the receiver pin receives the data from PC. The PC and microcontroller speed are denoted by using baud rate. When the baud rates of both PC and Microcontroller are same, then only the data transmit and receive correctly otherwise not. The TXD (Pin 25) & RXD (pin 26) pins are used for data transmission and receive operation. The UART is initialized and set to 19200 Baud rate, 8 bit, no parity and 1 stop bit. Make sure that the PC settings is also the same

processor pic16f877a
include <p16f877a.inc>
__config _LVP_OFF & _XT_OSC & _WDT_OFF & _PWRTE_ON & _CP_OFF &           _DEBUG_OFF


org 0x00
nop
nop
nop
nop

org 0x05
movlw 0x07         ;turn off the comparators
movwf CMCON

bcf STATUS,RP1
bsf STATUS,RP0
movlw 0x06         ;make all pins as digital i/o ports
movwf ADCON1

bcf TRISC,6 ;enable the Tx pin by clearing it

movlw 0x0c
movwf SPBRG   ;set the baud rate as 19200

movlw B'00100100'
movwf TXSTA ;

bcf STATUS,RP0
movlw B'10010000'
movwf RCSTA
main
movf PORTA,0         ;read the port A pins
movwf TXREG ;transfer the data into the register
bsf STATUS, RP0
here
btfss TXSTA, TRMT ;check whether data is transmitted to Tx pin
    goto here                         ;if no goto here
    bcf STATUS, RP0
clrf TXREG                 ;clear the register
goto main                 ;repeat the loop
end


Here initializing the PIC is very important. For UART turn OFF the comparator and make all analog ports as digital port by the using the register ADCON1.make sure that the PORTC TX pin is low and Rx pin to high for data transmission and receive. The baud rate is selected by SPBRG resister.
The TSR plays a major role in data transmission. The read data from the PORT A is send to the TXREG by using the software. Once the data was send to MAX 485 the TRMT bit will be set. Unless the data is not sent the TRMT bit is zero.
The input is given through the switches, the binary value is given as input which is displayed in the PC as a ASCII value
For example
When the input is: 00111101
The output is:         9
Similarly to get the different output varies the input binary value by switching ON & OFF of Port A input pins.   







No comments:

Post a Comment