Posts Tagged ‘Add new tag’

Serial Investigations 2

Sunday, June 14th, 2009

Connecting the Theremin to a computer for software MIDI sequencing
I bought a (cheap) USB to Serial converter from ebay to test how the Theremin works via USB, and was not successful getting it communicating the first time.

The Theremin requires a Yamaha CBX MIDI serial port driver to read MIDI over a serial port, and the USB converter cable had its own driver that was supposed to allow it to act a virtual serial port (COM1 or COM3 for the MIDI driver to pick up). This was the USB to serial driver I was trying to use: http://www.softwaredriverdownload.com/prolific_usb_to_serial_driver.html

To test the setup I ended up downloading two free MIDI sequencers — Rave (which is the one recommended by the kit and Silicon Chip) http://www.sonicspot.com/rave/rave.html The URL from the article is dead, this is the new location for the Rave sequencer.

And another one called Anvil, which has a good test mode showing all the MIDI commands received. http://www.anvilstudio.com/ The interface on Anvil looks neater, but Rave may have more features — I have not bothered to use either as sequencers yet, I just want something to trigger the MIDI samples.

For some reason, the signal coming from the Theremin was very sporadic — there would be a burst of data that would register as some sort of MIDI signal in Anvil, but none were actually note on signals, so all was silent.

I tried to find and download a free serial comms monitor to check what kind of signal was coming from the RS232 -> USB -> Virtual Serial port.  People seem to want to charge ridiculous amounts for serial monitors, some up around ~$200?, and there are a surprising number of commercial ones out there. The best I found was a trial limited version of something called Bill Serial Monitor that worked for 3 mins before quitting. The full version is $95 USD. After a short time I got sick of dealing with other people’s software the trial limits and spent 2 seconds writing something in Processing to read and output the contents of the serial port… which is what I should have done in the first place. I used Processing because it was convenient on my laptop, almost any language should let you do the same thing… If anyone is interested in what I wrote to do this, leave a comment and I’ll post the code. It’s not very special, but seriously, don’t spend ~$100 on a serial port monitor unless you REALLY know what you are doing and have a need for whatever extra features they offer — I obviously don’t know enough to understand what that might be… For casual debugging, just read the serial port using a couple of lines of code.

The outcome of the monitoring was that data was coming in one burst when the theremin was switched on, then nothing. After too much mucking around, I gave up and decided that going through two drivers, and unknown MIDI software had too many unknowns, so I’d try a direct RS232 serial connection and see if that worked.

This required ordering another cable from ebay — they are so much cheaper than what they cost going into a store in London. Ebay is under £2, a store charges £12-£17 for the same thing. It also required a laptop old enough to actually have a serial port, which I happened to have lying around.

Setting that up worked surprising well, considering my ‘creative’ reworking of the MAX232 chip and serial port (see photos in a previous post).
Here are the steps I took:

  1. In the Control Panel (Win XP) > Sounds and Audio Devices > Audio tab, make sure that MIDI music playback is set to ‘Microsoft GS Wavetable SW Synth’ (which it is by default)
  2. Install the MIDI sequencer, Rave (http://www.sonicspot.com/rave/rave.html) — this one actually supports MIDI bank and instrument changing from the Theremin. Anvil (http://www.anvilstudio.com/) only seems to play whatever instrument is selected in the software and ignores the Theremin selection. This does mean that you can use other MIDI instruments though.
  3. Plug in the MIDI Theremin using a RS232 serial cable, and switch it on.
  4. Download, install, and configure the Yamaha CBX driver, cbx200w.exe, from http://www.global.yamaha.com/download/cbx_midi/index.html
    and select either COM1 or COM3, whichever is a free serial port. I used COM1 as the laptop only had one serial port.
  5. Restart the PC
  6. Run the MIDI sequencer of your choice (if using Rave, make sure the Option ‘MIDI Thru’ is enabled to hear the Theremin’s output)
  7. Wave your hands about, and if your Theremin is tuned according to the kit instructions, you will hear a cacophony of piano key runs …. At least that’s what I heard :)

So, I now have a working MIDI theremin!

I tried again to get the Prolific drivers working again — after trying a number of versions and third party replacements, I was only able to get the ones that came with the install CD to work without the Code 10 error.
Even with this claiming to work, the serial port was only showing data for short bursts with the Theremin on. It seemed like the data stream was being cut off after a short while once reading started. Every time I started to read, I would get a burst of between 1 and ~100 bytes.

So, still no luck with USB there. Buying a cheap cable may not have been the best idea, but apparently the Prolific chip is commonly used for USB to Serial, and works perfectly for many applications, just obviously not this one. My next option is converting TTL to USB myself.

The chip I plan to use to perform the direct TTL to USB conversion is the FT232RL from FTDI (http://www.ftdichip.com/)

Datasheet: http://www.sparkfun.com/datasheets/IC/FT232R_v104.pdf

The FT232RL is a surface mount component, but it has exposed surface mount pins which could be soldered by hand. This is the chip that handles USB communications on my Freeduino (a Arduino clone kit I purchased from NKC Electronics)