6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sat Nov 23, 2024 1:03 pm

All times are UTC




Post new topic Reply to topic  [ 109 posts ]  Go to page 1, 2, 3, 4, 5 ... 8  Next
Author Message
 Post subject: serial interface bus
PostPosted: Fri Dec 29, 2006 10:42 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8545
Location: Southern California
Edit: The final spec. is at viewtopic.php?t=1064&start=105 . This is on the 8th page, after all the background that led up to it.

I originally wrote this as a private E-mail to Samuel Falvo, then decided it ought to be on the forum for everyone, and modified it accordingly.

This is regarding an interface to expand a 6502-based system, similar to how IEEE-488 is used to connect lab instrumentation in a rack or on the workbench to a computer through cables that may be up to several meters long. It is at best a medium-speed interface, maxing out at perhaps a few hundred kbps.

Goals:
  • The 6502's own buses are not run off the SBC-- not even in a card cage.
  • One connector, or a pair of connectors (in the case of an interface loop), is all the host computer needs in order to interface to many devices, without added hubs or expanders.
  • Simple software and hardware
  • inexpensive, not-too-big connectors. The board-side connector should fit into the .1" grid on breadboards.

Since our tiny new company is getting going and it looks like we may need a lot more in-house testing than before, I was again thinking about the interface loop idea and alternatives. I know home-brewing of test equipment in many big-company situations is unwise for several reasons; but I hope I never work in a big company again, and there are many reasons home-brewing may make sense for us. Regardless, my home-made workbench computer has been an invaluable tool in my work, and I will continue to develop it further.

Samuel, although I plan to go back and refresh my memory on the E-mails we exchanged a couple of years ago (which are on a different computer I don't use anymore) regarding the HPIL-inspired interface loop using the 6522's serial port, I'm sure your thinking has evolved some since then, and I'd like to hear it. I did go back and re-read your related threads here entitled "And the winner is . . ." and "Kestrel 8K Finished!", both under "Hardware". The latter especially has quite a bit of discussion on this sort of thing.

Regarding a port that's basically SPI like wirehead suggested:

Some possible pros are:
  • It would be easy to interface standard SPI parts
  • SPI would allow dumb devices to be simpler, using 74-family parts with no processor.
  • Custom smart devices can be home-brewed using microcontrollers that can act as an SPI slave.
  • SPI would be less complex softwarewise for both the controller and the devices than an interface loop would be.
  • SPI could be faster than an interface loop when message packs are small and/or there are a lot of devices connected.
  • With SPI, one slow device would not slow all the other devices down.

Some cons are:
  • Real SPI would require bit-banging if done with the 6522. (The 6522's serial port is close to one of the most commonly used SPI modes, but no cigar.)
  • To allow some cable length, slowish comparators like the LM339, along with hysteresis, should be used at the receivers to keep parasitically coupled transients from causing unwanted trigering. The interface loop OTOH could just use something like cat-5 cable with receiver ports terminated, so the cable would not limit the speed.
  • For devices that interface through a 6522, receive interrupts could be a little messier with SPI than with the CB1/CB2 serial port.

SPI might require setting each device's address, possibly with a DIP switch like IEEE-488, instead of having auto-addressing like an interface loop. Besides the fact that I'm not sure that's much of a problem, I did not list it with the "cons" above because there's a way around it, below.

I seem to be gravitating toward one SPI port on my workbench computer, possibly with TTL logic levels so it will work with 3V logic as well. Daisychaining of devices can be done with each device having two connectors. The CLK, DI, DO, and IRQ lines would be bussed; ie, the pair of connectors on a given device would be wired in parallel for these four lines (plus ground and power). There would be seven select lines. This accomplishes two things: the devices don't need to decode an address bus (which would otherwise be 3 bits in this case), and auto-addressing can be done by rotating [Edit: shifting, not rotating] the select lines from one connector to the other on each device such that the device closest to the controller responds to address 1, the next device responds to address 2 even though it thinks it's address 1, the device after that responds to address 3 even though it thinks it's address 1, and so on. I plan to put at least one power supply line through the connector so things that don't require much power don't have to have their own power supply (except maybe a small IC regulator).

This kind of interface would make it easy to implement things like programmable power supplies, loads, DMMs, signal generators, and signal-routing networks, graphic LCDs, flash storage, UARTs and modems, and maybe even a USB controller (plus tons of other possibilities).

I don't foresee any hot-plugging with the commonly available connectors. I don't know if that would really be a problem or not. It wouldn't be hard to shut the interface down at the controller end so at least the controller itself doesn't have to be turned off in order to connect or disconnect a device. Ribbon cable with twisted pairs might be appropriate. (It goes flat again every so many inches in order press IDCs on, and it's often more flexible than standard ribbon cable.) At least the CLK, DI, and DO lines would be paired with a ground line and a large ferrite bead for each pair should be added as a balun at each pin header on the boards for reduced crosstalk and radiation and improved noise immunity.

For myself, this topic is not for more vaporware discussions that don't lead to actual hardware. I'm ready to build it right now, but wanted to hear any new ideas first. A few years ago I devised serial and parallel do-everything expansion buses that were more complex (and thus never completed), but the added experience gained since then tells me that simpler is not only more realistic, but will do the job just as well. Besides, more SPI and I²C parts have become available since then, and I already have a working I²C port. I should add that I have successfully used SPI devices on several occasions, but not on a bus of this type.

_________________
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  
 Post subject: Re: serial interface bus
PostPosted: Sat Dec 30, 2006 6:26 am 
Offline

Joined: Sat Jan 04, 2003 10:03 pm
Posts: 1706
GARTHWILSON wrote:
I originally wrote this as a private E-mail to Samuel Falvo, then decided it ought to be on the forum for everyone, and modified it accordingly.


NOO!!!! Now everyone knows my superhero alter-ego!! 8)

GARTHWILSON wrote:
This is regarding an interface to expand a
6502-based system, similar to how IEEE-488 is used to connect lab
instrumentation in a rack or on the workbench to a computer through
cables that may be up to several meters long. It is at best a
medium-speed interface, maxing out at perhaps a few hundred
kbps.


I think you under-estimate the capabilities of IDE cables. These are
80-conductor ribbon cable terminated with 40-pin IDC connectors (IIRC,
every other conductor is automatically a ground). These allowed IDE
drives to transfer hundreds of megabytes per second with up to two
devices on a single cable. I strongly doubt that these cables would
be the limiting factor in speed for a 6502/65816 system. :)

Quote:
--> The 6502's own buses are not run off the SBC-- not even in a card cage.


Believe it or not, even traditional bus interfaces like PCI satisfy
this criterion. PCI is 100% CPU independent, as its bus tenures look
much more like network packets than actual CPU-generated bus interface
tenures. PCI-X goes further, being an actual serial expansion
infrastructure. The PC's northbridge chip is responsible for handling
bus-to-PCI translation.

But I am digressing.

Quote:
I'm sure your thinking has evolved some since then, and I'd
like to hear it.


For the Kestrel-2, I'm probably going to provide one or two CPU-local
bus slots for high-throughput devices (e.g., external video cards,
harddrive interfaces, etc), and the rest via some kind of high-speed
serial interface managed via the FPGA's logic (e.g., the FPGA would
implement a DMA channel and the requisite hardware for a real-life SPI
port).

