Analogue Input Board for the Pressure Sensor (Espiresso)

Having added a pressure sensor to my Espiresso Machine, I needed an analogue input to be able to read the output voltage from the sensor. Unfortunately, the Raspberry Pi doesn’t have analogue inputs, so an external ADC is required. I settled on the Adafruit ADS1015 which has 4 inputs, 12-bit resolution, includes a programmable gain amplifier, and also uses an I2C interface:

Adafruit ADS1015

There’s some useful information on how to set up I2C on the Pi on the Adafruit site. Having done that, there is sample code available to read the sensor from Python or C. With this, it was pretty easy to get readings from the sensor, and it seems to perform well.

The pressure sensor uses a 5V supply, and has a ratiometric output which ranges from 0.5V to 4.5V, proportional to input pressure. It has a 0-300 psi range (20.68 bar). The absolute maximum analogue input for the ADS1015 is VDD+0.3V. If we are running the ADS1015 from 3.3V for compatibility with the Pi I2C voltage levels, this limits the analogue input voltage 3.6V maximum.

Theoretically, the Ulka EP5 pump can develop up to 15 bar pressure, although this is limited by the OPV in the machine to 9~10 bar. If we assume the maximum pressure is 10 bar, and the response is linear, this would result in a maximum output voltage of:

4V x (10/20.68) + 0.5V = 2.4V

So it seems that for normal use, the output voltage should be below the maximum analogue input voltage limit of 3.6V. Even if we assume peak pressure of 15 bar is possible, that would be a maximum output voltage of:

4V x (15/20.68) + 0.5V = 3.4V

Based on these calculations the current plan is to interface the pressure sensor directly to the ADS1015.

The next step was to interface the board to the Pi in the Espiresso. Unfortunately, the SCL and SDA pins on my Pi are already used as inputs to read the two front panel buttons on the machine (using one GPIO per button). Also, almost all the other GPIOs are in use, so there was no free GPIO available to relocate the buttons.

To make the SCL and SDA lines available for the ADC, I decided to use a resistor ladder to read the buttons. This will make it possible to use a single analogue input to read all the buttons.

I’m also planning to use an opto-coupler to signal the Pi when the brew (pump) switch is switched on. Since that has an open collector NPN output, I plan to connect that to the resistor ladder also, so that it can be treated as another button input.

The pressure sensor and button input will only use 2 of the 4 analogue inputs, so there will be some inputs spare for future use.

Ulka EP5 Pump PWM Pressure Modulation

Recently I’ve been experimenting with using PWM to control the pump pressure in my Gaggia Classic. People have used various methods to control the pump pressure, ranging from triac/thyristor dimmers to using series resistance. A few have used PWM (notably Jonr on CG forums), and this looked by far the best solution, so I decided to use high frequency PWM with an IGBT. This would need to be opto-isolated so it could be driven safely from the Raspberry Pi.

I started off looking at the HCPL-3120 optocoupler with gate drive outputs. There are hundreds of suitable IGBTs. However, as I started sketching out the design, including 15V supply etc. it seemed a lot of components were needed for this solution. Instead, I decided to look at using an IGBT with logic level gate drive to simplify the design, preferably one with a TO-220 package. It turns out that there are very few which meet those requirements, so I’ll list them here in case it helps someone else:

  • IRGB14C40LPBF (430V / 20A) from IRF
  • ISL9V3040P3 (21A) and ISL9V5036P3_F085 (46A) from Fairchild
  • STGP18N40LZ (30A) from ST

From that list, the only one I could find at reasonable cost without importing was the IRGB14C40LPBF, so I settled with that one.

To safely interface with the Raspberry Pi, I use a 4N25 opto-isolator with a 270R series resistor, which is driven directly from a 3V3 GPIO pin (tested at a little under 8mA). Note that the series resistor would need to be increased for 5V input.

The NPN output of the opto-isolator is inverted by a BC556 PNP transistor to switch the IGBT input through a 1K series resistor.

The power supply is the VTX-214-003-105. This is a compact module which provides 5V at 600mA from 90V-240V AC mains input. Caution: in this circuit, note that the DC output GND is connected directly to mains NEUTRAL, meaning that the 5V and GND lines in this circuit are not isolated from the mains. This means that they should be insulated and boxed up.

On the output side, the IGBT is wired in series with the pump. There’s a series diode to prevent AC passing, and a flyback diode in parallel with the pump for protection.

Here’s the current circuit diagram for this design (to be used strictly at your own risk):

