Revisiting RS485 setup

Thread Starter

Nick Bacon

Joined Nov 7, 2016
130
Hi guys, some time ago I tried to understand RS485 connection and how to implement it. I would like to try this again, please understand that I have never worked with RS485 before and dont 100% understand what is needed.

The basic scenario is that I have an electronic level controller with 16 points of indication. Each point has its own detector circuit that is controlled by a TLC3702CP comparator, giving an on or off output. The output is fed into a Darlington array to give outputs for leds and relays.

I would like to use RS485 to power local and remote LED displays for the unit. The are 3 leds per channel and 16 channels. so 48 on / off signals. It is possible to reduce this to 32 signals if need be.

I guess I would need a chip to input the signals into, which then feeds a transceiver. A transceiver and decoder on the remote and local display. I really don't understand any more than that, so any help or guidance would be great.

Mod edit: fixed P/N of comparator
 
Last edited by a moderator:

MrChips

Joined Oct 2, 2009
30,802
If you are planning on supplying power on the same cable, you will need a 4-conductor cable, two for power and ground, and two for RS-485.

If there are 16 levels, can we assume that only one level is triggered at any instant?
Why are there 3 LEDs?

As I can imagine it, 16 signals will be fed to a microcontroller which will encode the information. This will be transmitted via an RS-485 transmitter to your remote display. At the remote end, the reverse occurs, i.e. an RS-485 receiver will send the signal to a microcontroller for decoding and display.
 

Thread Starter

Nick Bacon

Joined Nov 7, 2016
130
Hi there,

Thanks for the reply. As a level indicator, all 16 points work at the same time to give a visual display of the water level. Each point is connected to a probe. So if the water level is half way up the tank, then 8 leds will be illuminated Green (water) and 8 illuminated red (steam). The other led is amber flashing, this is used to indicate an alarm on the channel. On each channel at any one time there will be either a Green or a Red led illuminated and the possibility of the amber led illuminated.

The micro controller would need to transmit a minimum of 16 x signals for steam or water and 16 x fault. The remote can be configured to know that 12V = water and 0V = steam..
 

MrChips

Joined Oct 2, 2009
30,802
Hi there,

Thanks for the reply. As a level indicator, all 16 points work at the same time to give a visual display of the water level. Each point is connected to a probe. So if the water level is half way up the tank, then 8 leds will be illuminated Green (water) and 8 illuminated red (steam). The other led is amber flashing, this is used to indicate an alarm on the channel. On each channel at any one time there will be either a Green or a Red led illuminated and the possibility of the amber led illuminated.

The micro controller would need to transmit a minimum of 16 x signals for steam or water and 16 x fault. The remote can be configured to know that 12V = water and 0V = steam..
At any instant, n green LEDs are on and 16-n red LEDs are on. This can be encoded into a single 4-bit value from 0-15.
An amber alarm condition can be encoded with one bit. Hence in total, you only need to transmit a 5-bit code to the remote display.

Is the tank ever completely empty? If so, what LEDs indicate this condition?
 

MaxHeadRoom

Joined Jul 18, 2013
28,684
BTW, RS485 standard does not necessarily require more than two conductors for operation, just the two complementary signals.
Max.
 

Picbuster

Joined Dec 2, 2013
1,047
Hi guys, some time ago I tried to understand RS485 connection and how to implement it. I would like to try this again, please understand that I have never worked with RS485 before and dont 100% understand what is needed.

The basic scenario is that I have an electronic level controller with 16 points of indication. Each point has its own detector circuit that is controlled by a TLS3702CP comparotor, giving an on or off output. The output is fed into a Darlington array to give outputs for leds and relays.

I would like to use RS485 to power local and remote LED displays for the unit. The are 3 leds per channel and 16 channels. so 48 on / off signals. It is possible to reduce this to 32 signals if need be.

I guess I would need a chip to input the signals into, which then feeds a transceiver. A transceiver and decoder on the remote and local display. I really don't understand any more than that, so any help or guidance would be great.
RS485 full duplex or half duplex it seems difficult but it is not. ( multi drop or addressed)
when you start rs485 start with a full duplex as you can use one chip connected to tx and rx from controller.(sn65hvd379 (smd 3v3 but also in 8 pin dip available).

next step, if you want is to build 1/2 duplex ( (max 485) you should define master and slave) slave is listing( receive mode) and master will poll slave.) Xmit and Rcv is controlled by the enable signal.

Next step is to introduce an address send string like [stx address data etx]and when needed a terminator.
It will require some programming but this is will take no more than a few hours.

That's all.

If you do not like a processor or don't need one use a uart and a full duplex connection but this will limit the system to one byte at the time unless to add more hardware.