However, I have not adequately arrived at a means of addressing just yet.

One of the things that Commodore's systems could do was to instruct
one peripheral to talk, another to listen, and then you can yank the
serial cable out of the Commodore itself. The I/O peripherals were
still able to communicate to each other. Ideally, I'd really like to
retain that capability, even though it is not likely going to be used
often (but it can be useful in many situations; copying a file from
one storage device to another storage device, for example, without
involving the controlling host).

Quote:
--> SPI would be less complex softwarewise for both the
controller and the devices than an interface loop would be.


In some manners, yes. However, how would you handle the issue of
safely auto-detecting whether a device is physically present?
Assuming you can successfully identify the presence of a device, can
you next detect what kind of device is present (e.g., is it a
floppy drive, or a full-page scanner, or a robotics controller
interface, or . . . )?

Remember, one of your goals was the ability to not have to assign
addresses explicitly. Therefore, your software must consider
the possibility of addresses changing, at least between boots, if not
even at run-time if you support hot-swapping.

Quote:
--> SPI could be faster than an interface loop when message
packs are small and/or there are a lot of devices connected.


Oh, absolutely! SPI's highest average speed seems to be 25Mbps (I've
seen some MMC specifications claim that 52Mbps (!!) is the fastest for
MMC interfaces), and not through any Motorola-enforced spec either.
It's just what MMC cards typically support now-a-days. Higher speeds
are possible through customized connectors that make use of twisted
pairs, for example.

I should point out that 25Mbps is 2.5x faster than 10-base-T Ethernet.
25Mbps is actually the speed of ATM-to-the-desktop network connectors
as well, and SPI lends itself quite well to ATM networking.

Quote:
--> With SPI, one slow device would not slow all the other
devices down.


But, since different devices can operate at different maximum speeds,
you must assume the lowest common denominator until you've somehow
negotiated higher speeds with each device. What is the protocol to
achieve this?

Quote:
--> Real SPI would require bit-banging if done with the 6522.
(The 6522's serial port is close to one of the most commonly used SPI
modes, but no cigar.)


Or, you could jerry-rig a "SPI controller" by using a 6522's parallel
I/O interface coupled to a dedicated ATmega or PIC microcontroller,
programmed to serve as a 6522-to-SPI bridge. This would put almost
all the bit-banging onto the microcontroller, leaving the 65xx free to
work on other things.

Quote:
--> To allow some cable length, slowish comparators like the
LM339, along with hysteresis, should be used at the receivers to keep
parasitically coupled transients from causing unwanted trigering. The
interface loop OTOH could just use something like cat-5 cable with
receiver ports terminated, so the cable would not limit the
speed.


I do not see the logic of this, since the physical layer of both the
loop and the bus are essentially the same. Can you explain more about
this?

Quote:
The CLK, DI, DO, and IRQ lines would be bussed


I prefer to stick to the names MISO and MOSI personally, since the
concept of input and output is relative to the perspective of master
versus slave. MISO and MOSI names place the signal intentions in an
absolute frame of reference.

Quote:
There would be seven select lines. This accomplishes two
things: the devices don't need to decode an address bus (which would
otherwise be 3 bits in this case), and auto-addressing can be done by
rotating the select lines from one connector to the other


This is how the Amiga handled floppy addressing. It had four select
lines, which were shifted (not rotated) from one device to the
next. The shifting allowed 5 or more floppies to be connected to the
bus, but only the first four would respond. This prevented bus
contention issues.

