Converting Digital Watch into a Timer Stopwatch for Projects

Pictured below are the inner workings of a cheap digital watch which has been modified to enable remote operation of the buttons so it can be used for automatic stopwatch timing.

Modified digital watch used as stopwatch with remote buttons or relay control

This particular watch had a broken backlight and broken strap, but it had always kept very good time. Therefore it was a perfect candidate to be re-purposed.

The watch had rubber button tops integrated into the watch case. When the workings are removed from the case, the buttons themselves are exposed. They comprise a thin strip of metal separated from a metal pad on the watch PCB. When the rubber button top is pressed down, the metal strip makes contact with the metal pad making an electrical connection.

Inside look at a digital watch button

All of the metal strips are connected to the watch battery ground, so the watch detects button presses by waiting for 0V to appear on one of the metal pads (which are electrically connected to the microcontroller inside the watch).

We soldered wires to the three metal pads of the buttons we wanted to control, and a ground wire to one of the commonly connected metal strips. Shorting the end of this ground wire to the end of any of the other wires causes the relevant button operation to take place.

relay board to control a stopwatch for timing arduino projectsWe next made the above pictured board. We put three tactile switches on the board and wired them up so that when pressed, they would short a mode button input to ground. These tact switches make it much easier to interact with the wired-up watch manually.

Then we added a small 5V coil relay and connected its NO and COM pins to the Start/Stop button connection and to ground for the watch. When the relay is energised (closed) it will simulate the Start/Stop button of the watch being held down.

The final component is an Arduino Pro Mini in a socket. This board will be used to calibrate the internal clocks of Arduino Pro Mini clones as their crystals are not accurate enough for some of the projects we build.

(Note that we are powering this board with 12VDC for convenience as that is the voltage we use for all of our testing rigs with a bench power supply, but for a one off it would have been 5VDC powered – 4 AA cells for example.)

Controlling the Stopwatch via Arduino and Calibrating the Arduino’s Internal Clock

 digitalWrite(relay, HIGH);
 delay(50);
 digitalWrite(relay, LOW);

The Arduino code above is used to briefly energise the relay which starts and stops the stopwatch. We used a 50 millisecond delay so that the relay has time to energise (physically close its internal contacts) and button presses of under 20 milliseconds were ignored by this watch. When someone presses a button, they typically keep it held down for from 30-70 milliseconds, so we replicated that.

To roughly measure how long is 10 seconds for the Arduino, we used the following code:

digitalWrite(relay, HIGH);
delay(50);
digitalWrite(relay, LOW);

delay(10000);

digitalWrite(relay, HIGH);
delay(50);
digitalWrite(relay, LOW);

It starts the stopwatch, waits 10,000 milliseconds, and then stops the stopwatch. If the Arduino is accurate, the stopwatch will stop with 10.00 seconds displayed. In a few quick runs we got 10.03, 10.07, 10.06, 10.06, 10.03, 10.03, and 10.06 seconds. This seems to show that this particular Arduino Pro Mini was running a little slow (it could also be that it takes longer for the relay to energise than de-energise which could be significant when only timing 10 seconds).

The delay() function is not accurate in general since we do not know how long the loop execution time is. Instead for accurate time testing we use millis().
Replacing delay(10000); with the following:

unsigned long startTime = millis();
do{
  delay(1);
} while (startTime + 10000> millis());

we got 10.00, 10.00, 10.00, 10.00, 10.00, 10.00, and 10.00 seconds on the stopclock in initial testing.

For calibration we test for a minimum of 8 hours, but sometimes 12 or 24 hours. The longer the test, the greater the accuracy of the results and therefore the better we can calibrate the Arduino’s internal clock.

There are 28800000 milliseconds in 8 hours for example. So we’d modify the code above to have while(startTime + 28800000 > millis()); . After 8 hours, the stopwatch will show a time. We found that that this Arduino Pro Mini was running 4 seconds slow….so after 8 hours the clock showed 8h 00m 04s.
There are 28,000 seconds in 8 hours, so the error in the Arduino clock is
1 – 28,000/28004 = 0.0001428 = 0.01428%.
We can save this percentage error in memory on this Arduino Pro Mini and take it into account when using it in timing applications. If we want to use this Pro Mini to time 5 hours accurately, we’d run the timer for 5 hours minus 0.01428% of 5 hours.

Modified Spot Welder Timer from 555 Circuit

