Vibration measurement using analog in

02 Dec 2012

Hi All,

I am looking for some information regarding using an analog input for vibration measurement. I am looking to use a Piezo sensor to measure vibration level. I currently have a piezo sensor wired up using an extremely basic set up. I have only managed to get it showing a value in teraterm. It shows about 0.03 and will display 1 when i subject it to a sudden impact but its very 'rough'.

I was wondering if someone could offer some help regarding the value i will get form the analog input and how to scale it, perhaps with a reference voltage??

Its in very early stages and any help would be very appreciated. I also only have a fairly basic knowledge of microcrontrollers so apologies if my query is worded a little vague. I have looked through some other threads regarding analog inputs but they dive a little deep for my basic understanding at this time.

Many thanks

Rob

02 Dec 2012

Hi Robert,

it all depends on the output of your sensor. A very basic unit, such as the one you describe, will output a voltage signal that is proportional to the 'vibration' it senses in a given direction (i.e. x, y and z). You connect that voltage output to the analog input of the mbed. On the the mbed itself you need a program that periodically reads the analog input pin. The easiest way of doing this is just having a loop that reads the voltage. If you then want to read the vibration level on your PC you need to interface it in some way. You used teratem, but you can use anything that can make a serial interface.

I'm not sure what specifically you want to do with the reference voltage, can you explain that more.

I've made something similar a while ago: http://mousevr.blogspot.co.uk/2012/01/rig-diagnostics.html

in my case the mbed only reads the analog input pin and writes the result to the serial interface. A java program runs on the PC that reads the serial input and makes a sliding graph.

Let me know if anything is unclear, it's really quite easy to understand once you grasp the basics.

02 Dec 2012

Hi Lukas, Thanks for the reply. I checked out your link and its very similar to what i'm after. The level of vibration i need to measure is quite small. I've attatched some pics of what i have. A picture of the rough circuit using the piezo sensor and my (extremely simple :) )program. I threw the program together quick just to see if i could look at what values its giving. I believe the analog input is ten bits so it has a range of 1024 bits?? (i think). I need to get the piezo sensor giving some values in that range when the sensor is subject to subtle vibration. At the moment it just sits at one value and jumps around slightly when i give it a hard knock. Again, i'm sorry if my explanations are a bit off but if there is any more info i can give just let me know. Thanks for the help. Robert /media/uploads/robert111/program.png /media/uploads/robert111/scan.jpg

02 Dec 2012

Holy crap, that came out big!!!!

02 Dec 2012

Robert, just a few comments to help you look further...

The piezo are very high impedance devices and really need to feed a high impedance circuit, FET or FET input type op amps (op amps and FETs still need a DC bias via a high value resistor though).

Your circuit does not have very high gain (approx Rc/Re), so about 22/3.3 so about 7 at DC and rising as the extra RC comes into play.

Also remember analogue inputs on the mbed are unipolar, not bipolar so you will get a half wave rectified approximation of the input signal.

You may also wish to consider the mechanics of the piezo. Many many years ago back in the 1980's (yes that far ago!) I used a piezo sensor to measure hand tremor and a key part of the design was to add a mass to the moving part of the piezo as this gives it some inertia that provides a much larger signal than the standard part. I simply glued a small nut in place with epoxy to centre of the sensor.

I hope the above helps with your ideas.

02 Dec 2012

Hi Kevin, Thanks for the information. To be honest, the circuit i used above was obtained from a website. There where other examples using op amp's so maybe i should look into that instead. Could you possibly help with the values i am getting. I appreciate the circuit may be all wrong but by taking the value i have in the original and multipying by 30 and then printing to screen, it gives a value between 4 (ish) and 30 when maxed out? I was wondering why i get this. The original appears to be somewhere between 0 and 1 (again very roughly) because when you impact the sensor so it reaches maximum it goes to 1. How can i get the resolution of 1024 bits?? I ask because the task requires depecting between very slight changes so i require a wide range to work with. Thganks again Robert

P.S I have looked at some other piezo sensors on sale and some do come with built in weights at one end, i'm guessing for the reason you explained above :)

02 Dec 2012

Hi, just a quick thought, you could increase Rc for more gain and adjust you bias pot 100k to get a reasonable DC level at the collector (i.e. biased into linear region of transistor). Add a capacitor from the output to the analogue input of the mbed to remove the static DC component.

this way mbed is only going to measure change in force or the vibration and will not be affected by DC drift in the transistor circuit.

I would also add a diode from the input to ground such that if the input goes negative the diode turns on and clamps the signal to -0.6V max. Similarly another diode can protect the input and clamp at 3.3V supply +0.6V by connecting to the +ve mbed (3.3V) supply. You only need small signal diodes.

The inputs probably are internally clamped from memory, but I always like to make sure with experimental circuits!

You can increase Rc to get the higher gain and keep adjusting the 100k pot for approx 2 to 3V at the transistor collector to see if this gives you a useful idea of the gain required.

02 Dec 2012

The only way there could in theory be damage to the mbed is with the capacitor added. Without capacitor this circuit cant possible damage an mbed since it is always between 0 and 5V. Also this circuit has Rc/Rm AC gain, due to the cap at the emitter providing another AC path there. That said generally an opamp just works better. Especially since the official maximum impedance that may drive an analog input is 7.5kOhm. You are already way above it, in the beginning it will only limit the accuracy, but in the end the ADC can become unstable, resulting in bogus returns.

Regarding the resolution, if you read the analogin documentation you see the read function returns a float between 0 and 1, so it is simply a scaled version of the input. Afaik the mbed has 12-bit ADCs, so it takes the input which is between 0 and 4095, and divides that by 4095 to get the value it returns. There is also another read function that doesnt do that. If you multiply the value you get from read with 3.3, you get the voltage measured by the ADC.

Btw while gain is nice, it does depend on how large signals you want to measure, since you now apparently already go over the ADCs max.

02 Dec 2012

Hi,

Robert, was there a datasheet that came with your sensor? Before making a circuit yourself that would be the first thing to consult. The sensor I used in my example I bought from https://www.sparkfun.com/products/9269 which tells you exactly what supply power you need and what comes out of the sensor.

If you don't have that much experience with circuits I would strongly recommend doing that.

One thing you need to keep in mind when it comes to serial connection is the data-transmission rate: if you want to sense high-frequency vibrations you can't just read the analog in and send it to the serial port as the number of packages per second that can be transmitted via serial will determine your maximum frequency you can measure. E.g. if you can send 100 packages per second (i.e. 100Hz) the maximum frequency of vibration you can detect will be 50Hz (Nyquist frequency). A better solution would be to read the analog in for a certain amount of time (say 0.1 sec), calculate a spectrogram and send that to the PC.

As you can tell from Kevin and my responses it's not all that easy and there is no super-quick solution, but you can mike your life a lot easier by buying a 'high-level' sensor circuit where you just need to wire up the pins and get a pre-defined output.

02 Dec 2012

Thanks very much for that info. It's very appreciated. I see now that the analog input is altered within the microcrontroller and gives out the value between 0 and 1. The sensors I have are very cheap and I realised this when they arrived, no data sheets or anything. I have just ordered some proper ones which are on the way. I will also look at the circuit and look at using an op amp instead as it appears it is the way to go. Thanks for all the info, plenty to get on with and research. Ill let you know how I get on and if I get stuck. Thanks again. Robert