Automatic Head Tracking with Arduino

Kiihtyvyys-sensorein varustetut lasit jotka tunnistavat miten päin käyttäjä kääntää päätään ja näin ollen kääntää esim. lentosimulaattorissa lentäjän katsetta muttei itse konetta. Vastaavia on kyllä olemassa mutta tässä sama idea on toteutettu käyttäen arduinoa.

Linkki:

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1231185714

Video:

http://vimeo.com/2590122

Comments

Roope Kuikka's picture

include <math.h> include

include <math.h>

include <string.h>

define gPin 0

define xAccePin 1

define yAccePin 2

define zAccePin 3

define ledPin 7

define rledPin 7

define Vin 322

define xOffset 5081

define yOffset 5080

define zOffset 5517

int gOffset = 0;//, xOffset = 0, yOffset = 0, zOffset = 0; long gRaw = 0, xRaw = 0, yRaw = 0, zRaw = 0; unsigned long timeold_fast = 0, timeold_med = 0;
float rate = 0, rateold = 0, angle = 0, Azi = 0, Ele = 0, Roll = 0, AziOld = 0, EleOld = 0, RollOld = 0; char tempc[10], printStr[50];

void A2Ddata(unsigned int n) { long tempG = 0, tempX = 0, tempY = 0, tempZ = 0;

for(unsigned int k = 1; k <= n; k++){ tempG += analogRead(gPin);
tempX += analogRead(xAccePin); tempY += analogRead(yAccePin); tempZ += analogRead(zAccePin); //delayMicroseconds(10); } gRaw = tempG10/n; xRaw = tempX10/n-xOffset; yRaw = tempY10/n-yOffset; zRaw = tempZ10/n-zOffset; }

void setup() { pinMode(ledPin, OUTPUT);
pinMode(rledPin, OUTPUT); Serial.begin(38400);

analogReference(EXTERNAL); digitalWrite(rledPin,HIGH); delay(1000); //Find Gyro rate offset A2Ddata(10000); gOffset = gRaw*Vin/100; printStr[0]= '\0'; digitalWrite(rledPin,LOW); }

void loop() {

if (millis()-timeold_fast > 10) { timeold_fast = millis(); A2Ddata(8);

//Calculate gyro turn rate
rate = (gRaw*Vin/100-gOffset)*0.0150;

if (abs(rate) > 2.5) {
  angle += (rateold+rate)*0.010;  //trapz intergration
}
rateold = rate;

//Calculate elevation and roll angles
Ele = (atan2(zRaw,xRaw)*57.296-90+EleOld)/2;
Roll = (atan2(zRaw,yRaw)*57.296-90+RollOld)/2;

}

if (millis()-timeold_med > 50) { timeold_med = millis(); // hysterisis dead band if (abs(Ele - EleOld) > 0.5) { EleOld = Ele; } else { Ele = EleOld; }

if (abs(Roll - RollOld) > 0.5) {
  RollOld = Roll;
}
else {
  Roll = RollOld;
}

// reset yaw angle to 0 when head is lowered > 60 degrees if (Ele < -60) { angle = 0; }

/* // code to reduce gyro drift under steady conditions if (rate < 5) { if (rate > 0) { gOffset++; } else{ gOffset--; } } */ digitalWrite(ledPin, HIGH);

strcat(printStr,floatToString(tempc,rate,2,6,false));
strcat(printStr,",");
strcat(printStr,floatToString(tempc,Ele,3,6,false));
strcat(printStr,",");
strcat(printStr,floatToString(tempc,Roll,3,6,false));
strcat(printStr,",");
strcat(printStr,floatToString(tempc,angle,3,6,false));
Serial.println(printStr);

printStr[0] = '\0';
/*
Serial.print(floatToString(tempc,rate,2,6,false));
 Serial.print(',');
 //Serial.println(floatToString(tempc,angle,2,6,false));  
 Serial.print(floatToString(tempc,Ele,2,6,false));
 Serial.print(',');
 Serial.print(floatToString(tempc,Roll,2,6,false));
 Serial.print(',');
 Serial.println(floatToString(tempc,angle,2,6,false));
 */
digitalWrite(ledPin, LOW);  

}

}

Blogs are always a main

Blogs are always a main source of getting accurate information and provide you the handy results; you can get instant and reliable pass4sure 646-204 information pass4sure 642-062 which surely helps you in any field of your concern. I am post graduate in IT and HR. pass4sure 220-701 These days I am doing preparation of different online certifications and I found ccie guide is the best helping source which is providing 100% authentic material. I also spend my extra time in surfing internet,pass4sure RH302 listening music and playing games. After my exams I would like to join your group.Blogs are always a main source of getting accurate information and provide you the handy results; you can get instant and pass4sure E20-850 reliable information which surely helps you pass4sure 642-812 in any field of your concern. I am post graduate in IT and HR. These days I am doing preparation of different online certifications and I found ccie guide is the best helping source which is providing pass4sure 1z0-050 100% authentic material. I also spend my extra time in surfing internet, listening music and playing games. After my exams I would like to join your group.pass4sure 640-822

Cisco Certified Network

Cisco Certified Network Associate (CCNA®) validates the ability to install, configure, operate, and troubleshoot medium-size route and switched networks, including implementation pass4sure HP0-S18 and verification of connections to remote sites in a WAN. CCNA cpass4sure 1z0-052 urriculum includes basic mitigation pass4sure 1z0-007of security threats, introduction to wireless networking concepts and terminology, and performance-based skills. This new curriculum also includes (but is not limited to) the use of these protocols: IP, Enhanced Interior Gateway Routing Protocol (EIGRP), Serial Line pass4sure 642-062 Interface Protocol Frame Relay, Routing Information Protocol Version 2 (RIPv2),VLANs, Ethernet, access control lists (ACLs).

isco Certified Network

isco Certified Network Associate (CCNA®) validates the ability to install, configure, operate, and troubleshoot medium-size route and switched networks, including implementation and verification of connections to remote sites in a WAN. CCNA curriculum includes basic mitigation 70-291 of security threats, introduction to wireless networking concepts and terminology, and performance-based skills. This new curriculum also includes (but is not limited to) the use of these protocols: IP, Enhanced642-892 642-642 640-863C Interior Gateway Routing Protocol (EIGRP), Serial Line Interface Protocol Frame Relay, Routing Information Protocol Version 2 (RIPv2),VLANs, Ethernet, access control lists (ACLs).