Mains Backup for Solar Charged Battery Bank

Pictured below is a controller designed to automate backup mains charging of a battery bank which is charged by an array of photovoltaic solar panels.

Main charger back up for solar pv charged battery bankThis controller is based around our low voltage disconnect products. It constantly monitors the voltage of the battery bank. When the voltage falls below a user set low voltage (e.g. 12.0V), the on board relay closes which connects a mains powered battery charger to the battery bank.

When the battery voltage then gets up to a user set high voltage (e.g. 13.6V), the on board relay opens which disconnects the battery charger.

This controller is fitted with manual overrides so that the user can ‘override’ the controller and force the mains powered battery charger to come on when off, or turn off when on.

This is very useful for a solar powered system since the battery bank voltage may be getting low and the weather forecast may also be bad for the coming day. In that scenario, it is worth charging up the battery bank fully immediately to prevent the battery bank from hanging around at a low voltage for an extended period of time (which is bad for battery longevity).

Similarly, if the mains charger is on because the battery bank was low on charge, but the weather forecast is for non-stop sunshine, the override enables the charger to be turned off to leave the solar panels to do the rest of the work.

If you need a controller like this, email neil@reuk.co.uk with details of your exact requirements.

 

Automatic Car Windscreen Heater Timer

Pictured below is our timer for an after market car windscreen heater – in this particular example, for a Land Rover.

car windscreen heater prototype connection diagramThe biggest seller of after market heated windscreens in the UK is Ricky Evans Motorsport. (Click here for the relevant heated windscreen wiring diagram.)

The relay output from our programmable timer fits into the wiring in place of the standard on/off switch. The timer can be programmed by the driver to turn on the heated windscreen for from 1-20 minutes after the button (which can be mounted in the dash) is pressed. A panel mountable LED is provided to show when the heater is on.

Automating windscreen heating in this way prevents the heater from being left on unnecessarily long.

The exact button and LED can be substituted with whatever switchgear and indication lighting matches the vehicle in which the system is installed.

If you need one of these car windscreen heater timers, email neil@reuk.co.uk with details of your exact requirements.

PICAXE Arithmetic Problems

Hitting the maximum number limit with PICAXE microcontrollers

In a recent post we showed our 24V Low Voltage Disconnect with Data Display. This device monitors and logs the voltage of a 24V battery bank, disconnects the output loads if that voltage is too low to protect the batteries, and has an LCD display on which the last 100 days of battery voltages can be checked, summarised, and the maximum and minimum recorded voltages displayed for analysis.

This device is built around a PICAXE microcontroller. These are simple to use and quick to programme microcontrollers, but they have a few ‘features’ which can make life difficult (sometimes making an Arduino a far better alternative). PICAXE chips can only process numbers in the range 0-65535, they cannot process negative numbers, and cannot process floating point (decimal) numbers.

In most cases those limitations are not an issue, but with our 24V LVD for example it was. The microcontroller is powered via a 5V regulator. In order to measure incoming voltages over 5V, a voltage divider (Wikipedia) is required – a pair of resistors connected in series with one end connected to the incoming voltage to be measured and the other end to 0V. The values of the resistors are chosen so that the voltage measured where the two resistors meet is in the range 0-5V across the full range of likely input voltages.

For our standard 12V low voltage disconnects we use a 47K resistor for R1 and a 10K for R2. The voltage output from this voltage divider is equal to R2/(R1+R2) multiplied by in the input voltage. So, if the input voltage is 13.00V for example, the voltage divider output voltage will be 13*(10K/(10K+47K))=2.281V which the 10-bit ADC on the PICAXE will see as (2.281V/5V)*1023=467. Only when the input voltage exceeds 28.5V will the voltage from this voltage divider exceed 5V, and 28.5V is never going to be seen from a 12V battery.

With our 24V datalogging LVD we chose 68K for R1 and 10K for R2. This gave an input voltage range of 0-39V corresponding to the ADC range of 0-1023 which is perfect for a 24V battery system. However, we hit upon a problem.

