Cockpitbuilders.com

Arduino Projects => General Discussions => Topic started by: Trevor Hale on October 22, 2014, 02:43:28 AM

Title: Voltage control gauge help!
Post by: Trevor Hale on October 22, 2014, 02:43:28 AM
Hi guys,

I have two REAL instruments in my possession  that came out of my cockpit. One of them is pictured below.
They operate on a voltage input.

The Flap indicator and the stab trim indicator.

When a voltage of about 1.5 volts DC is applied to the gauge the indicator moves about 1/2 an inch.  when voltage is removed from the Stab Trim indicator it rests at the bottom of the scale. The flap position indicator rests at a 12-o-clock position which indicates nothing as there isn't any numbers at the 12-o-clock position.

My question is, how would you guys control this?

I have an output board that will activate with 12V, I was thinking if I used 3 or 4 outputs, and put resistors off each output I could activate each output based on flap position and just put all the outputs in parallel. with a diode on each output protecting it. each resistor value would change the voltage drop across the instrument at the various positions.

Will this work?

the Trim indicator would be tricky because it is a constant voltage varying in small increments all the time when the trim is used. Does anyone have any ideas here?

Thanks,

Trev
Title: Re: Voltage control gauge help!
Post by: KyleH on October 22, 2014, 04:09:06 AM
How would I do it?
I would design a microcontroller circuit to drive a transistor with a PWM signal that corresponds to the various flap/trim settings sent from the sim. But that's me.

I would suggest a 0-10V phidgets card: http://www.phidgets.com/products.php?category=0&product_id=1002_0 (http://www.phidgets.com/products.php?category=0&product_id=1002_0)

The 12V outputs with Resistors may work with the flaps gauge. You'll have to test needle positions and measure current and voltage required for each one, then carefully select your resistors. A problem with this is the resistor may end up dissipating a fair amount of power depending on the current draw of the gauge, requiring a higher power resistor.
This will also just cause the needle to jump to each position, no values in between will be shown.
Also, if 2 of the outputs on the card happen to come on at the same time you could end up damaging the gauge.

Be sure to check the maximum current the gauges draw to make sure whatever card you use can handle it.

Title: Re: Voltage control gauge help!
Post by: Trevor Hale on October 22, 2014, 04:17:41 AM
Quote from: KyleH on October 22, 2014, 04:09:06 AM
How would I do it?
I would design a microcontroller circuit to drive a transistor with a PWM signal that corresponds to the various flap/trim settings sent from the sim. But that's me.

I did electronics engineering 18 years ago, might be out of my reach now.  But if I build the circuit to drive the gauge, how would I tie that to an output?  Are you suggesting a complete new interface card that will read the offsets directly and apply the pwm based on the reading?

My god, I think I would rather throw it in the garbage LOL.  My head hurts just thinking about it.

The gauges have part numbers, but there is likely no way to get specs on the gauges like current etc.
Title: Re: Voltage control gauge help!
Post by: Bob Reed on October 22, 2014, 04:25:21 AM
Careful what you say Kyle.. We will have you captive for several days!! lol
Title: Re: Voltage control gauge help!
Post by: Trevor Hale on October 22, 2014, 04:30:31 AM
I found this...  An indistructable for PWM and Transistors, but controlled through the parallel port..  Not such a good plan...  and a pain to write in lua.

http://www.instructables.com/id/A-Simple-Introduction-to-Transistors-and-PWM-Puls/?ALLSTEPS (http://www.instructables.com/id/A-Simple-Introduction-to-Transistors-and-PWM-Puls/?ALLSTEPS)

Maybe Fs2Phidgets would drive the Phidgets board for what i want it to do.  that would probably be the easiest solution.  Anyone running FS2Phidgets care to tell me if the card Kyle suggested is supported?

Trev
Title: Re: Voltage control gauge help!
Post by: 727737Nut on October 22, 2014, 04:46:45 AM
Teensy series cards have naitive X-plane support,  use PWM out with correct resistor and cap to smooth it out a little.  Piece of cake.
Title: Re: Voltage control gauge help!
Post by: Trevor Hale on October 22, 2014, 05:43:29 AM
Doesn't help when I use FSX LOL


Correction, I guess some people are using it with FSX, needs more investigation, and for $16.00 for the board, this may be a very cheap solution.

http://www.jimspage.co.nz/link2fs_experts.htm (http://www.jimspage.co.nz/link2fs_experts.htm)

https://www.youtube.com/watch?v=OSzE6hgFWCM (https://www.youtube.com/watch?v=OSzE6hgFWCM)
Title: Re: Voltage control gauge help!
Post by: KyleH on October 22, 2014, 06:37:39 AM
Quote from: Trevor Hale on October 22, 2014, 04:17:41 AM
Quote from: KyleH on October 22, 2014, 04:09:06 AM
How would I do it?
I would design a microcontroller circuit to drive a transistor with a PWM signal that corresponds to the various flap/trim settings sent from the sim. But that's me.

