lesthegrngo Posted October 4, 2023 Posted October 4, 2023 Hi All So now my Rig is essentially working, I'm going to try to knock off the little bits and pieces that are not quite right. In that list is some weird glitching I get with RS485 connected components, which I ascribe to me not being an electronics wizz, and probably not knowing how to correctly implement the requirements of RS485. Don't get me wrong, most work really well, but the more you add to a particular slave line the more likely it is that the glitching happens. One of the things I was doing, rightly or wrongly, was including multiple nanos onto one PCB, with traces connecting all the RS485 buses (GND, A, B, 5V) so essentially making it a solid state affair and reducing the number of wires and connectors. however this may not be the best way. For example, my Altimeter and Climb gauge PCB actually has four Nanos, each with it's own MAX487 chip. That's one each for the Altimeter and Climb gauges, and one each for the Altimeter and Baro Alt OLED's. If anyone is wondering why so many Nanos, if you drive the OLED and a stepper from the same Nano, the stepper refresh frequency is driven by the OLED display and so it becomes very jerky, and the OLED's are i2C and so as the nano has only one set of i2C pins (A4 and A5) it was simpler to use two Nanos than going to the complexity of a multiplexer. Being homemade PCB's I have to design them so that they can be manufactured with my limited facilities, so using double sided PCB board I run the traces as best I can then link any that have to cross but putting matching traces on the rear of the board, and linking the two side with bits of wire soldered through holes. Crude, but it works. Very often the GND is a common large trace that utilises the rest of the board not designated as a trace, similar to the way that a car uses the bodyshell of the structure as a common earth. The 5v bus is then woven between everything else, and again is a common 5v bus, often with a 5v supply on a dedicated connector so that there is sufficient power. The A and B busses are then normally done using traces on the rear of the board so that they can reach the MAX487 chips and the keyed RS485 cable connector. I usually solder the X27 steppers directly to the board, again using traces on the rear side so hardwiring the steppers to the nano headers. Any switches, LED's, OLED connections etc are also connected this way. It results in a vastly reduced amount of wires, and firmly attached components that don't have potential connector issues. The PCB forms a module that can be attached easily using screws to the back of the panel, which you can see in my numerous posts. It clearly isn't perfect though as the glitching phenomenon exists. I believe that the concept of the RS485 is that it is a daisy chained setup, but my use of the PCB's described above is not true to that - it's more of a spiders web, or tree in concept, with one cable connecting multiple parts of the network. I do have a main bus system that runs down the side of the console, with multiple connectors, so maybe the best way to describe it would be a house ring main circuit, with a multiple power outlet adapter plugged into each socket So is there something I should be doing to ensure that the RS485 is being given the best chance to function? Any suggestions gratefully received Cheers Les
lesthegrngo Posted October 5, 2023 Author Posted October 5, 2023 Thanks If I interpret this statement correctly "if you use termination, you should locate the termination networks at the two extreme ends of the cable, not at every node" I should definitely put a resistor at the furthest point on the slave line, but also at the Mega end of the line too, or am I misinterpreting? I see the use of capacitors too in multiple node termination situations but references as to what type of capacitors to use are lacking I (presumably) can make a simple mod to solder on the resistor / resistor and capacitor combo onto a patch board to add that to my existing PCB's and would do that at the end furthest the RS485 in connection Cheers Les
No1sonuk Posted October 5, 2023 Posted October 5, 2023 Yup. It's basically like testing a radio transmitter using a dummy load. Try simple resistors first. Your lines might not need more than that as they're relatively short.
lesthegrngo Posted October 6, 2023 Author Posted October 6, 2023 is there any reason that the resistors can't be SMD types? Les
Vinc_Vega Posted October 6, 2023 Posted October 6, 2023 Hi Les, Have a look at the ready made RS485 modules. All the resistors seem to be of the SMD type. In my opinion R7 is one of the resistors you are looking for, 120 Ohm between the A and B lines. https://arduinoinfo.mywikis.net/wiki/RS485-Modules So the answer to your question is: No Regards, Vinc Regards, Vinc real life: Royal Bavarian Airforce online: VJS-GermanKnights.de [sIGPIC][/sIGPIC]
lesthegrngo Posted October 6, 2023 Author Posted October 6, 2023 Great thanks for the responses guys. Nice example there too Vinc! With the exemplar network diagram it also shows two 470 ohm resistors at the mega end, each going to the 5v and GND, I can try those too, I assume they are there for a similar reason and I am not using the RS485 modules Cheers Les
Vinc_Vega Posted October 6, 2023 Posted October 6, 2023 (edited) Yes, R5 and R6 are for signal stability, pulldown (line B low) and pullup (line A high) respectively, and should reduce the noise on the lines. You sometimes see such resistors in I2C connection too. Those resistors, if necessary, are only applicable to one end of the lines. Regards, Vinc Edited October 6, 2023 by Vinc_Vega Regards, Vinc real life: Royal Bavarian Airforce online: VJS-GermanKnights.de [sIGPIC][/sIGPIC]
lesthegrngo Posted October 6, 2023 Author Posted October 6, 2023 ok, 1st attempt, putting a 120 ohm resistor between the A and B channels of the HARS panel ( last one on the RH console)seems to make the RS485 line worse, with a delay when actuating a switch or potentiometer. I soldered it between the traces that take the RS485 signal from the RS485 connector to the MAX487 chip I've checked the resistance with a multimeter, and it correctly reports circa 120 ohm Any ideas? Les
Vinc_Vega Posted October 6, 2023 Posted October 6, 2023 (edited) In theory both ends of the line should have termination resistors. Not shure if it is getting better if you'd used an additional resistor at the Mega's end. Regards, Vinc Edited October 6, 2023 by Vinc_Vega Regards, Vinc real life: Royal Bavarian Airforce online: VJS-GermanKnights.de [sIGPIC][/sIGPIC]
lesthegrngo Posted October 6, 2023 Author Posted October 6, 2023 I will give that a go tomorrow, I'll make some removable modules with the different resistors on them. Once I can see what works I will make a more permanent solution Cheers Les
lesthegrngo Posted October 7, 2023 Author Posted October 7, 2023 Well, I fixed the glitching problem ******PURISTS STOP READING NOW****** I followed the circuit design that puts the various resistors in, so 120 Ohm at each end between the A and B lines and 470 ohm resistors from the A and B lines to 5V and GND respectively (although lack of caution on my first attempt meant I put the 470 ohm resistors from B to 5v and A to GND). If anything at best it seemed to make everything worse, with really slow responses, and at worst just corrupted the whole lot, including those items on other slave lines. Last night I was at a group of people who were meeting for a beer or five at a neighbour's house, and people were asking how I was getting on with building the rig. During that conversation I though of something at the speed of beer - you know, one of those 'brilliant' ideas that only occur to you after you've had one too many. Why not, I thought, put another mega master in alongside the original one...? After unsuccessfully trying the other things above, the idea from last night came back to me, so I thought why not give it a go. So I did. And blow me down if it doesn't work perfectly. I have the three original slave lines from the original master Mega, and I am currently using one of three more on another master Mega, and have two spare lines in case I need it. It is rock solid, stable, all the artefacts have disappeared, anything that wasn't displaying properly now does, and there is none of the gauge twitching that I used to get. The down side is I now have one more com port to open, but that seems to be no issue. I'm sure that there will be electronics experts out there screaming at the PC about what an aberration this is and that I should go away and do it properly, and they would be right that I am only compensating for some designed in or manufactured in problem of my own creation. But it works, and so while I would like to track down what it is so that I can improve any future components or projects, the only way will stop using the second Mega is if I do fix it. Until then, it stays. So, taking my own advice, it doesn't matter how you do it as long as it works and you are happy with it Les 1
No1sonuk Posted October 7, 2023 Posted October 7, 2023 I'm not understanding what you've done. Could you provide a diagram?
lesthegrngo Posted October 7, 2023 Author Posted October 7, 2023 (edited) It's simple - I pulled another Mega out of the drawer, made another RS485 shield with 3 MAX487 chips on it, and have two parallel masters, giving me a total of six slave lines I can use. Essentially it means that there is only a limited number of devices connected to each slave line ***EDIT*** For the record I didn't think it would work, as I though it would only recognise one instance of the master, by they seem to just function as one system Cheers Les Edited October 7, 2023 by lesthegrngo
Vinc_Vega Posted October 7, 2023 Posted October 7, 2023 (edited) Congrats, you finally made it working! It's your design and therefore, has to work only at your rig. If, sometimes in the future, you'll improve details or your own PCBs, you may get rid of the second Mega. But do I understand it right, that the termination, pullup and pulldown resistors brought no more stability? And the additional line of the second Mega fixed the glitches? Regards, Vinc Additionally, did you split the inputs and outputs to different lines? Edited October 7, 2023 by Vinc_Vega Regards, Vinc real life: Royal Bavarian Airforce online: VJS-GermanKnights.de [sIGPIC][/sIGPIC]
lesthegrngo Posted October 7, 2023 Author Posted October 7, 2023 (edited) no, the terminating resistors for my design at least actually made things worse. None of the iterations made any improvement. The setup that I have now is two master Megas running in parallel, each running three MAX487 chips. No resistors at all anywhere. It shouldn't work, but it does, I can't explain it but I won't complain The problems I seem to have seem to stem from too many devices being on one slave line, so more slave lines, the less devices on each. I'm sure there's a logical reason I think I should do as No1SonUK suggested and provide a schematic for what I did Les Edited October 7, 2023 by lesthegrngo 1
No1sonuk Posted October 7, 2023 Posted October 7, 2023 Hang on. So each Mega is running 3 RS485 busses at once? If that's the case, I'm not surprised you had trouble. That's a LOT of data the Mega has to handle, and the reason adding another helped is that you halved the load on the one that was running everything on 3 busses.
lesthegrngo Posted October 8, 2023 Author Posted October 8, 2023 Yes, I went that way a while back after we had discussions over my setup, where I was saying about the way to deal with making the RS485 setup for me was to have a mega using three slaves, on each for the side consoles and one for the dash instruments - here's the discussion we had https://forum.dcs.world/topic/208455-dcs-bios-over-rs485/page/7/ I found that it really helped my setup and worked well, of course as we know now up to a point. Having said that, the extra Mega has simply cured all my issues with RS485, so while it may not be the most elegant solution, I am happy with how it works. I expected the two Megas to interfere with each other, so that was why I didn't think it would work If I was younger and could get my head around all the electronics stuff better, I probably could have devise a way better setup, but like most of us (I suspect) I just kept trying things and when it worked I kept it, but the next thing learned from the prior issues. As a result there is a lot of sub optimal stuff on my rig that would not be done like it is if I ever did this again Les
Recommended Posts