With 7 select lines (I'm curious to learn why not 8?), you're looking
at a lot of pins.

You also lose the ability for peripherals to communicate with other
peripherals as well, since peripherals can no longer know which
addresses correspond to which devices.

Quote:
I don't foresee any hot-plugging with the commonly available
connectors. I don't know if that would really be a problem or
not.


The critical factor for hot-plugging is making sure the grounds
connect first upon device insertion, and are broken last upon device
removal. For example, if you look at MMC cards, which are designed
for hotplugging, you'll see that some pins are longer than others.

Quote:
It wouldn't be hard to shut the interface down at the
controller end so at least the controller itself doesn't have to be
turned off in order to connect or disconnect a device.


Nope; and, you can even specify a standard device interface feature
such as an "eject" button that requests the safe removal of the device
from the chain (e.g., it generates an interrupt, the host OS sees this
and properly shuts down the power to the specific device, then signals
the user that it's OK to remove the device).


Quote:
Ribbon cable with twisted pairs might be appropriate


7 select lines + MOSI + MISO + CLK + GND + power = 12 lines minimum.
If you interweave a ground pin on every line, you end up needing 24
conductor cables and IDC headers (worst-case, but heck, it's cheap
enough!). 32 conductor cables will allow you to push more power on
the supply rails.

My question is, though, what if you want more than 7 devices on a
single bus? There are two methods:

* A completely independent bus controller in parallel with the first,
thus adding 7 additional devices.

* Replacing the original with a controller that addresses (e.g.) 7 or
more devices. The bus topology is altered so that devices 7 through N
come first in the daisy-chain. What used to appear as devices
0-6 must now come at the end of the chain, since their selects have
now been rotated down into the compatible select lines of the older,
narrower connectors.

However, the only thing I dislike about this system is that most of
the leads will be wasted on select lines. But, with relatively cheap
IDE cables, you can support 30 devices on a bus (10 pins used for
MOSI, MISO, CLK, GND, and VCC and their corresponding returns, leaving
30 more pins to be used for selects). This at least comes close to
IEEE-488, and with a substantially faster master/slave data throughput
at that (25Mbps average top-speed, versus 8Mbps for GPIB).


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sat Dec 30, 2006 11:52 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8545
Location: Southern California
Quote:
I think you under-estimate the capabilities of IDE cables.

Here's one reason it's good to get a response: it shows me I was not clear. The reason for the slowness was not so much the cables but how fast a 6502 could run serial data, especially if it has to bit-bang.

Quote:
(IIRC, every other conductor is automatically a ground).

I wondered about that. It makes for a wide connector and cable, but easily makes a row of pins on a header to be ground.

Quote:
hundreds of megabytes per second with up to two devices on a single cable.

I'm sure that number of megabytes per second would have to come way down with longer cables and greater numbers of devices like you get in a rack-and-stack IEEE-488 set-up.

Quote:
Quote:
--> The 6502's own buses are not run off the SBC-- not even in a card cage.


Believe it or not, even traditional bus interfaces like PCI satisfy this criterion. PCI is 100% CPU independent, as its bus tenures look much more like network packets than actual CPU-generated bus interface tenures.

Makes sense. STD bus is the only one I've worked with, and that one, with 8-bit processors 20 years ago, generally was a buffered extension of the processor's own bus.

My particular reason for saying one goal was to not have the 6502's own buses going to peripherals is that past years' threads about "the ultimate 6502 computer" have always had various contributors wanting the buses accessible off the board, not realizing how much that limits the processor's maximum speed.

Quote:
PCI-X goes further, being an actual serial expansion infrastructure.

Maybe you guys who have been working with CPLDs could make and sell us a 65xx serial bus interface that would allow SPI ICs that are on the market to easily be interfaced. I would just hope you publish the source code so users aren't orphaned if you become unable to keep selling it (or no longer interested in selling it). I doubt that it would be necessary to go to the extent of an FPGA for this.

Quote:
One of the things that Commodore's systems could do was to instruct one peripheral to talk, another to listen, and then you can yank the serial cable out of the Commodore itself. The I/O peripherals were still able to communicate to each other. Ideally, I'd really like to retain that capability, even though it is not likely going to be used often (but it can be useful in many situations; copying a file from one storage device to another storage device, for example, without involving the controlling host).

That has some attraction, although I wasn't thinking in terms of transferring large amounts of data from one device to another. It seems like it would only be valuable for copying discs (or other media), which is something we rarely do even with desktop computers. If you were distributing software on media that you could put in a box (as opposed to internet or other electronic means), then you'd want to be able to have more than one listener. The controller would still need to be able to monitor the progress and be ready to do more controlling actions when the transfer is done though, right?

Quote:
Quote:
--> SPI would be less complex softwarewise for both the controller and the devices than an interface loop would be.

In some manners, yes. However, how would you handle the issue of safely auto-detecting whether a device is physically present? Assuming you can successfully identify the presence of a device, can you next detect what kind of device is present (e.g., is it a
floppy drive, or a full-page scanner, or a robotics controller interface, or . . . )?

Remember, one of your goals was the ability to not have to assign addresses explicitly. Therefore, your software must consider the possibility of addresses changing, at least between boots, if not even at run-time if you support hot-swapping.

If the devices all had enough intelligence, you could simply ask one device after another, "What kind of device are you?" which HPIL (which is too complex for what I want here) can do, and each device knows its model number, what class of device it is and what it can do, etc.. This allows for example copying one disc to loads of others at the same time (if the others can all be made listeners at once) on identical disc drives; but the requirement for such intelligence exclude a lot of SPI devices or dumb shift registers we might want to put on the bus. Simply trying to poll them might have undesired effects of telling them to do something you didn't intend. For the applications I'm thinking of, it's not a big deal to either connect the devices in a particular order, or tell the controller what order they're in and thus where to find things.

I see where you're going with it though, and I am reminded of the differences in our thinking based on different backgrounds. I'm thinking more of things like low-cost automated test equipment, instrumentation and machine control, and data collection on the workbench, whereas you're thinking more of office-type applications. It would be good to be able to do both, but this might require two (or more) different interfaces instead of trying to have a single do-everything interface.

Quote:
Quote:
--> SPI could be faster than an interface loop when message packs are small and/or there are a lot of devices connected.

Oh, absolutely! SPI's highest average speed seems to be 25Mbps (I've seen some MMC specifications claim that 52Mbps (!!) is the fastest for MMC interfaces), and not through any Motorola-enforced spec either.

I was referring not so much to the bit rate as to the added message processing the interface loop requires from every device including ones that are not intentionally involved in a particular transaction. The interface loop idea could still be implemented however with high-speed serial over cat-5 cable though.

For those unfamiliar with the serial interface loop, there are a lot of nice things about it. You can theoretically connect an almost unlimited number of devices to one or more controllers with only two small connectors on each device or controller, one being "in" and the other "out". The "out" of each device goes to the "in" of the next, connecting everything in a big circle. Since each output goes to only one input (ie, that of the next device), there are no fan-out limitations like parallel connections have. No line needs to be bi-directional. The initial controller initiates auto addressing. Control can be passed from one controller to another. Every message goes around the loop in the same direction regardless of origin, and when it comes full circle, the originator of the message can even check to make sure it did not get corrupted on its way around.

Quote:
Quote:
--> With SPI, one slow device would not slow all the other devices down.

But, since different devices can operate at different maximum speeds, you must assume the lowest common denominator until you've somehow negotiated higher speeds with each device. What is the protocol to achieve this?

Right. What I'm thinking of at this point, since I want to be able to add not-so-intelligent devices, is that along with telling the controller where things are (or just connecting them in the order that you've written your program for), the controller would just have to know various devices' top speed. To start with bit-banging on a 6522 however (if indeed I do it that way), speeds aren't normally going to be pushing the Mbps limitations of the devices.