We work out what an input voltage of 1V corresponds to as an ADC value after passing through the voltage divider. With the 68K/10K divider on our 24V LVD, 1V on the input corresponds to an output of 0.12821V which corresponds to (0.12821/5)*1023=26.23. Therefore, if we divide the ADC value on the microcontroller by 26.23, we calculate the input voltage.

BUT, the PICAXE chip can only do integer arithmetic. An ADC value of 415 in this example corresponds to a measured input voltage of 415/26.23=15.8216V, but with integer arithmetic 417/26=15V so off by almost a full Volt.

In order to retain resolution and accuracy while forced to use integer arithmetic, we multiply the ADC reading by 100 and divide it by ten times the per volt ADC value. The result given is ten times the input voltage – for example (415*100)/262=158 which means 15.8V which is close enough to the actual value.

But, this approach can then lead to another problem. In the case of our 24V LVD with the 68K/10K voltage divider, when the input voltage exceeds just below 25V (which will almost always be the case with a maintained 24V battery bank), the ADC value is greater than 656. When we multiply this ADC value by 100 we get a number of over 65600 which the PICAXE (with its maximum number limit of 65535) cannot process. For example it will see 65536 as 0, 65537 as 1, 65538 as 2, and so on and will think that an input voltage of 25V is less than 1V which is not much use.

There are many (very complicated) ways around this maximum number problem using variables and/or the EEPROM to store parts of large numbers while doing calculations, but in the case of the 24V LVD with datalogger, all the internal data EEPROM was dedicated to datalogging, and all the variables were already being used. Therefore, instead of multiplying the ADC value by 100 and dividing it by ten times the per Volt ADC value, we modified our code to multiply the ADC value by 50 and divide it by five times the per Volt ADC value. This results in a small loss of accuracy of less than 0.1V at the upper range of predicted voltages, but works well enough for this particular device.

So, when choosing a voltage divider for an accurate voltage measuring device with a PICAXE chip, choose the resistors to ensure that the full possible input voltage range is more than covered, and also that any multiplication of ADC values in order to maintain resolution with integer arithmetic does not generate numbers over 65535. (Alternatively just use an Arduino with floating point arithmetic!)

Playhouse Lighting Controller with LVD

Pictured below is the connection diagram for a controller we have built to be used in a child’s playhouse. The playhouse will have a solar charged battery which will be used to supply power to three LED spotlights with a light switch, a small fan to circulate air and prevent the playhouse getting damp or too hot, and a dual cigar lighter socket with USB sockets which will be used to charge battery powered gadgets.

Connections for low voltage disconnect with twin outputs - regulated for LED lighting and to power a fan for ventilationAs the playhouse will be used by children, safeguards have been fitted to prevent the battery from becoming excessively depleted and permanently damaged.

In order to prevent the lights being left on and forgotten, when the light switch is turned on, a timer starts and if after one hour the light switch has not been turned off, the lights turn off automatically and will not turn back on until the light switch is toggled.

The output from the controller to the LED lighting is regulated to 12.0V so that excessive voltage (particularly when the batteries are being charged) does not damage the voltage sensitive bulbs.

To reduce power consumption, the fan which is used to ventilate the playhouse is turned on for just one hour every six hours automatically by the controller. The output to the fan is not regulated as the fan is rated for use with up to 18V, and if the battery voltage is high it is because there is or has been a lot of sunshine. Therefore the faster fan speed will prevent the playhouse getting too hot and stuffy.

In order to prevent the battery from running too low on charge, an automatic low voltage disconnect is incorporated. When the battery voltage falls below 11.9V, the outputs to the fan and lighting turn off, and only turn back on again when the measured battery voltage exceeds 12.4V.

The cigar lighter / USB socket is connected directly to the battery as the gadgets being charged by it will not draw much current for long if left connected since their batteries will get full and charging will stop automatically.

If you need a controller such as this, or with any of the features it has, email neil@reuk.co.uk with details of your exact requirements.

Solar Water Heating Pump Controller with LCD

Pictured below is the connection diagram for a new solar water heating pump controller we designed and built recently for use with a swimming pool heating system.

