RFID Sequencer
RFID Sequencer
Introduction
I have always like the idea of a physical music sequencer but I didn't want to make one like the other I had seen so I decided to come up with, what I believe, is a unique take on the concept an RFID sequencer. In this it is the RFID tokens that hold both the note and the instrument, and where that note is played, is controlled by where about you physically place that token on the sequencer. This is not a simple project so don't expect to build one in a few weeks. It took me six months to complete this and there were a few false starts with circuit design on the way, but the results, I am sure you will agree, are well worth the effort.
In order to make the project interesting enough, I reckoned that I needed at least 32 RFID readers, even with the low cost reader options costing about $20, then multiplying that up by 32 times was a non starter with my budget, it had to be a home constructed reader with coils. Also, RFID readers do not normally work well when they are in close proximity because the fields from each reader interfere with all the other readers, so the design had to be a bit unconventional. The tokens as well, had to be able to be mounted easily on a board and positioned quite precisely. This is because in order to achieve the reader packing density I wanted, I had to make the read range quite small.
Theory
The RFID tokens by Stanley Security Products were just the right physical shape so I built my design around them http://www.stanleysecurityproducts.co.uk/products--services/pac-proximity-tokens.html, they work in the 125 to 153KHz range. This design is for these tokens only, other types of RFID tokens can be made to work but they need modifications to the decoder circuit's component values, and also to the software that reads them.
The idea of an RFID token is that an electric field from a coil in the reader excites a coil in the token. This generates a small amount of electricity in the token and this is used to power a chip. That chip then simply switches a resistor, placed across the coil, on and off in synchronism with the frequency of the field, in a unique bit pattern. The exciting coil then can detect the load on it changing through inductive coupling, and uses that load change to reconstruct the bit pattern being produced by the chip inside the token. Hence the number in the token's chip is transferred to the reader, this number is unique to each token. The pictures here show an RFID token laminated so you can see the coil and chip.
A Physical Music Sequencer
By Mike Cook
Design
In order to have many readers working at the same time, then the conventional design is turned somewhat on its head. This is because I wanted to make this with the minimum number of components, and I also wanted to avoid the high voltages normally associated with the RFID reader signal. You can easily get 300V from a tuned resonant circuit and that sort of signal is difficult to multiplex. In my system I had one excitation coil for every 8 token positions, and I had a reading coil under each token. The 32 readers were made by having four excitation coils each driven by exactly the same signal, so the fields they produced were all synchronised to avoid any interference. The problem then, with having eight reader coils excited by one coil, is that all the reader coils are inductively coupled, which means that a token placed on one reader coil will induce its signal back into the excitation coil, and from there onto all the reader coils. The upshot is that one token appears to be on all eight of the readers. The way round this is to disable all but one of the readers in a group of eight, by shorting out the resonant tuned circuit, using a triac. Now triacs are normally use for switching mains electricity at high current to control things like heaters and lights, they are used with AC. Here, I got some small very cheap triacs BT131 and placed them across the tuned circuit. If you look at the basic diagram of my reader you will see that it consists of a tuned circuit with an 80 turn coil and a 4n7 polystyrene capacitor across it. These are rather expensive but do have very small losses, you might be able to get away with a cheaper capacitor here but I don't know. You will also see another capacitor across this marked AOT which stands for Adjust On Test, you might have to add an extra small capacitor here when you have all the readers working. The triac has a 680R resistor in the gate to limit the gate current. The output then goes through a 4K7 resistor to two catching diodes, these prevent the signal from the reading coil from going outside the 0 to 5V range so it means we can treat them like normal logic signals. The exciter coil is driven at 12V from a TC4428 H-bridge chip, this ensures the coil is driven fully positive and negative.
You will see that from the pictures of the oscilloscope traces, the signal from the token being amplitude modulated on the much higher excitation frequency. If you zoom into that excitation frequency you can see the two amplitude sin waves. Now, what I did in order to put this into the digital domain, was to turn those signals into logic signals in order to multiplex them more easily. I did try analogue multiplexing these signals, but I found that the standard multiplexers were very poor at these frequencies despite what the data sheets said. Digitising these signals by passing them through an input of an OR gate (74HC4078) of course destroys all the amplitude information on them, but fortunately the information about the token number is still there in the form of a phase shifted signal. So after digital multiplexing, the information can be extracted with a phase detector circuit.
Schematic
The schematic shown here is rather small but by clicking on the corner you can download a scalable PDF of this to allow you to see the components more clearly. If you look at the schematic, for the whole system you can see this phase detector as the three exclusive OR gates feeding into a filter. This filter removes the excitation frequencies leaving just the phase shift signal, then this is fed to a comparator where a threshold voltage is set by a pot to turn this phase shift signal into a logic level signal. A last RC filter cleans up any oscillation or ringing on the edges of this signal and is fed into the arduino / ATmega 328 chip for decoding. Note this amplifier uses the trick of having the +5V line as its signal ground to allow a split supply to be made from two single ended supplies. The arduino generates the excitation frequency that is fed to the coils and the phase detector. The arduino also feeds the 74HC42 4 line to 10 line decoders to select only one out of the eight reader coils to enable, and the 74HC151 selects which active reader from the four excitation coil sets to pass on to the phase detector. So in order to read the token, first the reader coil is activated and then each of the four coil's active reader is read in turn.
The rest of the circuit is somewhat more conventional. First off there is a PCF8574AP port expander chip on the I2C bus, this is used to drive an LCD display, this is a 40 X 2 display with orange backlighting, it is supposed to look like a retro neon display. Then there is the LED drivers, I wanted the peg that the RID token rests on to light up when it detects a token and also to allow the pegs to show what note position is currently being played. For this I used a two colour LED in the unusual combination of red / blue, giving a purple light when they were both lit. They were driven by two M5451 constant current LED drivers with 32 outputs for each chip. In order to keep the power dissipation down, the red LEDs had a series diode to drop a bit of the voltage and so prevent the chip from dropping that voltage. The brightness of each colour is controlled by a pot attached to pin 19 of these chips. This made it possible to turn the brightness down so as to be able to get a decent photograph. All too often LEDs that look fine in real life just burn out in a photograph. These chips are easy to drive as well, just requiring a clock and data signal, they work rather like four shift registers in that respect.
The output of the sequencer is MIDI notes and so the serial output is hijacked to provide a MIDI output. I prefer to drive the MIDI output with a PNP transistor, the type is not critical any general purpose type will do, I used a BC212.
Finally the power is supplied by a 12V mains adaptor. I used a switching DC to DC converter to generate 5V for the logic circuits, with two Pi circuits isolating the 12V supply for the coils from the 12V for the filter circuit.
Firmware
Well onto how I wanted it to work. With a project of this complexity I wanted to get the most out of the hardware so the system works with a number of modes and options. There has to be an enrol mode where you match up the token with the MIDI note number, velocity, and channel it should play on. There is another enrol mode where you set up what voices go on each channel and a mode to check what you have a set up. All this data is stored permanently in the EEPROM ,so once programmed up it is persistent over power cycles.
The sequence mode was really where I want to have a lot of options, and you might think with only thirty two readers then that would limit the length of sequence you could produce with it. However, my experiments with my Hexome project has shown the there is a lot more you can do with sequencers than you might think.
The simplest is just to have one position played at one time, a single sequence of 32 steps. You can also have two positions played at each time and this results in a sixteen step sequence. Finally, in this simple minded sequence, you can have up to four notes playing at once in a sequence of eight. This also sits well with the way the tokens are laid out in four rows of eight.
Now if you take the concept of having four rows you can play with the options of having a different length sequence on each row. These can be based on the numbers of polygons. This is derived from my work on Polyrhythms and Polymelodies which followed on from the Hexome project. If you want to look at the concept of this you can find a keynote presentation file here:- Poly Sequencies.key, or if you do not have the Keynote application you can get a PDF of the slides here:- Poly Sequencies.pdf. Note there are no movies embedded in the PDF like the presentation. If you want to try these concepts for yourself without building any hardware you can download the Processing files here:- Poly3.zip. So the other modes of sequencing are those based on my N connected space concept for for rows, however, unlike the earlier work where each row (or circle) represented one note, here each position can play any note depending on the RFID token. It might seem very restrictive only being able to access the first eight notes in a row but in practice this does not restrict the combinations you can get from it. The video at the end of this page shows a sequence in hexagonal connected space.
In order to manage these options there is a menu structure that navigates you round, while this seems logical, to me at least, it could be confusing so I have made a diagram of the interaction and modes. The basic idea is that the left hand button controls the menu option, the next is the accept button and the last two are increment and decrement for any parameters that might need changing. These last two buttons also have a auto mode that kicks in when the button is held down, to allow you to zip through things like the MIDI numbers.
Construction
Construction is lengthy but not overly complex. I laid out the overall mechanics like I showed in the diagram above. The dimensions are chosen so that the coil in the token sits directly over the reader coil. I made the case out of 6mm plywood and stained it with a wood staining varnish. I used acrylic rods for the pegs and drilled a blind hole for the LEDs in one end. The coils were wound on ‘I’ section styrene beams the sort used for constructing models. The reader coils were wound on octagonal formers made by gluing very short lengths of ‘I’ beam together, the angel was cut by using a Proxxon bench saw. I used 38 SWG wire for the reader coils giving 80 turns each. The long excitation coils were wound with thicker 28 SWG wire and I used 20 turns on each coil. I fixed the coil wires using the same staining varnish I used for the case, which is why they look a bit dirty in the photographs.
Each reader circuit was built on a small piece of strip board mounted with hot melt glue between the excitation coil former on small pieces of ‘I’ beam, just to lift it off the coil a little. The processor and most of the logic circuitry was built on a length of Euro prototyping board fitted with two 64 way Euro connectors, one at each end. This allowed for all the external wires to be connected to the board, but still allowed the board to be removed to be worked on. I built up one row of eight readers at a time, and tested them before moving onto the next.There is about three hours of solid wiring to get each row in place. Use cable ties to make the wiring as neat as you can, it will still look like a mess after you have, but hopefully not too much of a mess.
The software, downloadable here:- RFID Software.zip, reads the RFID places in an asynchronous manor with the playback of the sequence, so when you first put a token on a peg it might take a second or two to register, when it does the peg will light up red. A pattern of token numbers and positions is built up and when it comes to playing that position these tokens are looked up and the MIDI note is found and output. I think this is a bit inefficient and limits the output speed of the sequencer. In version two I plan to do the MIDI looking up when the token is presented and also try and speed up the reading of the tokens by tying to detect if there has been a change in peg occupancy rather than simply reading it again. Anyway that is for the future the current software can be downloaded here Note that this also includes a hacked version of the LCD library to take into account the fact that LCD is hung of the end of the I2C bus. Note not all the menu options regarding start and stop are implemented yet.
The full tune is called The Waves and can be got from Sound Cloud https://soundcloud.com/mike-k-cook/hexseq1-the-waves