EP5 Pump PWM with IGBT

To test it, I built a small prototype on strip-board. Note that the IGBT is separate, as I plan to mount the board inside an enclosure, and mount the IGBT externally. Ultimately I would like to make a custom PCB for this. After extended testing, the IGBT is absolutely stone cold so the heat-sink appears redundant.

Pump PWM Prototype

Since I’m using the Raspberry Pi’s one and only hardware PWM pin to drive the boiler, I used the excellent ServoBlaster which provides high resolution software PWM on any GPIO pin. Initially I set this up for 1kHz PWM, and varied the duty from 0% to 100%. For example, to set up 1kHz PWM on GPIO pin P1-22 and using the PCM hardware, you would use:

sudo ./servod --pcm --cycle-time=1000 --min=0% --max=100% --p1pins="22"

To set up 50% duty cycle on that pin, you would use:

echo P1-22=50% > /dev/servoblaster

Before testing this with the pump, I tested with a 60W incandescent light bulb and series diode. Adjusting the duty cycle allowed the lamp to be smoothly and precisely dimmed. The average voltage drop across the IGBT was around 0.33V and (after fully disconnecting mains power) it was cold to the touch.

I then moved onto testing this with the EP5 pump. For easier testing, the machine was temporarily rewired so that the brew switch supplied power to the entire circuit above, so that I could kill power if needed, without relying on the IGBT alone.

Using a Portafilter pressure gauge, the pump was tested at various duty cycles from 0% to 100%. I found that the pump only seems to start operating at about 30%, and then pressure rises to about 1 bar. Increasing the duty cycle allows the pressure to be controlled quite easily between 1 to 9 bar (or wherever your OPV is set).

So far I’m really pleased with performance. The next step is to box it up and wire it in more permanently. I’m also thinking of adding a small SSR to switch the solenoid. Once I’ve done some further testing, I’ll upload graphs of duty cycle versus pressure.

Update: check out the slightly amended design here which replaces the BC556 with the TC426 driver.

NVIDIA 3D Vision Pro and VESA Stereo Sync

We ran into problems recently getting the NVIDIA 3D Vision Pro glasses to work on a dual-pipe stereo projector (clone mode stereo). The projector takes two DVI inputs, one for the left and one for the right eye at 1920×1080 and 60Hz. These are then displayed frame sequentially at 120Hz. The projector has the standard BNC connector which outputs the stereo sync signal for the glasses (Sync and Ground).

The NVIDIA RF base station (pyramid) has a 2.5mm stereo jack socket which accepts external stereo sync, so we tried feeding the projector sync into that input. Unfortunately, the pyramid seemed to ignore the external sync and wouldn’t activate the glasses…

We had the NVIDIA pyramid working well on another system in active stereo, using the 3-pin VESA sync output from the graphics card, so I decided to test that. This is what I found:

  • When running at 120Hz active stereo, the Sync signal is a simple 5V square wave with 50% duty cycle of around 8.33ms high and 8.33ms low, exactly as you would expect.
  • The LED on the back of the pyramid lights up blue when it’s using external sync, green otherwise.
  • When using active stereo, the Sync light only illuminates when stereo is activated (i.e. when running a stereo application)
  • 5V power is always present on the 3-pin VESA stereo connector.
  • If the 5V power is removed, it ignores the external SYNC input. Using only SYNC and GND is not enough to get it working.
  • Once it has switched on and started accepting external Sync, I tried disconnecting the 5V power: the blue LED stayed lit. This suggests it only checks for presence of 5V at start up.

This is what the Sync LED looks like when the unit is persuaded to accept external sync:

NVIDIA 3D Vision Pro Pyramid

The solution was to make a cable which combines the Sync output from the projector with 5V (taken from USB) and Ground onto a standard 3-pin mini DIN VESA stereo connector (pinout shown below). The picture above shows the cable (white Y-shaped cable) taking Sync via a BNC connector (the T-piece is used to connect another IR emitter in parallel) and the connectors on the right are the 3-pin mini DIN stereo cable, which goes to the 2.5mm jack sync input on the NVIDIA pyramid.

This is the pinout of the VESA Stereo 3-pin mini-DIN socket:

 VESA Stereo 3-pin DIN

 And here’s the corresponding pinout for the NVIDA 3D sync jack:

NVIDIA 3D Sync Jack Plug

Caution: the jack plug isn’t a great choice of connector for something carrying GND and 5V, as there is obvious potential for a temporary short when the plug slides in and out of the socket. Avoid connecting/disconnecting the jack when the system is powered up. It’s safer to disconnect the USB and mini-DIN plugs.

