1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

Serial comm between uC and PC...

Discussion in 'Microcontrollers' started by koolguy, Apr 26, 2013.

  1. koolguy

    koolguy Active Member

    Joined:
    Aug 24, 2010
    Messages:
    2,196
    Likes:
    9
    OK, here is the schematic....
     

    Attached Files:

    • aa.jpg
      aa.jpg
      File size:
      83.1 KB
      Views:
      135
  2. DerStrom8

    DerStrom8 Super Moderator Most Helpful Member

    Joined:
    Aug 9, 2010
    Messages:
    5,484
    Likes:
    503
    Location:
    Vermont (GMT-5:00)
    .........................................
     
    Last edited: May 1, 2013
  3. Ian Rogers

    Ian Rogers Super Moderator Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    9,159
    Likes:
    907
    Location:
    Rochdale UK
    Hi DS... Are you also in awe of Ritesh's diagram skills
     
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. DerStrom8

    DerStrom8 Super Moderator Most Helpful Member

    Joined:
    Aug 9, 2010
    Messages:
    5,484
    Likes:
    503
    Location:
    Vermont (GMT-5:00)

    That's exactly it, Ian :D:D:D
     
  6. koolguy

    koolguy Active Member

    Joined:
    Aug 24, 2010
    Messages:
    2,196
    Likes:
    9
    Is this fine now?? the power is taken from usb 5volt
     

    Attached Files:

  7. koolguy

    koolguy Active Member

    Joined:
    Aug 24, 2010
    Messages:
    2,196
    Likes:
    9
    here is the real term.............
     

    Attached Files:

    • cxc.jpg
      cxc.jpg
      File size:
      143.3 KB
      Views:
      103
  8. Ian Rogers

    Ian Rogers Super Moderator Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    9,159
    Likes:
    907
    Location:
    Rochdale UK
    Sorry Ritesh... I don't mean to take the mick, but as you can see the second schematic is MUCH easier on the eye..

    What USB to TTL have you got... FT232RL?... Also what are the characters in the terminal window... They are too small to see..
     
  9. koolguy

    koolguy Active Member

    Joined:
    Aug 24, 2010
    Messages:
    2,196
    Likes:
    9
    this one http://robokits.co.in/shop/index.php?main_page=product_info&cPath=6&products_id=64
    and i am writting random charater i have also installed Tera team for testing i am also sending data from uC to terminal window here is the code!


    Code (text):
    #include <htc.h>
    __CONFIG(LVP_OFF & BOREN_OFF & PWRTE_ON & WDTE_OFF & FOSC_HS);
    #define _XTAL_FREQ 20000000
     
    void  HSerinit();
     
    void main(void)                        // program entry
        {
    TRISB=0X00;
    PORTB=0X00;
        int index = 0;
        unsigned char ch;
        ADCON1 = 0x6;                    // Analogue off                    
        HSerinit();
           __delay_ms(150);
        while(1)                        // endless Loop
            {
    RB7=1; //for testing code is working!!
           
             while(!TXIF);                    // Wait for module to finish
             TXREG = 'A';  
                 
     
            }
        }
    void HSerinit()
    {
        TRISC = 0x80;                    // TX was an input!
        SPBRG = 129;                    // 20Mhz xtal 9600 BAUD
        TXSTA = 0x24;                    // TXEN and BRGH
        RCSTA = 0x90;                    // SPEN and CREN
    }

     
     
  10. Ian Rogers

    Ian Rogers Super Moderator Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    9,159
    Likes:
    907
    Location:
    Rochdale UK
    What output do you get from this little device.... Is it TTL? Or is it +10 -10 volt signals...
     
  11. koolguy

    koolguy Active Member

    Joined:
    Aug 24, 2010
    Messages:
    2,196
    Likes:
    9
    It is used to convert the serial to usb you can see the manual of it in link!
     
  12. Ian Rogers

    Ian Rogers Super Moderator Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    9,159
    Likes:
    907
    Location:
    Rochdale UK
    There is no datasheet or manual listed..

    This is described as a Virtual Serial port, suggesting that the output is RS232 levels , not TTL... If this is the case it will damage your pic.


    Have you got a scope to measure the output voltages???
     
  13. koolguy

    koolguy Active Member

    Joined:
    Aug 24, 2010
    Messages:
    2,196
    Likes:
    9
    I am using 5V from USB only the chip used by it is http://robokits.co.in/shop/index.php?main_page=product_info&cPath=14&products_id=267

    they said:
     
  14. koolguy

    koolguy Active Member

    Joined:
    Aug 24, 2010
    Messages:
    2,196
    Likes:
    9
    One thing more:
    Code (text):
    On the USB to TTL module, connect your TX and RX pins together and type in the terminal window.
    It is working!!
     
  15. Mr RB

    Mr RB Well-Known Member

    Joined:
    Jul 22, 2008
    Messages:
    4,716
    Likes:
    194
    Location:
    Out there
    I'm pretty sure that module has a TTL output level suitable for direct connection to 5v microcontroller pins.

    One simple test is to send a 0x00 byte manually out the PIC TX pin at 1200 baud, then set the terminal program in the PC to 1200 baud and see if it is received ok.

    That can check your wiring and does not depend on any USART stuff.

    To do that, you turn the USART off and use this manual code;
    while(1)
    {
    LATC.F6 = 0; // TX pin forced LO
    Delay_mS(7);
    Delay_uS(500); // 7500 uS delay is 9 bits at 1200 baud (start bit + 8 LO bits)
    LATC.F6 = 1; // TX pin back to idle state HI
    Delay_mS(100); // pause between bytes
    }

    Then run the code and a byte 0x00 will be sent from the PIC about every 100mS. Then you can check the wiring and make sure Hyperterm is receiving the 0x00 byte ok.
     
  16. koolguy

    koolguy Active Member

    Joined:
    Aug 24, 2010
    Messages:
    2,196
    Likes:
    9
    cam you give me hi tech c code..?
    and how to set 1200 baud rate??
     
  17. DerStrom8

    DerStrom8 Super Moderator Most Helpful Member

    Joined:
    Aug 9, 2010
    Messages:
    5,484
    Likes:
    503
    Location:
    Vermont (GMT-5:00)
    :facepalm:
     
  18. koolguy

    koolguy Active Member

    Joined:
    Aug 24, 2010
    Messages:
    2,196
    Likes:
    9
    It is working on 5V from USB i think TTL
     
  19. koolguy

    koolguy Active Member

    Joined:
    Aug 24, 2010
    Messages:
    2,196
    Likes:
    9
    It is working on 5V and i think TTL based
     
  20. misterT

    misterT Well-Known Member Most Helpful Member

    Joined:
    Apr 19, 2010
    Messages:
    2,697
    Likes:
    368
    Location:
    Finland
    You could sometimes try to read the datasheet specs yourself. That way you would not have to guess.

    The datasheet says:
    RS232 pins RXD_I, RI_I, DSR_I, DCD_I, CTS_I are 5V TTL Schmitt Trigger inputs.
    RS232 pins TXD, DTR_N, RTS_N are 3.3V tri-state outputs.
     
  21. koolguy

    koolguy Active Member

    Joined:
    Aug 24, 2010
    Messages:
    2,196
    Likes:
    9
    so, what changes to do now???
     

Share This Page