I did electronics engineering 18 years ago, might be out of my reach now.  But if I build the circuit to drive the gauge, how would I tie that to an output?  Are you suggesting a complete new interface card that will read the offsets directly and apply the pwm based on the reading?

My god, I think I would rather throw it in the garbage LOL.  My head hurts just thinking about it.

The gauges have part numbers, but there is likely no way to get specs on the gauges like current etc.

Yes you would essentially be developing your own interface to FlightSim.  This is what I am doing for my sim, so I already have a c program that reads FSUIPC / LevelD variables and sends the required info over to a bus to my microcontrollers. So...that's what I would do.
(https://farm6.staticflickr.com/5281/13736624863_3bda0baeb1_s.jpg) (https://flic.kr/p/mVRMZH)IMG_20140402_210918 (https://flic.kr/p/mVRMZH) by m_disco (https://www.flickr.com/people/87529678@N00/), on Flickr

For these types of gauges it is best to get a card that can output a variable voltage signal, especially for the trim.

As far as getting the current, just measure it. Put the current meter in series with the gauge, and a variable dc power supply; adjust the dc supply to get the needle to deflect to the proper locations and measure the values. BE SURE TO START AT 0V to avoid damage to the gauge.
Title: Re: Voltage control gauge help!
Post by: Trevor Hale on October 22, 2014, 06:47:14 AM
I can measure it, just not sure if the current would run away on it that's all.  I will meter it later tonight perhaps and see if I can figure more out.

Thanks for the advice..
Title: Re: Voltage control gauge help!
Post by: Trevor Hale on October 22, 2014, 08:17:07 AM
Just bought the card below.  It will do 6 PWM outputs, I only need 2 now, which will leave me 4 additional for later use.  Jimz software interfaces with Simconnect and FSUIPC Direct, and will allow me to drive the gauges with a little bit of code that I will somehow need to experiment with LOL

I never realized this existed, and I have no programming experience, but Maybe it will be ok!


UNO R3 Compatible - ATMEGA328 w/USB Cable For Arduino
[/color]Descriptions

This Board is 100% compatible with Arduino UNO / UNO R3 ATmega328P-PU

The Uno now uses an ATmega32U2 instead of the 8U2 found on the Uno (or the FTDI found on previous generations). This allows for faster transfer rates and more memory. No drivers needed for Linux or Mac (inf file for Windows is needed and included in the Arduino IDE), and the ability to have the Uno show up as a keyboard, mouse, joystick, etc.

The Uno R3 also adds SDA and SCL pins next to the AREF. In addition, there are two new pins placed near the RESET pin. One is the IOREF that allow the shields to adapt to the voltage provided from the board. The other is a not connected and is reserved for future purposes. The Uno R3 works with all existing shields but can adapt to new shields which use these additional pins.

Arduino is an open-source physical computing platform based on a simple i/o board and a development environment that implements the Processing/Wiring language. Arduino can be used to develop stand-alone interactive objects or can be connected to software on your computer (e.g. Flash, Processing, MaxMSP). The open-source IDE can be downloaded for free (currently for Mac OS X, Windows, and Linux).

Main Features ATmega328P-PU microcontroller[/l]
[/color][/size]
  • ATmega32U2 USB Controller
  • 14 Digital I/O Pins (6 PWM outputs)
  • 6 Analog Inputs
  • 32k Flash Memory
  • 16Mhz Clock Speed
  • Resource Arduino official website (http://arduino.cc/en/Main/Software)[/color][/size]
  • Package includes 1 x USB cable[/color][/size]
  • 1 x header kit
  • 1 x Arduino compatible UNO R3 Clone


  •  
    [/l]
Title: Re: Voltage control gauge help!
Post by: Trevor Hale on October 22, 2014, 09:34:04 AM
Some of you may be surprised that I would post this, but clearly not everything resides here like I wish it would. :)
regardless Credit where Credit is due I guess.

The following is a really great resource for interfacing with Arduino cards and link2fs.

http://www.mycockpit.org/forums/arduino-cards-link2fs/ (http://www.mycockpit.org/forums/arduino-cards-link2fs/)

best regards,

Trev
Title: Re: Voltage control gauge help!
Post by: RayS on October 22, 2014, 10:53:49 AM
I think Gene Buckle wrote something to interface these gauges to an Arduino with great success....

If memory serves, I think these voltage gauges have 3 separate movements and the full range is divided into 3 angular areas... I think... maybe I had to much wine that night...

Title: Re: Voltage control gauge help!
Post by: Trevor Hale on October 22, 2014, 11:08:24 AM
LOL..  I should maybe ask Geneb if he knows of this, or maybe the wine has completely sent you over the edge LOL.

Thanks Ray, I will check it out!


Title: Re: Voltage control gauge help!
Post by: Bob Reed on October 22, 2014, 12:36:45 PM
Gene is in the middle of switching his entire F-15 sim over to Arduino interface. He is a good one to ask.
Title: Re: Voltage control gauge help!
Post by: Trevor Hale on October 22, 2014, 01:20:39 PM
Quote from: Bob Reed on October 22, 2014, 12:36:45 PM
Gene is in the middle of switching his entire F-15 sim over to Arduino interface. He is a good one to ask.

Apparently Ray wasn't into the wine as hard as he thought then.  :cheers: I have asked him for his help to see if he can get me going.  Heck it is only 7 instruments in total.  (really only 6 cause that's all the card I got will handle, but no big deal)  It will take me a long time to get 6 working LOL
Title: Re: Voltage control gauge help!
Post by: Caflyt on October 22, 2014, 05:54:53 PM
My first generic sim was Arduino based and I used Jimz old IO program to run some led's and an LCD.
It was much more limited then (2011-12) but was surely easy to use.
I still have 2 UNO's and a Mega which I reflashed to act as joystick cards but can easily reconfigure to their original state.
I was using one of them in my throttle.
They are more capable now and are inexpensive enough to make them very attractive.
I will likely use them for something in my new build.
Just need to figure out what I would want them to do and I'm sure they can do it.
Love this thread!

Craig
Title: Re: Voltage control gauge help!
Post by: Trevor Hale on October 23, 2014, 03:08:43 AM
Thanks Craig.

I have been in contact with somoene in the Arduino community, and they have walked me through a basic program.  I am only going to use the arduino Uno for gauges. 2 voltage gauges and 4 or 5 stepper/servo gauges.  It has been mentioned to me to watch out for Hysteresis issues with the servos and I will, its a good warning.

In any case for the voltage controlled instruments I have This should work and as you said for the price you can;t really go wrong.

Here is my code.

Quote
*/
// ***********************BEGIN DECLARATIONS
********************************************
#include <Wire.h>
#include <Adafruit_PWMServoDriver.h>
Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver(0x40);  //Base address
for PCA9685
uint8_t servonum = 0;          // servo (or analog device) is connected at
position 0 on the PCA9685.
int trimFSX;
int old_trimFSX;
int trimPWM;
String data;
int const a=(1); //(replace 1 with your number for a) int const b=(1);
//(replace 1 with your number for b) int CodeIn; //
**********************************************************************
// ***********************BEGIN VOID SETUP*******************************
void setup()
{
Wire.begin();               //Join the bus as master
Serial.begin(115200);
trimFSX=0;                  //Just to put an initial number for starters
// --------Increase PWM refresh rate to 240Hz
---------------------------------------
pwm.begin();           //Starts communication with PCA9685
pwm.setPWMFreq(240);
}//end void setup
//
****************************************************************************
**********
// **************BEGIN VOID LOOP
********************************************************
void loop()
{
old_trimFSX=trimFSX;

  //**** Check for data from L2FSX ****
  if (Serial.available() > 0) {  //if there is a charactor in the serial
receive buffer then ,,,,
    CodeIn = getChar();// read it via the "char getChar" routine
    if (CodeIn == '<') {
      LESSTHAN();
    }// The first identifier is "<" goto LESSTHAN void
  }//end of serial.available
if (trimFSX!=old_trimFSX) {
   trimPWM=(a*(trimFSX) +b);
   pwm.setPWM(servonum, 0, trimPWM);
   old_trimFSX=trimFSX;
}//end of if
}//end void loop
//--------------- Subroutine getChar ------------------------------ char
getChar()// The serial buffer routine to get a character {
  while(Serial.available() == 0);// wait for data
  return((char)Serial.read());
}// end of getchar Routine.

//--------------- Subroutine LESSTHAN ------------------------------ void
LESSTHAN() {//the first identifier was a '<'
  CodeIn = getChar();//get another charactor from serial port
  if (CodeIn == 'H'){//found the identifier "H"
    delay (11);    // It seems to need a delay here
    data = ""; // Empty data string
    data += char(Serial.read());    //Read the first data charactor sent
    data += char(Serial.read());   //Read the second data charactor sent and
add it to the first
    data += char(Serial.read());   //Read the third data charactor sent and
add it to the other two.)   
    trimFSX = data.toInt();
  } //end of "found the identifier "H"
}  // end of LESSTHAN loop

// ************** END
*********************************************************