Hardware (Electronics) Update May 2016

From the many reactions I receive from fellow home-brewers, I understand that, for most of you, it is rather difficult to reconstruct the electronics part. Nevertheless, there are brewers who have an interest in automating their brewing setup. Some of you use ready made components, like a PID controller, a PC IO card or a solid-state-relay. There's nothing wrong with that approach, but I decided to choose an alternative approach. Playing around with electronics is one of the most enjoyable things for me to do. And since I hold a masters degree in electrical engineering (Eindhoven University of Technology), I also should be capable of designing such a system. Therefore I chose to design the hardware and the software as professionally as possible. The hardware design, presented on this page, should be sufficient for anybody who is familiar with electronics, to rebuild (some of the) parts of my brewing electronics.

In short: the hardware is capable of the following:

Even if you are not really into electronics, maybe you pick up some new ideas along the way. If not, you can also skip this page :-)

This page consists of the following paragraphs:

1. Overview / Architectural Design

An architectural design provides an overview of the hardware parts and the various interfaces between them. For the electronics of the brewing system, it looks like this:

This picture looks complicated at first sight, but I will try to explain things:

To start with a legend of the symbols used. The Gray filled areas indicate that a printed circuit board (PCB) has been made for this. So the temperature sensors, the Triacs, the pressure sensor interface and the brewing-electronics all have dedicated PCBs. The orange signals are the names of the Arduino Nano port pins. This is needed by the software for the Arduino Nano, since it needs to control this. The blue CON names are the connector names on the main PCB.

The first component is the PC itself. It is connected with an USB cable to the PC-Interface. This PC-interface is controlled by the brewing program which runs on the PC.

The brewing electronics is equipped with an Arduino Nano, which is mounted on the main PCB with a dedicated connector. An Arduino Nano is a standard PCB with an Atmel 328P microcontroller. It also generates the signals needed for the I2C bus. This I2C bus is often used to connect ICs to each other and is designed originally by Philips. The advantage of this I2C bus is that there are only two binary signals, a clock line (SCL) and a DATA line (SDA). Every IC connected to the I2C bus, has its own unique address. An even address means a write action, an odd address means a read action. Example: one of the ICs on the main PCB (the MCP23017) has 0x40 (hexadecimal or 64 decimal) as base address. If you want to write to this IC, use address 0x40. If you want to read from this IC, you have to use address 0x41. Most of the electronic components of my brewing setup are connected through this I2C bus, e.g. the two temperature sensors. This means that the two binary I2C wires (SCL and SDA) are also connected to the sensors in the HLT and MLT (together with the +5 Volt and the GND wires). To make reading these sensors as reliable as possible, separate I2C channels are being used. Every sensor has its own unique I2C channel. Multiplexing of the I2C bus (from 1 to 4 channels) is done by a dedicated IC, the PCA9544. With the latest hardware update, it is now also possible to replace these I2C sensors with DS18B20 One-Wire sensors. The HLT and MLT connectors facilitate both types (I2C: LM92 or One-Wire: DS18B20) of sensors.

Despite the complexity of this architecture, the main thought behind all this, is a simple one: read values from sensors (such as temperature and volume) and use this to control the actuators (heating element, gas-valves, solenoid valves). And in order to do all that, you need a bit of electronics!

2. PC-Interface

The communication between the PC and the brewing-electronics is done through the USB port of the Arduino Nano. The Arduino Nano is recognised by Windows (if the standard drivers for the Arduino Nano have been installed) and a virtual COM port is installed, e.g. COM5. All communication between the brewing program (on the Windows PC) and the brewing electronics is done through this virtual COM port. The port settings are 38400,N,8,1, which means: 38400 Baud,no parity bit, 8 data-bits and 1 stop-bit. Both the brewing program and the brewing electronics must have these settings.

After this is done, a simple communication protocol with short commands is used. The following commands (from the brewing-program) and responses (from the brewing electronics) are possible:

Besides these commands, a few more diagnostic commands have been made to monitor the brewing electronics itself. By using these simple commands, it is also possible to control the brewing electronics with a PC terminal program. This is convenient during testing and commissioning of the entire system.

A registration in a log-file is made every five seconds of everything sent and received. This is convenient for debugging purposes. A little excerpt from such a log-file looks like the following:

	File opened (28-05-2016, 16:34:23)
	W25.110[S0]R5.25.220[E-Brew V2.0 rev.1.28]
Back to the Top of the Page

3. Temperature Sensors

My first design with temperature sensors involved a LM35, which increases its output voltage with 10 mV for every °Celsius. That voltage was amplified and then being read by an AD-converter. The disadvantage of this approach was the relatively large number of ICs needed.

My current design uses a 12-bit + sign bit digital temperature sensor, the LM92. This sensor has all necessary electronics already on-board. The only thing still needed, is a connection to the I2C bus. The 12-bit digital code that is read from the device, is the digital representation of the actual temperature. The LM92 has an accuracy of 0.33 °C. The biggest problem with this device is to mount it reliably in your kettles. I solved this by placing it on a small printed circuit board, glue that at the bottom of a copper pipe, and then cast it with clear plaster resin (with thanks to Marco Mantel for the brilliant idea!).

The picture shows the LM92 soldered to a small printed circuit board, next to a copper pipe already filled with plaster resin. It takes a couple of weeks before the plaster resin has hardened. But then you do have a waterproof construction, which can be mounted inside the kettles.

The address of the LM92 on the I2C bus is adjustable with 2 pins A0 and A1. You can either ground these pins (a logic 0) or connect to the +5 V (logic 1), which creates a total of 4 possible addresses. For the HLT sensor I use address 0x92/0x93 (A1=0, A0=1) and for the MLT sensor I use address 0x94/0x95 (A1=1, A0=0).

I have been experimenting with temperature sensors for a couple of years, but these LM92 are absolutely perfect. You obtain a digital code directly, there's no need for a separate conversion/calibration (which you do need with a PT100 element), no additional electronics are required, they are very reliable and they always work! For more information about construction, including design-files and source-code, please read my blog: http://wordpress.vandelogt.nl/?p=13

Have we now covered everything w.r.t. temperature sensors? No, lots more to tell: many fellow homebrewers use One-Wire temperature sensors (DS18B20). Why? Because this sensor comes in a waterproof containment (stainless steel) and are dead cheap on ebay. By mounting these sensors inside your kettles, you don't have to mess around with plaster resin (which we needed to do for the I2C LM92 sensors).

The one-wire protocol is a completely different communication protocol than the I2C bus. But, since not all connections were in use at the connectors (CON10 and CON11) for the temperature sensors, it was relatively easy to add one wire for the one-wire protocol. More difficult is the control and reading part of the one-wire sensor: it works on a microseconds base, so you need to have accurate timing. Many people use a standard library from the Arduino for this. So a software solution. For reasons of reliability I chose for a hardware solution here. There is a nice little IC (DS2482-100) available that connects to the I2C bus and sends out a one-wire signal. You could therefore call it an I2C to one-wire bridge. This IC is present twice in the brew-electronics, one for every temperature sensor (HLT and MLT temperature). This seems like overkill, since only one IC would do for a one-wire solution. The big advantage with 2 ICs is that you can hot-swap the temperature sensors. Disconnect one and reconnect another: the brew-electronics detects this and reads out the new temperature value. The order is that first a check is done whether or not an I2C sensor (LM92) is connected. If not, the brew-electronics tries to read a one-wire sensor. This is all done through the same connector as for the I2C sensors, which makes it very flexible and easy to use. The PC-program does not know which temperature sensor (LM92 or DS18B20) is connected, it just receives a temperature value. With the latest hardware update it is now possible to read four temperature sensors at the same time. Either you use four One-Wire DS18B20 sensors or you use two LM92 (I2C) and two DS18B20 sensors. The additional sensors are used to read the temperature of the boil-kettle and the temperature at the outlet of the counter flow chiller (during cooling, after boiling).

