Archive for the ‘Electronics’ Category

Rancilio Silvia Espresso Machine Water Level Alert

Sunday, August 16th, 2009

This is something I have been wanting to put together for a while.

I have the Rancilio Silvia (2009) Espresso machine, which is a great coffee maker, but one of its (minor) problems is that there is no indicator when the water level is out, and it is somewhat inconvenient to always check before making a cup. Especially when it is positioned under kitchen cupboards and has to be slid out for re-fill.

I had a brief search for descriptions of similar mods online, but didn’t find anything. All I found were people complaining about the lack of water level indicators, or mods which added temperature PID mods (http://coffeegeek.com/forums/espresso/machinemods/139192), or Arduino based Wii-nunchuck mods that still didn’t tell you if the water was out (http://www.engadget.com/2008/04/21/rancilios-silvia-espresso-machine-gets-hacked-via-the-arduino-a/)…. so I went and solved the problem myself.

DISCLAIMER: I take no responsibility for anyone damaging their coffee machine, or any other electronics from trying to copy this. What you immerse in your coffee machine reservoir is your own responsibility. This documents what I did to my machine, and what has worked for me, I can’t guarantee you’ll have the same success if you try and replicate any of this…. so don’t try unless you have some idea of what you are doing, this is pretty simple compared to some of the things you could add or do to your coffee machine, but I’m sure there are plenty of ways it could go wrong…. Seriously, don’t break your Rancilio!   That said, if you do try anything similar that works well, I’d be interested in knowing your approach too.

Investigation

I thought up a number of methods to meter the water level –

  1. Capacitive sensing — which would hopefully mean no parts actually in the water, the sensor could be placed on the outside of the water container and stay dry. I may look into this further, it would require quite a bit more research to see if it practical. I would expect to have to use an Arduino to read and calculate water level from capacitance.
  2. Pressure sensors — These can be placed at the bottom of a tank to measure the exact level of a water tank — see this project for details:  (http://www.practicalarduino.com/projects/medium/water-tank-depth-sensor). I expect it would work for a coffee machine reservoir too, but may be overkill. I decided I didn’t really care how full it was, I just wanted to know when I should refill it.
  3. Optical sensors — using some sort of IR reflector on the water surface and measure the brightness to determine how close the water is to the top. This would also mean no parts are immersed, but would require calculation, and a lot of calibration. I don’t even know how well this would work, again, I never got around to pursuing it further.
  4. Physical (float) switch.

Using an Arduino just to control one LED to let me know I was out of water seemed excessive — I’d want it do pretty much _everything_ else — temperature monitoring, remote control, LCD displays, social networking, and whatever else anyone has got a coffee machine to do with an Arduino. I mention these other methods above in case someone else wants to run with them, or has any experience with constructing anything similar, I’d be interested in knowing whether they could work.

My Solution

The simple option I went with that does the job is to use a float switch that turns on an LED when the level drops below a certain point. The circuit is broken when the water level is sufficient, so no power is drained from the battery. The only concerns were that the battery does not get hot from the machine heating, or wet from the steam and water. Oh, and also that the float switch doesn’t leach carcinogens into my coffee….

I bought a small float-switch off ebay. These things can be configured by turning the float around so that the ‘up’ position changes between on and off. There is a little magnet moulded into the plastic float, and a reed switch inside the rod it floats on.

It came with a rubber washer and the wires sealed up with (presumably) water proof sealant. It is designed to be mounted through a hole and then screwed into place. The thread and washer diameter was 5mm. I bought a short length of 5mm plastic tubing and heated the end of the tube with hot water to expand it, and jammed it over the end. I then pushed the solid plastic washer back down on it to further jam it together. Once cool the seal seemed to hold. I tested it in a glass of water before dropping it into my coffee water supply.

Here is the basic circuit diagram,

Rancilio Silvia Espresso Machine Water Level Alert Circuit Diagram

and some photos of what it looked like, when it was all alligator clipped together to test the concept — which showed that it worked nicely, and once I soldered the parts together.

The extra button is for testing that the battery is good once it is in place, and because I thought that if anyone asked what the hell all those wires sticking out of my Rancilio were; me answering with “a water level alert for my Espresso Machine” isn’t as exciting as showing the spooky Violet light bar that lights up when the water is out. The push button lets me do this without running the tank dry each time. The whole point of this was to prevent me from opening the water reservoir unless absolutely necessary. It also lets me check taht the battery isn’t dead.

The LED is violet, with a 2.something voltage drop. I am using it quite bright with only a 330 ohm resistor. Something higher would make the battery last longer, but since I don’t expect it to be on much it shouldn’t matter. The ‘light channel’ is just the clear plastic body of a pen that was lying around when I slapped all this together. I made all the wires about 30cm long, and the tubing about 25cm. I’d actually make the wires longer as there was less room to manoeuvre the tank and the battery in place with the wires and extra tube, which surprised me. There isn’t much room to fit anything larger than another 5mm tube through the gap from the main body to the water tank as there are already the water intake and steam outlet hoses (which are also about 5mm diameter).

I put the battery and a little proto-board where all the wires are attached in a plastic bag with a moisture absorbing gel sachet (again, it was lying around and I thought it might do some good) and used a twist-tie to secure it a bit against moisture and contact with the metal case.

The whole thing works pretty well — I could probably do more with the presentation, but the basic concept seems sound. The float switch could trigger anything, so I could attach any number of lighting mods or other alert things to it if I feel like a MK2.


Design Considerations:

  • 9v supply because I didn’t want to touch the coffee machine power supply as it is all mains level, I’d need a transformer to mount inside the machine, and again, too much work for what I was trying to achieve.
  • No power consumption during normal coffee machine operation.
  • Didn’t want to stick anything in the water supply. Oh well that didn’t happen… I’ll look at capacitive sensing some other time maybe.
  • This sensor is super cheap. (the float-switch was a pound or two)
  • Small parts — not too much room in the case and it does heat up, so having plenty of room left for air circulation is good. Also - doesn’t interfere with refilling.
  • No unnecessary control logic for a really basic function.
  • No permanent alteration to the machine. The whole float switch assembly just lifts out, and if it does fail at some point there is no harm done.
  • Everyone loves adding LEDs to stuff, but blue has been done to death. These violet ones seem to have a red and a blue LED. If they are under-powered they shine red.

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)

Serial Investigations 1

Sunday, May 24th, 2009

The MIDI-Theremin kit uses a MAX232 chip to handle serial output, via a DB9 connector on the main board.

There is also standard MIDI out, and the old MIDI via gameport, which I am not bothering to install as I don’t have any receiving hardware with a gameport, although I have soldered the opto-isolator (IC3: 6N139) to the board, I’ll remove it and re-use when I find a need for one.

The Theremin’s PIC16F628A microcontroller outputs serial on pin 11, which goes to :

  • pin 5 of the MIDI connector (via 220R)
  • the gameport optocoupler
  • pin 11 of MAX232 (TTL Driver 1 input)

The MAX232 outputs RS-232 on pin 14 (Driver 1 output), which goes directly to pin 2 of the DB9 connector.

The Silicon Chip article states that a serial to USB converter can be used to connect the Theremin to a PC, I am hoping to eventually build in direct USB output.

Using a serial to USB converter cable, or even disassembling one and mounting it in the case, means that the serial signal is converted from TTL (5v) to RS-232 (-10V / 10V) to USB (~+/- 3V/5V?)

Removing the RS-232 chip completely and going directly from TTL to USB is the direct method.

First steps: mounting the MAX232 on a breakout board to test the kit as intended (before I potentially damage it with a mod), this also separates the RS-232 components completely from the main board so that I can swap in and out other serial output circuitry easily.

Breaking out the MAX232:

Three wires are required from the main PC to the breakout board:

  • Ground
  • TTL serial output from the microcontroller pin 11
  • +5V power for the MAX232.

When I first assembled everything, I only had only two wires coming from the main board, I had forgot the +5V supply line. There are a number of tests for the data output in the kit instructions. The voltages I measured without the supply were obviously much lower than they should have been.

The DB9 connector is attached to the breakout board by only two wires. This is a basic transmit only serial implementation. The MIDI-Theremin does not receive anything from the connected PC.
Here are the layout and connection points for the MAX232 breakout. This circuit may be useful for other RS-232 experiments/projects:

MAX232 Breakout layoutconnection points to MIDI Theremin PCB

I have soldered the DB9 pins directly together on the underside of the DB9 PC-mount right angle connector using short lengths of shielded and unshielded wire, being careful to avoid unintended shorts. The whole thing is held together with a rubber band, and shielded with a square of cardboard. It’s a bit messy, but compact, and hopefully only temporary.

With everything assembled (including the +5v supply wire!) and powered on, I am now reading the correct test voltages on the MAX232.

  • +5V at pin 16
  • -8.53V at pin 6 (ideal = -9V, but seems to be acceptable?)
  • 9V at pin 2 (up to 9.6V is acceptable)

breakout_topsidebreakout_underside

MAX232 info and pinout:
http://en.wikibooks.org/wiki/Serial_Programming/MAX232_Driver_Receiver
http://www.datasheetcatalog.org/datasheet/texasinstruments/max232.pdf

RS-232 serial pinout:
http://www.lammertbies.nl/comm/cable/RS-232.html#pins

Next post: TTL to USB plans using the FT232RL chip.

Jaycar MIDI-Theremin

Monday, May 18th, 2009

I recently finished assembling all the parts of my MIDI-Theremin kit and powered it on — it appears to work!

Here are some photos of the various sections, and the assembled kit undergoing testing and tuning. This is not properly assembled for presentation — but all the electronics are connected and it should work. I still have not decided how much effort I am going to put into the case and final presentation. That depends on how well my other mods turn out, and how much use I imagine I’ll get from a MIDI-theremin after trying it out.

I bought this kit from a Jaycar in Sydney at the beginning of the year. I have previously assembled a basic Jaycar theremin kit, which was easy enough to build, had a few improvements to the design which I found online, and was quite fun to play with. Currently that is in storage in NZ. I was going to buy another so I could use it in the UK, but was eventually convinced that I should ‘upgrade’ to a MIDI-theremin. To be honest, I am not fully convinced that a MIDI-theremin is a good idea — it seems to lose all the interesting analog advantages and coolness factor of the body-capacitance modulated sine waves from the ether. It does add MIDI, but then I have never been that excited by MIDI, I believe some people are, and I’m sure there is lots that can be done with it — this will be my chance to find out.

The basic Jaycar theremin kit is still available from Jaycar for AUD $59.95 (CAT. NO. KC5295). The MIDI version seems to be discontinued, but I bought mine for AUD $159.95 (yes, that’s quite a bit more!). The kit number is/was KC5410, and the Silicon Chip magazine articles that cover its construction are in the April and May 2005 editions. I just have the reprinted articles that came with the kit. The store I bought mine from in Sydney actually had a couple more on the shelves back in February, but they were in the process of taking them off their catalogue.

I couldn’t find much info on the web from anyone else who had assembled this kit. Some people had heard of it, some people had ordered one and had yet to construct it. I could not find any actual reviews of how good it was, or of any suggested mods or improvements. It also appears that this kit has been discontinued by Jaycar, so there might not be much more info forthcoming. Hopefully my writeup will be of interest to anyone else who has this kit, or has heard about it and wants to know more.

My planned mods:

Volume plate
— the aluminium volume plate that comes with the kit is quite ugly, and not really that substantial for playing, and looks nothing like a professional theremin volume loop.
For my original kit theremin I used some number 8 wire I had lying around (seriously :) ) to make a template / mock-up volume loop based on photos of pro-theremins (like the Moog Etherwave) that fitted with the kit’s plastic casing. The plan was to make a wooden case and get some metal tubing and shape it to match the template, but the wire fit perfectly in the case and looked ok, and was comfortable to play, so I kept it. I plan to start with the same kind of loop for this one, and potentially upgrade the whole case. The midi-theremin’s current silk-screened plastic top is nicely made, but does not scream ‘professional’.
For this current incarnation I have improvised No. 8 wire from a coat hanger. It’s not quite the same, but will do in a pinch.
I appreciate my current solution isn’t the most aesthetic either, but I feel it’s a step in the right direction.

USB Output
The kit comes with MIDI, serial (RS232), and Game Port output. There is no direct audio output.
I currently don’t have access to a desktop PC with serial ports, and only 1 old crappy laptop that happens to have a DB9 port. USB would be far more useful to me, and in place of having a converter cable, I’d like to have all the required electronics within the unit.

I considered a number of ways to get this functionality, and did a bit of research on various cables and chips which may be useful to others trying to do similar things with other devices. Currently I have all the RS232 circuitry on a temporary breakout board to test the original design, and how it works with a USB to RS232 cable I have. There are some warnings in the original Silicon Chip article about USB comms and drivers, so I want to try it out before making any permanent mods.

Creating custom MIDI patches for use with a theremin — something I’ll think about when I have the hardware sorted!

Upcoming post on my USB / RS232 investigations, and more details and comments on the kit.