Need Help - Using 8051 with RS232

Discussion in 'The Projects Forum' started by maxfourier, Aug 7, 2011.

  1. maxfourier

    Thread Starter New Member

    Aug 7, 2011
    16
    0
    I'm an electronics student working on my first project. I have explained my problem below. Need some help.

    Please consider that I'm a newbie with projects.. I have only brought a few things and downloaded some software. Apart from that I have my logic ready. So, all i would need to do is write the code and program the microcontroller.


    This is what i have :

    Hardware :

    8051 (NXP 80V51RD2)
    RS232 with DB9
    max232

    Software :

    Keil
    Flash Magic


    What i want to do : is just program the microprocessor. I have tried Googling "Interfacing 8051 rs232" but could not really get it.

    I can interface the microprocessor and the max232 but I'm having problems interfacing the RS232.

    Moreover, I have NO idea how (& where) to connect the RS232. Here is what my cable looks like :

    [​IMG]



    Again, What i need to know is:


    -Which side of the cable goes where(PC n 8051)
    -How is it connected to the microprocessor.
    -How do I write my c code into the microprocessor - How to convert it to hex(or whatever required)? Why do I need Keil & Flash Magic?
     
  2. Chygoz

    New Member

    Apr 27, 2011
    14
    1
    You'll use the serial communication pins of the 8051 microcontroller. They should be pins 10 and 11. I can't remember the details now and i'm not on my pc but you can google serial communication in 8051. Also you can look for a textbook "microcontrollers and embedded systems" by Mazidi. It should help you.
     
  3. maxfourier

    Thread Starter New Member

    Aug 7, 2011
    16
    0
    I have already interfaced the 8051 & the max232.
    All i need now is how to interface the max232 & the rs232. And how to connect the rs232 to my pc.
     
  4. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    The signal chain will be 8051->max232->PC port.
    This is the 9 pin PC port. In the simplest form you need to use pin 2,3 and 5. On the PC side pin 2 is the input pin. So this must be connected to the output pin on the max 232 chip. And the opposite for pin 3 on PC side. Connect pin 5 GND on the PC side to ground (0 volt) on your 8051 board.
    [​IMG]
     
    maxfourier likes this.
  5. maxfourier

    Thread Starter New Member

    Aug 7, 2011
    16
    0
    The problem is, I don't have such a port on my PC. However, i was told that this cable would do the job. (Please see the image in the original post). Now, how do i use that cable to interface to the max232 & my pc?

    If the cable i have is the wrong one, then which one do i need?
     
  6. bertus

    Administrator

    Apr 5, 2008
    15,638
    2,344
    Hello,

    The cable needed is dependend on the type (brand and model) of the motherboard inside your PC.
    There should be information on the connector on the motherboard in the manual of the motherboard.

    Bertus
     
    maxfourier likes this.
  7. maxfourier

    Thread Starter New Member

    Aug 7, 2011
    16
    0
    I'm really confused here.. :(

    Do i need a cable that has two ends - one connecting to the max232 & other connecting somehow to the PC? (on an existing port on the PC?)

    OR

    Do i need a new port on the PC?
     
  8. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    Many/almost all modern computers do not have RS232 serial ports. The most common way is to use a USB to serial converter. If this is a school project, ask your teacher if he/she has a one USB to serial you can use. If the school PCs do not have RS232 ports
     
    maxfourier likes this.
  9. maxfourier

    Thread Starter New Member

    Aug 7, 2011
    16
    0
    @t06afre - I do have the port on my pc.

    But, how do i connect it to the max232? Do i directly connect the pins 2 & 3 of the db9 port to the T & R pins of the max232.

    Or do i need to use the cable?(please see the image in the original post)
    If yes, how do i use it?
     
  10. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    The cable you have will fit into a PC 9 pin Rs232 port. One end of the cable goes into the PC and the other end goes to the correct pins of the MAX232 circuit. If this done via some connector or not is not important. Hope this help
     
    maxfourier likes this.
  11. MrChips

    Moderator

    Oct 2, 2009
    12,415
    3,354
    Do you have something that looks like this on your PC?
     
    maxfourier likes this.
  12. maxfourier

    Thread Starter New Member

    Aug 7, 2011
    16
    0
    Right! So, now i have the cable connected to the pc 9 port. And all i need to do now is connect the other end (the molex )to the max232. And I do that by a 5 pin molex header/ And then I have everything ready.

    Please correct me if I'm wrong.
     
  13. bertus

    Administrator

    Apr 5, 2008
    15,638
    2,344
    maxfourier likes this.
  14. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    Well it is not insane ;). As long as the internal signal routing is correct you should be OK. However I do not known if the pin 1 on the moles goes to pin 1 on the RS232 connector. Can not tell from the picture
     
    maxfourier likes this.
  15. maxfourier

    Thread Starter New Member

    Aug 7, 2011
    16
    0
    t06afre, here's how the cable looks:

    Connections 5 - 9 :
    [​IMG]

    back :
    [​IMG]
     
  16. MrChips

    Moderator

    Oct 2, 2009
    12,415
    3,354
    Do you have a testmeter? Take an ohmmeter and tell us which pin on the molex is connected to which pin on the female 9-pin socket.
     
    maxfourier likes this.
  17. maxfourier

    Thread Starter New Member

    Aug 7, 2011
    16
    0
    got it.. thank you everyone!!!
     
  18. maxfourier

    Thread Starter New Member

    Aug 7, 2011
    16
    0
    Just need to know one more thing. I have a tack switch with 4 pins.. I need to use it for the rest circuit. How do i do that.. I need a pinout for the switch/?
     
Loading...