Title: Volumeter Project

Author: Paul and Joe


Project Outline

We were to construct a system around a raspberry pi and an ADC which connected via SPI.

Project Description

We built a background volume meter, a system which was to detect the background noise in a room. A compressor microphone was used to gather the input signal and the results are displayed both on the raspbery pi using Qt and an LED matrix. The LED matrix would allow the system to operate without the need of a screen and provides an easy visual feedback if the area you are in is too loud.


Hardware:

There are two boards in this design: the input board which provides an analogue signal to the ADC and the output board which connects to the raspberry pi via I2C.

Input Circuit Diagram:

Input Circuit

R2 and R3 are tuned for gain, we used R2=10k, R3=1M giving a gain of 100

R4 and R5 can be tuned to bias the ADC for a 'no background noise' measurement, we used R4=1M;R5=2.2M

C3 can be tuned, we used 100nF

Output Circuit Diagram:

Output Circuit

The diodes D1:D8 are all LEDs. D1:D3 are Green, D4:D5 are Yellow, D6:D8 are Red.

The green diodes represent a quiet background, ambient noise.
The yellow diodes represent a busy background, some quiet conversation.

The red diodes represent a loud background, people are shouting or traffic is particularly bad.

The resistor bank R1:R8 were all 1K resistors, this can be changed, but they provide a good light on the LEDs.

Software

The software is available at: https://github.com/jpentland/qwt-example

This is based on the qwt-example. The project has been renamed to volumeter, and a new readme file has been added.

The following files have been added:

  1. adc.h - Contains definitions for reading from the ADC
  2. adc.c - Contains implementation of reading from the ADC. This was based on the ad7705_test program, with a wrapper added to make it accessible through a simple adc_read() function.
  3. ledout.h - Contains the definition of the functions required for interacting with the MCP23017 GPIO expander. The led_init() function takes two values for the possible maximum (0 LEDs) and minimum (8 LEDs) values which could be displayed on the thermometer display. The led_write() function then takes the raw value from the ADC, and scales it to a value from 0-8, based on the maximum, minimum and given value. It then creates an 8-bit thermometer value, and writes it to the GPIO expander using I2C.
  4. ledout.c - Contains the implementation of the functions defined in ledout.h. The I2C communication parts were based on information from:

    http://hertaville.com/2013/04/01/interfacing-an-i2c-gpio-expander-mcp23017-to-the-raspberry-pi-using-c/
    http://elinux.org/Interfacing_with_I2C_Devices

The following files were also modified:

  1. main.c - This was simply modified to allow a single parameter to be passed containing a filename, to which the data log will be written.
  2. window.cpp - This was modified to periodically read the value from the ADC into the display buffer. The gain knob is used as a multiplier for the incoming value. Additionally, the ADC value is sent to the LED output, and to the file, if it has been specified. All references to the example sin wave were removed.
  3. window.h - A small modification was made to allow the specification of a filename, and the storage of the file pointer as a private variable in the window class.
  4. volumeter.pro - This was modified to include all required files for the build, and to produce the binary as "volumeter" rather than "QwtExample".
  5. In order to run this successfully, the system file /etc/modprobe.d/raspi-blacklist.conf must be modified to remove the i2c blacklist.

Additionally, the following command must be executed before running the application:

sudo modprobe i2c-dev

Evaluation

We tested the responsiveness of the software by generating different noise levels. When the code (in GUI) is running on the raspberry pi the system is very responsive, the output LEDs adjust to noise very quickly, even when a spike of noise - such as a clap of the hands - occurs. When the application is Xforwarding the GUI to the lab machines there is a very noticeable delay, this will be because of the hardware restrictions on the raspberry pi.

http://www.youtube.com/watch?v=3OQ--QFT6xs&feature=youtu.be

Future Work

Despite our glorious efforts, there are improvements which could be made. The hardware was prototyped on veroboard, the size and reliability of such hardware could be significantly improved if a pcb was built specifically for it. With a custom pcb both the input and output boards would be about the size of a credit card.

In addition to this, the software could be modified to produce more meaningful values, instead of displaying the analogue signal it could be changed into decibels. This would provide a more useful display of the noise level in the environment as that is the normal unit of sound.

Lastly, another improvement which could be made would be to increase the quality of the LED outputs. We could change the output bit depth from 8 to 16 bits. This would provide a very clear indication of background noise.

Conclusion

This project uses both SPI and I2C to communicate with external devices and is a good example of working with the raspberry pi at a low level.