PDA

View Full Version : non-inverting 2400 baud



cooksydesign
- 13th April 2009, 14:07
I have a PIC to PC and PC to PIC circuit operating just fine. However, when the circuit is moved to different PC's, I have noticed the data coming from the PC is not always detected by the PIC. It appears the voltage level from the IO port on the PC is lower. I have placed a MAX3180 on the receiving side of the PIC to boost the voltage. And it does. The MAX3180 inverts the data. I have been using N2400 and 16780 as buad rate perimeters on both sides of the PIC, Xmit and receive, and things had been running quite well. I changed the receiving side of the PIC to 396 but haven't had any luck making the connection. Is there another value or trick to this? This is the first time I have had to use a line driver with a PIC.
The basic PIC data circuit is layed out like the manual suggests, nothing else.
Thanks in advance.

Brad

mister_e
- 13th April 2009, 16:09
Try the same with DEBUG or HSEROUT instead of SEROUT/SEROUT2 and see how better/worst it is.

Side note, RS-232 @2400 baud already gave me few weirdies on some PCs. Problem disappear for me by using an higher baudrate.

cooksydesign
- 13th April 2009, 21:13
Sorry about that. I left out some important information. I am using a 16F628A, it does not have a USART so I am unable to use HSER function. Thanks for the suggestion though. I am also using the WAIT parameter. I am expecting to see a hex value between 31 and 39 but I am receiving fe. Not sure what fe is, but it is consistant.
Again, thanks for any suggestions.

b

Archangel
- 14th April 2009, 02:17
Sorry about that. I left out some important information. I am using a 16F628A, it does not have a USART so I am unable to use HSER function.
Don't know where you got those, BUT the 16F628A chips I use has USART pin7 RX, pin 8 TX.

cooksydesign
- 14th April 2009, 10:31
You are correct, I clicked on the wrong link when I was looking at dataseets yesterday. As I mentioned earlier, the circuit was working for quite awhile so I made a few boards. Now I see there are some problems with a few other PC's. Back to my original question, if 16780 works for 2400 baud in a SER2 command, what is the True seeting? I tried 396, then I get something other than what I expect. Looks like a baud rate setting. I can remove the MAX8130 and the circuit works fine, when the SER2 commands are returned to the proper settings. Thanks for pointing out the USART pins. Unfortunately, I have made boards and those pins are used.

b

Archangel
- 16th April 2009, 06:51
You are correct, I clicked on the wrong link when I was looking at dataseets yesterday. As I mentioned earlier, the circuit was working for quite awhile so I made a few boards. Now I see there are some problems with a few other PC's. Back to my original question, if 16780 works for 2400 baud in a SER2 command, what is the True seeting? I tried 396, then I get something other than what I expect. Looks like a baud rate setting. I can remove the MAX8130 and the circuit works fine, when the SER2 commands are returned to the proper settings. Thanks for pointing out the USART pins. Unfortunately, I have made boards and those pins are used.

bIn the back of the Book, Appendix A


B/R OUTPUT CONVERSION PARITY MODE
2400 DRIVEN TRUE NONE 396
2400 DRIVEN TRUE EVEN 8588
2400 DRIVEN INVERTED NONE 16780
2400 DRIVEN INVERTED EVEN 24972
2400 OPEN TRUE NONE 33164
2400 OPEN TRUE EVEN 41356
2400 OPEN INVERTED NONE 49548
2400 OPEN INVERTED EVEN 57740

mister_e
- 16th April 2009, 15:45
What I suggest is to set the TX pin to the normal idle State at the top of your program and add a pause of few mSec. True mode idle high, while inverted idle low.

cooksydesign
- 20th April 2009, 14:17
I changed the baud rate setting from 396 to T2400 and the correct data was sent out. What's the difference between 396 and T2400? I don't know. Something similar to this happened before and I ended up using N2400 when a line driver is not used. I didn't see a reference to T2400 in the book.

Is there a way to clear the output buffer in the PIC 16F628a? The PIC sends a D0 first time, every time. Nowhere in the program do I load a D0. When I send the proper data twice, the receiving program discards the D0 and recognizes the correct data and accepts that. Strange.

Thanks for all suggestions earlier.

B

mister_e
- 20th April 2009, 16:04
You need to set the idle level first at the top of your program, then send your data.

For true mode, your serial output must be set high, for inverted, it's low.

T2400, N2400 are for SEROUT, all other numbers 396,16780 are for SEROUT2

cooksydesign
- 23rd April 2009, 13:40
Well, between the T2400, SerOut vs SerOut2, setting the line high for true data, the problem has been resolved. Before each transmission I put the data line in a high state. Works fine. Thanks again to all for answering.

B

Melanie
- 23rd April 2009, 14:17
Winding back to the start of this thread, if your INPUT voltage is too low for a PIC, and it has Comparators, configure it as an Amplifier... you can receive Serial at 9600 Baud at MILIVOLT levels and the Comparator will happilly reconstruct 0-5v (and Invert it or not at your choice) which can then be read by SERIN, DEBUGIN or by a USART. Who needs a MAX232 anyway. A Comparator will do it all for you.

cooksydesign
- 23rd April 2009, 19:57
Hey Mel,

Thanks for the additional information. I think it's too late for this project though. I have already spun the boards. My in/outs are on B.4 and B.5 of the 16F628a.

B

Byte_Butcher
- 23rd April 2009, 21:32
Winding back to the start of this thread, if your INPUT voltage is too low for a PIC, and it has Comparators, configure it as an Amplifier... you can receive Serial at 9600 Baud at MILIVOLT levels and the Comparator will happilly reconstruct 0-5v (and Invert it or not at your choice) which can then be read by SERIN, DEBUGIN or by a USART. Who needs a MAX232 anyway. A Comparator will do it all for you.

Heh. Now THAT's one of those things I'm gonna try and remember, because SOME day it's bound to come in handy for me!

What a great idea!




steve