Author Topic: Can Someone Educate Me on Software Serial, and RS232 Sensors in General?  (Read 4127 times)

0 Members and 1 Guest are viewing this topic.

Offline PotomacTopic starter

  • Regular Contributor
  • *
  • Posts: 71
  • Country: us
I have some questions regarding RS232 sensors, which I have laid out in structured form below. If you could educate a total beginner, that would be greatly appreciated



1).  To communicate with my Arduino Pro Mini, I know that I'll need a RS232-to-TTL converter module. I found two below that seem to have good reviews.  Are there any better options around?  I would like to keep it as small as possible, with the one caveat that it have 2-4 holes on the corners so I can mount it with screws and metal standoffs.

The modules I found:

a). "RS232 Serial Port to TTL Converter Communication Module for Arduino - DX.com"

b). "RS232 Serial Port To TTL Converter Module for Arduino #04902615 - MiniintheBox.com"


2). Those two modules I listed above have different numbers of pinouts, and different abbreviations for pinouts.  Excluding VCC and GND, one has 2 additional pinouts and one of them has 4. See picture attachment called "Pinouts" below. Is there a set of pinouts you'd want in general?




3). For reference, the sales brochure for the oxygen sensors I want to attach to my Arduino Pro Mini is here. (I need to email them to ask for a real datasheet) Does this inform which pins I need on a converter module? I don't see any data relevant to answering this question. 

http://www.presens.de/fileadmin/user_upload/products/Transmitters/EOM-O2-mini/160615_TR-EOM-O2-mini-16-01_w.pdf


4). I know that the Pro Mini has one UART.  Could I attach 3 of the oxygen sensors above with SoftwareSerial?  How reliable has it gotten over the years? I've read that previous versions were dicey in terms of data quality. And also that are limitations to data speed. 
 
I found this resource but it hasn't been updated in awhile:  https://www.pjrc.com/teensy/td_libs_SoftwareSerial.html
« Last Edit: September 21, 2016, 05:14:18 am by Potomac »
 

Offline 3db

  • Frequent Contributor
  • **
  • Posts: 331
  • Country: gb
