Home > Net >  Reading High/Low from Pins through RS232
Reading High/Low from Pins through RS232

Time:06-06

I am new to RS232 and have some confusion about reading the pins. Here is the scenario I am trying to achieve:

There is a motion sensor on a line and when someone passes it, it triggers and sends a signal to a different terminal's IO board - connected through RS232.

I am uncertain of the format the data comes in, but I assume it is an high or low input. But in C# I don't know how to read the actual Pins except for the handshake pins DTR, RTS and CTS. More specifically I can listen to the SerialPort.OnPinChanged event.

But here is my confusion: Where is the high/low signal being sent to.

I can easily read the data in C#. But I'm not even sure if I want to read the data if it is a simple high/low signal, and definitely not sure if this is a valid option for RS232 connections. At the moment I am leaning towards No.

CodePudding user response:

Here is a quick tutorial on RS-232 for you to reference https://www.codrey.com/embedded-systems/rs232-serial-communication/

"There is a motion sensor on a line and when someone passes it, it triggers and sends a signal to a different terminal's IO board - connected through RS232."

Attach an electrical schematic of this circuit and the datasheet for the motion sensor you're talking about. This is kind of a bullshit question and as posed does not describe a practical functioning circuit. Digital sensors signal through an electrical contact that if NO (normally open) is open/de-energized 0VDC when not triggered, or closed/energized 24VDC when triggered.

A sensor does not communicate over RS-232.

  1. A digital sensor signal-wire is typically connected to a controller (like a PLC) input-terminal, and the controller provides 24VDC power to the digital sensor, and a seperate 0VDC potential common terminal if a 3-wire digital sensor.
  2. controller converts the sensor input signal to the 8-bit binary format that the RS-232 interface can transmit to another nodes RS-232 interface
  3. the RS-232 interface at the recieving node, your terminal, detects a voltage drop at the RxD as the start bit, and recieves the transmitted 8 bit byte by detecting the number voltage blips in the communication interval that is determined by the baud rate setting.

RS-232 is a communication protocol between 2 systems that specifies which pins are used for "hardware handshaking" when 1 node wants to send data to another node. The data pulses are transmitted from the TxD "transmit data" pin by the transmitting node, and if a recieving node is connected with a null-modem cable, the pulses are recieved at receiving node's RxD "recieve data" pin.

Sofware handshaking is done by using the TxD & RxD transmit & recieve pins but sensors generally do not use it, its slower and if signal is dropped after handshake neither side is aware.

The DB9 9-pin connector is most commonly used, but a 7-pin RJ45 Ethernet connector can be used when communication is one-way because the transmitting node doesn't need a CTR clear to recieve pin, nor does the recieving node need the RTS request to send pin.

Applying the tutorial to your example, your PC will have both a DTE Data Terminal Equipment port and a DCE Data Communications Equipment port mapped to your model interface card

The "format" the data is transmitted on the TxD pin#2 of the sending-sensor, & recieved on the RxD pin#3 of the recieving terminal, is 8 bits of binary. which the sender-sensor (in your example) is changing the voltage-potential between 0 volts DC to 24 volts DC

How to "read" the data? If you had really fast eyes you could use a volt-meter to watch the voltage-potential change from - to by connecting the black electrode to GND pin#5 & red electrode to TxD on pin#3 on the sending node. Or do the same thing with an osciloscope and set your X-axis for the baud-rate time-interval

  • Related