6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sun Oct 06, 2024 9:30 pm

All times are UTC




Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: Tue Sep 21, 2021 10:35 pm 
Offline
User avatar

Joined: Tue Oct 25, 2016 8:56 pm
Posts: 362
I had an idea today for a simple RS-485 based network with auto-configuration and hot-swap, and I thought I'd share it to gather feedback. The network is a half-duplex, single-master, multi-slave network in a daisy-chain topology. See attached PDF for a diagram. I don't have a name for it yet, but just so we have something succinct to refer to it by I shall tentatively christen it "SCN-485" (for Self-Configuring Network, rs-485).

Whilst not specific to 6502-based systems, I envisage the simple networks this would create could work well for such systems. A single SC28L91 UART provides all the necessary I/O - the only additional components required (ignoring miscellanious Rs & Cs) is an RS-485 transceiver, a buffer and a 100k resistor. The interconnect between devices requires 4 wires, or 5 if the master provides power to the slaves.

I won't got into detail about the on-wire protocol for the main RS-485 bus, principally because I haven't finished writing it all out, but it doesn't really matter exactly how it works provided that:
1. The slaves only "speak" when instructed to do so by the master.
2. The master addresses slaves by assigned addresses.
3. The master can send a packet containing a new address assignment without addressing a specific slave (e.g. a reserved address for "broadcast").
4. The ability for the master to ping a slave to solicit a response.

When a slave is added to the network, either by connection or being powered-up, it does not know what address is should respond to and will idle on the bus until it gets an address assigned to it by the master.

As you can see from the diagram, its a fairly standard RS-485 network, aside from the addition of the ARQ signal, which stands for "Address Request". A slave that is without an address for any reason will assert its ARQ_OUT signal, regardless of anything else. If any upstream slaves receive an ARQ on their ARQ_IN signal, they will assert their ARQ_OUT in turn - in this way any slave requesting an ARQ will propagate to the master's ARQ_IN. Note that multiple slaves can require an ARQ at the same time without conflict.

When the master receives an ARQ, it sends a special Address Assignment packet out to the bus, and any slave looking to receive an address will be listening for this special packet. However, only the requesting slave whose ARQ_IN is not asserted (or floating - I'll come back to this) will actually save the address. That slave will deassert their ARQ_OUT, and will now respond to that address. (This has the effect that the farthest downstream slave that still needs an address is the one that actually receives it.) If other slaves still need an address, they keep their ARQ_OUT asserted and, after a short timeout to allow for propagation through the slaves, if the master still sees an ARQ it will send out another Address Assignment. This process repeats until all slaves have an address and the master's ARQ_IN is no longer asserted.

Note that the timeout period between Address Assignments can still be used to communicate with any slaves that already have an assigned address. The amount of time between Address Assignments is flexible and could be configured based on user needs.

Once a slave has been assigned an address, the master can then interrogate it directly to learn more about what kind of device it is and load the appropriate software.

The ARQ_FSP signal is used to determine if the ARQ_IN signal is being driven, or is floating (and thus not connected to anything). This is done by setting ARQ_FSP to either a HIGH or LOW, measuring ARQ_IN, inverting ARQ_FSP and measuring ARQ_IN again. If the read values for ARQ_IN paralled ARQ_FSP then the input is floating and not connected to a downstream slave; if ARQ_IN maintained a single value regardless of ARQ_FSP then it is being actively driven by a downstream slave.

On the master, being able to determine that the ARQ_IN is floating allows the master to know there are no slaves connected to the port, and it can put the port into a low-power state (if supported).

On slaves, if they detect that the ARQ_IN is floating, then they should enable their internal bus termination network using the TE signal. This means that correct termination for the bus is also auto-configured, in addition to addresses.

Finally, the master should track which slave addresses are in use. If the master hasn't required a response from a slave within a certain timeout, it should send a noop/ping packet to that slave to solicit a response. If the master does not receive a response from a slave it has assigned an address to, it can surmise the slave has been removed from the network and free the address for future assignment. This part is flexible: the timeouts and number of retries could be configured based on user needs.


Attachments:
SCN-485-topology.pdf [18.59 KiB]
Downloaded 60 times

_________________
Want to design a PCB for your project? I strongly recommend KiCad. Its free, its multiplatform, and its easy to learn!
Also, I maintain KiCad libraries of Retro Computing and Arduino components you might find useful.
Top
 Profile  
Reply with quote  
PostPosted: Tue Sep 21, 2021 11:31 pm 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8415
Location: Midwestern USA
I don't have time right this moment to read your PDF, but will do so later.

Don't forget your TIA-485 network requires termination at the bitter ends. Without termination, you're bound to get reflections that may cause trouble if the total bus length is significant. Incidentally, you can run TIA-485 at ~1 Mb/sec, which with 8N1 data format, would give you a raw throughput of 100 KB/sec. You might have to clock the interface to make that fly, however. Maximum standard speed with a 28L9x UART is 230.4 Kbps, which would not require clocking over and above what the standard bit rate generation provides. A 23 KB/sec network doesn't sound very fast but it can be if your protocol isn't too corpulent.

The last time I checked, the 28L91 was only available in QFP packaging, which isn't very hobby-friendly. The PLCC version is obsolete and out of production. If QFP is too dinky for you, you could consider using a 28L92, which is available in PLCC.

_________________
x86?  We ain't got no x86.  We don't NEED no stinking x86!


Top
 Profile  
Reply with quote  
PostPosted: Tue Sep 21, 2021 11:40 pm 
Offline
User avatar

Joined: Tue Oct 25, 2016 8:56 pm
Posts: 362
The 28L91 is only given as an example of a suitable UART that doesn't require a seperate I/O chip to drive the additional signals that SCN-485 needs. Most UARTs would suffice and, if they lacked sufficient built in I/O, you could use a VIA for the additional signals.

I am aware of the need for termination, and this has been addressed in both the PDF and the text of the first post. That being said the scheme as it is wouldn't put the auto-termination right at the end, there would be a small stub in the final slave between the transceiver and the unused input connector. I am unsure how much effect such a stub would have in practice - we're probably talking an inch or less. I wouldn't envision using this network over vast distances, but it would be nice if it could be that robust. If the stub would be a problem, it could be resolved by not relying on the transceiver's in-built termination provision - mainly I was just trying to keep the part count down.

_________________
Want to design a PCB for your project? I strongly recommend KiCad. Its free, its multiplatform, and its easy to learn!
Also, I maintain KiCad libraries of Retro Computing and Arduino components you might find useful.


Top
 Profile  
Reply with quote  
PostPosted: Tue Sep 21, 2021 11:53 pm 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8415
Location: Midwestern USA
Alarm Siren wrote:
The 28L91 is only given as an example of a suitable UART that doesn't require a seperate I/O chip to drive the additional signals that SCN-485 needs. Most UARTs would suffice and, if they lacked sufficient built in I/O, you could use a VIA for the additional signals.

One nice thing about using the NXP UARTs or their Exar equivalents, is the availability of the high precision timer to configure (theoretically) any bit rate you want.

Quote:
I am unsure how much effect such a stub would have in practice - we're probably talking an inch or less.

At the speeds you are likely to run this thing a stub shouldn't be an issue. In any case, TIA-485 transceivers drive pretty hard, but without the super-fast edges of high-speed logic.

Quote:
I wouldn't envision using this network over vast distances...

I'd think that given a reasonable implementation you could manage 100 meters. Distance-wise, that's as good as an Ethernet segment, though not as fast, of course. Plus you can run it on inexpensive CAT3 cable or even the old station D cable if you have some lying about.

_________________
x86?  We ain't got no x86.  We don't NEED no stinking x86!


Top
 Profile  
Reply with quote  
PostPosted: Wed Sep 22, 2021 3:43 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8521
Location: Southern California
Alarm Siren, I do like RS-485 (or what I know of it anyway, as usually the same signaling protocol as RS-232 but with different line drivers and receivers, and able to go much faster like 35Mbps over cables with controlled impedance), but I've never used it. So don't the following as any kind of criticism. You might get good ideas that you'll want to take into consideration if you read the development of our 65SIB (6502.org Serial Interface Bus) topic which starts at viewtopic.php?f=4&t=1064, and has the final spec at viewtopic.php?p=10957#p10957 . 65SIB is mostly SPI but more flexible and extended in many directions at once, and leaves a lot of options open but the basics are simple.

_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


Top
 Profile  
Reply with quote  
PostPosted: Wed Sep 22, 2021 9:15 am 
Offline
User avatar

Joined: Wed Feb 14, 2018 2:33 pm
Posts: 1468
Location: Scotland
Econet, as used on the BBC Micro in the early 80's is worth a look at - there are still folks today maintaining Econet networks on their BBC Micros, Acorn ARCs, etc. There was even a Linux driver for it at one time. (Still is in older Kernels)

In essence, it was a multi-drop bus with synchronous data and clock. RS-422. There were bridges and file servers.

There was a network file server as well as processor to processor communications. Lots of schools were fitted out with it back then. The diskless workstation was a thing.

I used it extensively in some factory automation projects I was working on/studying at the time. Speed was essentially determined by the length (and often quality) of the wiring, but 250Kb/sec wasn't uncommon.

See here for more details: https://en.wikipedia.org/wiki/Econet

But sadly, like many old things, the Motorola MC68B54 IC used to control it is now hard to find unless you manage to get a lab-full of BBC Micros with them already fitted. The BBC Micro motherboard had space for them and you could either buy the Beebs with it fitted or not.

-Gordon

_________________
--
Gordon Henderson.
See my Ruby 6502 and 65816 SBC projects here: https://projects.drogon.net/ruby/


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 17 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: