Project idea: fotball goal sensor

I’ve been playing with the idea of making a fotball goal sensor. Well not quite, but to detect when (and where) a ball hits a wall. The plan is to use 3 microphones and either the analog or digital input of a microcontroller to measure the difference in timing of the loud bang of the ball hitting the surface. Feasible?

The position could be transfered via BLE to a smart phone or a display. Could probably make a game out of it.

Some code snippets below for testing:

#include "msp430g2553.h"
#pragma location=0x0200
unsigned int adc[3];
int triggered = 0;
signed long adc_average[3];
long count = 0;
void main(void) {
 WDTCTL = WDTPW + WDTHOLD; // Stop WDT
BCSCTL1 = CALBC1_16MHZ; /* Set DCO to 16MHz */
 DCOCTL = CALDCO_16MHZ;
ADC10CTL1 = INCH_3 + CONSEQ_1 + ADC10SSEL_3 + ADC10DIV_0; // A3/A2/A1, single sequence
 //ADC10CTL1 = CONSEQ_3 + ADC10SSEL_3 + ADC10DIV_0 + SHS_2 + INCH_3;
 ADC10CTL0 = ADC10SHT_2 + MSC + ADC10ON + ADC10IE;
 ADC10DTC1 = 0x03; // 3 conversionso
 ADC10AE0 |= 0x0E; // P1.3,2,1 ADC10 option select
 P1DIR |= 0x01 | BIT6; // Set P1.0 output
for (;;) {
 ADC10CTL0 &= ~ENC;
 while (ADC10CTL1 & BUSY)
 ; // Wait if ADC10 core is active
 ADC10SA = 0x200; // Data buffer start
 ADC10CTL0 |= ENC + ADC10SC; // Sampling and conversion start
 __bis_SR_register(CPUOFF + GIE);
if (triggered && count++ > 1000) {
 count = 0;
 triggered = 0;
 P1OUT &= ~(BIT0 | BIT6);
 }
// Filter
 int i = 0;
 for (i = 0; i < 3; i++) {
 adc_average[i] += ((signed long) adc[i] - adc_average[i]) / 10;
 }
if (triggered) {
 // Do nothing
 } else if (adc[0] > (adc_average[0] + 100)
 || adc[0] < (adc_average[0] - 100)) {
 P1OUT |= BIT6;
 triggered = 1;
 } else {
 P1OUT &= ~BIT6;
 }
 if (triggered) {
 // Do nothing
 } else if (adc[1] > (adc_average[1] + 100)
 || adc[1] < (adc_average[1] - 100)) {
 P1OUT |= BIT0;
 triggered = 1;
 } else {
 P1OUT &= ~BIT0;
 }
 }
}
// ADC10 interrupt service routine
#pragma vector=ADC10_VECTOR
__interrupt void ADC10_ISR(void) {
 __bic_SR_register_on_exit(CPUOFF);
}

One thought on “Project idea: fotball goal sensor”

  1. Thanks for the code. It helped me get my own sensor system running. For a while now I’ve been reading this MSP430 Tutorial which helped me get offthe ground, but I needed some pieces of your code to average my ADC data.

Leave a Reply

Your email address will not be published. Required fields are marked *