求用于检测汽车加速度和转向的方案
RT,本人目前的项目中的一个模块要求可以检测到汽车的加速度和转向,目前采用的是加速度传感器MMA7660和磁传感器MAG3110,MMA7660用于检测加速度貌似比较靠谱,但是MAG3110用于检测转向觉得没有底,不知道总体来说是否靠谱?so,请教大家伙 单用电子罗盘看转向没有动态效果(而且在汽车上,需要做很好的硬铁和软铁纠偏),结合一个陀螺仪积分算角度,然后利用加速度传感器和电子罗盘对陀螺仪积分进行校准,一般要这么干吧…… 可以用MPU6050就可以了。 laber_1912 发表于 2012-9-27 08:06 static/image/common/back.gif单用电子罗盘看转向没有动态效果(而且在汽车上,需要做很好的硬铁和软铁纠偏),结合一个陀螺仪积分算角度 ...
不同的硬铁和软铁纠偏,不同的汽车可能还不一样吧?如果这样,就蛋疼的紧了 johnsonz999 发表于 2012-9-27 08:11 static/image/common/back.gif
可以用MPU6050就可以了。
有没有便宜一点的类似于MPU6050的片子,这个貌似很贵的说 参见光电鼠标原理,即能检测加速度又能检测转弯 {:cry:}{:cry:}{:cry:}有没有资料。。 大家好,中间停顿一会,我又回来了,目前有个问题不能确定,MMA7660最小可以测量多大的加速度值?网上众说纷纭,没有统一口径啊,有的说是1.5g以上,那就别玩了,我目前的理解是1.5g应该是最大量程,按照XOUT、YOUT、ZOUT的最大表示为32,也就是最小分辨率应该是1.5g/32=0.047g=0.46m/S2?
不知道我理解是否有误? // inspired by Martijn The's sketch, adding all functionality of the 2610 chip, skipping
// the whole library-thing
#define SCLK 2// Serial clock pin on the Arduino
#define SDIO 3// Serial data (I/O) pin on the Arduino
#define sensorConfig 0x00
#define sensorStatus 0x01
#define Delta_Y 0x02
#define Delta_X 0x03
#define SQUAL 0x04
#define Maximum_pixel 0x05
#define Minimum_pixel 0x06
#define Pixel_Sum 0x07
#define picture 0x08
#define Shutter_MSB 0x09
#define Shutter_LSB 0x0A
unsigned char pixels;
void setup(){
Serial.begin(38400);
pinMode (SCLK, OUTPUT);
pinMode (SDIO, INPUT);
reSync();
forceAwake(1); // LED on
}
void loop(){
getPicture();// take snapshot
sendPicture(); // send the picture
delay(100);
}
void reSync(){
// ReSync (startup) mouse
digitalWrite(SCLK, HIGH);
delayMicroseconds(5);
digitalWrite(SCLK, LOW);
delayMicroseconds(1);
digitalWrite(SCLK, HIGH);
// wait for OptiMouse serial transaction timer to time out:
delay(1000);
}
void getPicture(void){
writeRegister(picture,0); // default write: initiate picture transfer
for (int x=0;x<18;x++){ // 18 rows of pixels
for (int y=17;y>=0;y--){// 18 collumns (reverse order)
unsigned char pix = readRegister(picture); // SPI read operation
int timeout = 12; // Try 12 times max to
while (!(pix & 0x40) && timeout>0){ // check for valid data
pix = readRegister(picture); // read the picture data
timeout--;
}
pixels=pix&0x3F; // store the data (might still be invalid after 12 tries) // was pix&0x2F
}
}
}
void sendPicture(void){
for(int z=0;z<324;z++){
Serial.print((unsigned char)(pixels&0x3F)); // send block of 324 bytes //was pixels&0x2F
}
}
void forceAwake(char value){
if (value>0) writeRegister(sensorConfig,0x01);
else writeRegister(sensorConfig,0x00);
}
signed char getDx(void){
return (signed char) readRegister(Delta_X);
}
signed char getDy(void){
return (signed char) readRegister(Delta_Y);
}
signed int getShutter(void){
signed int shutter = readRegister(Shutter_MSB) <<8;
shutter += readRegister(Shutter_LSB); // + LSB
return shutter;
}
uint8_t readRegister(uint8_t address){ // Bitbang SPI read operation
int i = 7;
uint8_t r = 0;
pinMode (SDIO, OUTPUT); // Write the address of the register we want to read:
for (; i>=0; i--){
digitalWrite (SCLK, LOW);
digitalWrite (SDIO, address & (1 << i));
digitalWrite (SCLK, HIGH);
}
pinMode (SDIO, INPUT); // Switch data line from OUTPUT to INPUT
delayMicroseconds(100); // Wait according to datasheet
for (i=7; i>=0; i--) { // Fetch the data!
digitalWrite (SCLK, LOW);
digitalWrite (SCLK, HIGH);
r |= (digitalRead (SDIO) << i);
}
delayMicroseconds(100);
return r;
}
void writeRegister(uint8_t address, uint8_t data){
int i = 7;
// Set MSB high, to indicate write operation:
address |= 0x80;
// Write the address:
pinMode (SDIO, OUTPUT);
for (; i>=0; i--){
digitalWrite (SCLK, LOW);
digitalWrite (SDIO, address & (1 << i));
digitalWrite (SCLK, HIGH);
}
// Write the data:
for (i=7; i>=0; i--){
digitalWrite (SCLK, LOW);
digitalWrite (SDIO, data & (1 << i));
digitalWrite (SCLK, HIGH);
}
} http://wiki.edwindertien.nl/lib/exe/detail.php?id=modules%3Aopticalmouse&media=modules:mouseletterd.png
页:
[1]