555 timer for weldingPictured above is a standard circuit design for controlling a spot welder for use in building battery packs and other applications. The welder is 12VDC powered from a large battery, and the 555 timer circuit controls the duration of the brief (sub one second) pulse of high current required to perform the spot welds.

We sell a selection of programmable timers with displays which are much simpler to use and set up than a 555 timer circuit with just a potentiometer used to set the current pulse duration. One of these user programmable options is our dual pulse welder timer controllerhttp://www.reuk.co.uk/wordpress/dual-pulse-spot-welder-timer-controller/ . A dual pulse when spot welding gives much better results, but requires a complicated circuit and many components to achieve using a 555 timer.

Therefore we put together the following controller which can work with the output side of a standard 555 spot welding circuit to give much better control and dual pulse capability for customers who already have an array of power MOSFETS set up to supply current to their 12V welding apparatus.

modified welder timer circuit based around old 555 timer circuitry, but giving dual pulse capability

The duration of the first pulse, pause, and second pulse can each be set by the user from 0.01 to 1.99 seconds duration with 0.01 second resolution facilitating consistent welds which can be reproduced again and again.

If you need any kind of spot welding timer controller, please email neil@reuk.co.uk with details of your requirements.

Multiple Switch Bathroom Fan Controller

Pictured below is a bathroom extractor fan controller we were recently commissioned to build.three switch bathroom extractor fan controller

The client has a house with a newly renovated bathroom and three existing light switches which are to be used to control a mains powered extractor fan in the new bathroom. If any of the three light switches is on, the fan is to run.

If the output from these three switches were to be connected directly to the fan, then the fan would turn on if any of the switches is on, but it would also result in the lights controlled by the three switches (in different rooms) all turning on simultaneously. This would be a problem.

Therefore, the output from the three switches is connected to three independent relays with 240V AC coils on the board pictured. These three relays each switch a single 12V signal from a nearby mains transformer to energise a 12V DC coil relay which in turn switches mains live to supply power to the fan when one or more of the light switches is on.

If you require any kind of bespoke controller, please email neil@reuk.co.uk with details of your requirements.

PPC 1500 Target Shooting Timer

PPC 1500 target shooting timer controller relay

Pictured above is a timer we recently built to control the start and finish horn for PPC 1500 shooting competitions.

In competition a button is pressed followed by a 3 second delay. Then the timer begins counting down from 8 secs,12 secs, 20 secs, 35 secs, 90 secs, or 165 secs with a horn sounding for 0.75 seconds as the timer starts, and again for 0.5 seconds after the timer has finished.

The user can select the timing option using the on board button, an external button, or using a remote control switch.

The on board display shows the current setting while the timer is not running, and then shows the countdown ticking down while it is running. The start button can also be used to stop the timer when it is running to reset the system.

A second button enables the user to sound the horn at any time while the button is being pressed.

If you need any time of timer controller, please email neil@reuk.co.uk with details of your specific requirements.

Raspberry Pi 3 Model A+

Raspberry Pi 3 Model A+

Today (November 15th 2018) the new Raspberry Pi Model 3 A+ was released, four years after the release of the original Raspberry Pi Model A+.

The new A+ is a physically smaller (65mm × 56.5mm compared to 85.6mm × 56.5mm) and cheaper (US$25 compared to US$35) version of the Raspberry Pi Model 3 B+ with slightly reduced features.

The A+ has just one USB 2.0, the B+ has four. The A+ has half the LPDDR2 RAM of the B+ with 512MB compared to 1GB.  And, the A+ has no ethernet port whereas the B+ has gigabit ethernet connectivity.

The Raspberry Pi Model 3 A+ and B+ share the same 1.4GHz quad-core Arm Cortex A53 processor, and the same WiFi and Bluetooth connectivity.

Arduino Two Channel Thermometer with Display (Full Code)

Pictured below is a two-channel thermometer we recently built for a customer. This device takes inputs from two ds18b20 temperature sensors and displays their measured temperatures on a 1602 LCD display module. The thermometer is built around an Arduino Pro Mini.

Arduino double thermometer with lcd display - full code provided

Below is the full Arduino sketch (code) for our device.

See this guide to Connecting an I2C Display to Arduino for the LCD connections. We have added the necessary 3k3 pull up resistors between pin A4 and 5V, and pin A5 and 5V – click here to read about I2C Pull Up Resistors. We have also used an external 5V regulator rather than relying on the 5V regulator built into the Arduino Pro Mini, and added reverse polarity protection on the input with a 1N4001 diode.

// © reuk.co.uk - 2018
// Double Thermometer with Display.

