Heh, I stop paying attention to the reprap project for a bit and come back to find a whole new generation of electronics.
I am very pleased with the choice of RS485, I always thought something like that would be the right way to go. I just have one suggestion that I think will help us out in the long run and can be implemented in a fully backwards compatable way with the gen 3 boards that are already out there.
The main disadvantage of RS485 is that it is half-duplex, so generally requires a 'master' node to coordinate all communication, generally this means the master node must be constantly in a poll loop, asking each device if it has anything to say. This not only eats cycles of the master but also introduces a delay in servicing any device as it needs to wait around for the next time around the poll loop.
The solution is pretty straightforward, take one of the ground lines in the RS485 cable and turn it into a shared interrupt line. Basically, the interrupt line (that is shared across all devices on the bus) has a weak pull up resistor on it so it is normally high. Whenever a device needs servicing, it pulls the line low and keeps it there until the master gets around to it and it says whatever it needs to say. Since the line is level triggered (the master polls as long as it is low, and the devices keep the line low until they have nothing more to say) there is no problem with multiple devices interrupting at the same time or the possibility of lost interrupts. The master only polls when needed, and even better, it can attach a software interrupt to the pin so it can respond immediately, rather than waiting for the next polling cycle.
For the cost of a single resistor and an IO pin, this seems well worth it to implement in the hardware now, even if it takes the software a bit to catch up.
The change is backwards compatable because legacy devices all have the interrupt line connected to ground, so if any legacy device is plugged in, the master simply resorts to the old 'polling' behavior, likewise, if a legacy motherboard is used with a new device, then nothing bad happens because the motherboard will eventually get to it in its normal poll loop.
So, what do people think? When we start adding things to the RS485 bus, I can see this being a big help in the future. It also provides us with a really handy 'side-channel', which we can use for instance to assign modbus IDs to devices using something like the one-wire protocol or the ISA PNP trick on boot up.
The line is also helpful in a token passing situation, rather than constantly passing the token around when no one wants to say anything, whoever has the token just sits on it unless the interrupt line is pulled low. as long as the line is pulled low, the token is passed around like normal. When the line goes high, whomever has the token simply holds it until it has something to say or the line goes low in which case is passes it on.
Seems well worth it to make the hardware changes now, for a resistor and an IO pin and some trivial circuit changes we open up a lot of software possibilities in the future
John - [
notanumber.net]