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.

Accelerometer Project

Status
Not open for further replies.

demestav

Member
Hello, everybody.

I am into this acceleration measuring project because a friend requested a meter for his nice car :D

I got the ADXL202AE which outputs PWM. Questions:

1) Of course I have to measure the high state of each pulse to determine the sample value. To do this with 16f627 I thought of the following:
a. Interrupt RB0 set to trigger when high
b. When the pulse goes high start the timer etc etc
c. Return from the interrupt and change the interrupt RB0 to tirgger when LOW
d. When pulse goes low, stop the timer, return from interrupt and change the RBO to trigger when high, to be ready for the next pulse.

Although it seems it is going to work, I dont like it so much. Is there a better way to do this? I remember I worked with another mc in a similar situation and there was a pin that would trigger on both high/low changes, but I could not find this here.


2) ADXL takes also 2 capacitors for filtering the two axis samples. The datasheet talks about bandwidth.
a. What is this bandwidth? The rate of which the samples are taken? i.e. when bandwidth is set to 10Hz, ADXL will generate 10 pulses per second?
b. We do this to eliminate spikes from the output pin, so we dont have false measurements in PIC?



3) To analyse the data you have to aplly a small mathematical formula :
(variable/constant - 0.5)/12.5%
How to do this with assemly?


That all for now! Thank you very much for reading and I would be greatful if you could help me out!

ADXL DATASHEET : https://www.analog.com/UploadedFiles/Data_Sheets/567227477ADXL202E_a.pdf#search="adxl datasheet"
 
I've used the 202 a fair amount. You can use the interrupt on change feature of the 627 - rb4-7. use one for each channel.

but your method works fine for a single channel if you move flipping the edge sense into the ISR.

bandwidth refers to the low pass filtering that they do using Cx and Cy. The higher the cap, the lower the cut off frequency and thus the lower the maximum frequency of vibrations you can measure. (Ok Ok, its more like the max rate of change of the acceleration.) Unless you need to measure fast transients, I'd set it to 10 hz. You use Rset to determine the period of T2.

Note also that you want to know T2 as well as T1 to determine ratio. Since T2 can change due to environmental issues (voltage, temp), you will need to measure it. You can take advantage of the fact that the T1 pulses for both X and Y are centered (i.e. if you see the X leading edge first, you will see Y leading, Y trailing and then X trailing, in that order). I use a single timer to measure both. Start the timer on the first edge, record the next edge (leading), the third edge (trailing) time minus the second is one T1, the next edge (trailing) time is the other T1 and the next edge (leading) time is T2.

I do this in C on an F88 so the division isn't an issue. You can find asm source on the pic list site, iirc.
 
Great answers! Thanks for you reply philba. I dont know how I missed those RB7:4.... Sigh....


Anybody can help on the (3) question?
 
demestav said:
Anybody can help on the (3) question?

Don't play with floating point, scale the values to be integers - then it's simple to do, and MUCH faster and smaller - using 16 bit integer maths routines should be all you need!.
 
I agree with nigel. the reason why it's ok is that you won't need extreme accuracy. 8 bit (result of 16 bit divide) will give about .4% accuracy. probably more than your system's noise will allow.
 
Ok thank you for the replies.

But can you help me a bit further?
For the ADXL the formula goes like :
(period of T1/Period of T2 - 0.5)/12.%

How am I going to divide T1 by T2?
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top