CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

3 in RS232 1 out RS232

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Carnage
Guest







3 in RS232 1 out RS232
PostPosted: Fri Oct 21, 2005 12:57 pm     Reply with quote

I'm using a PIC16F873A and I'm trying to get data from 3 rs232 concatenate all in a buffer and send it to a pc via rs232 (so 4 rs232 in total). But I'm having trouble with this. Some people told me this was impossible so I ask.
Is there any way to do this?
Neutone



Joined: 08 Sep 2003
Posts: 839
Location: Houston

View user's profile Send private message

PostPosted: Fri Oct 21, 2005 2:08 pm     Reply with quote

If your data is not all at the same time it can be done. You can use logic gates to control the input and output PINS to the USART. If you AND all the RX pin into the USART you can recieve data from all three but only if they dont happen at the same time. You can use a few other pins to select where transmit signals go.
asmallri



Joined: 12 Aug 2004
Posts: 1634
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Fri Oct 21, 2005 6:10 pm     Reply with quote

It can be done, even when all are operating simultaneously however you will need to write your own RS232 drivers and use interrupts with multiple timers.

Experience shows it will be easier with an 18F series PIC. I have an implementation that has three RS232 ports running full duplex at 115Kbps and a USB port concurrently. However to achieve this I coded high and low priority interrupt handlers in assembler and has multiple high priority interrupt sources.

The project would be greatly simplified if the 3 RS232 input sources were literally input only (do not need to transmit) and the PC RS232 port was output only. Similarly if you could use a lower baud rate for the 3 input sources.

An alternative approach could be to use multiple PICs and interconnect the PICs via SPI or I2C. Sounds messy but in my cae I spent a lot of time tuning my interrupt handlers to ensure all paths through the handlers for setting and clearing bits for a port were identical so as not to introduce jitter. Project development would have been quicker to use multiple PICs.
_________________
Regards, Andrew

http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!
Carnage
Guest







PostPosted: Sat Oct 22, 2005 8:17 am     Reply with quote

Thanks for your answer.
In fact is that the 3 RS232 input sources are literally input only and the PC RS232 is output only. How can I make this posible?
asmallri



Joined: 12 Aug 2004
Posts: 1634
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Sat Oct 22, 2005 8:52 am     Reply with quote

There are multiple ways to do this. Here is one approach...

Are you able to use a PIC18F instead of a 16F? If so then I would feed the RX input for each receive 232 port to a INTx (where x is 1 to 3). This way you can use interrupts to detect the start bit. To make it simple allocate a timer to each of the receive ports for bit timing. If you are using a low baud rate then you could get away with a single timer running at say 4 times the maximum bit rate to do this.

Use the Hardware UART for the fast port (the one to the PC)

For each of the rx serial ports you will need to attempt to discover the start bit (with the interrupt) When you have found a candidate for a start bit then sample the input again at between 0.25 and 0.5 times the bit rate to ensure it is still the corrct level for a start bit. Now sample at each bit time to construct your character.

If you are dedicating a timer per rx port this is straight forward. If not then I would use a single timer running at 4 times the maximum bit rate and, using timer interrupts, perform you bit sampleing once you have detected a start bit.
_________________
Regards, Andrew

http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group