Back to the Top of the Page

4. Volume-measurements

Measuring volumes in a kettle can be done in a couple of different ways. The most used ones are with a pressure-transducer of with a flow-sensor. I now solely use flow-sensors, because they have many advantages over pressure-transducers.

Using a Flow-sensor: mount a water flow-sensor between two kettles, for example between the HLT and the MLT. The flow-sensor has a little wheel inside that starts to turn when a fluid passes through. The signal from these flow-sensor are connected to connectors CON14 to CON17. These signals are then read in by the Arduino Nano, which counts the number of pulses. The flow-sensor used here is a FS300A flow-sensor and delivers approximately 330 pulses per litre of fluid. With this it is possible to accurately measure the number of litres passed through the system. In this setup you always need three flow-sensors: one between the HLT and the MLT, one between the MLT and the boiling kettle. These are essential for proper calculation of the volumes. A third flow-sensor is mounted at the outlet of the counter flow chiller, so you can determine the amount of litres transferred into the fermentation bin. The hardware also supports a fourth flow-sensor, but this one is not used yet.

Back to the Top of the Page

5. Triac: Interface for Pump and Heating element 3 kW

Switching parts that work with 230 Volts is done by a separate printed circuit board (the 'Triac PCB') in the electronics cabinet. The picture show two Triac PCBs, the one on the left is for the HLT heater, the one on the right is for the pump. A Triac PCB receives a signal ('HLT_230V' and 'Pump_230V') from the brewing electronics. With this, the heating element and the pump are switched on or off.

The most common used method by home brewers is to use a ready-made Solid-State Relay (SSR). It is not too difficult to create your own SSR, because there are special power electronic components available, which can do the job. A good example is the Triac. The brewing electronics uses a BTA25H. This Triac is capable of switching up to 25 A at 600 V. This is more than adequate for our purposes. The advantage of this Triac is that it's back is isolated! So if you mount this Triac to a heat-sink, the heat-sink is not connected to the mains (which is a good thing).

The Triac for the heating element has its own cooling plate, to which I glued a LM35 temperature sensor. The Triac temperature is controlled continuously by the brewing program. If the temperature increases above a predefined level, the Triac is switched off. NOTE: the picture above shows the pcb with a small heat-sink (and no LM35). This is sufficient to switch a pump, but it is inadequate for switching a 3 kW heating element! For that, you need a larger heat-sink!

Most of the intelligence w.r.t. switching is done using a special IC, the MOC3043. This IC contains a zero-crossing circuit. It means that the Triac is switched on, when the AC voltage crosses 0 Volts. This assures a smooth switching behaviour, leading to almost no disturbances. Furthermore, the IC also contains a galvanic isolation: if there's a problem in the power electronics, then this does not result in additional damage in the electronics and/or the PC. The last picture shows the schematic and the PCB layout of the Triac PCB:

Back to the Top of the Page

6. Interface for Gas-valves / Burners

One of my neighbours is a plumber and for every new central heating boiler he installs, and old one is removed. These old central heating boilers are then given to me. Such a central heating boiler contains, next to a decent burner, a gas-valve. Since early 2005 I switched over entirely to these gas-burners, since they have far more power than the ones I used. These gas-valves come in two flavours:

6.1 Non-modulating gas-valve

A non-modulating gas valve only needs to have a 24 V AC voltage. The schematic shows how this is realised (this schematic is actually a part of the entire brewing electronics PCB). CON4 is a jumper block that is connected to 24 V AC. This is used to control the proper configuration. If a gas-valve already has a voltage supply, it only needs a voltage-free switching contact. The brewing electronics does not have to supply 24 V AC. If this is the case, then pins 2 and 4 of CON4 need to be connected to each other.

If the gas valve DOES need a 24 V AC signal (which is the situation for most non-modulating gas-valves), the brewing electronics can also supply this. In this case, pins 1 and 2 need to be connected to each other AND pins 3 and 4 needs to be connected to each other. The actual switching of the gas-valve is done by relays. The Arduino Nano generates two signals BOIL_NMOD and HLT_NMOD, which are the signals for the boil-kettle and the HLT. The relay is controlled by a NPN transistor, a BC547. The output signal is present at connector CON9, which should be connected to the non-modulating gas-valves.

The output of the PID controller in the brewing program is a percentage (between 0% and 100%). The is the amount of power needed. This signal can not be used directly to control the relay. If more power is needed than a predefined threshold value (e.g. 40%), the relay is switched on. The relay is switched off when the PID controller output is lower than another predefined value (e.g. 35%). This hysteresis prevents that the burner is switch on and off again within a short time period.

6.2 Modulating gas-valves

A modulating gas-valve is controlled by means of a PWM signal, as stated before. The picture shows a PWM signal. Striking for a PWM signal is that the frequency of the signal is fixed. Most gas-valves expect a PWM signal with a frequency f of about 25 kHz (the period time T is then 40 microseconds). The amplitude (height of the signal) is often a value between 24 and 28 Volt.

For a pulse width of 50 %, the duty-cycle of the signal is the same (on-time is the same as off-time), for a pulse width of 20 %, the signal is high for 20% of the period time and low for 80% of the period-time. A PWM signal of 100% always high, whereas a PWM signal of 0% remains low all the time.

To control a modulating gas-valve, we need the following:

The use of an Arduino Nano is convenient in this situation. For a microcontroller, such as the Atmel 328P, it is relatively simple to generate such a 25 kHz signal. A separate oscillator circuit is not needed, we simple need to program a Timer (Timer 1 in this case) of the ATmega 328 microcontroller. The PC brewing program delivers an output signal from the PID controller with the Bxxx and the Hxxx commands. This is used by Timer 1 of the microcontroller. Timer 1 is configured in such a way that it generates a 25 kHz square wave signal with a duty-cycle equal to the PID controller output signal. The outputs of Timer 1 (OC1A and OC1B) are the input signals for the PWM circuit. These signals are called HLT_PWM and BOIL_PWM in the schematic below. This schematic shows the PWM circuit, which is part of the entire schematic of the brewing-electronics.

The Power-Supply section has already generated a 28 V DC voltage. This is now connected together with the PWM signals to a comparator with an open-collector output (the LM393). The open-collector outputs of the LM393 can be connected directly to the 28 V DC voltage. The PNP transistor BC640 controls the gas valve itself. Connector CON6 sends these signals to the modulating gasvalves.

Back to the Top of the Page

7. Solenoid Valves

The solenoid valves need 24 V DC in order to switch them on. Switching of the solenoid valves is directed by the State Transition Diagram. The first component of the hardware interface for these solenoid valves is a 16-bit I2C IO expander, the MCP23017. This IC is used because the ATmega328 microcontroller doesn't have sufficient free IO pins available. Every port pin of the MCP23017 controls 1 solenoid valve. Such a port pin is connected to one of the inputs of a ULN2803 Darlington Transistor Array. This IC contains 8 Darlington transistors which can switch up to 0.5 Ampère. During testing however, one problem has arisen: the valves drew more current than expected. At 24 V DC this was close to 1 Ampère. This led to the following two solutions:

These DC-DC converters are cheap and easy to find on ebay. Just search for: "DC-DC Step Down Adjustable Power Supply Module Converter Max 5A 0.8V-24V". I added a LED to have a visual indication of the actual status of the solenoid valve. With the potmeter shown on the picture, it is easy to accurately set the output voltage to 13 V DC. With these two solutions the current draw per solenoid valve is approximately 0.5 Ampère. The State Transition Diagram makes clear that there are no more than 3 solenoid valves active at the same time. The maximum current draw for the 24 V DC circuit is approximately 1.5 Ampère. This is helpful information when dimensioning the Power-Supply.

The picture below shows a possible installation of the DC-DC converter in a splash-proof containment. The Gray wires comes from the brewing-electronics (24 V). The output of the DC-DC converter is wired to the solenoid vale (the red wires).

The schematic of the solenoid valve interface is given below. It is part of the entire schematic of the brewing electronics PCB.

The only thing not covered in the schematic are the resistors R49 until R56. These are resettable fuses or PTCs. They have a low resistance at a current of 0.5 Ampère, but this resistance greatly increases when the current gets close to 1 Ampère. The increased resistance limits the maximum current possible. In case of a short-circuit these PTCs hopefully prevent permanent damage to the electronics. In industrial PLCs, the outputs are often protected with these devices. So it is a good thing to add them here too.

With the use of the new 'Solenoid Ball Valves', the DC-DC converters are no longer essential. This is because the Solenoid Ball Valves draw much less current and can therefore be connected directly to V1-V8.

Back to the Top of the Page

8. Power-Supply

The power-supply section of the brewing electronics is worth mentioning here, because different voltages with different power are needed. The architectural design shows a number of transformers:

The power-supply schematic (which is part of the entire schematic of the brewing-electronics PCB) is given here as reference:

Back to the Top of the Page

9. Cabinet for the electronics

All PCBs are mounted inside a cabinet. This is a standard metal case from Hammond. Sizes are 17" (43.2 cm) width, 4" (10.2 cm) high and 10" (25.4 cm) deep, typenumber is Hammond 1441-33BK3. The bottom plate has type number 1431-30BK3. To give it a professional look, I made faceplates for both the front and the back. Excellent service from Tube-Town. These faceplates are shown in the picture below:

The front has the following connections:

The faceplate for the back with all connections looks like this (this still needs an update!):

The following connectors are seen:

Most of the subparts of the brewing-electronics PCB are now already explained. A professional PCB has been made (at IteadStudio) that looks as shown here:

Here is another picture of an empty PCB (bottom) and a completely assembled PCB (top) with the Arduino Nano mounted on top:

The quality of these PCBs is very good, especially the silkscreen (printed white text) helps you a lot in assembling this PCB. Finally another picture of the front of the PCB, showing all connectors clearly:

If you want to make the sensors with the cables and connectors, the following picture shows you how to make these:

Back to the Top of the Page

10. Assembly and Bill of Materials (BOM)

I get lots of requests from other home-brewers worldwide how they can create a similar automated brewing system. A Bill of Material (BOM) is a good starting point for this. Although it is impossible to list all different kinds of configurations, I can give you a Bill of Materials for a standard setup, which is in my case the following:

Bill of Materials: General Items

Bill of Materials: Triac PCB

In this configuration two Triac PCBs are required to switch the pump and supply the 230 V AC for the HLT gas-burner. The BOM for the Triac looks like (beware: you need to have 2 of these):

Bill of Materials: Brewing-electronics

Without doubt the most complex piece of electronics in the system. You can find a detailed component list below. Component prices are just an indication (price-level is from July 2015). Many of these components can be ordered on ebay for a fraction of the price listed here. So it really is worthwhile to do a bit of shopping there.

If your soldering skills are not really up to par, you can also order a PCB directly from me, with the SMD devices already soldered in place. If you would like to have a completely soldered and tested PCB: that might be possible too. If you want to do it all yourself: take proper ESD measures! An anti-static wrist-band is the very minimum for this.

Bill of Materials: Cabinet

Last Bill of Materials is for the cabinet of the electronics, together with all jacks and plugs.

Not listed here but also needed: lot of wires, isolated, non-isolated and in various gauges.

Back to the Top of the Page

11. Datasheets of components

The various ICs used in the electronics brewing setup are listed here with their datasheets:

Back to the Top of the Page