Sanity check on USB -> RS485 -> Serial setup

Wondering if someone might be willing to help me think through something. For context, this is in an escape game, and I want to connect multiple microcontrollers (RPi Picos, most likely) back to a single PC, communicating over Serial. Multiple being up to 20. The Picos are serving as IO devices, controlling electromagnets, addressable leds, lcd screens, etc., and returning the states
of dials, buttons, sensors, and so on. On the PC, I have a Unity application which processes all the input and controls the lighting, audio, and the logic for various puzzles.

My first attempt was to use USB over cat5 extenders, which did work, mostly, but we are in the basement of an apparently electrically noisy building, and just touching certain pieces of metal causes the USB port to temporarily lose connection, even if the Pico in question is nowhere near said piece of metal, and often requiring a physical disconnect before the Pico would be detected again. And, since I don't have 10+ USB ports, I have to run them through a hub, and other Picos on the same hub would also disconnect. I did a proof of concept with 4 max485 modules (two pairs at each end for full duplex, see picture), and now my connection/comms are solid, if a tiny bit slower (I guess the max485 caps at 115200).

Now, I know rs485 is generally meant to be used in something like a modbus network with multiple nodes across the same bus, but I'm not sure a setup like this would be fast enough for the instantaneous response time I'm after. This setup would, however, make it easier to connect everything back to the PC, but my preference is to have full duplex communications, 1 to 1 between a Pico UART and PC Com port.

So the chain of connections is Pico Rx/Tx -> pair of max485 modules -> cat5 (also carrying gnd and 5v) -> second pair of max485s -> TTL to USB converter -> USB port. My current plan is to make PCBs for either end of the cat5 that each have the rj45 ports built in, and each with 2 max485 chips. The PC end would the TTL-USB converter/USB port, and the Pico end would have pins for Rx, Tx, 5v, and ground.

Does this plan seem sound? Any obvious problems? Needless complexity? Better solutions? Ready-made adapters that won't set me back $40 apiece?

That does appear quite often on these forums but you can use whatever protocol you like - standard or invented by you - as RS485 is just a method of getting 1's and 0's from A to B.

I think you may need to decide what this means in numerical terms as that may determine the type of comms interface.

How frequently do these sensors change state such that they need to report back to the PC? You might be able to use an ad-hoc RS485 bus with collision detection so that your PC doesn't have to continuously poll each device.

That sounds ok. You might have issues with the 5V supply (re voltage drop) over CAT5 but I can't comment from personal experience.

I'm going to chuck in CAN Bus. I know little more than how to spell it (dangerous I know!) but I've read in these forums that it handles message collision etc. I don't know what the length limits are on a CAN Bus or even what data rates are used. But it may be an alternative.

1 Like

That's asking for trouble as soon as more than one controller wants to send at the same time.

I keep reading that people experience issues with latency for anything above 9600 baud, which I think is probably too slow for me. In one of my rooms I have 600 addressable LEDs doing various effects. Granted, most of the time, not every LED is being updated at once, but if they were, the "frame rate" would be something like a frame every second and a half. I'm already worried about 115200.

Yeah, I don't know if I have ability to figure out something like that myself. Unless there's a library that does the heavy lifting, I think I want this to be as simple as possible, where devices just send and receive packets freely. I do have error checking and resend packets that don't receive a confirmation, though.

Yep. I am powering them separately, but just wanted to include the possibility to power over cat5.

Seems like it's for shorter distances than I need.

Sorry, in which context? The usb com port setup or the rs485 node setup?

In the context of data integrity. If multiple persons speak at the same time then nothing can be understood.

That's why each device is connected to its own com port? Sorry if I'm still not following, I just don't quite know what you're getting at or how I should apply it to my problem, which is not collision-related (my USB disconnect issues happen even when only one device is plugged into the PC).

Sorry, my bad :frowning:

I thought that your other problems have been solved?

That is potentially caused by ground voltage being different for the devices. Best to measure for ground voltages between different parts of your system. Both AC and DC voltage differences. The voltage, theoretically should be zero for both AC and DC, but seems to be something significant in your situation.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.