Picbuster
 

MaxHeadRoom

Joined Jul 18, 2013
28,684
Probably one of the best ways to learn it is to study Modbus, which most systems use RS485 for communication to achieve.
There are many sites out there with details and tutorials.
Max.
 

Thread Starter

Nick Bacon

Joined Nov 7, 2016
130
Thanks for the replies. I am trying to get my head round this but struggling with the technicals. I am happy to use a micro controller to take the inputs and convert them for sending over the RS485. What I really need is an idiots guide. Where do I start? What is the simplest method to get 32 12V/0V signals over RS485.

I just dont get the terminology.
 

MaxHeadRoom

Joined Jul 18, 2013
28,684
There are quite a few RS485 Transceivers out there if you want to hook up to a micro.
What is present origin of the 12v signals?
I have used the Modbus protocol with a Pic, but Modbus generally is set up for 8 word packets and master/slave operation and the slave is intended to return the information as confirmation.
If you are using a unique operation then it does not necessarily need to conform to any protocol.
Also what is the receiving device?
Can you use RS232? Also the pic has a module for a USART.
I tested the pic routine I wrote using a RS232 port I had and sent/received to a PC 9pin COM port using free software, RS232 HEX COM .
Probably a Pic is easiest to do what you want to, the USART is fairly straight forward to set up and there are many tutorials out there.
Max.
 

Thread Starter

Nick Bacon

Joined Nov 7, 2016
130
There are quite a few RS485 Transceivers out there if you want to hook up to a micro.
What is present origin of the 12v signals?
I have used the Modbus protocol with a Pic, but Modbus generally is set up for 8 word packets and master/slave operation and the slave is intended to return the information as confirmation.
If you are using a unique operation then it does not necessarily need to conform to any protocol.
Also what is the receiving device?
Can you use RS232? Also the pic has a module for a USART.
I tested the pic routine I wrote using a RS232 port I had and sent/received to a PC 9pin COM port using free software, RS232 HEX COM .
Probably a Pic is easiest to do what you want to, the USART is fairly straight forward to set up and there are many tutorials out there.
Max.
There are quite a few RS485 Transceivers out there if you want to hook up to a micro.
What is present origin of the 12v signals?
I have used the Modbus protocol with a Pic, but Modbus generally is set up for 8 word packets and master/slave operation and the slave is intended to return the information as confirmation.
If you are using a unique operation then it does not necessarily need to conform to any protocol.
Also what is the receiving device?
Can you use RS232? Also the pic has a module for a USART.
I tested the pic routine I wrote using a RS232 port I had and sent/received to a PC 9pin COM port using free software, RS232 HEX COM .
Probably a Pic is easiest to do what you want to, the USART is fairly straight forward to set up and there are many tutorials out there.
Max.

The 12v signals come from the sensing circuits. Each channel, 16 in total detects the presence of water. When water is detected the TLC3702CP comparator gives a 12v output. This output is fed into Darlingtons to provide the led indication and relay action.

The transceivers are cheap so it is just finding how to implement a pic to encode and one to decode.

RS485 is the preferred standard as it needs to transmit over 500m or more and in an industrial environment.

If I can start by finding how to get the signals into a pic, I can build up the system
 

djsfantasi

Joined Apr 11, 2010
9,163
If I can start by finding how to get the signals into a pic, I can build up the system
The signals may come from the controller as 12V, but they don't have to input into the microcontroller as 12/0V signals. For example, a simple voltage divider can change the levels into an appropriate set of values for the micro.
 

AnalogKid

Joined Aug 1, 2013
11,038
As MrC indicated, if the 16 red/greens form a linear, monotonic bar graph, then all of that can be cooked down to a single 4-bit nybble with a priority encoder chip (or pair of smaller chips). By monotonic I mean that there never are reds and greens intermixed. Is it possible to have more than one amber LED on at any given time? If so, then they all have to be sent without encoding.

How much of that is correct?

So now you are down to 20 bits worst case, or only 5 bits if there is only one alarm signal.

ak
 

Thread Starter

Nick Bacon

Joined Nov 7, 2016
130
As MrC indicated, if the 16 red/greens form a linear, monotonic bar graph, then all of that can be cooked down to a single 4-bit nybble with a priority encoder chip (or pair of smaller chips). By monotonic I mean that there never are reds and greens intermixed. Is it possible to have more than one amber LED on at any given time? If so, then they all have to be sent without encoding.

How much of that is correct?

So now you are down to 20 bits worst case, or only 5 bits if there is only one alarm signal.

ak
Thanks for the reply........ The problem is that they can be intermixed, but not during normal operation. If there is a sensor fault then it is possible to have red between two greens etc.