// For the DS18B20 temperature sensors.
#include <OneWire.h> // (https://github.com/PaulStoffregen/OneWire)
#include <DallasTemperature.h> // (https://github.com/milesburton/Arduino-Temperature-Control-Library)

// Data wires are plugged into pins 2 and 3 on the arduino.
#define ONE_WIRE_BUS 2
#define SECOND_BUS 3

// For the 1602 LCD module.
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>
#define I2C_ADDR 0x27 // Note that some modules have address 0x3F

#define BACKLIGHT_PIN 3
#define En_pin 2
#define Rw_pin 1
#define Rs_pin 0
#define D4_pin 4
#define D5_pin 5
#define D6_pin 6
#define D7_pin 7
LiquidCrystal_I2C lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);

// Setup a oneWire instances to communicate with OneWire devices.
OneWire oneWire(ONE_WIRE_BUS);
OneWire secondWire(SECOND_BUS);

// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensor1(&oneWire);
DallasTemperature sensor2(&secondWire);

float sensorOneTemperature = 0.0;
float sensorTwoTemperature = 0.0;

void setup(void)
{
 // Start up the temperature sensor library.
 sensor1.begin();
 sensor2.begin();
 
 // Set the temperature sensor resolutions to 11 bit
 // ADC (12 bit is much slower but higher resolution).
 sensor1.setResolution(11);
 sensor2.setResolution(11);
 
 // Initialise the LCD.
 lcd.begin (16,2); // For a 16x2 character LCD
 // Switch on the LCD backlight.
 lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
 lcd.setBacklight(HIGH);
 // Clear the LCD screen.
 lcd.clear();
}

void loop(void)
{ 
 // Read in the temperatures of the two sensors.
 sensor1.requestTemperatures(); // Read temperature of sensor1
 sensorOneTemperature = sensor1.getTempCByIndex(0);
 sensor2.requestTemperatures(); // Read temperature of sensor2
 sensorTwoTemperature = sensor2.getTempCByIndex(0);

 // Display the temperatures of the sensors on the LCD.
 displayTemperatures();
}

void displayTemperatures(){
 // Display sensor1's temperature.
 lcd.setCursor(0,0);
 lcd.print(" T1: ");
 lcd.print(sensorOneTemperature,2);
 lcd.print((char)223);
 lcd.print("C ");
 
 // Display sensor2's temperature.
 lcd.setCursor(0,1);
 lcd.print(" T2: ");
 lcd.print(sensorTwoTemperature,2);
 lcd.print((char)223);
 lcd.print("C ");
}

If you need any kind of bespoke thermometer or thermostat, please email neil@reuk.co.uk with details of your specific requirements.

Hen House Door Controller with Manual Override Buttons

Pictured below is a new hen house door controller we recently made for a customer.hen house door controller with manual overrideOur most common design for a door opener/closer is our Dawn Dusk Henhouse Door Controller – a device which uses a couple of roller limit switches to keep track of the position of the door, and a light detector to detect dawn and dusk.

This new device is designed for operation with an aluminium screen door opened and closed by a linear actuator which has its own internal limit switches. At dawn, voltage is supplied to the actuator for one minute giving the actuator time to fully open the door with no worries that it will overrun thanks to the limit switches. At dusk, reverse polarity voltage is supplied to the actuator one one minute to close the door. The user can set the ambient light level threshold at which the door will open or close.

A further requirement for this controller was the ability to manually open or close the door at any time in order to give access to the chicken run. For this the user can select manual mode, and use the lower door or raise door buttons when they need to use the door. The controller keeps track of the position of the door during manual operation which is vital as there are no limit switches connected to the controller to tell it where the door is. On board buttons are available, but also screw in terminals so that external push-to-make buttons can be more conveniently located.

If you need any kind of door controller, please email neil@reuk.co.uk with details of your requirements.

Door Controller Instructions

Light Detector

With the board connected up as per the diagram, the first step is to set the light detector threshold. The light detector is not waterproof, so it must be protected from rain, but also positioned so that it is exposed to natural light. The leads to the light detector can be extended to get it in an optimal safe location.

In the late afternoon / evening when the ambient light is at the level below which you want the door to be closed, press and hold the calibrate light detector button for more than one second. The red and green LEDs will then alternately flash for a few seconds and the current measured light level will be saved in memory as the night-dawn and day-dusk threshold.

Manual Operation

If the yellow LED is on, the device is in manual mode. To toggle between manual and automatic mode, press the choose auto/manual button.

