Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

What does opening the standard PC serial port do, in electrical terms (i.e. what voltages on which pins)?

For example, the ancient VB6 program which controls an apparatus I am tasked with maintaining toggles .PortOpen to control some TTL. The connection only used 2 pins (bad solders fell apart), so which pins do I solder to?

The only labels / documentation refer to pins 7 and 9, saying 0V and 5V parenthetically, but does .PortOpen really just put 5V between RI and RTS?.

As a post script, this isn't the weirdest thing about the set up. The TTL I referred to above also connects to an instrument via a BNC to DB9 (!), with only 1 pin used. I guess there was an assumption about a common ground, since the BNC shielding isn't connected to the GND pin? The connection is to the instrument's 'foot pedal' pin, it was a way to remotely trigger the device.

Update

According to this page, the DTR and RTS pins can go high when the port is opened. If they were so configured, they will subsequently go low when the port is closed.

If DTR and RTS are not enabled, opening the port should set both to low (and keep them low).

share|improve this question

migrated from electronics.stackexchange.com Jun 29 '11 at 13:46

This question came from our site for electronics and electrical engineering professionals, students, and enthusiasts.

    
TTL? Through-the-lens? Transistor-transistor-logic? –  Federico Russo Jun 23 '11 at 6:49
    
The latter. It's a pass through that is opened and closed by a flip-flop toggled by opening/closing the serial port. –  reve_etrange Jun 23 '11 at 6:53
    
@reve_etrange: I was asking because serial ports aren't TTL level, so you can't connect them directly. I thought you meant something else. –  Federico Russo Jun 23 '11 at 6:56
    
@Federico Russo, in my embedded applications and debugging I often use TTL level UARTS without drivers. Doesn't everyone have one of these ftdichip.com/Products/Cables/USBTTLSerial.htm? –  kenny Jun 23 '11 at 12:47
    
@kenny: OP says he's on a PC, and there a serial port goes from -12V to +12V. –  Federico Russo Jun 23 '11 at 15:00
show 1 more comment

3 Answers

up vote 1 down vote accepted

I disagree with @Stevenvh answer. For windows in particular. The "port open" and "port close" API calls, say in .NET or MSCOMM OCX will force DTR and RTS lines to change or not change their state electrically.

On port open, the DTR will be set to electrical state, corresponding to boolean property DTREnable, if it was set "true" before opening port. By default, it will stay "false", if user, never set DTREnable, then on "open port" DTR line will stay "false" as before opening port.

Same logic and defaults for line names "RTS" and property "RTSEnable". You choose "RTSEnable" before opening port, depending on communication party on other end of cable and amount of wires involved (hadware handshake vs software handshake vs no handshake).

  • Data carrier detect - is input, no effect
  • Receive data - is input, no effect
  • Transmit data - is output, will stay "SPACE" instead of "MARK"
  • Data terminal ready - will change to "TRUE" if property was set before "Port open"
  • Signal ground - no change
  • Data set ready - is input, no effect
  • Request to send - will change to "TRUE", if RTSEnable property was set before "Port Open"
  • Clear to send - is input, no effect
  • Ring indicator - is input, no effect

In reverse, when port is closed. The pins DTR and RTS will change to "FALSE" state, or stay in "FALSE" state, if they were not set through properties at opening time.

share|improve this answer
    
How about the other pins (besides DTR and RTS)? –  reve_etrange Jun 30 '11 at 4:44
    
The output data pin of PC will stay in "SPACE", not "MARK" state. Other pins are input pins, so they will not change (Ring Indicator, Carrier Detect, Clear To Send, Data Input). –  user27803 Jun 30 '11 at 14:46
    
Awesome, thanks! By "stay" SPACE/MARK do you mean that when the port is closed it will revert to some device dependent undefined state? –  reve_etrange Jul 1 '11 at 0:57
    
Yes. But SPACE/MARK can be treated as "defined", I mean predictable voltage. Sya in TTL "SPACE" is "FALSE", is zero volts, or MARK is "TRUE" is +5 Volts. But in RS-232 SPACE is +12V and MARK is -12V. –  user27803 Jul 1 '11 at 13:15
    
"Transmit data - is output, will stay "SPACE" instead of "MARK"" - An idle RS-232 data line will be MARKing at a negative voltage. –  sawdust Jun 23 '12 at 6:19
add comment

Opening the port doesn't do a thing in electrical terms. It just tells the OS that from that moment on the port is assigned to the application. The OS will deny other apps to access the port while yours has it open, and allow your app to access it.

share|improve this answer
    
That makes sense. Both the serial communication and Windows programming aspects of this are outside my expertise. –  reve_etrange Jun 23 '11 at 7:10
    
And on some OSes it can still be shared, but by programmer intention, however perhaps flawed the decision. –  kenny Jun 23 '11 at 12:50
    
I unmarked the answer since it's clear that other things can happen when the port is open. Sorry for the rollercoaster. –  reve_etrange Jun 29 '11 at 12:50
    
Is this definitely the behavior on non-Windows OSes? –  reve_etrange Jun 30 '11 at 4:45
add comment

Opening a serial port will force all pins to a defined state (I don't remember which handshake lines default to marking or spacing, but it's standard). Until the serial port is opened, the state of the lines may be undefined. Unless Microsoft has changed things, closing a serial port would leave the lines in whatever state they were prior to closure, so if the last program one used left them in a weird state they would remain in that state until the next time they were opened. Also, I don't know whether this is still an issue under Windows, but under DOS there were some PC's that would set their serial ports to a goofy state on power-up. At least one brand of PC would set its serial port to transmit continuous long-break until instructed otherwise; this was memorable because it would wreak havoc on a certain embedded controller if it was plugged in before the vendor's software had started.

share|improve this answer
    
Does it do anything besides set RTS and DTR to low/high depending on configuration? I.e. are all pins set low on open, do some transmit continuously, etc? –  reve_etrange Jun 29 '11 at 12:48
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.