Yes there could be more than one amber led on at any one time. There will be alarm and trip levels set in the system and the amber led can be set to flash when that level is reached. So if an alarm is set on channels 3 and 5 and the water level drops to 3, then amber led will flash on channels 3 and 5.

I have had a look at micro controllers and found this below. I has 35 Analogue-to-Digital Converters, I guess this would encode the signals for transmission but could the same chip decode as well.

http://uk.rs-online.com/web/p/microcontrollers/9053185/

I am looking for the simplest and cheapest way to implement this.
 

Thread Starter

Nick Bacon

Joined Nov 7, 2016
130
It may be that once the analogue signals have been converted to digital, the digital signals can be used to switch the LEDS. All I need to do is provide a local and one or two remote displays that use LEDs to display Red, Green and Amber on each channel.
 

djsfantasi

Joined Apr 11, 2010
9,163
First, let me clarify something that's been bugging me for a while. You are considering RS485 for its distance specification, RS485 transmits digital data over two differential lines, So when you talk of analog data (as in 36 ADC pins), I am confused as to what you are talking about,

Lets review the review the requirements. You have 36 sensors, which supply 12v or 0v depending on the water level, It will also supply an alarm signal. So, for a given channel, it will take one of three states: water, steam and alarm. Or not? Why would you have the sequence green, red and green?I could understand the sequence red, amber, red...

So what I am getting at is with 6 bits, you could encode the sensor position as 1 through 16 and encode it in 4 bits, Then, assign two more bits for the state: 0 = red, 1 = green and 2 = amber (3 is unused). Then your master microcontroller would scan the sixteen sensors and send one byte to the slave microprocessor, which would decode the status.

Two microcontrollers and two RS485 modules and a teeny bit of code and your good to go. You would need at least 32 output pins (16 pins for red/green, the latter merely the negation of the former and the alert pins) plus the pins for supporting functions (the RS485 functions), any input buttons, an optional display, and etc...
 

djsfantasi

Joined Apr 11, 2010
9,163
It may be that once the analogue signals have been converted to digital, the digital signals can be used to switch the LEDS. All I need to do is provide a local and one or two remote displays that use LEDs to display Red, Green and Amber on each channel.
WHAT ANALOG SIGNAL? You keep mentioning this ghostly analog signal, but then only describe a digital signal. The signal coming from your sensors can be either 0V or 12V, correct? Nothing in between? It is either on or off? Then, it is a digital signal. No analog here. Move on. Nothing to see.
 

Thread Starter

Nick Bacon

Joined Nov 7, 2016
130
WHAT ANALOG SIGNAL? You keep mentioning this ghostly analog signal, but then only describe a digital signal. The signal coming from your sensors can be either 0V or 12V, correct? Nothing in between? It is either on or off? Then, it is a digital signal. No analog here. Move on. Nothing to see.

Yes I admit I may have this wrong. The TLC3702CP which provides the 12v or 0V output is described as a Dual analogue comparitor. I have asked myself this question before but have only read conflicting information on the actual definition of analogue and digital. Moving on from that.....

I have 16 sensors ( I assume 36 is a typo) Each sensor has its own circuit (lets call it a channel), that channel will have an output from the analogue comparitor of 12V for water (Green LED) or 0v for steam (Red LED). Each channel will display either Green or Red at any one time, never both and never none. Each channel could also display the Amber LED (alarm) at any time. It could be that all 16 Amber leds are illuminated at any one time as well as a Green or Red on each channel.

What you have said about the.....

Two microcontrollers and two RS485 modules and a teeny bit of code and your good to go...

Is what I am looking for as long as I can have the display in 2 or 3 locations by having a microprocessor and RS485 module on each display.
 

djsfantasi

Joined Apr 11, 2010
9,163
Ok, I think you are getting it. The hidden truth is as follows; digital signals are really analog at heart. What makes them digital is there are defined thresholds where the signal is considered to be a '1' or a '0'.

RS485 protocal is designed for multi-drop situations, so your last point is a go.
 

Thread Starter

Nick Bacon

Joined Nov 7, 2016
130
Ok, I think you are getting it. The hidden truth is as follows; digital signals are really analog at heart. What makes them digital is there are defined thresholds where the signal is considered to be a '1' or a '0'.

RS485 protocal is designed for multi-drop situations, so your last point is a go.
Thanks great. So now to decide how to implement?

Microcontroller - this is a 40 pin chip with 35 IO pins, so one to take the signals in and encode for RS485, then one at each location to decode so to speak.
http://uk.rs-online.com/web/p/products/9053185/

A transceiver at each location to send and receive. Will any transceiver do? Like this one
http://uk.rs-online.com/web/p/products/1000738/
 
Top