- Tue Mar 27, 2007 12:56 pm
#27882
Without buffering the output, you'll definitely need to switch from auto-sampling to manual to get a long enough sampling time for things to stabilize. Try it and see if it makes the results settle down.
The op-amp just converts the high-impedance output into a low-impedance output suitable for the ADC at high speeds.
thanutz wrote:Its much more than 1.5 degree im getting im afraid to say. i suspect its just from auto sampling - my code is here: MChip ForumMicrochip must employ an entire team of engineers whose job it is to prevent links from working. Found it, though...
No buffering in the connection.The big gotcha with the analog accelerometers is that their outputs have a high impedance -- 32k ohms. The type of ADC used on the PIC requires a fairly low impedance input, 2.5k ohms or less. The higher the source impedance, the longer it takes to charge the sampling capacitor in the ADC, meaning for higher impedance sources you need to increase the sampling time (time between selecting the ADC channel and starting the conversion) to allow the capacitor to charge. Past 2.5k ohms, the leakage will start to prevent the sampling capacitor from fully charging, and your readings will be somewhat lower than they should (but fairly stable, if I understand this correctly). The datasheet has the calculations of how long a sampling time you need for a given source impedance.
Without buffering the output, you'll definitely need to switch from auto-sampling to manual to get a long enough sampling time for things to stabilize. Try it and see if it makes the results settle down.
The op-amp just converts the high-impedance output into a low-impedance output suitable for the ADC at high speeds.
Also when the zeroing occurs in the code for the accelrometer, does the Y value take gravity into account so i.e. Y and X have different values subtracted so at rest (when gravity is fully active) they are both set to 0. Looks a bit clearer in my code (look at X and Y values).We're subtracting the zero-g points for all three axes in our code, so upright, the corrected readings will be 1g for the Z axis, 0g for X and Y. So when it's level, we're calling atan2(0g, 1g).