Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Help and advice on filtering accelerometer data from pothole event

Status
Not open for further replies.
Read the data sheet. Unfortunately our Internet at work is down but this evening when I get home I'll give you a few thoughts. Well for what you want how I would think about doing this anyway. I would just keep it real simple. Use the analog outputs, maybe add a filter to ground as mentioned for additional filtering over what the unit offers.

Ron
 
Thanks to Dougy for the .wav files. I was able to read them both, and use them as stimulus to a running LTSpice simulation. The 100Hz resampled one runs the sim much faster, but preserves sufficient detail to be useful.

Here is a plot of pothole100hz.wav (upper trace, green) and the output (lower trace, red) of a circuit I created. Did my circuit find all the potholes?
 

Attachments

  • Pots.jpg
    Pots.jpg
    379.2 KB · Views: 192
WOW how did you do that?! lol seems perfect I hit about 5 potholes there was a 6th one that was kinda a hybrid bump so 5 looks great!
 
HP is the Wav signal high-passed with a time constant of 2.3ms and gain of -4.6.
Rect is HP rectified, gain of 5.
Ave is Rect low-pass filtered with a time constant of 10s.
AveB is Ave buffered with a gain of 1.
RL is Rect low-pass filtered with a time constant of 0.27s and a gain of 0.36.
RLB is RL buffered with a gain of 1.
PotHole is the output of a comparator of the difference between AveB and RLB with a few mV of hystersis.

