Tilt measurement and alarm prototype

An ADXL335 and Arduino prototype that detects lateral tilt from the vertical-axis acceleration and switches on a DC motor and warning LEDs past a threshold.

The assembled tilt prototype on a breadboard, with the accelerometer, the op-amp, potentiometers, LEDs and the Arduino UNO.

Overview

A drone or a levelling platform needs to know when it is tilting too far. Framed as a product for a client, this prototype measures lateral tilt with an accelerometer, conditions the signal with op-amps and reacts past a threshold: an Arduino switches on a motor and a warning LED, while a second, independent circuit lights a red alarm even if the microcontroller fails. Calibrated in LabVIEW, it met the specification’s targets for range, resolution, accuracy and bandwidth.

The specification asked for a measuring range of ±1.5 g, a resolution of 5 mg, a 10 Hz low-pass filter so that the motor’s vibration does not disturb the reading, an action threshold of 0.8 g, and a red alarm LED that works even if the microcontroller fails.

System design

We split the circuit into functional blocks, so that each could be calculated, simulated and tested on its own before assembly.

  1. Sensor and filter. The ADXL335 accelerometer’s vertical-axis output goes through a first-order low-pass filter and a voltage follower that stops later stages from loading it.
  2. Gain and offset. A differential stage built with a TLC2274 rail-to-rail op-amp maps the sensor range onto the 0 to 5 V input of the Arduino, with 2.5 V at 0 g and a gain of 4.7.
  3. Redundant alarm. A second op-amp of the same chip, wired as a comparator, lights a red LED below the threshold without going through the microcontroller.
  4. Microcontroller. An Arduino UNO reads the conditioned signal and a speed potentiometer, handles an on/off button and drives the LEDs and the motor.
  5. Power stage. An IRF510 MOSFET switches a DC motor on a separate 15 V supply, driven by a PWM signal from the Arduino, with a 1N4001 diode across the motor.

The filter cut-off sets the resistor. With the 100 nF capacitor available:

fc=12πRC⇒R=12πfcC≈159 kΩf_c = \frac{1}{2\pi R C} \quad\Rightarrow\quad R = \frac{1}{2\pi f_c C} \approx 159\ \text{k}\Omega

The sensor already contains 32 kΩ in series, so the external resistor is 127 kΩ.

Measuring the sensor gave its real offset and sensitivity, Vout=1.67165+0.32585 aV_\text{out} = 1.67165 + 0.32585\,a (volts, with aa in g), and the gain and offset stage was calculated from these values instead of the datasheet’s nominal ones.

Proteus schematic of the complete circuit: accelerometer conditioning, op-amp stages, Arduino UNO, LEDs and the motor stage.
The complete circuit, simulated in Proteus before assembly. Source: Team report.
Schematic of the motor stage: 15 V supply, DC motor, N-channel MOSFET switched by the PWM signal, and a diode across the motor.
Power stage: the MOSFET switches the 15 V motor supply from the Arduino's PWM signal; the diode absorbs the motor's switching spikes. Source: Team report.

How it behaves

The prototype detects tilt; it does not correct it. When the vertical-axis acceleration drops below 0.8 g, the Arduino lights the red LED and switches the motor on, at a duty cycle set by hand with the potentiometer. Otherwise the green LED is on and the motor is off. The motor’s behaviour does not depend on how far past the threshold the board is tilted. The threshold in the code is 815 ADC counts, taken from the calibration, against 762 in theory.

Calibration and validation

A two-point calibration in LabVIEW, at +1 g and −1 g, gave the line used to place the 0.8 g threshold.

SpecificationRequiredMeasured
Measuring range±1.5 g±1.5 g
Resolution5 mg3.19 mg
Accuracy0.03 g±0.00314 g
Bandwidth (−3 dB)10 Hz9.82 Hz
Output at 0 g2.5 V2.5011 V
Action threshold0.8 g0.8 g
LED currentabout 1 mA0.64 mA

The LED current did not meet the specification. We raised the LED resistors to bring the circuit’s consumption down to 2.913 to 2.95 mA, and the LEDs became dimmer than required.

Problems found during development

The first readings made no sense and the Arduino saw no signal. Measuring the voltage at every node of the circuit led to the first voltage follower: the op-amp itself was faulty, and replacing it solved the problem. The on/off button did not seat well in the breadboard and made intermittent contact; soldering two wires to its legs fixed it. A last fix in the code made the button switch the system both on and off.

Cost and sustainability

A cost study was made for the components and materials used in the prototype, giving an approximate total of €64 at the course supplier’s prices. All the components are RoHS-compliant according to their datasheets, and the modular design makes the prototype easier to repair and reuse, in line with the WEEE directive.