Brother MFC-8860DN Fuser Replacement

We have one of those multi-function scanner/printer/fax/copier machines at work, the Brother MFC-8860DN. After a few years of faithful service, it started displaying “Fuser Error” and refused to print. We needed a new one fairly urgently, so I immediately bought a new HP one as replacement, but I wasn’t quite ready to send the old Brother to the graveyard and decided to try replacing the Fuser.

Having switched off the power, I pulled the back cover off the printer and located the fuser unit. This wasn’t too difficult to get to: there are two panels which pop out, two screws to remove, and two more covers to gain access to the connectors for the heater and sensor cables.

The picture below shows the panels/covers to be removed. The Panels A and B can simply be popped out by bending one of their plastic “hinges” at either the left or right hand side. The cover C is held on by one cross-head screw, and the cover D simply pops off if you push on the spring tab (near the letter D below). Having removed cover D, you will gain access to another cross-head screw. After removing those two screws, and disconnecting four cable connectors, the Fuser can be lifted out of the printer.

Accessing the Fuser

The Fuser is basically just a heated roller, so there are only a limited number of things that could go wrong. For example, it could be a loose connection, a burnt out heating element, or a faulty sensor.

At the left hand side there are two fairly thick cables with spade connectors, and the cover has a temperature warning sticker. It seemed fair to assume these were the heater terminals…

MFC-8860DN Fuser Heater Terminals

Having pulled off the two spade connectors, I measured the resistance and they were open circuit. Concluding that the heating element had burnt out, I ordered a new Fuser unit (Brother LU7941001).

When the new unit arrived, I measured the resistance across the same two terminals and found about 4.5 ohms. So, if you have access to a multimeter, this is a simple way to test if the heater element has burnt out.

When the new unit arrived it was a simple job to reinstall. If you are attempting this job, there are a few final things to be aware of:

  1. The new Fuser will arrive with its pressure roller set in the “low nip pressure position”. Basically, before installing, you just need to push up on the two blue tabs to release two spring loaded levers. There are (poorly) illustrated instructions included with the Fuser.
  2. Replacing the left hand cover (C) in the picture above is a little bit fiddly. It has two tabs which slots into a couple of holes in the side panel, then needs to be pushed down and rotated backwards to get the screw hole to line up.

The printer then needs to be told that the Fuser has been replaced, and I found out how to do this here. Enter the maintenance menu by pressing MENU * 2 8 6 4 with exactly the right timing (about 1 second per button push). It took me several attempts to get this to work. Another way is to hold MENU while you power on the machine. From maintenance mode you then:

  1. Select option 88 which is ‘Part Replacement’
  2. Scroll to ‘Fuser’
  3. Press OK or Start.
  4. Select option 99 to exit the menu and restart

Having done this, the printer was back in operation again!

Shuttle PN15 Wireless not installed/detected on Ubuntu

I have an old Shuttle PC (SB75G2… I think) which I seldom use, and decided to recycle it to drive a small CNC mill that I’m building. The first step was to wipe off Windows XP and install LinuxCNC (which is built on Ubuntu). The PC runs great but, unfortunately, neither the built in Ethernet or Wireless card worked out of the box.

This really surprised me, as  network and driver support in Ubuntu seems to have improved a lot since the early days, but there are clearly still some gaps in the range of supported devices.

The wireless module is a PN15, and a quick search didn’t turn up many hits, but eventually I found a solution, so thought I’d write it up here in case it helps someone else in the same position.

The wireless module is connected internally via USB, so first I tried lsusb and got the following back:

$ lsusb
$ Bus 001 Device 002: ID 124a:4023 AirVast

This led me to a forum post which said it was supported by the p54usb module built into the kernel, but it needed proprietary firmware downloading. If you have a network connection of some kind, you can do this apparently (haven’t tried yet):

$ sudo -i
# apt-get install linux-firmware-nonfree
# modprobe -r p54usb
# modprobe p54usb

In my case, I didn’t have any network at all, but instead found these instructions pointing to a download link to a firmware file:  https://wiki.debian.org/prism54

Mine turned out to be a first generation device with the ISL3886, so I downloaded the firmware as follows:

$ wget https://daemonizer.de/prism54/prism54-fw/fw-usb/2.13.1.0.lm86.arm --no-check-certificate

Then I copied that file over to the Shuttle with a USB stick, and moved it into the firmware folder, and reinserted the module to load the firmware:

