[simpits-tech] Common aviation gauges that are air-core?

dabigboy at cox.net dabigboy at cox.net
Wed Apr 4 23:15:14 PDT 2012


---- Gene Buckle <geneb at deltasoft.com> wrote: 
> On Wed, 4 Apr 2012, dabigboy at cox.net wrote:
> 
> > - Successfully driven an air-core motor....woohoo!!!
> >
> I'd love to see the code for this.  Care to post a demo? :)

Really? I'm flattered! :) I took one of the example sketches and modified it extensively to suit my needs (I tend to prefer taking *working* code when I am learning, and modify it one step at a time as needed....I'm a hand-on learner and this avoids a lot of frustration). Pardon me if this is obvious to you already, but basically I'm just using pulse-width modulation to deliver an "average" voltage to each of the motor's two poles, with the voltages being the inverse of each other (the X and Y values of a sine wave, basically). If you wanted to get cute, you could use the Arduino's built-in trig functions to simply pass the Arduino an integer representing whatever info you want the gauge to display, convert it to a value between 0 and 1.0, and figure the X and Y values using sin() or cos().

// Setup two values, one for each pin/each pole of the motor. These are basically the X and Y
// values going to the motor, should probably be labeled as such I suppose.....

int A = 0;
int B = 255;

int mode = 0; // set to 0 when A increasing/B decreasing..tells us if our sine value is going up or down, basically.

void setup()  { 
  // setup output pins
  pinMode(3, OUTPUT);
  pinMode(5, OUTPUT);
} 

void loop()  { 
  analogWrite(3, A);
  analogWrite(5, B);
  if (mode == 0) { // if mode is 0, A is on the rise and B is going down......
    A += 5;
    B -= 5;
    if (A >= 255) { // once A hits 255, we switch direction...now A beings to decrease, and B goes on the rise.
      A = 255;
      B = 0;
      mode = 1; }
  }
  else {
    A -= 5;
    B += 5;
    if (B >= 255) { // same as above, but for B of course
      A = 0;
      B = 255;
      mode = 0; }
  }
  // wait for 30 milliseconds, so we have a chance to see the beautiful air core sweep :)
  delay(30);        
}

> Any single needle instrument that doesn't need more than 360 degrees of 
> rotation is a perfect candidate for air-core motors.

Well, what I'm really interested in is driving REAL instruments, without hackerizing them. :) So far I have learned by finding sweet deals on ebay and then tearing into the instrument to see what makes it tick (like the ADF indicator). I suppose I can keep going this route, so long as it doesn't get too expensive. :)

Matt


More information about the Simpits-tech mailing list