go away spammer

Author Topic: Serial Uart Passthru code  (Read 2845 times)

0 Members and 1 Guest are viewing this topic.

Offline AsellithTopic starter

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 648
  • Helpful? 9
  • "I'm a leaf on the wind. Watch how I soar"
    • CorSec Engineering
Serial Uart Passthru code
« on: December 11, 2007, 11:54:31 AM »
I'm working on a project to put extra data into an RS-232 connection. we have one piece of equipment that talks to a modem and I want to interface another piece of equipment into the same modem. However the second machine needs an analog interface so I want to put an ADC in there and monitor the equipment with a microcontroller. We are only looking for faults so no need to send periodic data back through the connection. It is a serial modem so I'm going to include in any uart messages the AT commands to send the text message with my info. The problem is I have the first peice of equipment that will need to talk on the serial line as well. So my thouhg twas I could put the controller in the middle and just pass all the incoming serial data out and when I need to interject a signal into the stream I can just send it out the outgoing uart. I have been doing some reading and originally I thought I could do it without using the cts and rts lines. The more I think about it the more I think I might need to control the flow better. However my question is would it be better to simply buffer whatever is coming in while I transmit out and then transmit the buffered data or should I try to flow control it to save on memory?

Jonathan Bowen
Jonathan Bowen
CorSec Engineering
www.corseceng.com

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: Serial Uart Passthru code
« Reply #1 on: January 03, 2008, 09:29:07 AM »
Im not experienced enough on UART to really help you . . . but I have a few thoughts . . .

I don't believe there are any microcontrollers that can use two UART's simultaneously. So if you receive data on UART 1 while you are sending data on UART 2, the data on UART 1 will be lost. I don't see how you can buffer data while your mcu is busy transmitting data . . .

If you can time when you aren't receiving data, and transmit only in that time, then your idea seems to be good. Perhaps use a fixed timer interrupt after each received stream or something to know when to start listening again . . .

Oh and I don't see any reason to use cts and rts . . . but I'm definitely no expert on this . . .

Offline AsellithTopic starter

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 648
  • Helpful? 9
  • "I'm a leaf on the wind. Watch how I soar"
    • CorSec Engineering
Re: Serial Uart Passthru code
« Reply #2 on: January 03, 2008, 03:53:41 PM »
We brainstormed the problem some more and found a way to just switch the signal lines using a relay. We figured that the controller only needed control when we didn't want to talk to the receiver through rs-232. So we decided to use one uart to talk to the receiver and monitor the other one. If a command came through or after a timer fires(still not sure what we are doing there) Then we would transmit a log back or if the data dropped below specified values it would send an alert message. Now all I have to wait for is the cell modem to get here so I can play with it.

Jonathan Bowen
Jonathan Bowen
CorSec Engineering
www.corseceng.com

Offline GUmeR

  • Jr. Member
  • **
  • Posts: 24
  • Helpful? 0
Re: Serial Uart Passthru code
« Reply #3 on: January 04, 2008, 07:54:05 AM »
Just quick thought. Make additional line between two equipments. Equipment #1 want to use modem. Pull line up or something so equipment #2 knows to wait, after data send restore line to original state. Receiving: both equipments receives all data from modem and checks if data if for them.

 


Get Your Ad Here