In manual mode, pressing the manual lower door button will see power output to the actuator for one minute to close the door. (If during that one minute, you press the manual raise door button, power to the actuator will be cut leaving the door somewhere between open and closed.) Similarly, you can manually open the door by pressing the manual raise door button.

If you find that pressing the button to close the door instead opens the door, reverse the polarity of the power connections to the actuator.

Automatic Operation

When initially powered on, the device assumes that it is day time and the door is open. (If you connect the power at midday with the door closed for example, the door will not open until the following morning unless you manually open it.)

When it gets ‘dark’ – light level measured to be below the user set threshold – the red LED will turn on. After 10 seconds of continuous ‘darkness’, the door will automatically be closed with power supplied to the actuator for one minute and the actuator’s internal limit switches preventing the door from overrunning. Now the device will sleep for two hours – red and green LEDs alternately flashing – so that no false dawns are detected if the skies suddenly brighten.

After the sleep, it will now be very dark. The device will wait through the night until dawn – light level measured to be above the user set threshold – and then turn on the green LED. After 10 seconds of continuous ‘light’, the door will automatically open, again followed by a 2 hour sleep to prevent the detection of a false dusk if clouds cover the sun.

Formula 1 Race Starting Lighting Timer

formula 1 racing timerPictured above is a timer we recently built for a customer which will be used in a Formula 1 style race start lighting gantry. This gantry will be fitted at the top of a slope with toy cars held by a small gate latched up by a small solenoid with a spring loaded core. When the race is to start, the solenoid is energised which drops the gate allowing the cars to roll down the slope in their race.

In the photograph, five red LEDs are temporarily attached to the timer board for testing, but these will be mounted into the gantry across the track when it is finished.

When the user presses the button, the LEDs follow the standard F1 race start sequence – each red LED turns on in sequence with a one second interval. As each LED turns on, an on board piezo buzzer briefly pips. Then, when all five LEDs are illuminated, there is a random time interval of between 1 and 3 seconds before all the LEDs are turned off.

formula 1 race starting gantryThe lights turning off indicates that the race is to start. The buzzer sounds for 1 second, while the on board relay energises for 1 second to energise the solenoid and start the race.

If you need any kind of bespoke timer or controller, please email neil@reuk.co.uk with details of your requirements.

Solar Water Heating Pump Controller with Timer Override

solar water heating pump controller with maximum temperature and timer override

Pictured above is a solar water heating pump controller we recently made for a customer. This device is based around our popular 2016 solar water heating pump controller with display and datalogger, but has some added features.

The first added feature is a maximum temperature override. As this device will be used for solar heating of a swimming pool, we added user programmable maximum pool temperature override. If the pool starts to get too hot, the pump bringing hot water from the solar panel will not be run again until the pool temperature has fallen by at least two degrees Celcius.

The second added feature which we have not been asked for before is a timer override. The user of this device only wants the pump to be allowed to run between 10am and 4pm, so we have added a 12V programmable digital timer so that the user can set the times of operation of the heating system.

If you need any kind of pump controller or timer, please email neil@reuk.co.uk with details of your requirements.

Raspberry Pi Home Automation with Machinon

Pictured below is Machinon, hopefully soon to be released industrial-grade hardware originating from a community project, and designed to manage home and small business automation with a Raspberry Pi.

machinon home automation iot raspberry piThis smart home solution adds smart IO to a Raspberry Pi – 16 digital inputs, 16 digital outputs, and 8 analogue inputs.

The digital inputs can be used as pulse counters (for kWh meters etc) or to detect status changes (doors opening and closing, buttons being pressed, motion sensors triggered etc).
The analogue inputs (0 to 20mA, 4 to 20mA, and 0 to 10V input with 14bit resolution) can be used to measure currents and voltages, light levels, temperatures, and more.
The digital outputs each supply up to 500mA which can be used to switch high voltage and high current appliances via a relay, or directly power low current low voltage devices.

Machinon utilises two ATxmega microprocessors which take care of all the complex pulse counting, timing, analogue measuring, and data collection. The Raspberry Pi then simply communicates with Machinon via UART (serial port) to grab data and control and configure the smart IO.

machinon smart home prototype internals

Machinon is designed to interface with many open source home automation software packages including Domoticz, openHAB, and HomeGenie so the overall user experience should be relatively simple.

The price of this device is likely to be around £200 plus the cost of a Raspberry Pi and microSD card to go in it. Therefore, probably under £250 all in including delivery.

machinon smart home with raspberry pi

For more information, click here to visit the Machinon website.