Think of the E2 thingys as an ideal opamp with an open-loop gain of 100K. These simulate much faster that real opamps (this simulates in less than 1s, isn't the wav input neat?). In real life, the E2s could be almost any IC opamp.
 

Attachments

  • Potc.jpg
    Potc.jpg
    137.9 KB · Views: 184
  • Potd.jpg
    Potd.jpg
    401.9 KB · Views: 166
wow so to build this out of real electronic components, all the E's are actual opamps configured to be a buffer, or an open loop gain. Damn looks confusing haha. Is the program you used SPICE? that takes the .wav file?
 
LTSpice. I have posted the circuit file so you can run the sim yourself if you down load and install LTSpice.

Here is a more logical, simplified version. This is better than the previous one. Converting it to real opamp circuits is straighforward. You will have to download the .wav file.
 

Attachments

  • Pot2s.jpg
    Pot2s.jpg
    128.2 KB · Views: 147
  • Pot2d.jpg
    Pot2d.jpg
    597.7 KB · Views: 159
  • W2.asc
    3.3 KB · Views: 132
Would the Precision rectifier work from the accelerometer if the voltage does not go negative? it goes from 0 to 3.3V and I have it converted to Gforce. Would I have to subtract the VCC/2 1.65Volts from it to zero it, so it goes negative and positive instead before it goes in the rectifier? with a difference comparator.

I'm not sure if I get the purpose of the precision rectifier is it a peak detector?

I have a bunch of 741's laying around would they be able to do the filters and rectifier?
 
Last edited:
Would the Precision rectifier work from the accelerometer if the voltage does not go negative? it goes from 0 to 3.3V and I have it converted to Gforce. Would I have to subtract the VCC/2 1.65Volts from it to zero it, so it goes negative and positive instead before it goes in the rectifier? with a difference comparator.

Just run it through a d.c. blocking capacitor. Does this mean that the signal coming out of the accel. is not the same as the .wav file?

I'm not sure if I get the purpose of the precision rectifier is it a peak detector?

No, It acts as a rectifier. Look at V(bp) {red trace} and V(rect) {lgt. blue trace} in the attachment to post #28. If v(bp) < 0, then V(rect)= 0 else V(rect)=V(bp), i.e. pass only the positive part of the waveform.

I have a bunch of 741's laying around would they be able to do the filters and rectifier?

Yes.
 
Just run it through a d.c. blocking capacitor. Does this mean that the signal coming out of the accel. is not the same as the .wav file?


The voltage from the Accelerometer is 0.330 to 2.97 VDC going into the arduino ADC

Basically I find the ADC value of 1G (gravity) acting on the Z-axis (Datasheet VCC/2 or 1.65V), and subtract that as a offset to get 0G's within software

Then when the bump is hit, it is set at 0G's in software, and has negative and positive Gforce because it is zeroed in software

The sensitivity of the accelerometer is 440mv per G a -3G/+3G Accelerometer

The actual voltage coming out of the accelerometer isn't conditioned to be negative, so instead of subtracting the 1G gravity offset in software, I should "zero" the output of the accelerometer by a differential amplifier, since 1G = 1.65V If I apply 1.65 of DC offset it will be 0 volts, like it was within the software. So the signal actually gets rectified

Question, The rectifier with the opamp, I found is called a super diode, what makes this better than a single regular diode? Is it because the diode drops the signal .7 volts?



I have a KXPS5-3157 Accelerometer, that outputs 0.330 to 2.97 VDCVDC

The zero-G offset is 1.65VDC (VCC/2)

1G of gravity = 1.65VDC + 0.440 = 2.09 volts = ZERO to cancel out gravity

I want to "zero" the output of the accelerometer strictly in hardware. I was thinking of using a Differential Amplifier, and inputting -2.09 and the output of the accelerometer to zero it. Not sure if this will work, my application is as follows:

The sensitivity of the accelerometer is 440mV/G

I want to zero out of the accelerometer on the Z axis to cancel out gravity, so subtract 2.09 volts.

Then I want the output of the accelerometer to swing positive G's Positive voltage, and negative G's negative voltage.

I want the accelerometer to output negative and positive voltage corresponding to the -G and +G's, canceling out the affect of gravity also

The supply voltage is 12volts, I'm assuming a would need a rail to rail opamp?

I was doing this all in software with subtracting ADC values of the voltage within the software, but to use the filters and rectifiers I have to have positive and negative voltage
 
Last edited:
If you were going to do the processing external to the arduino, then you can get rid of the effect of gravity just by ac-coupling the accel signal. That effectively subtracts out 1g...

Here is a reference to the precision rectifier.
 
Ah, yeah the signal I gave you is what my arduino plots all within the arduino program. But since all the analog components of your circuit need a signal generating negative and positive voltage, I'm not sure how to implement it since the accelerometer does -G's by subtracting 0.440mV from 1.65V (Zero G's) which is still positive voltage,

I handle all this in software:

datafromADC is the ADC value of the voltage of the accelerometer

one_G_ADC is the ADC value of 1G so cancel out gravity

senZ is the 440mv sensitivity

float GForce = ((float)datafromADC - (one_G_ADC)) / senZ; // ZERO BASE WITHOUT GRAVITY

Then I can plot the negative and positive G's that way


Think I got it:

**broken link removed**

can't figure out a perfect ratio of voltage divider to get exactly 0volts though with standard components
 
Last edited:
What is the dynamic range of the Arduino's ADC input? Is it 0-5V?

What is it's internal ADC reference voltage? Is it 5.00V (same as the Arduino Vdd pin)?

What voltages do you naturally have available? 5V from the Arduino? 12-14V from the car? But no negative voltage?
 
Last edited:
yeah Arduino 0 to 5V

I'm using a 3.3V reference voltage (external) for the ADC since the Accelerometer is also 3.3V

So I have +5VDC, +3.3VDC, and I have 12volts from the car, but no negative voltage
 
So you want the accelerometer at rest to make a voltage at the mid point of the ADC's dynamic range (0+3.3)/2 = 1.65V?

How many Gs total to span the ADC dynamic range? +-1G?, so +1G would be 3.3V and -1G would be 0V?
 
So you want the accelerometer at rest to make a voltage at the mid point of the ADC's dynamic range (0+3.3)/2 = 1.65V?

How many Gs total to span the ADC dynamic range? +-1G?, so +1G would be 3.3V and -1G would be 0V?


The accelerometer at rest outputs 1.65Volts meaning zero G's (vcc/2) (3.3V/2 = 1.65V)

The accelerometer is -3G/+3G range

The sensitivity of the accelerometer is 440mV per G, so 1G = (1.65Volts + 440mV = 2.09), 2G = (1.65Volts + 880mv = 2.53V) 3G = 2.97V

Similarly the -G's are represented by subtracting from the at rest voltage -1G = (1.65V - 0.440mV = 1.21V, etc, -3G = (1.65 - 1.32 = 0.33mV)

so the dynamic range is 0.33mV (-3G) to 2.97V (+3G)

In my application the accelerometer is measuring vertical acceleration, so gravity is acting upon the accelerometer all the time, so the opamp will have to zero out of the 1.65V and the 0.440mV (1G gravity) = 2.09V

Then the accelerometer will output negative and positive voltage representing -G's and +G's, so I can use the rectifier, and filters like in your wav file circuit.

The accelerometer output 0.440mV per Gforce is probably a little small going through all the filters, so maybe amplify the output so 1G = 1Volt?


So the accelerometer at rest out of the opamp will output 0V

+1G will output 0.440mV
-1G will output -0.440mv

But I guess this would have to be amplified to go through all the filter stages so

+1G = 1V
-1G = -1V

+2G = 2V
-2G = -2V
 
Last edited:
If I don't have negative and positive voltage the signal won't be centered around zero like in the wav file It will all be referenced around 1.65volts 2.09 bots to cancel gravity of 1g. But it wouldn't need rectified then ? I was thinking of using a Dc to do converter to get negative voltage ?
 
Ok, here is an implementation of my circuit which is drawn with opamps and only uses one positive supply voltage, namely +5V. I have simplified it even further, and biased things so that the circuit works with only a single supply. Note that the V(Pot) output can go directly to the Arduino ADC input. It is up to you to decide how big a pulse constitutes a pothole. e.g., a trip level of 0.5V would catch 5 potholes, but ignore the one at 25sec. I centered the 12.5Hz filter output at 2.5V, but the other circuits are referenced to ground. Note that these opamps must be modern CMOS rail-to-rail output OpAmps; they cannot be a clunky old 741.

The circuit relies on the car suspension being resonant at 12.5Hz; if you move the accelerometer to another car, you might have to re-tune the 12.5Hz filter to the new car's resonance. The input circuit on the 12.5Hz filter ignores DC offset, so you don't have to worry about the effect of gravity, or the offset out of the accelerometer.
 

Attachments

  • W2s.jpg
    W2s.jpg
    154.3 KB · Views: 153
  • W2p.jpg
    W2p.jpg
    441.9 KB · Views: 160
Last edited:
Ok, here is an implementation of my circuit which is drawn with opamps and only uses one positive supply voltage, namely +5V. I have simplified it even further, and biased things so that the circuit works with only a single supply. Note that the V(Pot) output can go directly to the Arduino ADC input. It is up to you to decide how big a pulse constitutes a pothole. e.g., a trip level of 0.5V would catch 5 potholes, but ignore the one at 25sec. I centered the 12.5Hz filter output at 2.5V, but the other circuits are referenced to ground. Note that these opamps must be modern CMOS rail-to-rail output OpAmps; they cannot be a clunky old 741.

The circuit relies on the car suspension being resonant at 12.5Hz; if you move the accelerometer to another car, you might have to re-tune the 12.5Hz filter to the new car's resonance. The input circuit on the 12.5Hz filter ignores DC offset, so you don't have to worry about the effect of gravity, or the offset out of the accelerometer.

Wow Mike there are no words... Thanks for your work, I need to read up on how you designed the bandpass filter to ignore DC offset, I'm looking into low noise rail to rail opamps

Thank you
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top