Hi, I'm currently working on a project where I want to use communication over RS485 via MAX485. I've gone through a lot of the sources but some things are still unclear.
First I'll start with bias resistors. To my understanding, they are used as a failsafe when there is no communication over RS485 bus to hold the lines at a specified state and thereby avoid random start bits created by noise etc. Also, the chosen IC (MAX485) should have this failsafe inside but can you do any wrong by using external bias resistors? Then there is the question of value. If my source is right you should be trying to calculate differential resistance or something like that - the equation I've seen was basically a parallel resistor combination equation where the first value was the sum of bias resistors and the second one was the value of terminating resistor. In that case, the viable option would be a combination of two 820 and one 130 ohm resistor or two 10K and one 120R. There should be a correlation between the size of bias resistors and the speed of the bus but I haven't found any specifics so I'm open to suggestions. And the last question is about the position of the bias resistors. Bias resistors are only used at one point, right? What I mean is that the master has a terminating resistor and bias ones but the slaves don't have any bias resistors and not even slave with the terminating resistor.
The next thing are pull-up/pull-down resistors on the R, D, RE a DE lines. First I'll state that I'm planning on connecting RE and DE together because I don't see any benefit of being able to control both separately. Again as I understand the pullup on the DE/RE is there to mainly avoid unpredictable behavior during boot up and maybe some noise resistnce. So if I tie DE and RE pins together and use 10K pull-down resistor the transceiver will be by default enabled in receiver mode and thus avoiding sending some random stuff to the bus. Another resistor used is the 10K pull-up on the R line which should bring the R line to a known state (high) that is also used as a sign of an idle state. And that's it, no more pull-up/down resistors shlould be needed right?
My other question is about TVS diodes. I know that it would be best to have TVS from both data lines to the ground and one between the data lines but after some research, I've decided to use dual bidirectional TVS SM712. I think that it should be okay for home applications. Or am I wrong?
Due to the daisy chain topology of RS485 and myself trying to avoid excessive cable runs I've come up with a solution that seems like reinventing the wheel but I haven't found anything similar. The topology is transformed into a sort of hybrid star topology. Basically, I'll daisy chain a few slaves and on the "last" one I will turn on the dip switch allowing the signal lines to go through the same cable back to the master board. There will be the same lines connected to another RJ45 connector working as a link to the previous lave in a daisy chain. I hope that it is clear what am I trying to do. At this moment I would like to use both UARTs and on each of them have one slave just to avoid problems with collisions. Later I would like to implement Modbus which should take care of addressing slaves and thus collisions. I'm also open to suggestions on which library to use.
I would imagine that the dip switch used to route data lines back to the master would be best placed as close as possible to the RJ45 connector. Also, I'm planning to add an address selection circuit. Probably just 6 pin dip switch some resistors and 74HC4051. I know I could get away with only two pins (something like PCF8574) on ESP instead of four in the case of 74HC4051 but I don't have the best experience with I2C and mainly the libraries. I would like to point out that the exact pins used on ESP and RJ45 connectors aren't final, just connected to be connected. Mainly the circuit was created to help visualize what I'm talking about and found any errors. The last thing that I would like to point out is the +5V on the RJ45 connector. I'm thinking about using the cable as sort of the POE for some slave devices. Therefore it would be probably wise to use two wires for common ground and two for +5V (maybe even +12V).
First I'll start with bias resistors. To my understanding, they are used as a failsafe when there is no communication over RS485 bus to hold the lines at a specified state and thereby avoid random start bits created by noise etc. Also, the chosen IC (MAX485) should have this failsafe inside but can you do any wrong by using external bias resistors? Then there is the question of value. If my source is right you should be trying to calculate differential resistance or something like that - the equation I've seen was basically a parallel resistor combination equation where the first value was the sum of bias resistors and the second one was the value of terminating resistor. In that case, the viable option would be a combination of two 820 and one 130 ohm resistor or two 10K and one 120R. There should be a correlation between the size of bias resistors and the speed of the bus but I haven't found any specifics so I'm open to suggestions. And the last question is about the position of the bias resistors. Bias resistors are only used at one point, right? What I mean is that the master has a terminating resistor and bias ones but the slaves don't have any bias resistors and not even slave with the terminating resistor.
The next thing are pull-up/pull-down resistors on the R, D, RE a DE lines. First I'll state that I'm planning on connecting RE and DE together because I don't see any benefit of being able to control both separately. Again as I understand the pullup on the DE/RE is there to mainly avoid unpredictable behavior during boot up and maybe some noise resistnce. So if I tie DE and RE pins together and use 10K pull-down resistor the transceiver will be by default enabled in receiver mode and thus avoiding sending some random stuff to the bus. Another resistor used is the 10K pull-up on the R line which should bring the R line to a known state (high) that is also used as a sign of an idle state. And that's it, no more pull-up/down resistors shlould be needed right?
My other question is about TVS diodes. I know that it would be best to have TVS from both data lines to the ground and one between the data lines but after some research, I've decided to use dual bidirectional TVS SM712. I think that it should be okay for home applications. Or am I wrong?
Due to the daisy chain topology of RS485 and myself trying to avoid excessive cable runs I've come up with a solution that seems like reinventing the wheel but I haven't found anything similar. The topology is transformed into a sort of hybrid star topology. Basically, I'll daisy chain a few slaves and on the "last" one I will turn on the dip switch allowing the signal lines to go through the same cable back to the master board. There will be the same lines connected to another RJ45 connector working as a link to the previous lave in a daisy chain. I hope that it is clear what am I trying to do. At this moment I would like to use both UARTs and on each of them have one slave just to avoid problems with collisions. Later I would like to implement Modbus which should take care of addressing slaves and thus collisions. I'm also open to suggestions on which library to use.
I would imagine that the dip switch used to route data lines back to the master would be best placed as close as possible to the RJ45 connector. Also, I'm planning to add an address selection circuit. Probably just 6 pin dip switch some resistors and 74HC4051. I know I could get away with only two pins (something like PCF8574) on ESP instead of four in the case of 74HC4051 but I don't have the best experience with I2C and mainly the libraries. I would like to point out that the exact pins used on ESP and RJ45 connectors aren't final, just connected to be connected. Mainly the circuit was created to help visualize what I'm talking about and found any errors. The last thing that I would like to point out is the +5V on the RJ45 connector. I'm thinking about using the cable as sort of the POE for some slave devices. Therefore it would be probably wise to use two wires for common ground and two for +5V (maybe even +12V).