solar water heating pump controller with solid state relay and LCD and programmable timer override for swimming poolThis controller is the next step up from the solar water heating pump controller with solid state relay discussed previously. It has the same ds18b20 waterproof digital temperature sensors we use in all controllers for swimming pools and similar, but with the addition of an LCD to display measured temperatures and other system status information. (There is also a 12v digital programmable timer override function added as a specific customer request.)

LCD for solar water heating pump controller

The LCD constantly displays the temperature of the outlet from the solar thermal panel (S) and of the pool (P). It also displays the current measured temperature difference between the solar panel and pool, as well as the temperature difference required for the pump to turn on or off (as programmed by the user).

Having the LCD makes it possible to add a lot more features to this controller on request – for example keeping track of the average temperatures and peak temperatures of the pool and solar panel, tracking for how long each day the pump is running, and many other potential datalogging features.

Email neil@reuk.co.uk if you need a solar water heating pump controller with or without an LCD and datalogging with details of your exact requirements.

GertDuino for Raspberry Pi

GertDuino board to expand Raspberry Pi

Pictured above is the new GertDuino board, developed by Gert van Loo – inventor of the popular Raspberry Pi add-on (GPIO extension) Gert Board.

The GertDuino is designed as a Raspberry Pi add-on, and gives the best of both worlds – the low power consumption and many input/output options of Arduino with the processing power and connectivity of the Raspberry Pi.

Gertduino board mounted to Raspberry PiThe image above shows the GertDuino connected to the Raspberry Pi.

The GertDuino is based around the popular Arduino Uno with a non-surface mounted ATmega328 microcontroller which can be programmed directly from the Raspberry Pi with code written and compiled on the Raspberry Pi. The GertDuino is compatible with all existing Arduino shields (Uno).

Once programmed GertDuino can be used as a standalone board or left coupled to a Raspberry Pi if the project calls for it. When connected to Raspberry Pi, it takes its 5V power supply directly from it, but as a standalone an external 5V power supply is required.

In addition to all the functionality and input/output of the Arduino Uno, a second microcontroller has been added to GertDuino (a surface mounted ATmega48) which gives an IrDA interface to the board (infrared receiver), a real time clock (with battery back up power supply – CR1025 3V button cell, not included – and high precision crystal). There is also an RS232 interface, and a couple of user push buttons and an array of six LEDs. And all this comes at a cost comparable with an original Arduino Uno board at £22.20 inc VAT available from Farnell / Element14.com.

Of most interest to us at REUK is the ability to use the GertDuino and its real time clock to wake up the Raspberry Pi only when it is needed – for example, the GertDuino could be used to monitor battery voltages or a solar water heating system, and turn on the Raspberry Pi for just a few minutes every 12 hours to process and publish the collected data. The overall power consumption of such a system would be far less than keeping the Raspberry Pi active all the time, making it much more economical to run everything from solar power. (See our article Solar Powered Raspberry Pi for details).

The user manual for GertDuino is full of information, schematics, and more on this new Raspberry Pi add-on. Click here to download and view the GertDuino User Manual (30 page PDF).

Arduino Solar Water Heating Pump Controller

The REUK 2013 Solar Water Heating Pump Controller (pictured above) is one of the most popular products on the REUK.co.uk website. With a temperature sensor on the solar water heating panel, and a second on the hot water tank, this controller decides when to turn the pump on to circulate solar heated water from the panel to the tank.

This controller is based around a PICAXE-08M2 microcontroller which gives a good balance of programmability and simplicity. It does however have one large disadvantage – it can only do integer arithmetic, i.e. performing operations on whole numbers only.

Therefore when we come to make modifications to the controller for particular customer requirements – e.g. frost protection and maximum temperature shut offs etc – things get unnecessarily complicated. Additionally there is limited memory on a PICAXE-08M2 which becomes a serious problem as the complexity of the desired programming increases.

For this reason we are currently porting a lot of our PICAXE based controllers to Arduino which allows floating point arithmetic and far more memory space.

Pictured below is our latest Arduino solar water heating pump controller. It is functionally identical to the standard 2013 PICAXE controller, but offers much more flexibility for modifications and added features.

Arduino pro mini based REUK solar water heating pump controller

The Arduino board used here is the Pro Mini – the smallest of the Arduino range. The red board plugged on to the blue Arduino board in the above photograph is used to connect the Arduino to a PC via USB for programming and/or so that data can be outputted to a serial monitor in real time or for later analysis as shown below where the temperature of the solar panel and of the hot water tank is outputted once every second. If monitoring is not required then this break out board can be removed.

Serial terminal output for arduino solar water heating pump controllerIf you have any particular requirements for a solar water heating pump controller which are not met by our standard controller range, email neil@reuk.co.uk with details of what you need.

If you are interested in building and programming your own solar water heating pump controller as a project, click here for our simple Arduino Solar Water Heating Pump Controller Design and Code which should help you get started.

Analogue Inputs with Raspberry Pi

We have been doing a lot more work with Raspberry Pi over the last few months on some interesting projects which we will soon be covering on the REUK.co.uk website.

Raspberry Pi has an infinite number of uses and offers a great mixture of power, flexibility, and price, but it is lacking in one regard – its GPIO (general purpose input output) does not offer analogue input (ADC – analog digital converter) pins. Therefore it cannot be connected directly to non-digital temperature sensors, light detectors, or measure voltages etc. (This is in comparison to the similarly priced Beaglebone Black which offers seven  12-bit ADC pins for analogue inputs, or Arduino.)

mcp3008 10 bit adc analogue to digital converter 8 channelThere are however simple and relatively cheap ways around this, one of which we will cover here: the MCP3008 10-bit 8 channel ADC pictured above. This is a microchip which can take up to 8 analogue inputs, and communicate their digital equivalent values (0-1023) to the Raspberry Pi via the SPI serial interface.

mcp3008 board to connect to raspberry pi with light detector and other analogue inputs

Pictured above is a small board we have made with the MCP3008 at its centre. Coming in on the left side are six connections to the Raspberry Pi GPIO – 3.3V and GND power connections, and the four connections for the SPI interface.

male to female jumper links for raspberry pi

To make the connections to the GPIO we used male to female jumper links. The female end pushes over a GPIO pin, and the male end goes into a screw in terminal on our MCP3008 board.

raspberry pi GPIO analogue inputs

In order to set up the Raspberry Pi to use the SPI interface there are some commands which are required and you also need to install the SpiDev module. This is all detailed together with connection diagrams in the links to some external resources at the end of this post.

Python code for raspberry pi analogue light detector input

The above shows the simple Python script we used to measure the light level of a light detector connected to our MCP3008 board (making a voltage divider with the light detector and a 10K resistor and feeding the output voltage into channel 0 of the MCP3008 ADC chip. The script simply measures the light level once per second and outputs it to the terminal.

Python light detector on raspberry pi outputThe measured light level is given a digital value from 0-1023. As we wired it, higher values correspond to darker light levels, so the above screen shot shows the results as the light detector was slowly shaded.

Having got the digital value for the analog light level in the Raspberry Pi, you can do anything with it – control lights, detect dawn and dusk, control motorised curtains, log it, view it online and so on. It is also possible to use the exact same technique and MCP3008 to measure a huge range of other analogue signals including temperature sensors, voltage measurement, potentiometers, etc.

Here are links to some useful resources online to find out more information about reading analogue signals with a Raspberry Pi:

Analogue Sensors on the Raspberry Pi Using an MCP3008 – this offers comprehensive details on setting up the Raspberry Pi for SPI as well as connecting it to the MCP3008 and related Python scripts.

Analog Inputs for Raspberry Pi using MCP3008 – a guide from Adafruit.

MCP3008 Datasheet – get a better understanding of the ADC.

Target Controller for Competitive Shooting

Pictured below is a controller we have just made for use in competitive shooting. The competitor has a line of five targets to hit, each of which has a microswitch which closes when the hit target flips over. When each target is hit, an LED lights up, and when all five targets have been hit and all five lights lit, the lights flash on and off five times before the system resets for the next competitor.

Controller for competitive shooting with five targets and five lights which turn on when targets are hit.

We made this as a standalone Arduino project with the ATmega328 microcontroller. This has more than enough IO (input/output) pins to cope with the five inputs (target microswitches) and five outputs (LED lights switched by MOSFETs). The lights are 12VDC powered, so the controller was also made to be powered by 12VDC.