Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
11 years, 11 months ago.
New to all this
anyone know how to calibrate this program to give the reading of zero in all three axis at the start regardless of position because when the mbed on flat surface values still change, as well as give the values at quickly as possible once it's changed ??
kind regards Lincoln
- include "mbed.h"
- include "MMA7660FC.h"
- define ADDR_MMA7660 0x98
MMA7660FC Acc(p28, p27, ADDR_MMA7660); Serial pc(USBTX, USBRX);
int main() {
float G_VALUE[100];
Acc.init();
pc.printf("Value reg 0x06: %#x", Acc.read_reg(0x06)); pc.printf("Value reg 0x08: %#x", Acc.read_reg(0x08)); pc.printf("Value reg 0x07: %#x", Acc.read_reg(0x07));
while(1) { float x=0, y=0, z=0;
Acc.read_Tilt(&x, &y, &z); pc.printf("Tilt x: %2.2f degree", x); pc.printf("Tilt y: %2.2f degree", y); pc.printf("Tilt z: %2.2f degree", z);
wait_ms(100); pc.printf("\n"); pc.printf("x: %1.3f g", G_VALUE[Acc.read_x()]); pc.printf("y: %1.3f g", G_VALUE[Acc.read_y()]); pc.printf("z: %1.3f g", G_VALUE[Acc.read_z()]); pc.printf("\n"); wait_ms(100);
}
1 Answer
11 years, 11 months ago.
Use <<code>> and <</code>>
around your code.
Your first question, you can make yourself calibration code. But that can remove an offset or gain error, if your values keep changing it is probably just measurement inaccuracy of the device.
Then second one, give the values are fast as possible? Don't put a delay in it, just keep requesting new values.