Programmable, 2 wire, relay controller

Although the previous posts described the two wire, 4-20 mA transmitters’ internal workings, sometimes a simpler action is adequate.

The first and pretty obvious example is the temperature switch (which is actually a bimetal). It doesn’t need any power supply, it makes (or breaks) a contact if the temperature reaches a certain threshold.

Another example is the float switch used in water tanks. it also makes (or breaks) a contact if the water level reaches the given level.

If the power they can deliver is insufficent, then these “sensing devices” usually operate a relay, and the relay’s contact switches on the higher power mechanism.

For example a reed switch based float switch (used in a water tank) can only switch a maximum of 0.5 A, but the water pump (operated by this float switch) needs multiple amps for its operation. In this case the float switch operates a relay, and the pump’s multiple amps flow through the relay’s contacts.

On the other hand there are more complex issues to be solved, as simple as can be.

Let’s see the following situation: There is a garden with an automatic sprinkler system. This system has a rainwater storage tank, a water pump, sprinklers and a soil humidity sensor. If the soil moisture falls below a certain level then the sprinklers begin to operate, and if the moisture rises to an other certain level the water pump stops.

It is a simple hystheresis function with adjustable low (turn on) and high (turn off) threshold.

This sensor is connected in series with a relay. The reason is simply to reduce the cabling need, in our particular case only 2 wires are needed.

rel_swThe sensor is connectred in series with the relay

The solution described below shows how to control the relay.

At first the starting values must be settled. This particular solution is working with either 12V or 24V relays.

Every relay has a “must turn off voltage”, which is usually 10% of the rated voltage (1.2V in case of 12V relay, or 2.4V with 24V relay). This means that the relay is surely turned off (not energised) if the voltage – applied to it – is below this level.

The other important data is the “must turn on voltage”. It is usually 80% of the rated voltage (for example a 24V relay is surely on, if at least 19.2V is applied to it).

These two parameters allow us to draw some current through the relay without turning it on and to have some spare voltage while the relay is in operation.

In this example the “worst case” condition is taken into account: a 12V, sensitive relay with 0.5W rated power. Any other type (standard 12V, or 24V relay) provides (allows) more power to the sensor.

 rel_sw_OFF_ONRelay ON and OFF state voltages and currents.

Starting with the OFF state: the relay has a must turn off voltage of 1.2V, so 1V relay voltage was chosen to have some safety margin.12V rated voltage with 0.5W rated power equals to 288 ohms coil resistance. If the relay has 1V potential, then the current flowing through it is approximately 3.5mA.

The sensor has 11V and maximum 3.5mA available. The sensor incorporates a microcontroller (MCU) that needs 5V.

In the OFF state a step down (buck) regulator is needed to generate a stable 5V for the microcontroller and the sensing circuitry. The efficiency of such regulator with the given parameters is about 85%. Let’s take 80% into account (worst case condition) thus we have 3.5 mA * 11V/5V * 80% = 6.1mA @ 5V for the microcontroller and other circuits. This power level is adequate for moderate performance.

step_downRelay OFF state circuitry

At the ON state the relay has 11V voltage across it, the current is about 38 mA.

In order to have 1V for the sensor a simple shunt regulator is needed, actually a silicon and a schottky diode in series will do the job. A step up (boost) regulator is needed too, to generate 5V.

Let’s say the efficiency of this boost converter is 80% too, so in the ON state the MCU have 38mA * 1V/5V * 80% = 6.1mA @ 5V. This power level is almost the same as in the OFF state, so the MCU programmer doesn’t have to switch between power modes in OFF or ON state.

Since the sensor is a microcontroller based, programable device it needs to have a communication line, practically USB based. USB is useful not only because its widely availability but it also supplies power to the device.

Putting these 3 power supply modes altogether the sensor module’s internal schema is:


Programmable relay controller schematics

At start-up the step-down converter begins operating (its enable input is on by default), supplying power to the MCU, the relay is in OFF state.

If the microcontroller’s internal program (can be a function block programmable microcontroller) decides to switch the relay into ON state, then sensor’s internal switch is operated. At the same time the step-down converter is disabled (to save power) and the step up converter is activated.

If the USB interface is connected, then the MCU senses it through its “USB_sense input” and the communication line is activated (usually it is deactivated to save power).

The MCU is fully programmable via USB (switching levels, sensing parameterisation…) making it a very attractive device.

The example is about a programmable soil humidity sensor, but of course its input is flexibilly variable to meet everyone’s need.

This version of relay controller can accept either 12V or 24V rated relays, the only exception is that the relay must meet the initial requirements of the controller (must turn off voltage, power ratings, must turn on voltage levels…).

The controller protective devices are not show (just for clarity), but they cannot be omitted.

The minimal protection consist of a power diode parallel with the relay (this prevents the overvoltage condition occuring when the relay is swiched on). Optionally a min. 24V rated zener diode can be connected parallel with the sensor to protect the internal circuitry.


There could be another features included in the schematics (current measuring, relay switching time measurement, fault prediction…) but this minimal concept shows most clearly how these devices work.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s