Reputation: 424
I am working on a project and I use several PIC18F26K83's for this project. For communication between PIC's I use UART. Now I also need to send data with RS232 to the user. As I have understood the main difference between UART and RS-232 is voltage levels. And with PIC I cannot supply proper voltage level that is required for RS232. Because of that UART to RS232 converter's look like a must. (i.e. MAX232) I have two questions.
1) Using UART to RS232 chips is the only option in this case? Are there any alternative ways?
2) I am planning to send UART data directly to the Uart to RS232 converter chip. I do not know how they work, codewise do I need to change anything? Can I directly put UART tx data to the receive pin of these chips? Thanks beforehand.
Upvotes: 1
Views: 3690
Reputation: 1897
Using UART to RS232 chips is the only option in this case? Are there any alternative ways?
For converting from UART to RS-232, using RS-232 level-converter IC like MAX232 is the most economical, reliable and convenient approach. You can build the respective RS-232 line drivers and line receivers using discrete parts but that's not recommended for above mentioned reasons (economical, reliable and convenience).
I am planning to send UART data directly to the Uart to RS232 converter chip. I do not know how they work, codewise do I need to change anything?
Coding wise nothing will change. Just verify taht the baud rate of your UART is supported by RS-232. Most MAX232 will operates up to 120 kbit/s and MAX3232 operates up to 250 kbit/s.
For typical connection where baud rate is generally 9600 either of IC will suffice.
Can I directly put UART tx data to the receive pin of these chips?
Your UART TX needs to connect to Logic Data Input pin of MAX232 (T1IN (Pin Number - 11) or T2IN (Pin Number - 10)).
Your UART RX needs to connect to Logic Data Output pin of MAX232 (R1OUT (Pin Number - 12) or R2OUT (Pin Number - 9)).
If you connect you UART TX to T1IN (Pin Number - 11) then you will get your RS-232 TX signal on T1OUT (Pin Number - 14) else if you connect you UART TX to T2IN (Pin Number - 10) then you will get your RS-232 TX signal on T2OUT (Pin Number - 7).
Similarly, If you connect you UART RX to R1OUT (Pin Number - 12) then you have incoming RS-232 data/signal line should be connected to R1IN (Pin Number - 13) RS232 line data input(from remote RS232 system) or if you connect you UART RX to R2OUT (Pin Number - 9) then you have incoming RS-232 data/signal line should be connected to R2IN (Pin Number - 8) RS232 line data input(from remote RS232 system).
Upvotes: 1