Category Archives: hardware

Water level measurements

Measuring liquid level is quite a common task.

There are numerous ways of doing this.

Probably the most known of them is the fuel level measurement in cars.
This post is about a tank water level gauges incorporating different types of sensors.
In principle the water level can be determined by measuring the water pressure at the bottom of the tank. The higher the pressure, the higher the water level.

Measuring water level with water pressure sensor can cause errors.

Unfortunately this method has some oversimplification. The environmental air barometric pressure hasn`t taken into account.

As weather continuously changes, so does the ambient air pressure. There is an average variation of 3 kPa, which corresponds to roughly 300 mmH2O measurement (even if the actual water level in the tank is unchanged).

This calls for measuring the barometric pressure. Instead of measurung the ambient air pressure, an alternative measurement method is used.

The ambient air pressure can be continuously taken into accout if a differential pressure sensor is used. One port of the gauge goes to the bottom of the water tank, while the other port stays open. This way the open port “monitors” every change in the ambient air pressure.
This is useful for measuring rainwater storage tanks.


Measuring water level using differential pressure sensor

Due to the fact that integrated differential pressure sensors have some long term drift, optionally the measurement system can be completed with water level switches. One at the bottom and one at the top of the tank. These two switches create a so called auto tune option: they provide zero and full range levels, the differential pressure’s output value can be adjusted if either switch operates (changes state).


More accurate measurement using level switches

An alternative method is the floating ball water level measurement. Basically the angle of the floating ball’s stick is directly related to the water level. The angle can be measured with a potentiometer, but the casing must be watertight, which is difficult to achieve because of the moving elements.


Floating ball water level measurement with potentiometer

Another solution is to use an acceleration sensor. The sensor has to be mounted to the moving rod, so the angle of the rod can be calculated. Having the angle information the water level can be determined.

There can be additional level switches in the system to provide more accurate measurements, or to serve “underdraining” or “overfilling” signals.


Floating ball water level measurement with acceleration sensor

These techniques don’t provide highly accurate measurements, but are accurate enough for rainwater of greywater tanks level measurements.

Powerline load balancing

Nowadays there are a lot of posts and articles about renewable energies, smart grids, electric vehicles, energy efficient products and other environmental friendly solutions.
Their usage are increasing day-by-day in everyday life.
Starting from a simpler example, a flat’s electric distribution panel.


There is a main circuit breaker near the power consumption meter (20A rating in the picture), which protects the whole flat.
The power infeed in then divided into 3 lines, each protected with its own circuit breaker.
As more and more electrical appliance in used, there can be certain intervals when the instantenous power need is more than the circuit breakers’s ratings.
Let’s assume that the mians is nominally 230V, there’s a waching machine operating in the bathroom, an electric oven in the kitchen and one want to do some hoovering in the living room.
Normally the waching machine is rated at 2200W (~9.6Amps @ 230V) but this much power is only needed in the water heating phase, otherwise the power need is only 150-200W.
The electric oven has a pure resistive heating element which is connected in series with a bimetal temperature switch. It switches on and off when it reaches the desired temperature.
If this happens at the same time, the 20A breaker trips.


To avoid these situations the current consumption must be measured. The voltage also could be measured but the breaker only senses current, so basically only current measurement is needed.
There are quite a few techniques to measure current, the simplest of them is using AC current transformers (CT). These provide AC current output which is in direct relation to the measured primary current.


The idea is to provide information about the available current on a certain line.
In case of a washing machine, the available current information could be used to decide if the water heating phase can be started or not. If there is not enough power, then the waching machine (so called smart device) waits until the desired available power level comes.
The breaker’s rating is known, from which the measured current must be substracted, the result is the available current.
The smart device gets this information and since it knows its own power need, the decision on switch ON can be done.


Looking back to the starting situation: having a 10 Amps breaker supplying the bathroom is enough for the washing machine, but the rest of the flat uses power as well, so the overall power usage trips the main breaker at the infeed line.
This problem can be solved if there is information about the “parental” supply line’s available current.
If there is less available current from the infeed line, this must be taken into account.


Staying with the flat example, the infeed line and the flat’s individual supply lines’ current consumption must be measured, and a calculation unit is to be used to generate the available current outputs for each line.
Practically this is a microcontroller based unit, which measures the instantenous current usage, calculates the RMS current consumption and computes the available current output.


As stated above there must be an additional input for measuring the available current from the supplying line. In case of a block of flats, this comes from the main distribution box.


The example can be ridiculous, but looking from bigger perspective, this method is very useful in urban environment, where the power need is concentrated, and the power consupmtion is to be controlled.
Electric vehicles need much power for charging, but this power need can be delayed or reduced (resulting in longer charging time) in peak power usage intervals.


On the other hand, if there are a lot of solar panels installed and electric vehicles are charging at the same time, the charging power can be dinamically adjusted depending of the solar irradiation, thus some kind of grid power peak shaving can be obtained (besides the narrower grid voltage regulation).

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.

Continue reading Programmable, 2 wire, relay controller

Universal, 4-20 mA, two wire industrial transmitter

This post unifies together the following posts:

Industrial, 4-20 mA current loop, measuring basics I.

Industrial, 4-20 mA current loop, measuring basics II.

Industrial, 4-20 mA current loop, measuring basics III.

Industrial, 4-20 mA current loop, measuring basics IV.

Internal workings of process controllers I

. Internal workings of process controllers II.

There are a lot of types of transmitters nowadays. Usually a separate one (a specific type) is needed for thermocouple measurement, an other one (an other type) is needed for level measurement…

The basic concept of this post is to present a way for a universally usable transmitter, which can accept almost any type of input (Pt100, pH probe, rotation, level, light…) and produce a configurable, standard 4-20 mA output.

Continue reading Universal, 4-20 mA, two wire industrial transmitter

Industrial, 4-20 mA current loop, measuring basics IV.

Continued from the previous post

Although the title says “basics”, here are some advanced circuits about the 4-20 mA current loop transmitters.

In the first example a USB connection is shown. Nowadays almost every transmitter incorporates a microcontroller. The transmitters can be programmed through their display, or through HART protocol, or via DIP switches.

Transmitters with HART communication are expensive, using displays also increases the cost, and using DIP switches provides a not so flexible way of configuration.

Some manufacturers use USB as a programming / configuration interface, but most of them are not loop powered, so they need a separate power supply, which increases the cabling costs.

The following solution shows a way of how to include the USB communication in the transmitter design, while the transmitter is powered from the loop.

Continue reading Industrial, 4-20 mA current loop, measuring basics IV.

Industrial, 4-20 mA current loop, measuring circuits basics III.

Continued from the previous post

There’s a major problem with the circuits shown earlier. They all have a capacitor between their output pins (marked C3 in the following picture).

4_20ma_2wire_transmitter_capacitorThe capacitor shown in the red circle

This capacitor is needed by the voltage regulator (LDO) and provides other features like filtering and stability, so it cannot be omitted.

Let’s see the following situation:

2-wire-transmitter_simple2 wire transmitter elements in the measuring loop at startup

We have a 24V power supply with a maximum of 2A output current, a 2 wire transmitter and a 4-20 mA analogue PLC input (with measureing resistance of 50 ohms).

The power supply is switched off, so the transmitter is de-energised (not working because the lack of power). At the time we switch on the power supply, the transmitter’s internal (output, C3) capacitor is beginning to charge and actually it is functioning like a short circuit. For a little time, the power supply’s output 24V falls across the transmitter’s output resistor (10 ohms) and the PLC’s input 50 ohms, which means 400 mA current.

Continue reading Industrial, 4-20 mA current loop, measuring circuits basics III.

Industrial, 4-20 mA current loop, measuring circuits basics II.

Continued from the previous post.

The same priciple is true for the followings, temperature to current transmitter. In this case the input voltage is propotional to the measured temperature, not the rotation.

4_20ma_2wire_transmitter_tempTemperature input, full analog, 2 wire, 4-20 mA loop powered transmitter

U3 is a low cost, NTC based, integrated temperature sensor.

The next schematic is a differential pressure to current transmitter.

4_20ma_2wire_transmitter_pressureDifferential pressure input, full analog, 2 wire, 4-20 mA loop powered transmitter

This circuit needs a little explanation.

Continue reading Industrial, 4-20 mA current loop, measuring circuits basics II.