+ Reply to Thread
Results 1 to 15 of 15
  1. #1
    Join Date
    Oct 2006
    Posts
    8

    Smile Direct PIC to PC without MAX232

    A good idea in order to have a direct PIC and a PC bilateral communication using the PIC's UART and HSERIN and HSEROUT without an external inverter like MAX232 is choose a PIC with Comparator Module like the 16F877A or 16F88 or 16F628.

    You just need configure the comparator module as "Two Common Reference Comparators with Outputs" where the output of comparators are redirected to pins. Then the TX pin used to HSEROUT is hardwired to the input of comparator 1 . The inverted output (true) is now outputed in the C1.

    To receive from PC serial is directed to input of C2 and output is hardwired to RX pin used by HSERIN.

    Both comparators may use the internal reference (Comparator Voltage Refrence Module enabled and routed to C1, C2 ) or use an external.

    I already have tested this trick with 16F88 with good results.

    Of course this is not the true level converter like the MAX232 but works fine in my PC.

    I hope this be useful for some users.

    ACJacques

  2. #2
    Join Date
    Dec 2005
    Posts
    1,073

    Default

    Neat idea.

    I was hoping to use it with a 16F688 but C2OUT and TX share RC4.

  3. #3
    Join Date
    Mar 2008
    Posts
    16

    Default Re: Direct PIC to PC without MAX232

    Thank you for this idea!!

    Also, would the following work:

    HSEROUT - First invert all bits in the data byte, then send with HSEROUT.
    HSERIN - Read the data as usual, the invert the data byte prior to using.

    Thanks!

  4. #4

    Default Re: Direct PIC to PC without MAX232

    Quote Originally Posted by swr999 View Post
    Thank you for this idea!!

    Also, would the following work:

    HSEROUT - First invert all bits in the data byte, then send with HSEROUT.
    HSERIN - Read the data as usual, the invert the data byte prior to using.

    Thanks!
    Sorry, won't work. You need to invert everything, including the idle state, start and stop bits, etc.

  5. #5
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,254

    Default Re: Direct PIC to PC without MAX232

    No risk of overvoltage on PIC?

    Robert

  6. #6

    Default Re: Direct PIC to PC without MAX232

    No risk of overvoltage on PIC?
    Yes, this exceeds the max voltage spec on the pins. Bad idea, esp the negative voltage.

    RS232 levels could be as much as +/-25V, although you normally won't see them anywhere near this high out of your typical PC.

    If you're interested, read TB3013 (http://ww1.microchip.com/downloads/e...tes/93013a.pdf). Then see if you still want to recommend doing this.

  7. #7

    Default Re: Direct PIC to PC without MAX232

    It's simple enough to protect the device with a series resistor and clamp diodes to limit the excursion to the rails give or take a diode drop. You only need to protect the receive, of course.
    I'm not sure I'd recommend this for a commercial application, but for a hobby build it would be fine. Of course, many of the devices offer the ability invert everything, set up by the UART configuration bits. But if you have a device without that capability, this is a "quick and dirty" way to get communications going.

  8. #8

    Default Re: Direct PIC to PC without MAX232

    It's simple enough to protect the device with a series resistor and clamp diodes to limit the excursion to the rails give or take a diode drop
    Right, but that's not what the OP suggested. FWIW, Fig 3 in the PDF suggests some simple ways of protecting the input pin, including your method.

  9. #9
    Join Date
    Mar 2008
    Posts
    16

    Default Re: Direct PIC to PC without MAX232

    Quote Originally Posted by Charlie View Post
    Sorry, won't work. You need to invert everything, including the idle state, start and stop bits, etc.
    Of course you're right! Why didn't I think of that? ;-\
    I'm just using a 3-wire connection, so I suppose, aside from a dedicated RS232 translator chip (MAX232 etc), I could use any scheme to hardware-invert the Rx and Tx lines?
    Thanks for the helpful responses!

  10. #10

    Default Re: Direct PIC to PC without MAX232

    Quote Originally Posted by swr999 View Post
    Of course you're right! Why didn't I think of that? ;-\
    I'm just using a 3-wire connection, so I suppose, aside from a dedicated RS232 translator chip (MAX232 etc), I could use any scheme to hardware-invert the Rx and Tx lines?
    Thanks for the helpful responses!
    You can use any scheme to invert the signals and it will work, bearing in mind that you might encounter an interface that it won't work with because it doesn't strictly meet the spec. You'll have more success with a 5V PIC, and you should protect any input from overvoltage on whatever device you use. I do this all the time for one way communication out of the PIC for dumping status logs or other information that doesn't require a response from the computer. Typically, I use an N-channel FET to do the inversion, but a spare comparator or op-amp will do too.

  11. #11
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,254

    Default Re: Direct PIC to PC without MAX232

    Quote Originally Posted by Charlie View Post
    ..., I use an N-channel FET to do the inversion...
    Not P-channel?

    Robert

  12. #12

    Default Re: Direct PIC to PC without MAX232

    P-Channel devices are usually more expensive and have other design considerations, so I design 99% of the time with N-channel and have several devices rolling around my parts bin when I need one. It's 6 of one, a half dozen of the other. You might be able to save a little power by using one or the other, since a comms channel is usually idle a lot - I have not had a design where I needed to care about power and also needed a cheap comms interface, so I really have not thought it through.

  13. #13
    Join Date
    Oct 2006
    Posts
    8

    Default Re: Direct PIC to PC without MAX232

    About the protection of PIC input pin lets go remember that generally input pins already have positive and negative clamp diodes built in the chip. I have tested even without a series resistor but 470R will do the job. The great majority of legacy RS232 ports already are 0- 5v compatible for input and are current limited for output.

  14. #14

    Default Re: Direct PIC to PC without MAX232

    Here's a good example of the strange things that can happen when you get creative and choose not to pay attention to the specs...

    PIC16F1847 HFINTOSC Slow and Unstable

    Note that this guy WAS limiting the current with a series resistor.

  15. #15
    Join Date
    Mar 2008
    Posts
    16

    Default Re: Direct PIC to PC without MAX232

    Back to my original question:
    Turns out that the 12F1xxx family (and likely others) have an option to invert data from the TX/CK pin. The control is the SCKP bit (bit 4) in the BAUDCON register, described on page 279 of the 12F1822 data sheet.
    Last edited by swr999; - 23rd October 2014 at 21:34.

Similar Threads

  1. Send data PIC to PC
    By konter in forum Off Topic
    Replies: 6
    Last Post: - 25th December 2009, 22:04
  2. Replies: 67
    Last Post: - 8th December 2009, 02:27
  3. HSERIN & Interupts (aka controlling PIC programs from a remote PC)
    By HankMcSpank in forum mel PIC BASIC Pro
    Replies: 16
    Last Post: - 17th June 2009, 14:46
  4. PIC18F4680 to PC via MAX232 (RS232 serial) no output
    By opticsteam1 in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 14th April 2008, 20:39
  5. PIC and MAX232 in/out
    By The Master in forum Serial
    Replies: 10
    Last Post: - 29th March 2008, 20:41

Members who have read this thread : 2

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts