Show Posts
Pages: 1 ... 11 12 [13] 14 15
181  Forum 2005-2010 (read only) / Exhibition / Re: Arduino 3DOF Head Tracker on: January 06, 2009, 10:14:29 am

I didn't really write the code for interfacing with FSX. I took a SimConnect SDK example in Delphi, and modify it to take serial data, that's about it... If that's what you want to look at, I'll post it here...

182  Forum 2005-2010 (read only) / Exhibition / Re: Arduino 3DOF Head Tracker on: January 05, 2009, 03:13:08 pm
Here's the code, will need to be modified to suit you own setup. Also, if anyone wants it, I've got a program that interfaces with FSX camera control and serial port, all you need to do is send a comma separated string of pitch, roll yaw and so on. Should make it easy for anyone wanting to control FSX camera from arduino.

#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);
  gRaw = tempG*10/n;
  xRaw = tempX*10/n-xOffset;
  yRaw = tempY*10/n-yOffset;
  zRaw = tempZ*10/n-zOffset;

void setup() {
  pinMode(ledPin, OUTPUT);  
  pinMode(rledPin, OUTPUT);

  //Find Gyro rate offset
  gOffset = gRaw*Vin/100;
  printStr[0]= '\0';

void loop() {

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

    //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) {
    digitalWrite(ledPin, HIGH);


    printStr[0] = '\0';
    digitalWrite(ledPin, LOW);  

183  Forum 2005-2010 (read only) / Exhibition / Arduino 3DOF Head Tracker on: January 05, 2009, 03:01:54 pm
I posted it at RC Groups, but a couple of people have asked me for the code, which I thought would be more appropriate to post here.
(For more detail, check this thread:

But I thought people here might be interested in it, especially the code.

It's a 3 degree of freedom (pitch, roll, yaw) head tracker built from:

  • A cheap RC heli gyro for ~$15
  • A cheap 3 axis accelerometer board for ~$16
  • RBBB for ~$12

The final goal is to fly my FPV plane through VR goggles, but I'm currently testing it with Microsoft FSX, here's a video:

184  Forum 2005-2010 (read only) / Exhibition / Re: Arduino Helicopter Autopilot on: February 03, 2009, 01:23:31 pm
Subscripted  smiley

With respect to the PPM noise, maybe you can try to add a limit for a maximum amount an axis can change between PPM frames. Since it is unlikely for any axis to change say >25% in 20ms (unless you have super fast commands).

I donno, just thinking...

185  Forum 2005-2010 (read only) / Exhibition / Re: Leds (n00b projects) on: March 01, 2010, 04:46:29 pm
Dude I wish I could program arduino when I was 11...
186  Forum 2005-2010 (read only) / Exhibition / Re: Arduino / Processing Timelapse with Pan on: September 08, 2009, 09:21:09 pm
Nice! I have a similar setup, except I use a servo driving a gear box

187  Forum 2005-2010 (read only) / Exhibition / Re: Robotic Arm on: February 19, 2009, 04:46:17 pm
Real industrial articulated robots use a counter weight or spring on the arm axis to balance the weigh of the arm and end effector, this reduces the load on the motor. Maybe you can try something like that?

188  Forum 2005-2010 (read only) / Exhibition / Re: Autonomous robot platform on: December 03, 2008, 03:25:17 pm
smiley-lol that music in your video was hilarious. Cool robot!


The servotimer lib makes the code look much nicer. I think I'll rewrite my robot code with the library instead of the old timer method...

189  Forum 2005-2010 (read only) / Exhibition / Re: Levitating magnet and improved Serial library on: March 03, 2009, 03:13:19 pm
That is very cool. Nice work!
190  Forum 2005-2010 (read only) / Exhibition / Arduino FPV RC flight instrumentation on: May 09, 2008, 03:22:14 am
If you haven't heard about FPV flying, check it out:

I'm using arduino to display low battery voltage warning and ground proximity (with a ultrasonic sensor) in flight. Here's a video:

191  Forum 2005-2010 (read only) / Exhibition / PC -> Arduino -> RC brushless motor on: October 01, 2007, 05:21:30 pm
OK, pretty simple stuff, I happened to have this video around. I send servo positions (as strings not bytes) from the PC program to the arduino, which runs a PMW to drive the motor controller. I wrote the program originally to test servos. I'm thinking about adding a RPM sensor and eventually measure battery voltage and current and all that, eventually...

Since it's pretty simple to do, and has probably been done hundreds of times before, I'm not going to explain too much here, unless anyone is interested.

192  Forum 2005-2010 (read only) / Exhibition / Re: HummBot on: December 25, 2007, 09:07:46 am
Cool, maybe you can turn one of the IR sensors backward, so it can see what's behind it.

193  Forum 2005-2010 (read only) / Exhibition / Re: Paint on the TV screen with Arduino on: April 22, 2007, 01:44:53 am

Thanks for your help! I tried both commenting out wiring.c and cli(), made no difference. I tried your first code in this thread, commented out the code in wiring.c, and I get a fairly clear image but with noise bands rolling over. Maybe we have different PAL standards? I'm guessing my TV tuner was trying to automatically detect what the input format is, and the improper formating of the signal is making it choose the wrong format. Because if I try to watch TV after I'm done messing with it, I have to reset the signal to PAL-GB, otherwise the picture would be messed up. I'll see if I can test it on someone else's TV.

I'm about to give up, maybe get a dedicated chip or board for this. I love how the German guy's high res test picture says: "Hello World, I'm super good, and test image generator is easy"

194  Forum 2005-2010 (read only) / Exhibition / Re: Paint on the TV screen with Arduino on: April 21, 2007, 04:35:51 am
I figured it out, I needed to change the number of the time wasting portb = black lines to get timing just right. Would this be different on different boards? Anyway, now the image is better but still not very good:

Full Hi-res can be done, but I don't think this for loop based method is fast enough, and it doesn't scale properly. Some clever math is needed.

195  Forum 2005-2010 (read only) / Exhibition / Re: Paint on the TV screen with Arduino on: April 21, 2007, 02:25:50 am

I'm in the UK so I've got PAL as well. I hooked up my TV tuner, and got a black screen. I thought it wasn't working, but I didn't know that's what I was supposed to get! Now it's kind of working, but I get a lot of scan line looking noise:

The actual pictures looks slightly better than the still image. I disabled and enable interrupts, doesn't seem to make any difference.



Pages: 1 ... 11 12 [13] 14 15