Card Reader Wiring Diagram
The card reader/writer is constructed by wiring a standard SD socket to a teensy. Our prototype is a SD socket, glued to PCB and hand-wired to a 28-DIP socket into which the Teensy is plugged. Way simple!
There are no active components, although you WILL have to solder the teensy to 3.3V mode and install the voltage regulator on the bottom, as the DF is not 5V tolerant. Although, in a pinch, you can use a 2n7000 transistor as a source follower and it’s VGS will tend to droop the voltage down to just about 3.3v. Tie Gate/Drain to the 5v supply and Source outputs the 3.3V rail.
The handwired prototype ain’t much to look at. The SD socket outputs to a row of vertical header pins for attaching the logic analyzer (Hello again, ZP!), and you can catch a glimpse of the ratsnest of wires that connects the SD socket to the Teensy. The wiring strategy was revised a couple of times, from bit-banged, to full SPI, to partial SPI. Partial SPI was the winner, where the MISO/MOSI/CLK lines from the DF card attach to the SPI port of the Teensy. However, the CS(SS) line of the Teensy is NOT connected to the card. That actually gets connected to some other line of your choosing. We used PD6, the LED line, so we could watch the LED flicker while transfers were taking place. Hence the nest gets rattier.
Also shown is the Xyron Disc Maker connected to port B of the logic analyzer. The test that was being run was a comparison between how often the real Disc Maker polled the status line after a write or erase, versus how often we could poll it with the Teensy. Turns out it doesn’t matter – both poll so fast it’s virtually instantaneous with respect to the 7-10mS write/erase time.
The wiring is trivial – simply connect the Xyron card to the hardware SPI port on the Atmega, with one exception: The CS pin. The card’s CS pin will NOT be connected to the hardware SPI port, but rather some other port of our choosing. The reason is to have better control over long, multi-byte transfers. Most of the command sequences are “executed” upon the rising (disable) edge of CS. So if the atmega lowers and raises the CS line automatically for each transfer, none of the multibyte commands will ever work. So in our scheme, we will lower the CS pin by writing our desired pin low. Then we will do a bunch of transfers, and finally terminate the transfer/execute the command by raising our CS pin manually.
We chose to use PD6, which is also tied to the Teensy’s LED. When the software was really slow, you could see the LED flicker in time with the transfers. It was a neat visual indicator. But after several software speedups the flicker is nearly invisible, so having it all the way over on the LED pin is kinda useless now. You could easily change it to another pin just by modifying the #define statement up at the top of the source file.
And remember, the VCC is 3.3V, not 5V! Here’s the wiring diagram.
Fig 5 – The Super-Simple Wiring Diagram
Easy as pie. It’s probably worth it to scrap the cheapo hand-wired board and just make a PCB. So we fired up Eagle free and threw down a DIP24 and the Sparkfun SD socket, which should be close enough to use just about any SD socket. Even one that you desolder from a $3.99 multicard reader. Which might not be a bad idea – same price as a single SD card socket from other vendors, plus you get a bunch of other sockets and a USB cable.
Just for trivia’s sake – we’re calling this project XYRW internally. XYron Reader Writer. You’ll see this name pop up from time to time, especially in the filenames and software. So that’s what it means.