Mr.Anderson
New Member
Hi,
I'm trying to send RS232 serial data from the PIC to the PC without a max232 between them.
I developed a simple program for testing purposes, that sends about 50 words from the PIC to the PC in RS232 format, 9600 8 Odd 1.
Firstly, I tried to use the USART from the 16F628A but it did not work. After looking here on this forum and googling, I concluded it would never work without a max232 since the voltage levels are different.
Then, after googling a little more, I found out that modern PC serial ports can interpret 0v as -12v (logic 1) and 5v as +12v (logic 0). So, to send RS232 serial data from the PIC to the PC, I would need only to invert each and every bit so they are transmitted according to the voltages that can be understood by modern PCs. Then, I've written the following tutorial as a guideline:
After writing the above tutorial for myself, I tried to put it in practice with bit bang routines. Unfortunatelly it is not working. I'm doing the right thing with the timing and the logic levels. My PIC is sending logic 0 as 5v and logic 1 as 0v. Each bit is 104us long. Parity is Odd. The PIC is setup with a 8Mhz crystal. Everything was checked on the MP-Lab debugger...
I don't see what more I could do to put it to work... Does anybody have any tip?
For those who might think it does not work, I've seen already a 12c509a sending bit bang rs232 directly to the PC serial port, without the MAX232.
Thanks.
I'm trying to send RS232 serial data from the PIC to the PC without a max232 between them.
I developed a simple program for testing purposes, that sends about 50 words from the PIC to the PC in RS232 format, 9600 8 Odd 1.
Firstly, I tried to use the USART from the 16F628A but it did not work. After looking here on this forum and googling, I concluded it would never work without a max232 since the voltage levels are different.
Then, after googling a little more, I found out that modern PC serial ports can interpret 0v as -12v (logic 1) and 5v as +12v (logic 0). So, to send RS232 serial data from the PIC to the PC, I would need only to invert each and every bit so they are transmitted according to the voltages that can be understood by modern PCs. Then, I've written the following tutorial as a guideline:
Code:
[FONT="Courier New"]
If I would like to send a 0xFF for example, the normal TTL bit sequence would be:
start LSB MSB Odd stop
0 1 1 1 1 1 1 1 1 1 1
Ok, then the above means in TTL voltages:
start LSB MSB Odd stop
0v 5v 5v 5v 5v 5v 5v 5v 5v 5v 5v
What you need to do is to invert each bit so the voltage levels become near the correct:
start LSB MSB Odd stop
1 0 0 0 0 0 0 0 0 0 0
In the above, you see how the PIC will need to send the data so the levels achieve the right ones for the RS232 receiver.
Now, below, the translation of the above logic states in voltages:
start LSB MSB Odd stop
5v 0v 0v 0v 0v 0v 0v 0v 0v 0v 0v
If we had a real RS232 emitter, we would be sending the original logic levels, like this:
start LSB MSB Odd stop
0 1 1 1 1 1 1 1 1 1 1
The difference is that in the RS232 devices, the logic levels above will translate into the below:
start LSB MSB Odd stop
12v -12v -12v -12v -12v -12v -12v -12v -12v -12v -12v
Hmmm, then now, we have concluded that we will be sending the below with the PIC:
start LSB MSB Odd stop
1 0 0 0 0 0 0 0 0 0 0
5v 0v 0v 0v 0v 0v 0v 0v 0v 0v 0v
And the above is just the accepted voltage levels for the same data in RS232. The right levels for RS232 would be:
start LSB MSB Odd stop
0 1 1 1 1 1 1 1 1 1 1
12v -12v -12v -12v -12v -12v -12v -12v -12v -12v -12v
We will make 0v corresponding to -12v and 5v corresponding to +12v.
[/FONT]
After writing the above tutorial for myself, I tried to put it in practice with bit bang routines. Unfortunatelly it is not working. I'm doing the right thing with the timing and the logic levels. My PIC is sending logic 0 as 5v and logic 1 as 0v. Each bit is 104us long. Parity is Odd. The PIC is setup with a 8Mhz crystal. Everything was checked on the MP-Lab debugger...
I don't see what more I could do to put it to work... Does anybody have any tip?
For those who might think it does not work, I've seen already a 12c509a sending bit bang rs232 directly to the PC serial port, without the MAX232.
Thanks.
Last edited: