How can i read data from the serialport DCD pin ?

Discussion in 'Programmer's Corner' started by Embedded Lover, Mar 11, 2009.

  1. Embedded Lover

    Thread Starter Member

    Dec 22, 2008
    26
    0
    How can i read data from the serialport DCD pin ?

    Hi All,
    I am using C# and want to know how can i read data from the serialport DCD pin ?

    there is a class Serial port that has a nice stuff, but no way to get the data carried by the DCD signal , just the status

    can I ?

    or in C++ and port it !
     
  2. beenthere

    Retired Moderator

    Apr 20, 2004
    15,815
    282
    The data carrier detect signal is not used for data. It is used as a signal from a remote modem that is in online and ready to work with the signalling computer. When your computer sends the RTS (request to send) to a modem, it asserts DCD to show it is ready. It is only to show a ready status.

    Here is an article on how the RS-232 control signals work - http://www.sangoma.com/support/tutorials/rs232_rs422_and_v35.html.
     
  3. Embedded Lover

    Thread Starter Member

    Dec 22, 2008
    26
    0
    But I have a remote control ciruit that's designed to receive the signal on the DCD pin and it works well in already-made program called uICE . I made the circuit abd tested it with this program and it worked.

    however, do u have any alternatives ? and how to decode the IR signal ?
     
  4. beenthere

    Retired Moderator

    Apr 20, 2004
    15,815
    282
    Can you post up the circuit. It does not sound as if the connection is vanilla RS-232.

    What is the signal in question? -
    - details would help.
     
  5. Embedded Lover

    Thread Starter Member

    Dec 22, 2008
    26
    0
    The Circuit is IR receiver .It receives the IR signal from the remote control and pass it the PC.

    [​IMG]
     
  6. beenthere

    Retired Moderator

    Apr 20, 2004
    15,815
    282
    Pin 1 is DCD, pin 5 is Ground, Pin7 is CTS.

    When CTS is asserted, it powers the receiver. The received data is sent onto pin 1. The TSOP1738 is designed to work with IR modulated at 38KHz.

    It might work better if the data was sent to pin 2, which is the Rx (receive data) input. Is there some reason for using DCD instead of Rx?
     
  7. Embedded Lover

    Thread Starter Member

    Dec 22, 2008
    26
    0
  8. Embedded Lover

    Thread Starter Member

    Dec 22, 2008
    26
    0
    I did some thing else that worked with me

    Checking the status of the DCD pin at time slots(e.g. every 1 ms). That enabled me to get the data from this pin.
     
  9. xushirui

    New Member

    Apr 7, 2009
    8
    0
    If you are using SerialPort component, you can add a event handler of
    SerialPinChangedEventHandler
    like
    mCom.PinChanged += new SerialPinChangedEventHandler(Com_StatusChanged);



    void Com_StatusChanged(object sender, SerialPinChangedEventArgs e)
    {
    string info = string.Empty;
    switch (e.EventType )
    {
    case SerialPinChange.Break:
    info = string.Format("Break detected. BreakState = {0}", mCom.BreakState);
    break;
    case SerialPinChange.CDChanged:
    info = string.Format("Carrier Detect (CD) signal changed state. CD State = {0}", mCom.CDHolding);
    break;
    case SerialPinChange.CtsChanged:
    info = string.Format("Clear to Send (CTS) signal changed state. CTS State = {0}", mCom.CtsHolding);
    break;
    case SerialPinChange.DsrChanged:
    info = string.Format("Data Set Ready (DSR) signal changed state. DSR State = {0}", mCom.DsrHolding);
    break;
    case SerialPinChange.Ring:
    info = "Ring detected";
    break;
    default:
    break;
    }
    LineStatusChangeEventArgs args = new LineStatusChangeEventArgs(info);
    OnLineStatusChanged(sender, args);
    }

    Hope this could be help
     
Loading...