Re: Can Someone Educate Me on Software Serial, and RS232 Sensors in General?
« Reply #1 on: September 21, 2016, 06:14:45 am »
The module on the left is the better choice because of the additional "handshake" lines.
I would also check if those modules handle proper RS 232 voltage levels ie  +ve AND -ve volts WRT to 0 volts.
Yes you can use three of those modules ie one for each sensor.
You might have to modify the software serial library (didn't check it out)
I think it would be better in the long run to go for the RS 485 interface which is an option for those sensors.
Which has many other benefits.

3DB  :D
 

Offline PotomacTopic starter

  • Regular Contributor
  • *
  • Posts: 71
  • Country: us
Re: Can Someone Educate Me on Software Serial, and RS232 Sensors in General?
« Reply #2 on: September 21, 2016, 07:07:51 am »
thanks 3db

Can you elaborate on the usefullness of those "handshake" lines in this application? (RTS/CTS)  I found this wiki section, but I'm not sure I grasp the concept:  https://en.wikipedia.org/wiki/RS-232#RTS.2C_CTS.2C_and_RTR

Also, what's the benefit of RS485 over RS232 here?

 

Offline rstofer

  • Super Contributor
  • ***
  • Posts: 9886
  • Country: us
Re: Can Someone Educate Me on Software Serial, and RS232 Sensors in General?
« Reply #3 on: September 21, 2016, 01:39:38 pm »
thanks 3db

Can you elaborate on the usefullness of those "handshake" lines in this application? (RTS/CTS)  I found this wiki section, but I'm not sure I grasp the concept:  https://en.wikipedia.org/wiki/RS-232#RTS.2C_CTS.2C_and_RTR


The handshake lines allow for hardware flow control.  Flow control is a process whereby the receiver can tell the sender it is ready to receive and the sender can tell the receiver it is ready to send.

http://us.brainboxes.com/faq/items/what-is-rts--cts-hardware-flow-control-

These lines may not be used by the sensor.  I don't envision a huge amount of data transfer.

Quote

Also, what's the benefit of RS485 over RS232 here?


In real RS232, there is no way to share the signal lines with multiple sensors.  Any attempt to connect 3 sensors to a single serial port results in an ugly hack.

RS485 was designed as a network protocol and not necessarily with one master and many slaves.  Each sensor will be assigned an 'address' and the master will communicate with them by using this address.  Check your sensor datasheet for details.

We need to be specific about what we call these protocols.  Coming out of the uC is TTL serial, not RS232.  TTL serial has voltages between ground and the chip Vcc whereas RS232 has voltages of +-5V up through +-25V

https://en.wikipedia.org/wiki/RS-232

It takes some kind of dongle or chip to convert TTL serial to RS232 levels.  Your attachments will do that job.

There are similar gadgets for RS485

http://yourduino.com/sunshop//index.php?l=product_detail&p=323

For multiple sensors on a single UART, I would implement RS485.  Not only is it a multi-drop protocol, the distance to the sensors can be enormous.  A few thousand feet...
 

Offline 3db

  • Frequent Contributor
  • **
  • Posts: 331
  • Country: gb
Re: Can Someone Educate Me on Software Serial, and RS232 Sensors in General?
« Reply #4 on: September 21, 2016, 01:55:32 pm »
You can use RequestToSend and ClearToSend as a hardware flow control mechanism.
So you could for example tell the sensor to stop sending data while you deal with another sensor.
You connect RTS at one end to CTS at the other and vise versa.
The RS485 lets you connect many devices together like a local network.
Your devices can be located further away from the control unit.
The data rates are much higher.
There is better signal integrity.
The firmware once written is more reusable.
In addition you don't need to use RS232 connectors.
I'm not sure what your end goal is but you will also have access to a greater range of sensors.

3DB  ;D

 

Offline ebclr

  • Super Contributor
  • ***
  • Posts: 2328
  • Country: 00
Re: Can Someone Educate Me on Software Serial, and RS232 Sensors in General?
« Reply #5 on: September 21, 2016, 02:05:22 pm »
If you want to connect more sensors change to arduino Due have 4 serial ports available on hardware, also is much faster than regular Arduino But must use 3.3v rs-232 converters
 

Offline suicidaleggroll

  • Super Contributor
  • ***
  • Posts: 1453
  • Country: us
Re: Can Someone Educate Me on Software Serial, and RS232 Sensors in General?
« Reply #6 on: September 21, 2016, 02:24:07 pm »
The one on the left has a much better layout, the decoupling on the one on the right is basically useless.

RTS/CTS are used for flow control, so if your uC is getting overrun with data, it can tell the sensor to slow down until it clears the backlog.  This is mostly a remnant of decades past when MCUs were much slower than they are now, and isn't often an issue anymore.  Most sensors these days don't support hardware handshaking anyway.  If yours does then you should use the one on the left, if it doesn't then you could use either, but again I'd prefer the one on the left due to the layout alone.  The one on the left also uses arrows to indicate data direction instead of the ambiguous "Rx" and "Tx", so an extra two points there.

« Last Edit: September 21, 2016, 02:27:25 pm by suicidaleggroll »
 

Offline ebclr

  • Super Contributor
  • ***
  • Posts: 2328
  • Country: 00
Re: Can Someone Educate Me on Software Serial, and RS232 Sensors in General?
« Reply #7 on: September 21, 2016, 02:36:44 pm »
1st need to check if sensor understand RTS CTS otherwise will be useless
 

Offline Electro Fan

  • Super Contributor
  • ***
  • Posts: 3160
Re: Can Someone Educate Me on Software Serial, and RS232 Sensors in General?
« Reply #8 on: September 21, 2016, 03:07:45 pm »
Lots of good info and advice posted above. 

Just to clarify on RTS/CTS - they are a remnant of older technology but if you need them or choose to implement them they could be useful if the interfaces you choose happen to support them.  If the interfaces you choose include RTS/CTS but you decide not to use RTS/CTS you can ignore them, they will just be extra unused pins.  So having them might add some flexibilty - you can use them or ignore them.

I think the more important decision is how you will manage the point to multipoint communications; from there you can decide what functions, pins, and voltages you need.

Having said that, you might be able to get the project done through hardware or software (and likely both).  If you are inclined to manipulate the software and don't care too much about hardware size or cost, using an Arduino with three or however many physical ports you need might be a good solution.  If you want to manage communications with hardware the RS485 approach might be a good path.  The multi drop and longer wire distance supported by RS485 are two key reasons why RS485 was developed - but i'm betting that the point to multipoint requirement can be pretty readily handled in software by an Arduino (maybe a Due as suggested by ebclr). If the sensors are beyond the distance supported by RS232 you might be back to RS485.  Or you might wind up with something else (ethernet, Wifi, etc).  If the topology consists of short wire runs the RS232 approach should be relatively easier and less expensive.

For a quick look-see here is a TTL/RS485 converter; there are probably less and more expensive versions - but i think they will generally cost a bit more than the least expensive TTL/RS232 converters.
http://www.serialcomm.com/mobile_site/serial_rs232_converters/rs232_rs485_to_ttl_converters/rs485_to_5v_ttl_converter/rs485_to_5v_ttl.product_general_info.aspx

Your oxygen sensor link says it supports both RS232 and RS485.  I think for $3 more (than the non RTS/CTS board) I'd start with one of the RS232 boards that supports RTS/CTS and has the arrows.  You might not need either but if either saves you any time it will be worth it.  You might make a Phase I that gets one sensor successfully communicating with the Arduino and then see what it takes to add more sensors.  Or you might try to design the full multi-sensor architecture from the get-go and start coding and assembling, or assembling and coding.

Sounds like a very good learning project.  Let us know how it goes.
« Last Edit: September 21, 2016, 04:19:50 pm by Electro Fan »
 
The following users thanked this post: 3db

Offline rstofer

  • Super Contributor
  • ***
  • Posts: 9886
  • Country: us
Re: Can Someone Educate Me on Software Serial, and RS232 Sensors in General?
« Reply #9 on: September 21, 2016, 06:00:44 pm »
Your oxygen sensor link says it supports both RS232 and RS485.  I think for $3 more (than the non RTS/CTS board) I'd start with one of the RS232 boards that supports RTS/CTS and has the arrows.  You might not need either but if either saves you any time it will be worth it.  You might make a Phase I that gets one sensor successfully communicating with the Arduino and then see what it takes to add more sensors.  Or you might try to design the full multi-sensor architecture from the get-go and start coding and assembling, or assembling and coding.

Sounds like a very good learning project.  Let us know how it goes.

Pay attention to the ACTUAL direction of signals on uCs and adapters.  This problem is pretty unique to serial TTL -> RS232 adapters because TxD and RxD signal direction depend on which end you are looking at.  Sometimes the adapter TxD will want output data from the uC (TxD is an INPUT to the adapter) and other times it is actually carrying output data to the uC input (TxD is OUTPUT to the uC).  Unfortunately, there is no universal standard.  So, look at the schematics and look at the traces and make sure you don't have two outputs talking to each other.

You can't always connect the adapter TxD to the uC RxD.  Sometimes it really means to connect adapter TxD to uC TxD.  It depends on how the designer looked at it.
« Last Edit: September 22, 2016, 02:29:40 am by rstofer »
 

Offline ebclr

  • Super Contributor
  • ***
  • Posts: 2328
  • Country: 00
Re: Can Someone Educate Me on Software Serial, and RS232 Sensors in General?
« Reply #10 on: September 21, 2016, 11:15:41 pm »
Wana master the topic

Buy this book

http://janaxelson.com/spc.htm
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf