Hello, all and happy holidays!
Am working on my Boeing 727-200 home cockpit using (primarily) Teensy 4.1 boards (as they are all that seem to be available anywhere these days).
I'm currently playing with the interfacing of a Horizontal Situation Indicator and am attempting to get two (2) needles to move in concert with what's happening in X-Plane 11.55 and am not having any success.
On my instrument, I'm focusing my attention on four (4) different pins:
Pins 32 and 31 control the 'Course deviation' bar
Pins 38 and 37 control the 'Glide Slope' bar
As a bench test, when I apply 2V (from a 28V power supply) I get movement--
Pin 32+ / Pin 31- gives full deflection to the right at 2V
Pin 31+ / Pin 32- gives full deflection to the left at 2V
Pin 38+ / Pin 37- gives full deflection UP at 2V
Pin 37+ / Pin 38- gives full deflection DOWN at 2V
The sketch I'm using (and I'm not sure where I got it from......it might be Rob Archer) is below.
Can someone please guide me as to what is not right here or what I'm not doing correctly?
Help is appreciated, as always.
Jay
Code:
// Code for Course Dev Bar and GS on HSI
FlightSimFloat crsBar; //-2.0 to 2.0 2 dot deflection
FlightSimFloat gsBar; //-2.0 to 2.0 2 dot deflection
#define CourseDeviation 10
#define GsDeviation 9
//setup runs once
void setup(){
setupCourseDeviation();
setupGsDeviation();
}
//loop runs repetitively, as long as power is on
void loop(){
FlightSim.update(); // causes X-Plane's changes to be received
updateCourseDeviation();
updateGsDeviation();
}
voidsetupCourseDeviation(){
crsBar = XPlaneRef("sim/cockpit/radios/nav1_hdef_dot");
pinMode(CourseDeviation, OUTPUT) // PWM out
}
void updateCourseDeviation(){
// crsBar -2.0 to 2.0 2 dot deflection
int dev = (crsBar * 127); // dev = Deviation of course bar
dev = map(dev, -254, 254, 0, 255);
analogWrite(CourseDeviation, dev);
}
void setupGsDeviation(){
gsBar = XPlaneRef("sim/cockpit/radios/nav1_vdef_dot");
pinMode(GsDeviation, OUTPUT); // PWM out
}
void updateGsDeviation(){
//crsBar -2.0 to 2.0 2 dot deflection
int gsdev = (gsBar * 127); // dev = Deviation of GS bar
gsdev = map(gsdev, -254, 254, 0, 255);
analogWrite(GsDeviation, gsdev);
}