Sparkfun: Large Piezo Vibration Sensor - With Mass

 Overview: 1, Nice overview, but show a picture of the device Wiring:  0, Give specifics of how you wired it. Include a diagram. Think of what a beginner would like. Code:    2 git:     0, put in git Demo:    2 Total:   5/10 Comments: Good start, but more specific details are needed.

Overview
The Large Piezo Vibration Sensor is a basic piezo sensor which is often used for flex, touch, vibration and shock measurements. This sensor acts like a small capacitor which discharges up to +/-90V when the film moves back and forth. Some common uses this type of sensor are for impact sensing or as a flexible switch. A larger scale example are piezo sensors that are laid within the road for use of traffic signals.

This sensor can be purchased at SparkFun.

The Technical Manual and datasheet can also be found on Sparkfun's website.



Usage
Since the piezo sensor acts like a small capacitor, you can connect on a bread board as such. However an additional resistor is needed in order affect the low frequency of measurement. This is called the "loading effect". Additionally, if the signal from the piezo sensor is too low an op amp may be necessary.

More specific information and circuit diagrams can be found in the Technical Manual on pages 36-40.

Beagle Bone Usage
The value being read from the piezo sensor will be a voltage up to +/-90V. This means that an analog pin must be used to read the value from the sensor. The voltage being supplied to the sensor affects how much sensitivity you will receive. Look in the technical manual to find a desired voltage that will work for you. For the example below, I simply used a 5V source.



Reading the Analog Signal
You can simply read the value of the piezo sensor from the terminal by reading the contents of a file in the /sys/devices/platform/omap/tsc/ain# directory. The # is 1 + the number of the analog pin you selected as your analog input. However this method will not allow you to accurately see the change of voltage as the film moves. To do this you will need to write a c program to print the values to the terminal repeatably or plot the voltage over time. The sample code below shows a simple program to print the voltage of the sensor to the screen.

Sample Code
The following code can be found on git hub.

/************************************** Example Program for the Large Piezo Vibration Sensor - With Mass

This will display the value of the AIN0 Pin directly to the terminal repeatively.

wrtten by Kevin Geisler, 23-Sept-2012
 * 1) include 
 * 2) include 
 * 3) include 
 * 4) include 
 * 5) include 
 * 1) include 


 * 1) define SYSFS_AIN1_DIR "/sys/devices/platform/omap/tsc/ain2"

FILE *fp;

int readanalog{ if ((fp = fopen(SYSFS_AIN1_DIR, "r")) == NULL) {		printf("Cannot open value file.\n"); exit(1); }

//Set pointer to begining of the file rewind(fp); //Write our value of "0" to the file char inString[10]; fgets(&inString, 10, fp); fflush(fp); //			printf("...value set to 0...\n"); fclose(fp); //	printf(inString); return atoi(&inString); }

int main(int argc, char** argv) {

//Run an infinite loop - will require Ctrl-C to exit this program while(1) {	printf("%d\n",readanalog); usleep(100000);

}	return 0; }