Quote:
Quote:
--> Real SPI would require bit-banging if done with the 6522. (The 6522's serial port is close to one of the most commonly used SPI modes, but no cigar.)

Or, you could jerry-rig a "SPI controller" by using a 6522's parallel I/O interface coupled to a dedicated ATmega or PIC microcontroller, programmed to serve as a 6522-to-SPI bridge. This would put almost all the bit-banging onto the microcontroller, leaving the 65xx free to work on other things.

I probably should look into this further. We discussed something similar earlier, but I wonder if the software required by the added layer of isolation would offset the savings of not having to bit-bang. Ideally the µC could act as an actual 65xx part with various registers appearing directly in the 6502 memory map, but I'm not sure that possibility exists. What I've seen on µC parallel slave ports so far is that they require telling them what to do with the data that's coming, then giving them the data, then checking to see when they're ready for more, then telling the to dish up certain information, then checking for when it's ready, then reading it, etc., which, especially if you go through a 6522 as well, makes for a lot of overhead.

Quote:
Quote:
--> To allow some cable length, slowish comparators like the LM339, along with hysteresis, should be used at the receivers to keep parasitically coupled transients from causing unwanted trigering. The interface loop OTOH could just use something like cat-5 cable with receiver ports terminated, so the cable would not limit the speed.

I do not see the logic of this, since the physical layer of both the loop and the bus are essentially the same. Can you explain more about this?

The idea, which is kind of a brute-force method and might be excessive or need modification, is to buy permission to be kind of sloppy with cheap cables which might get rather long and have an unknown number of loads along the length of the run.

Quote:
Quote:
The CLK, DI, DO, and IRQ lines would be bussed

I prefer to stick to the names MISO and MOSI personally, since the concept of input and output is relative to the perspective of master versus slave. MISO and MOSI names place the signal intentions in an absolute frame of reference.

I agree. I was using the pin labels used on a lot of SPI devices. What do MOSI and MISO stand for though? "Master-out, slave-in" and vice versa?

Quote:
Quote:
There would be seven select lines. This accomplishes two things: the devices don't need to decode an address bus (which would otherwise be 3 bits in this case), and auto-addressing can be done by rotating the select lines from one connector to the other

This is how the Amiga handled floppy addressing. It had four select lines, which were shifted (not rotated) from one device to the next.

Yes, you're right. There would be no need to repeat the addresses 7 devices down the line.

Quote:
With 7 select lines (I'm curious to learn why not 8?)

If I use 3 6522 bits for address and then run those into a '138, the 0 output will mean no device is selected, which I may want if I need the data and clock lines for something else as well. When no SPI device is selected, it won't matter what the clock and data lines are doing.

Quote:
The critical factor for hot-plugging is making sure the grounds connect first upon device insertion, and are broken last upon device removal. For example, if you look at MMC cards, which are designed for hotplugging, you'll see that some pins are longer than others.

Yes, I was trying to think of a cheap connector (like IDCs) that would accomplish this, but I have not been able to so far. If you know of something, please share it.

Quote:
Quote:
It wouldn't be hard to shut the interface down at the controller end so at least the controller itself doesn't have to be turned off in order to connect or disconnect a device.

Nope; and, you can even specify a standard device interface feature such as an "eject" button that requests the safe removal of the device from the chain (e.g., it generates an interrupt, the host OS sees this and properly shuts down the power to the specific device, then signals the user that it's OK to remove the device).

I have this kind of thing on my I²C port, with an LED telling when it's safe to plug in or unplug. So far all I've used this port for is the half-postage-stamp-sized serial EERPOM modules I've made for it. I've used other I²C devices, but not like removable media like these EEPROM modules, and the other devices were part of bigger things that went through the edge connector along with a lot of other connections instead of through the 4-pin I²C port at the front.

Quote:
7 select lines + MOSI + MISO + CLK + GND + power = 12 lines minimum. If you interweave a ground pin on every line, you end up needing 24 conductor cables and IDC headers (worst-case, but heck, it's cheap enough!).

I wasn't going to pair every select line with ground, but I'll rethink that. Like you say, it's cheap. I was partly trying to keep the connectors narrower so they don't take up so much of the edge of a board, and keep the ribbons from getting so wide and unwieldy on the workbench. Inside a computer case, once the cover is on the width of the ribbons is not really an issue, but it would be on a workbench with a bunch of separate pieces of equipment hooked up.

Quote:
My question is, though, what if you want more than 7 devices on a single bus?

Possible, but unlikely. I like your idea of putting the first 7 addresses last. IEEE-488 has a fan-out allowing a max of 15 IIRC, although I've never used more than about 5 myself. (The last time I used IEEE-488 was maybe 1992, but that because my work has changed, not that the interface was obsolete.)

_________________
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  
 Post subject:
PostPosted: Sat Dec 30, 2006 6:32 pm 
Offline

Joined: Sat Jan 04, 2003 10:03 pm
Posts: 1706
GARTHWILSON wrote:
I'm sure that number of megabytes per second would have to come way down with longer cables and greater numbers of devices like you get in a rack-and-stack IEEE-488 set-up.


Yes, the length of the cable, as you purchase it from a computer shop, is the maximum length allowed. Still though, we're talking hundreds of megabytes per second (something like 150MB/s). So if you have a cable that is 10x as long, assuming no EMI, you'll still get a pretty hefty performance at 15MB/s. That's close to 65816's maximum bus throughput. :)

Quote:
Makes sense. STD bus is the only one I've worked with, and that one, with 8-bit processors 20 years ago, generally was a buffered extension of the processor's own bus.


The more I study this, the more I'm inclined to believe that this is only for convenience's sake -- minimum cost expansion. Now that PCs come in so many bus widths and speeds and chipsets, the need to fully decouple the CPU's local bus from the I/O bus is paramount; it's no longer a luxury, but an absolute requirement to ensure compatibility between the motherboard vendor and the peripheral vendor.

Quote:
Maybe you guys who have been working with CPLDs could make and sell us a 65xx serial bus interface that would allow SPI ICs that are on the market to easily be interfaced. I would just hope you publish the source code so users aren't orphaned if you become unable to keep selling it (or no longer interested in selling it). I doubt that it would be necessary to go to the extent of an FPGA for this.


I've acquired a new job, and with the increased income, I will hopefully be able to afford more toys. I will definitely look into this.

The only reason I'm going with an FPGA chip for the Kestrel is because (a) it's convenient -- there is already a pre-fabricated, off-the-shelf unit I can use that comes complete with SDRAM, a VGA port, and a few other goodies that I would have had to add myself anyway, and (b) I'm looking to pack a lot of stuff onto the chip.

For other people, a CPLD would be more appropriate.

Quote:
which is something we rarely do even with desktop computers. If you were distributing software on media that you could put in a box (as opposed to internet or other electronic means), then you'd want to be able to have more than one listener. The controller would still need to be able to monitor the progress and be ready to do more controlling actions when the transfer is done though, right?


Well, the controller needs to tell the various peripherals to untalk and unlisten on the next bus transaction, sure. But, otherwise, no, because at the end of the file transfer, EOI is signaled, and the various peripherals know to stop at that point.

(Commodore's serial bus was a serialized implementation of GPIB).

Quote:
If the devices all had enough intelligence, you could simply ask one device after another, "What kind of device are you?" which HPIL (which is too complex for what I want here) can do, and each device knows its model number, what class of device it is and what it can do, etc..


OK, so you're not concerned with pre-made SPI devices then, for the most part. It looks like the intended application space is custom-built peripherals, with the option of using pre-made SPI devices.

In that case, may I recommend one more bussed signal called CONFIG or DETECT? Theory of operation would be this:

* When asserted, it would gate off the appropriate _CS signal, thus preventing a "dumb" SPI device from accidentally responding to bus probes.

* When negated, it would gate through the appropriate _CS, thus allowing normal SPI operation.

A circuit like this ought to suffice:

Code:
PORT IN                        PORT OUT

             +---+
_SEL0 o-----o|   |
             | & |o---+
DETECT o----o|   |    |
             +---+    |
                      o
                +----------+
                |    _CS   |
                |          |
                | Dumb SPI |
                |  Device  |
                |          |
                +----------+
                   | | |
                   | | |
MOSI  o------------*-|-|------o MOSI
MISO  o--------------*-|------o MISO
 CLK  o----------------*------o CLK

_SEL1 o-----------------------o _SEL0
_SEL2 o-----------------------o _SEL1
_SEL3 o-----------------------o _SEL2
_SEL4 o-----------------------o _SEL3
_SEL5 o-----------------------o _SEL4
_SEL6 o-----------------------o _SEL5
             +Vdd )-----------o _SEL6


You know, another idea that just occured to me is to have the DETECT signal select an MCU that is programmed to respond to auto-configuration commands appropriately on behalf of the dumb SPI device, but when DETECT is negated, the normal/dumb SPI device is selected. I actually like this idea better, because then it would allow you to bolt on COTS SPI devices, while still taking advantage of auto-configurability.

Quote:
Ideally the µC could act as an actual 65xx part with various registers appearing directly in the 6502 memory map, but I'm not sure that possibility exists.


If you're willing to put up with wait-states, it is. At least, on the 65816 it is. Here is a simple circuit to demonstrate:

Code:
CPU BUS                                                     MCU Interface

RDY <--------------------*-----------------------------------> _IRQ
                         |
                    +---------*---------*---------*-----+
                    |    |    |         |         |     |
                    o    |    o         o         o     |
                 +-----+ | +-----+   +-----+   +-----+  |
                 |  S  | | |  S  |   |  S  |   |  S  |  |
_CS o------------|D   Q|-*-|D   Q|---|D   Q|---|D   Q|--+
                 |     |   |     |   |     |   |     |
                 |     |   |     |   |     |   |     |
                 +^----+   +^----+   +^----+   +^----+
                  |         |         o         o
                  |         |         |         |
                  |         +---------*---------|------------o BUSY
                  |                             |
Phi2 o------------*-----------------------------+


THEORY OF OPERATION:

  Assume that all flip flop outputs are high.

Phase 1:

  CPU asserts _CS via its address decoder.  When Phi2 is asserted, its
  state is clocked into Q1, thus bringing the microcontroller's _IRQ
  input low.  You could also use another non-interrupt input too,
  depending on your application, but you must remember to poll for it.
  Either way, the CPU's RDY signal is tied to this input, which is also
  negated.
  :)

Phase 2:

  When the MCU responds to the start of the bus, it will assert BUSY as a
  kind of acknowledgement.  This brings Q2's output low.  Note that any
  number of Phi2 cycles could have elapsed, but since Q3's output is
  still high at this point, nothing happens because RDY will remain
  negated.


Phase 3:

  When the MCU is done, it negates BUSY, thus indicating that it's done
  using whatever it needs off the CPU's bus.  Now Q3's output will go
  low.  However, we still need to wait for CPU to end whatever current
  cycle it's in.

Phase 4:

  We wait for Phi2 to go LOW at this point, thus signifying the end of
  the current 65xx bus transaction.  When it finally goes low, we set all
  four flip-flops concurrently, which brings RDY back high.  Thus, the
  65xx will wait for precisely one more cycle before moving on to the
  next bus transaction.


The sequencer (four flip flops) ensures that the bus data is taken or delivered at the appropriate times. Note that if BUSY is negated during the same processor cycle, zero wait states occur. If BUSY takes one Phi2 half-cycle in length, it waits 1 cycle, etc., which is desirable behavior.

For reading data, you can have the MCU latch data into an external register, and let the R/W and Phi2 signals gate it onto the bus. For writing data, no additional logic is needed.

Quote:
I agree. I was using the pin labels used on a lot of SPI devices. What do MOSI and MISO stand for though? "Master-out, slave-in" and vice versa?


Yes. I'm assuming that one, and only one, master is permitted on the bus.

Quote:
If I use 3 6522 bits for address and then run those into a '138, the 0 output will mean no device is selected, which I may want if I need the data and clock lines for something else as well. When no SPI device is selected, it won't matter what the clock and data lines are doing.


Ahh! I should have known that. Sorry.

Quote:
Yes, I was trying to think of a cheap connector (like IDCs) that would accomplish this, but I have not been able to so far. If you know of something, please share it.


One is to use gated power, like we were discussing before. However, have an R/C time-constant upon plug insertion. The idea being, when you first insert the plug, power is NOT applied to the device until an R/C time constant threshold is exceeded. However, this still doesn't address the issue of device removal. The EJECT button idea is still the proper way of handling that aspect.

Quote:
I wasn't going to pair every select line with ground, but I'll rethink that.


It might be a good idea if you're going to be addressing devices quickly and with fast turn-around times. Maybe tie four selects per ground? It won't need nearly as much grounding as the actual data lines, but they will be toggling rapidly "enough" if you're hammering I/O devices with short and quick I/O bursts.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sat Dec 30, 2006 8:06 pm 
Offline

Joined: Tue Jul 05, 2005 7:08 pm
Posts: 1043
Location: near Heidelberg, Germany
Hi there,

you are talking about a topic I have come about myself, now that my selfbuilt computer ( http://www.6502.org/users/andre/csa ) with a coprocessor has come to a limit in terms of expandability. Especially if I want to connect other architectures like the C64 or Commodore PET to it
So far I have been mostly using IEEE488 and RS232 interfaces. I have recently started with an I2C bus (see the SCSI board from the computer above), but I have used Philips controller and I/O ICs, which are not cheap though.

So I have been looking into serial "busses" or "networks" to see if I could find something more suitable. My requirements are:

- small (cheap) connector, small number of pins
- peer-to-peer, no "bus". I decided that it would be easier to separate out
the addressing etc from the bus to some kind of "hub" (similar to USB)
instead of having to implement this feature on every device
- devices should be able to handle different speeds without problems
-> this I guess results in a synchronous mode, with clock and data as
separate lines.
- so simple that it could be implemented with minimal effort on a 6522
(PET) or 6526 (C64) or even other I/O ICs. Minimal effort may include
say up to about three 74* ICs (like a shift-in, a shift out, and a glue
logic IC)
- If there is no better solution, a bidirectional connection may be similar
to two unidirectional connections. So there should if possible no
(by hardware) dedicated device like a specific controller
- It should be possible to have "receive-only" devices like additional
parallel output lines and similar for input lines
- automatic detection when device is plugged in
- should not be too much timing critical.

I have had a look into some serial interfaces and this is what I found
(please tell me if I got something wrong, all is gathered from the web...)

SATA: uses two signals (A for transmit, B for receive), each with
differential signals on the bus. No hardware handshake
peer-to-peer
USB: uses a single bidirectional data line - with differential signal on the
connector. No hardware handshake
peer-to-peer, with hubs
CBM serial IEC: three lines, DATA, CLK and ATN. DATA and CLK are
bidirectional, ATN goes from controller to devices. Controller
sends commands to devices
software handshaking on the CLK and DATA lines to emulate
IEEE488 lines NRFD/NDAC
bus structure, controller selects devices
PCIe: a single data line, with a 8/10 encoding, so that the clock is encoded
in the data signal (similar to GCR encoding)
I2C [1]: data and clock signal, bidirectional. controller and devices
bus structure
No handshaking. Controller addresses devices via special bus
values. Timeout handling
SPI [1][2]: four wire bus, master/slave setup, can use interface loop
MOSI/MISO unidirectional data lines, clock sent from master.
1-Wire [3]: single, bidirectional data wire. Specific timing required.

I did not have time (yet) to look into MMC/SD-Card interface, although your discussion seems to indicate that it uses an SPI interface?

But what I got from all of this so far is the following approach to my "network": Each bidirectional connection ("channel") is made up of two unidirectional connections. The connections are peer-to-peer with no master or slave.
Each unidirectional connection has three wires:

- DATA sender sends data here synchronously with:
- CLK sender sends clock pulses here
- WAIT receiver sends feedback.

Data is transferred in bytes (8 bits), as long as WAIT is low. So simple handshaking can be accomplished. (clock phases etc still have to be determined).

Physical layer could be pull-ups on the input and open collector drivers
on the output for small distances and more sophisticated stuff for longer
distances/harsher environments. The open collector stuff also allows for autodetection of plugged in devices, when the device pulls WAIT low the first time. This could trigger some software-level device identification protcol when required.

So a unidirectional channel would have three lines, a bidirectional channel 6 lines (plus GND, and optional VCC - similar to power-over-ethernet, to supply small devices)

OTOH it would allow to simply put a shift register (serial-2-parallel) on the CLK/DATA lines for simple additional output lines. (parallel-2-serial is a bit different but should easily doable)

Multiplexing output channels could be easily done with a single CLKout and DATAout, and a 74LS138 to distribute the CLK signal to multiple channel
Multiplexing input channels could be time-shared using a 74LS138 to pull the respective WAIT line low (and some wait time)

I have yet to look into how this could be implemented with the 6522 VIA or 6526 CIA (for the VIA I would probably have to sync the clock line with Phi2 to circumvent the VIA shift register bug though), but I hope to avoid bit-banging (sure for the CIA, not sure (yet) for the VIA).

If there is only a single shift register available for both sending and receiving, the register could be set to receive on standard, and when the device wants to send, it could assert the WAIT line, wait a moment, then send (if the other WAIT line is ok).

What do you think of this approach?

André

[1] http://www.epanorama.net/links/serialbus.html
[2] http://en.wikipedia.org/wiki/Serial_Per ... erface_Bus
[3] http://en.wikipedia.org/wiki/1-Wire


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sat Dec 30, 2006 8:57 pm 
Offline

Joined: Sat Jan 04, 2003 10:03 pm
Posts: 1706
fachat wrote:
- peer-to-peer, no "bus". I decided that it would be easier to separate out the addressing etc from the bus to some kind of "hub" (similar to USB) instead of having to implement this feature on every device


You mean, no master/slave. A true bus is inherently peer-to-peer (think 10-base-2 Ethernet!). I agree that a peer-to-peer solution is ideal, but along with that comes the asynchrony that comes with such a system. Your system software now becomes more complex.

Quote:
If there is no better solution, a bidirectional connection may be similar to two unidirectional connections. So there should if possible no (by hardware) dedicated device like a specific controller


ATM networking also divides a bidirectional link into separate uni-directional channels. In fact, ATM cell addressing takes advantage of this nicely, effectively doubling its already gargantuan channel address space to 32 million channels (16.7 million going out from a device, 16.7 million coming into a device, per port!).

Quote:
I did not have time (yet) to look into MMC/SD-Card interface, although your discussion seems to indicate that it uses an SPI interface?


MMC defines its own interface which is bit-parallel in nature to facilitate faster throughputs, but they also support an SPI mode of operation as well.

Quote:
So a unidirectional channel would have three lines, a bidirectional channel 6 lines (plus GND, and optional VCC - similar to power-over-ethernet, to supply small devices)


How does a peripheral signal to its peer that it has (unsolicited) data that it wants to send? If a peripheral isn't aware that data needs to be sent, it will leave its WAIT signal asserted, thus effectively inhibiting data transmission.

Quote:
Multiplexing output channels could be easily done with a single CLKout and DATAout, and a 74LS138 to distribute the CLK signal to multiple channel
Multiplexing input channels could be time-shared using a 74LS138 to pull the respective WAIT line low (and some wait time)


I'm not sure I follow this.

Quote:
I have yet to look into how this could be implemented with the 6522 VIA or 6526 CIA (for the VIA I would probably have to sync the clock line with Phi2 to circumvent the VIA shift register bug though), but I hope to avoid bit-banging (sure for the CIA, not sure (yet) for the VIA).


You can also use an out-board serial-in shift register driven off the VIA's clock. Just remember to read it (instead of the VIA) to get its current value. But the synchronization technique should work too, and may be simpler, provided you can deal with a transmission rate no faster than Phi2 / 4.

Quote:
What do you think of this approach?


What you're describing is basically a bidirectional SS-22 bus.

It's something I've thought of in the past, but I, like Garth, really didn't want to put up switches or hubs. I wanted a true bus or a true ring architecture, since they are the cheapest to build. Having to build switches would introduce additional complication and debugging that I considered excessive for the scope of the Kestrel project.

The other thing to consider is electromagnetic radiation. I'm a ham radio operator, and I'd like the ability to use my Kestrel alongside my ham rig. That means, really, I'd like as little EMI as possible from this bus. The use of external ribbon cables threatens to release a lot of EMI, since these cables are not constructed to be transmission lines.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sat Dec 30, 2006 10:57 pm 
Offline

Joined: Tue Jul 05, 2005 7:08 pm
Posts: 1043
Location: near Heidelberg, Germany
Quote:
How does a peripheral signal to its peer that it has (unsolicited) data that it wants to send? If a peripheral isn't aware that data needs to be sent, it will leave its WAIT signal asserted, thus effectively inhibiting data transmission.

Standard mode of the receiver (e.g. controller) would be to allow sends (deasserted WAIT) so the sender (peripheral) would be able to send anyway. Remember, the WAIT signal goes in opposite direction than the DATA/CLK signals.
If the sender cannot have WAIT always deasserted, it must poll, though. Maybe a "break" signal on the clock line (e.g. keep it low for a certain amount of time (assuming inactive high and shift pulses go low)) could generate a kind of interrupt then.

Quote:
Quote:
Quote:
Multiplexing output channels could be easily done with a single CLKout and DATAout, and a 74LS138 to distribute the CLK signal to multiple channel
Multiplexing input channels could be time-shared using a 74LS138 to pull the respective WAIT line low (and some wait time)

I'm not sure I follow this.


If a device has only one receiver, a 74LS138 could be used to ever only deassert a single WAIT line, so only one of the senders - that use DATA and CLK together - is allowed to send.
If a device has only one sender, it could use a 74LS138 to only ever toggle a single CLK line, while the DATA line is used by all receivers

.
Code:

Sender                     Receiver
------                     --------

CLK_out     ------>        CLK_in
DATA_out    ------>        DATA_in
WAIT_in     <------        WAIT_out


Multiplexing a single Receiver with multiple Senders
----------------------------------------------------

Sender1                             Receiver

CLK_out1    --+-------------------> CLK_in
DATA_out1   --|+------------------> DATA_in
WAIT_in1    <-||--+             +-- WAIT_out
              ||  |      '138   |
Sender2       ||  |     +----+  |
              ||  +-----|0 /E|--+
CLK_out2    --+|   +----|1   |
DATA_out2   ---+   |    |2  A|----- Select1
WAIT_in2    <------+    |3  B|----- Select2


Multiplexing a single Sender with multiple Receivers
----------------------------------------------------

Sender                              Receiver1

DATA_out    -------------------+--> DATA_in1
CLK_out     --+  '138      +---|--> CLK_in1
              | +----+     |+--|--- WAIT_out1
              +-|/E 0|-----+|  |
                |   1|------|-+|
Select1     ----|A  2|      | |+--> DATA_in2
Select2     ----|B  3|      | +---> CLK_in2
                            |  +--- WAIT_out2
WAIT_in1    <---------------+  |
WAIT_in2    <------------------+



Quote:
You can also use an out-board serial-in shift register driven off the VIA's clock

No, I use the input clock to shift in. So the serial-in shift register must be driven by the CLK line. Don't know if there is a 74* line that has a specific "SR full" output that could trigger a VIA interrupt.

I was concerned about bit-banging on the output side, probably I was not clear enough on that, sorry.


Quote:
The other thing to consider is electromagnetic radiation

Sorry, but you're discussing 12 and more signals for the bus. I think 6 lines should be more easily put into e.g. a CAT5 with shielding?

Quote:
It's something I've thought of in the past, but I, like Garth, really didn't want to put up switches or hubs


I can understand this. But OTOH you're discussing addressing issues now. Anyway, with my multiplexing selection I don't think I am too far away from SPI actually, or am I? And the '138 solution looks very similar to your solution with putting all the select lines on the "bus". Or does it not ;-) ?

I will be looking at the SS-22 bus later, thanks for the pointer.

André


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sun Dec 31, 2006 12:03 am 
Offline

Joined: Sat Jan 04, 2003 10:03 pm
Posts: 1706
Quote:
Sorry, but you're discussing 12 and more signals for the bus. I think 6 lines should be more easily put into e.g. a CAT5 with shielding?


My question was open, and not targeted specifically at your proposal. However, with six signals, it won't fit on a cat-5 cable; there are only 4 pairs per cable. Using some of the pairs in an unbalanced way will introduce the same EMI problem I'm referring to.

Unless you're willing to use two cat-5 cables (one for input, one for output) per device, but that's getting a bit expensive.

Quote:
I can understand this. But OTOH you're discussing addressing issues now.


Yes, in a way. It was tailored more for physical implementation issues, rather than logical.

Your solution is comparable to a typical ATM network configuration, consisting of a number of devices (nodes) interconnected with point-to-point links. For any one device to address another, you need to encapsulate your data into a frame, which intervening nodes must switch accordingly on their own (if they're switches at least). This seems to contradict your desire to not have dedicated controllers involved. But to ensure reliable and high-throughput operation, dedicated controllers (perhaps in the form of MCUs) are required.

Additionally, switches introduce latency into the data timing. This might not be suitable for real-time data acquisition.

Quote:
Anyway, with my multiplexing selection I don't think I am too far away from SPI actually, or am I?


From a physical perspective, it's somewhat similar. From a semantic perspective, you're way off. :) SPI states that when a device's SELECT input is asserted, it's supposed to be listening to a frame of data coming in on MOSI, and supposed to be sending data on MISO, at the rate determined by CLK. The command(s) sent to the peripheral are to be acted upon starting as soon as the SELECT input negates.

In other words, the SELECT input of a SPI device corresponds directly to a _CS input on a traditional interface chip. Note that most SPI devices also expose an _IRQ output as well. As such, SPI can be thought of as a simplified serial CPU interface. A more complete SPI interface might have these signals:

* MOSI -- data output from the master, input to slave
* MISO -- just the opposite direction
* CLK -- clock output from the master. The selected slave is expected to keep up.
* SELECT -- asserted by the master when talking to a specific device. Uses the same kind of logic as your average address decoder.
* IRQ -- driven by the slave, and hopefully responded to by the processor.
* IRQACK -- IRQ acknowledge driven by the master (somehow)
* RESET -- driven by anybody.

Note its similarity to, say, most microprocessor peripheral chips.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sun Dec 31, 2006 12:25 am 
Offline

Joined: Tue Jul 05, 2005 7:08 pm
Posts: 1043
Location: near Heidelberg, Germany
Quote:
My question was open, and not targeted specifically at your proposal. However, with six signals, it won't fit on a cat-5 cable; there are only 4 pairs per cable. Using some of the pairs in an unbalanced way will introduce the same EMI problem I'm referring to.

Good point. But I did not (yet) have a good idea how to reduce the number of lines further....

Quote:
From a physical perspective, it's somewhat similar. From a semantic perspective, you're way off.


You're right in one respect - my solution can be used in a semantically completely different way. However, if the device simply connects (when WAIT is not asserted, though) the incoming CLK to the outgoing CLK and sends the data appropriately, it is (basically) an SPI interface :-) In this case, however, the controller must be able to run full-duplex. This contradicts my (admittedly not explicitely stated) requirement that it should work on a PET or C64 - with only a single shift register. So these computers would (without additional hardware) only be half-duplex, and could thus not easily do it with hardware support, but had to fall back to bit-banging - which I want to avoid.

So if the controller knows which device is attached, the solution could be used in a semantically simple way similar to SPI, but if both devices are more sophisticate it could be the transport layer of a higher level - as you say ATM-like - protocol on top of it. That's some flexibility I like, as I have both usage scenarios planned.

You could even use a bus structure, if you put the WAIT outputs of the '138 on a single cable as (active low) "Select" lines, only each device should then deassert (I'm thinking of pulling down a wired-and active-high WAIT - or wired-or active-low /WAIT) WAIT only when its select line is asserted.

Thanks for your comments!
André


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sun Dec 31, 2006 3:54 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8545
Location: Southern California
Quote:
Quote:
Makes sense. STD bus is the only one I've worked with, and that one, with 8-bit processors 20 years ago, generally was a buffered extension of the processor's own bus.

The more I study this, the more I'm inclined to believe that this is only for convenience's sake -- minimum cost expansion.

Hence STD bus's name, which comes from "simple to design."

Quote:
I've acquired a new job, and with the increased income, I will hopefully be able to afford

That's good news! For awhile it seemed like things were pretty rough for you.

Quote:
Quote:
If the devices all had enough intelligence, you could simply ask one device after another, "What kind of device are you?" which HPIL (which is too complex for what I want here) can do, and each device knows its model number, what class of device it is and what it can do, etc..

OK, so you're not concerned with pre-made SPI devices then, for the most part. It looks like the intended application space is custom-built peripherals, with the option of using pre-made SPI devices.

Although something like large serial flash memories are able to identify themselves, there are a lot of other SPI and Microwire ICs that cannot. I'd like to be able to use any of them, plus dumb shift registers for extra I/O bits like André was talking about.

Quote:
Yes. I'm assuming that one, and only one, master is permitted on the bus.

Yes. It sounds cool to be able to pass control around, but in reality, I've never needed to, even when I've had more than one device that could act as the controller.

Quote:
The other thing to consider is electromagnetic radiation. I'm a ham radio operator, and I'd like the ability to use my Kestrel alongside my ham rig. That means, really, I'd like as little EMI as possible from this bus.

I'm a ham too (WB6NUY), but have been inactive for 22 years. I just keep my license current in case someday I want to do something wild like make my own radar.

Quote:
The use of external ribbon cables threatens to release a lot of EMI, since these cables are not constructed to be transmission lines.

You can get the ones with twisted pairs though, which should help dramatically, especially with a large ferrite bead over each pair at each end to act as a balun. I have some that I think is 20-conductor which has the twisted area loose, ie, one twisted pair is not glued or bound to the next, so the cable is ultra-flexible. Once every 10 or 12 inches, it reverts back to a normal flat ribbon for an inch or less so you can press an IDC on. I haven't done any looking around recently to see how common this is.

_________________
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  
 Post subject:
PostPosted: Sun Dec 31, 2006 11:25 am 
Offline

Joined: Tue Jul 05, 2005 7:08 pm
Posts: 1043
Location: near Heidelberg, Germany
Quote:
Quote:
The other thing to consider is electromagnetic radiation. I'm a ham radio operator, and I'd like the ability to use my Kestrel alongside my ham rig. That means, really, I'd like as little EMI as possible from this bus.

I'm a ham too (WB6NUY), but have been inactive for 22 years. I just keep my license current in case someday I want to do something wild like make my own radar.

Just for the record - DB5IM. But I also have been inactive for 20 years now (but also still keep my license :-)

vy 73
André


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sun Dec 31, 2006 6:18 pm 
Offline

Joined: Sat Jan 04, 2003 10:03 pm
Posts: 1706
I do some shortwave listening periodically. I'd like to QSO with other like-minded folks, but it seems that most of ham radio is restricted to old farts complaining about their health or passing NTS traffic. Oh, and nets dedicated to getting people certificates of various kinds (e.g., HHH net).


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sun Dec 31, 2006 10:44 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8545
Location: Southern California
This is getting off the topic, but I used to do low-band QRP CW. I got to where I could listen to the code at 30wpm and be scanning an article in QST for something for the other person at the same time and get most of both, but I sure can't do that now. I liked CW not just for the hardware simplicity, but for the fact that the fellows on CW were generally more serious about the technical things. I didn't really want to hear men on the phone bands cutting down their wife for things like how much she just spent on the 100th pair of shoes in the closet. I wanted to discuss technical things like we do here; but even though radio amateurs have to pass theory tests to get the license, there still aren't very many who know the subject to the extent that I wanted to discuss. Who knows-- maybe someday I'll want to use amateur radio to transfer data. I can hardly imagine myself talking with strangers on it again.

Back on topic
So Samuel, have you mostly set aside the interface loop idea?

_________________
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  
 Post subject:
PostPosted: Sun Dec 31, 2006 11:25 pm 
Offline

Joined: Sat Jan 04, 2003 10:03 pm
Posts: 1706
GARTHWILSON wrote:
So Samuel, have you mostly set aside the interface loop idea?


I don't know just yet; I was planning on using the SPI bus for solid-state storage devices like MMC cards. But, in retrospect, I think having a direct-access SPI bus for general purpose I/O is a good thing. And, I'll tell you why: a hub/switch is a proper peripheral too.

See, check this out . . .

Suppose for the sake of argument that we restrict a single daisy-chain to just 7 peripherals; let's give them the arbitrary POSIX-like names of /dev/spi/0 through /dev/spi/6. If we want to use 9 peripherals (for example), we can introduce a new kind of peripheral, a switch. This would allow us to add /dev/spi/7 through /dev/spi/13, at the expense of one of the /dev/spi/[0-6] devices. (unless you wanted to specifically talk to the switch for some reason, in which case, it's not really lost.) So, sending a stream of bytes to /dev/spi7 through /dev/spi/13 would be enough knowledge to tell the system software that it needs to prefix an address byte on its sent command/message. This is trivial for the OS to keep track of, provided switch (aka source) routing information is standardized in the output stream.

The switch is basically a dumb SPI device itself, consisting of an 8-bit shift register and a few MUXes. The idea is, the first byte sent to the device determines the addressed device to which all subsequent bytes are sent. For example:

Code:
"HELLO"   --- raw data packet, direct-addressed.

$02 "HELLO"  --- raw packet sent to the switch, which takes $02 to address device 2, and sends "HELLO" onto that device.

$02 $05 "HELLO"  --- Same concept; you can nest switches onto switches if required.


A switch may even support multiple ports, where each port supports a chain of 7 devices. Thus, a switch may allow address bytes larger than 6:

Code:
+---+---+---+---+---+---+---+---+
| 0 | 0 | p | p | p | d | d | d |
+---+---+---+---+---+---+---+---+

p: Selects specific chain port
d: Selects specific device on that chain


I think this represents the best of both worlds.

So, in retrospect, I have to agree, support for the interface loop idea is falling fairly quickly at this point. The loop still has the advantage of supporting higher throughputs since there is no significant loading on each individual link. BUT, it's not likely that 7 external devices will pose that much of a load either, even at 25Mbps.

If something faster is desired, a whole new connector would be required anyway to control unwanted EMI.

So, so far, I see the following pin-out:

Code:
Standard SPI functions:

MOSI
MISO
CLK
IRQ

Proprietary additions:

CONFIG -- selects auto-configuration SPI device instead of normal device
SEL0
SEL1
SEL2
SEL3
SEL4
SEL5
SEL6

Power:

6 GND pins (1 return each for MOSI, MISO, CLK, IRQ, plus one for CONFIG, SEL0-SEL2, plus one for SEL3-SEL6).

2 +5V power @ 100mA capacity (not sure if a ribbon can handle this; I'm drawing this from the old Commodore 64 expansion connector, where a single 5V pin was able to deliver 100mA of current)

TOTAL PINS: 20 pins


What do you think? I think it'd be nice to compare this interface against GPIB in a more formal manner. (And, then, we need to arrive at a specific pin layout too.)

Also, should we include a RESET pin as well?


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Jan 01, 2007 4:17 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8545
Location: Southern California
Interesting idea. There are already I²C port-expander ICs, but I haven't thought about doing it on SPI.

One thing that just occurred to me is that I may want to make a unit using two or more off-the-shelf (OTS) SPI devices. This might use up the address lines fast. Take for example a multiple programmable power supply, where one SPI chip has two or more D/A converters to set output voltages and current limits, and a separate SPI chip is used to read the actual currents. In automated test equipment, there would be yet another SPI IC or dumb shift register to select which of various outputs to route each power supply to. If there's an interrupt for something like overtemperature shutdown, you'll also want to be able to read a status register. On such a piece of equipment, the address lines from one serial bus connector to the other would be shifted over by more than one position.

I was originally looking to keep this really simple, so that minor projects could be interfaced with few parts (even a single IC) and minimal design and construction time. This is one reason for having the separate address lines, eliminating the need to decode the address on every device. If I ever sell it, I'd also like it really simple for the customer to understand and make more things for. (That's not just to be nice. Think customer-support phone calls and E-mails! Even with the product line I've been in for the last 20 years, the customers are supposedly pilots, and yet some of them make you wonder how they ever learned to tie their shoes.) Allowing more devices with more address lines means putting even more pins on a connector that already has more pins than I wish it did. Adding the switch gives the extra addresses without making the connector bigger, but each switch will need at least one IC (and probably more), adding complexity. So far I haven't found any such OTS SPI expander ICs. Cutting from 7 address lines down to 4 and setting each device's address with a DIP switch IEEE-488-style allows doubling the number of devices. That may not be all bad, but I'd rather not have to do it that way, especially if one unit has several SPI devices on the bus.

Quote:
2 +5V power @ 100mA capacity (not sure if a ribbon can handle this; I'm drawing this from the old Commodore 64 expansion connector, where a single 5V pin was able to deliver 100mA of current)

Since there can be considerable IxR drop across a long, small-guage 5V conductor but switching regulators are a piece of cake now compared to the C64's heyday, I might be inclined to have a line that's in the neighborhood of +12V instead, and not necessarily regulated. That way, things that require very little power can have cheap 3-pin TO-92 regulators like a 78L05, and the ones that need more power can use a switching regulator and get the needed current at exactly 5V or 3V or whatever they need without pulling as much current over the wire or pulling the voltage down enough to affect anything.

Quote:
Also, should we include a RESET pin as well?

I hadn't forgotten about this, but I don't think there's really any need. None of the SPI and Microwire parts I'm already familiar with even have a reset pin. They're reset simply by cycling the power, and of course the SPI state machines are reset anytime their select line is false, so you can always get their working attention again to give new commands. Adding a reset line adds a pin or two to the connector which is already up to a lot of pins.

Keep up the brainstorming.

_________________
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  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 109 posts ]  Go to page 1, 2, 3, 4, 5 ... 8  Next

All times are UTC


Who is online

Users browsing this forum: handyandy and 19 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: