For those of you who remember, I’m working on an Arduino based project that requires an Arduino “Master” with up to 16 “Slaves” (not PC of me, I know!) using the SPI bus. We’ve tested all of that and the comms path goes back and forth on RS485 hardware (thanks Bob for the tips on the terminators/pull ups/ pull down resistors).
I guess we’ve figured out that the Arduino based Master isn’t going to cut it when we need LoRaWAN, OLED display, Bluetooth and so forth.
So, my thoughts are to head into ESP32 family of processors and I’d like some guidance as to selection criteria.
Of course, the other glaring issue is prototyping and prototype assembly as it’s an SMT world we’re getting into. With the Arduino, through-hole assemply is pretty easy. Not so with this thing!
Without the details, hard to know. But it seems you are wandering into Raspberry Pi territory with a full blown operating system and multitasking. Mixing SPI Arduino slaves with a Pi master should not be a problem. Unfortunately, a whole new learning curve.
Thanks for the replies. Much appreciated. I need to be able to create my own PCB layout as it’s heading to a commercial product. This customisation is hard at the start (really hard!) but you can optimise costs doing it this way.
@Alan73922 Yes, a very steep learning curve! @John136772 Hmm…Teensy is definitely worth a look.
Hi Gerard
Thanks for the progress report. Success with RS485, pretty much guaranteed if you do all the right things but thanks for the thanks.
One important thing I did not mention.
DO NOT run lengths of cable from a junction point to the intermediate devices or you are likely to face the same echo problems. The interim devices MUST be connected directly to the main cable run. Some of these have 2 connectors simply labelled “in” and “out”. and are in fact connected straight through. The idea is to connect the incoming line to “in” and the continuing line to the “out” to carry on to the next device and so on. When the end is reached the “out” connector of course will have no cable connection and is a convenient place to put the 120Ω terminating resistor. Same at the other end, if you are using the “out” connector put the resistor across the “in” point.
If your devices do not have the 2 connectors you will need to connect both incoming and outgoing cables to the one connector or connection point. Ferrules are recommended here. Ferrules should be used with stranded wire anyway especially if (as with the cheaper connectors) the connector does not have wire protectors fitted. For reliability you should never put bare stranded wire directly under a screw.
Cheers Bob
As @John136772 has said Teensys are awesomely powerful for such a small unit, unfortunately they are harder to come by than Raspberry Pi Zeros at the moment with the silicon shortage hitting them especially hard.
ESP32 boards have an absolute tonne of varieties with a mix of different specs.
Tim put together a guide to the different ESP32 variants and all the different names each manufacturer has for them which I’ll link below.
Generally speaking ESP32 boards are a steeper learning curve than Arduino boards, but the level of documentation varies a lot depending on the manufacturer of the development board.
Adafruit and Sparkfun are pretty good with their docs, DFRobot tend to leave you to figure it out yourself, though the money saved on documentation is reflected in the price of the boards.
Bob, where I had trouble with the RS485 was the pullup/pulldown Rs. Actually, the transmission worked fine but the voltages were weird. But, since RS485 works on voltage difference rather than just voltage, the data got through. Anyway, I had an unsoldered gnd pin on the Maxim Rx/Tx chip (d’oh!!). Once I fixed that and added the pullup/down resistors, the signalling looked OK.
My bus is a chain from the Master all the way through to the final device which has a terminator pack right at the end.
Do you reckon I should terminate the MISO signal coming back to the Master? I think I should.
It IS a steep learning curve! I’ve engaged a gig-worker to write some code for me and he’s done quite a bit of work with ESP32. I guess I decided that hardware is more my thing. Even though I can code stuff, I just don’t like it that much! Better off giving it to someone who loves coding (weirdos!)
I’m about to start my final year at Swinburne in Robotics/Mechatronics and I can recommend Swinburne to any budding Engineers.
You should terminate the ends of all receiver lines . With half duplex where the RS485 both sends and receives (but not at the same time) since both ends receive both ends should be terminated. This may appear as a double termination which for DC it is but we are not dealing with DC so the 2 resistor terminations are correct. With SPI I believe it would have to be full duplex, that is a separate transmit and receive circuit which requires 2 RS485 circuits. In this case you have 2 separate receive ends which MUST be terminated. There is no need to put a termination at the transmitter end.
You should not need any pull up/pull down resistors on the RS485 wires. If you have them I believe all you are doing is unbalance the line and lose any advantage a balanced line provides. If you have fitted them at this point I would remove them. Pull up (down) resistors might be required at the SPI point though. I don’t know. You could post another circuit of what you actually have now so I can have a look. Won’t be until probably next Friday PM or Sat. though as I am going away early to-morrow and won’t be home until then.
By the way you can have a look across the RS485 line by connecting an oscilloscope directly with the ground clip on one side and the probe on the other BUT you must disconnect the mains earth to the oscilloscope. I know the purists will throw their hands in the air over perceived safety issues but believe me that mains earth can introduce obscure faults which are not really there.
My instrument is pretty much always in this configuration. I have it powered with a 300mm length of mains extension with the earth wire hanging out of the socket to make it obvious to everybody that this earth wire is not connected
Cheers Bob
The other way to correctly look across the balanced line is an oscilloscope with a differential input but I don’t honk this is too common in a hobbyist’s domain.
[Edit: When I was a callow youthful techie, I zapped myself using a Tektronix 465 (great 'scope!) using differential inputs measuring some HV AC. We did the same thing you did with the earth lead. A lesson I’ve not forgotten!]
While you are not using the DMX512A signalling protocol, you should look at the available doco on the standard.
This is a good overview, especially w.r.t. the interconnections … the need for the IN and OUT/THRU connection and terminations. Also note the limit on receivers in a single run from a driver, i.e. a total of 32 interfaces.
FYI - my background is many years in live theatre using this protocol for the Lighting systems
Cheers
Murray
Yes you can. You have still got terminations at the TX end where they will do nothing. They will still be needed at the receive end of those cables. The 120Ω for MISO goes across the A and B wires of the RS485. As for the other signals (TX) they become receiver at the other end so require the terminations there. I thought I explained all that.
By the way what is “SS”, I understand what CLK is but not SS.
Get rid of RN1. I advised that this sort of thing will only unbalance the line and you will only lose any advantage RS485 has. If your intermediate “slaves” or any of these things has pull up/down resistors fitted you will do well to get rid of them. Easy to check. Measure for any resistor between A and B and Pos or Neg (unpowered). There should be none.
Had a look at that link. Haven’t got time to digest it all but I could not see where it was going.
Cheers Bob
Thanks for that. Yes, you did explain previously and I don’t actually know why I put the 120R in at the TX end as I already knew it was superfluous. A brain fade.
I tested my circuitry after I fixed the missing GND both with and without the bias Rs. No difference with or without.
I don’t know how you tested your circuitry. I have said it before and will do so again for the last time. REMOVE THOSE RESISTORS. They are far too low in value anyway for pull ups/downs. How do you know there is no difference. Wait until the system suffers bad interference before you make that statement.
I am not going to repeat myself about why you should not have what you refer to as “bias” resistors but if you really need to not believe me I would respectfully suggest you do some research into 2 wire transmission lines and why they are used over longer distances
I will say this again for the last time. This resistor is not exactly superfluous as it is required at the other (receiver) end of the line. There appear to be 2 TX lines requiring this treatment by the way, “CLK” and “SS”. Still don’t know what SS is. If it is “Slave Select” (Chip Select) I think you need one separate for each slave for SPI unless you have some sort of coding system. One other reason for not having the “bias” resistors as you will have a permanent DC voltage appearing across A and B lines. I don’t know where this idea originates as I have yet to see any mention of this sort of requirement in any application notes or suggestions for any flavour of RS485 drivers. Those notes come from the manufacturers and such resistors do not seem to get a mention. Maybe they don’t know anything about their own chips. I don’t think so. If anyone has any published documentation regarding this “biasing” please let me know, I am open to learn. But I would like it to be from a reliable source, like a manufacturer.
Cheers Bob
Mate, you’re “singing to the choir”! The bias Rs are not in the prototype to be removed. They came into the testing regime as I was fault chasing what turned out to be a dodgy earth pin. If they make no observable difference (as per my oscilloscope observations) then, clearly, we wouldn’t include them in manufacture. The 560R value was from another forum that I can’t locate now so doesn’t matter.
With the SS/CS, the Slaves work out their station number on boot up (4 bits=16 stations) and then only respond when requested by the Master. That’s all in coding. So, in essence, every slave gets the SS/CS but only one will reply at any one time.
Good. I don’t know where this idea of using resistors here came from. As I said apparently not from the manufacturer, I don’t think they should be there and there are quite a few on this forum agree (from previous posts)
Thanks for clearing that up. I thought that would have to happen. I got a bit confused as your use of the terms MISO and MOSI seem to be used with SPI systems where it appears a separate CS connection is required for each slave in the system. As I have never used multiple slaves with SPI I am not even sure of that (I am not a very digital person) but as I see it it does not matter to RS485 as long as the system is the same and understood at both ends all will be OK.
Cheers Bob