$ sudo -i
# mv 2.13.1.0.lm86.arm /lib/firmware/isl3886usb
# modprobe -r p54usb
# modprobe p54usb

Having done this, the wireless came up and I was finally able to connect. As I write this, the PC is busily updating itself…

Renault Modus: Flashing Headlight Fault or Indicator Fault

Our Modus recently developed an alarming fault, where the dipped headlights or full beam flash on briefly when using the indicator stalk, or going over a bump in the road… not good! It could be pretty dangerous if someone thinks you’re flashing to let them out at a junction. This is the second time this has happened to us, so I thought I’d explain the cause and how I fixed it.

Basically, the problem was caused by a wire snapping off where it enters a connector inside the indicator stalk housing. Every time you move the indicator stalk, it flexes the wiring and after a few years it breaks due to fatigue on the wire. Here’s the offending wire, which you can see has broken free of the connector:

modus_stalk_wiring1

These are insulation displacement connectors, where the wire is pushed down between two blades. These pierce the insulation and make contact with the wire. Obviously, they also act as a nice point of stress to encourage the cable to fracture as it is flexed.

This is low-voltage logic wiring, and doesn’t carry much current judging by those tiny wires. It probably connects to some kind of digital controller and  uses MOSFETs to switch the lights.

Anyway, this is the second time this has happened on the same car, with about 2 years between occurrences. The first time, it was the right-most pin (as shown above). That previous repair is still good, but this time the wire next to it has failed.

Update: in June 2015 the right indicator stopped working. Again, this was due to a broken wire (the third one from the right this time). This was fixed in exactly the same way, as described below. Since I first posted this in April 2014, that’s just over a year gone by since the last repair.

You might find that several wires have broken simultaneously on your Modus (as Moss mentions in the comments below). The good news is that all of them are wired “straight through” so that pin 1 is connected to pin 1, pin 2-2, pin 3-3 etc. for all ten wires, so you should be able to reconstruct the correct order!

To begin with, I disconnected the battery as a precaution before carefully disassembling the housing round the steering column. Pop out the lower light grey plastic panel around the steering column (pull the top section towards yourself) to make it easier to access. There are two Torx T20 screws beneath the steering wheel housing, and the rest is snap fittings. The lower section of the housing can be lifted free (you may need to move the steering height adjustment lever to remove it).

2016-10-06_modus_steering_cowl_screws

Here’s a view of the steering height adjust release lever on the 2006 Modus. I had to release this lever before I could lift the housing off:

2016-10-06_modus_steering_height_adjust

The upper section of the steering housing doesn’t need to be fully removed, but can be lifted out of the way. The indicator stalk module unclips and slides out of the steering column (that part at least is  a surprisingly nice piece of design).

To fix the broken wire, I soldered in a short length (about an inch) of new cable to extend the broken wire so it will be under less stress, and insulated with heat-shrink tubing:

modus_stalk_wiring_repair

If you are considering doing this job, it’s probably worth adding that you need access to a soldering iron and some heat-shrink tubing (the wires are quite small, and would be hard to join by crimping I think).

Note that the distal end of the wire (which will go into the connector) is the original wire, to ensure it is the proper gauge for the connector. I gently picked out the remains of the broken cable from the connector with a pin, and pushed in a fresh piece. I then tested all pins for continuity, and all was good.

Again, if you are planning on doing this, be aware that the connector is fairly small and it’s fiddly to get the wires in (these connectors are not designed to be repairable – just intended for a single use / factory fit). It is possible though, if you have patience 🙂

Here’s a shot of the front side of the repaired connector. Note the black heat-shrink tubing on the repaired wires:

2015-06-08_modus_stalk_connector_front

Here’s a close up of the rear of the repaired connector, showing the wires pushed in between the blades of the IDC connector:

2015-06-08_modus_stalk_connector_rear

This is what it looks like when re-installed inside the indicator stalk module. Note that the central part (with the PCB and connector) is mobile, and moves when the stalk is used.

Modus Indicator Stalk Wiring

Here’s another shot of the internals of the indicator stalk assembly and wiring:

2015-06-08_modus_stalk_internals

Finally, here are some images showing the indicator and headlamp stalk units completely removed, showing the wiring loom between them:

2015-06-08_modus_stalk_assembly

And here’s a close-up image showing the connector on the headlamp stalk unit fitted:

2015-06-08_modus_stalk_connector_fitted

Having reassembled it, I did a complete test of all the lights and it all works fine again. Well, until next time at least!

Further investigation of the connectors…

So far the “zero cost” fix above has worked for me… but I was curious about the type of connector used, and whether the whole assembly could be replaced with new parts. Looking at the photo above, I noticed the connector has “JSTDF” printed on it, which made me suspect this is a JST connector. After a bit of searching on their web-site, I found the KR connector and CK connector, which look similar:

jst_kr_connector

These are 2mm pitch IDC connectors, and the 10 pin version would be 22mm long. I haven’t actually checked if this is compatible, as our Modus is working fine and I’m reluctant to take it apart again just to measure the pitch/size of the connector!

Anyway, the JST datasheet says that the housings are “Compatible with the PH crimp style connector”  which is interesting, because crimp connectors and tools are cheap and easy to use, so it might be possible to make a new 10 way cable using these. Again, I’ve not checked if these are compatible but RS have the PH connectors and even have ready made cable assemblies. Here are some direct links to the components on the RS web-site:

  • JST PHR Series 10 way housing (RS 8201462)
  • JSR Crimp contacts (RS 8201456)
  • JST Cable assembly 300mm length (RS 8201412)

If these connectors are compatible, this would be another possible fix to consider!

Nano Tabs and Line Numbers

To make the nano text editor nicer to use for development, you can change the tab size to 4 spaces, set it to convert tabs to spaces, make it always display line and character numbers and enable multiple file buffers. Since I always forget how, here are the settings that go in the ~/.nanorc file:

set tabsize 4
set tabstospaces
set const
set multibuffer

The multiple file buffer feature is really useful, as you can load multiple files with CTRL+R and quickly switch between them with ESC follow by > or <.

Sometimes you need hard tabs (in a Makefile for example). To achieve this, the -I flag can be used to ignore the .nanorc file for Makefiles:

nano -I Makefile

The Pressure Sensor Arrives…

After much searching, I found a reasonably priced pressure sensor for my project. It’s a Danfoss AKS 32R, which has 0-300psi range (20.68 bar). It takes a 5V supply, and the output is analogue ratiometric, ranging between 0.5V and 4.5V DC.

pressure_sensor_danfoss_AKS32R

No prizes for guessing where I plan to install this sensor!

This is an ebay special, so the first challenge was to track down some more detail on the sensor. The male thread is about  16mm long, and has 8 tracks in 11.4mm which is about 18 TPI. It clearly tapers, and the thread OD is about 13.3~13.8mm, so it looks like a 1/4-18 NPT thread.

I was keen to see if the sensor worked, so I tried hooking up a meter and blowing into the end. This produced a miniscule change in output voltage. After a bit of  research, it seems that maximum lung pressure during exhalation is only about 2.1psi for an adult male, which is less than 1% of the sensor’s measurement range. Hmm… that explains why it didn’t give much of a reading then!

Quite a bit of work will be needed to plumb this in. I might need to fit a pulse snubber to protect the sensor. To be continued…

Replacing the Gaggia Classic Coffee Thermostat with a TSIC 306

For some time I’ve been using the DS18B20 to measure boiler temperature, but decided to upgrade to the TSIC 306 which has a wider temperature range and faster update rate.

The TSIC 306 is a fairly small TO92 package (about 4.5mm wide, 2.2mm thick and 4mm high) so I decided to try encapsulating it in an M4 hex M/4 spacer (as suggested here). This worked out pretty well, as shown below, pictured alongside the original thermostat from the Gaggia Classic.

tsic306_vs_tstat_h300

The spacer is M4 Aluminium, 20mm high, 7mm across faces, male to female (Richco HTSA-M4-20-2, Farnell 1898535). The male thread has been filed down to about 6mm length, to match the existing thermostat.

I drilled out the female thread in the spacer with a 4.5mm bit to 15mm depth, filled with heat transfer compound and pushed the sensor deep into the spacer. The three sensor leads are individually insulated with heat shrink tubing, and more heat shrink is used to encapsulate the cable and sensor.

Aluminium has excellent thermal conductivity, and simply touching the case with a fingertip is enough to trigger an immediate change in temperature reading!

The only awkward part was fitting it into the boiler. I wasn’t able to do this in situ, but had to remove the steam wand and knob, unscrew the four allen bolts around the group to free the boiler. This allowed enough freedom to tilt and move the boiler slightly to the right, so that I could screw in the sensor by hand.

The new sensor is up and running on the machine, and I’ve left the DS18B20 installed in parallel, so I can compare performance.