The new board is working perfectly, but it's the old board suddenly doesn't work.
Printable View
The new board is working perfectly, but it's the old board suddenly doesn't work.
ah, ok.
How do you connect the old board to the setup, is it on the same cable like the new one.
or has it his own connector on the COM Board?
Stefan
The new board has it's own cable to the com board. The old DIO has a shared cable to the Servo board (you probably remember the problems with having the change the fuse bits on the servo board)
I was moving the cables (10pin) around to test a couple of things that weren't working on the new board and then the old one stopped.
Oh, I didn't change the fuse bits on the DIO, only the servo board
That all sound realy strange.
Do all parts of the board donīt work or only some parts?
Can you measure the 5V power on the Controller of the old board?
Stefan
Nothing works on the DIO board.
If I put the jumper on J16, the green led lights up so there is power going to the board.
Where is the easiest place to measure the 5vdc on the board?
David
pin 10 and 11 at the controller.
I would readout and verify the firmware in the Controller via PonyProg.
Stefan
Will do and I'll let you know.
David
Must be an intermittant fault, it's working now, but not sure for how long.
Ok, i had some problems with "erased" Controllers some times ago, that happend when i made a shortcut to the powersupply.
When it happens again, I'll check the voltage and whether or not I can read the firmware.
I may have shorted it out, but it doesn't seem to have erased the firmware as it's working perfectly at present.
Thanks again Stefan.
David
One problem I do have with the code for the MCP is that when I select the speed hold button, it holds the speed, but engine one shuts down.
I can restart it and then it stays on and it's then under the control of the autopilot.
Not sure what is triggering this in the code.
Any ideas.
Other than this, the code seems to be doing everything it should.
David
Can you post the code of the Speed Hold button?
Here's the code.
There is a lot of unecessary stuff I've commented out.
Code:#include "stdafx.h"
#include "modecontrolpanel.h"
// static variables: accessible by all functions in this module
static int ActAlt = 0; // actual altitude
static int Airspeed = 0; // knots
static int AirspeedHold = 0; // 0 off, -1 on
static int AltitudeLock = 0; // 0 off, -1 on
static int Altitude = 0; // feet
static int AltitudeSave = 0; // feet
static int ApproachHold = 0; // 0 off, -1 on
static int APHeading = 0; // 0..359 degrees)
static int AutoThrottleArm = 0; // 0 off, -1 on
static int MachHold = 0; //
static int MachSpeed = 0; // 0 spd, 1 mach
static int MasterAP = 0; // 0 off, 1 on
static int ValFlightDir = 0; // 0: ??
// 1: ??
// 2: ??
// 3: ??
// 4: ??
static int Cmda = 0; // 0 off, -1 on
static int Cmdb = 0; // 0 off, -1 on
static int Cwsa = 0; // 0 off, -1 on
static int Cwsb = 0; // 0 off, -1 on
static int CockpitATArmed = 0; // 0 off, -1 on
static int Course = 0; // 0..359 degrees)
static int Disengage = 0; // 0 off, -1 on
static short Engine1N1 = 0; // units: percent
static short Engine1N2 = 0; // units: percent
static int EngN1 = 0; // 0 off, -1 on
static int FSATArmed = 0; // 0 off, -1 on
static int HeadingLock = 0; // 0 off, -1 on
static int LvlChg = 0; // 0 off, -1 on
static int Mach = 0; // 0.01 units
static int Vertspeed = 0; // feet/min
static int VertspeedHold = 0; // 0 off, -1
static int apalt = 0;
/*-------------- Build Glareshield Objects --------------- */
void cbModecontrolpanelBuildObjects()
{
MkFsbusObject(BTP_DISPLAY, C_DCOURSEL, "",cbModecontrolpanel, 20, 0);
MkFsbusObject(BTP_DISPLAY, C_DCOURSER, "",cbModecontrolpanel, 26, 0);
MkFsbusObject(BTP_DISPLAY, C_DIAS, "",cbModecontrolpanel, 21, 0);
MkFsbusObject(BTP_DISPLAY, C_DHEADING, "",cbModecontrolpanel, 22, 0);
MkFsbusObject(BTP_DISPLAY, C_DALTITUDE, "",cbModecontrolpanel, 23, 0);
MkFsbusObject(BTP_DISPLAY, C_DVSPEED, "",cbModecontrolpanel, 24, 0);
DisplayOptions(C_DCOURSEL, 3, 0, TRUE, 0);
DisplayOptions(C_DCOURSER, 3, 0, TRUE, 0);
DisplayOptions(C_DIAS, 4, 0, TRUE, 0);
DisplayOptions(C_DHEADING, 3, 0, TRUE, 0);
DisplayOptions(C_DALTITUDE, 5, 0, TRUE, 0);
DisplayOptions(C_DVSPEED, 5, 0, TRUE, 0);
MkFsbusObject(BTP_ROTARY, C_RCOURSELR, "",cbModecontrolpanel, 28, 32);
MkFsbusObject(BTP_ROTARY, C_RIAS, "",cbModecontrolpanel, 28, 34);
MkFsbusObject(BTP_ROTARY, C_RHEADING, "",cbModecontrolpanel, 28, 36);
MkFsbusObject(BTP_ROTARY, C_RALTITUDE, "",cbModecontrolpanel, 28, 0);
MkFsbusObject(BTP_ROTARY, C_RVSPEED, "",cbModecontrolpanel, 28, 2);
MkFsbusObject(BTP_D_IN, C_SFLIGHTDIRL, "",cbModecontrolpanel, 28, 39);
MkFsbusObject(BTP_D_IN, C_SFLIGHTDIRR, "",cbModecontrolpanel, 7, 58);
MkFsbusObject(BTP_D_IN, C_SAUTOTHROTTLEARM, "",cbModecontrolpanel, 28, 38);
MkFsbusObject(BTP_D_IN, C_SN1, "",cbModecontrolpanel, 7, 12);
MkFsbusObject(BTP_D_IN, C_SSPDHLD, "",cbModecontrolpanel, 28, 56);
MkFsbusObject(BTP_D_IN, C_SSPDINTV, "",cbModecontrolpanel, 7, 46);
MkFsbusObject(BTP_D_IN, C_SCHANGEOVER, "",cbModecontrolpanel, 28, 58);
MkFsbusObject(BTP_D_IN, C_SVNAV, "",cbModecontrolpanel, 28, 61);
MkFsbusObject(BTP_D_IN, C_SLNAV, "",cbModecontrolpanel, 28, 62);
MkFsbusObject(BTP_D_IN, C_SLVLCHG, "",cbModecontrolpanel, 7, 10);
MkFsbusObject(BTP_D_IN, C_SHEADINGLOCK, "",cbModecontrolpanel, 28, 57);
MkFsbusObject(BTP_D_IN, C_SVORLOC, "",cbModecontrolpanel, 28, 60);
MkFsbusObject(BTP_D_IN, C_SAPP, "",cbModecontrolpanel, 28, 59);
MkFsbusObject(BTP_D_IN, C_SALTHLD, "",cbModecontrolpanel, 28, 4);
MkFsbusObject(BTP_D_IN, C_SALTINTV, "",cbModecontrolpanel, 7, 28);
MkFsbusObject(BTP_D_IN, C_SVSPEEDHLD, "",cbModecontrolpanel, 28, 5);
MkFsbusObject(BTP_D_IN, C_SCMDA, "",cbModecontrolpanel, 28, 6);
MkFsbusObject(BTP_D_IN, C_SCMDB, "",cbModecontrolpanel, 7, 56);
MkFsbusObject(BTP_D_IN, C_SCWSA, "",cbModecontrolpanel, 7, 62);
MkFsbusObject(BTP_D_IN, C_SCWSB, "",cbModecontrolpanel, 7, 57);
MkFsbusObject(BTP_D_IN, C_SAPDISENGAGE, "",cbModecontrolpanel, 28, 7);
MkFsbusObject(BTP_D_OUT, C_LFLIGHTDIRL, "",cbModecontrolpanel, 8, 34);
MkFsbusObject(BTP_D_OUT, C_LFLIGHTDIRR, "",cbModecontrolpanel, 8, 63);
MkFsbusObject(BTP_D_OUT, C_LMASTFLIGHTL, "",cbModecontrolpanel, 8, 33);
MkFsbusObject(BTP_D_OUT, C_LMASTFLIGHTR, "",cbModecontrolpanel, 8, 44);
MkFsbusObject(BTP_D_OUT, C_LATARMED, "",cbModecontrolpanel, 27, 11);
MkFsbusObject(BTP_D_OUT, C_LN1, "",cbModecontrolpanel, 8, 35);
MkFsbusObject(BTP_D_OUT, C_LAIRSPEEDHOLD, "",cbModecontrolpanel, 28, 9);
MkFsbusObject(BTP_D_OUT, C_LVNAV, "",cbModecontrolpanel, 28, 11);
MkFsbusObject(BTP_D_OUT, C_LLNAV, "",cbModecontrolpanel, 8, 57);
MkFsbusObject(BTP_D_OUT, C_LLVLCHG, "",cbModecontrolpanel, 8, 37);
MkFsbusObject(BTP_D_OUT, C_LHEADINGLOCK, "",cbModecontrolpanel, 28, 10);
MkFsbusObject(BTP_D_OUT, C_LVORLOC, "",cbModecontrolpanel, 28, 12);
MkFsbusObject(BTP_D_OUT, C_LAPP, "",cbModecontrolpanel, 28, 13);
MkFsbusObject(BTP_D_OUT, C_LALTITUDELOCK, "",cbModecontrolpanel, 28, 8);
MkFsbusObject(BTP_D_OUT, C_LVSPEEDHLD, "",cbModecontrolpanel, 28, 14);
MkFsbusObject(BTP_D_OUT, C_LCMDA, "",cbModecontrolpanel, 28, 15);
MkFsbusObject(BTP_D_OUT, C_LCMDB, "",cbModecontrolpanel, 8, 42);
MkFsbusObject(BTP_D_OUT, C_LCWSA, "",cbModecontrolpanel, 8, 40);
MkFsbusObject(BTP_D_OUT, C_LCWSB, "",cbModecontrolpanel, 9, 47);
MkFsbusObject(BTP_D_OUT, C_LAPDISENGAGEL, "",cbModecontrolpanel, 9, 61);
MkFsbusObject(BTP_D_OUT, C_LAPDISENGAGER, "",cbModecontrolpanel, 9, 62);
MkFsObject(FS_ALTITUDE, "",cbModecontrolpanel, 0x0574, 4, TP_I32, FS_NORMAL);
MkFsObject(FS_AP_MASTER, "",cbModecontrolpanel, 0x07BC, 4, TP_UI32, FS_NORMAL);
// MkFsObject(FS_AP_WINGLEVELER, "",cbModecontrolpanel, 0x07C0, 4, TP_UI32, FS_NONE);
MkFsObject(FS_AP_NAV1LOCK, "",cbModecontrolpanel, 0x07C4, 4, TP_UI32, FS_NORMAL);
MkFsObject(FS_AP_HEADINGLOCK, "",cbModecontrolpanel, 0x07C8, 4, TP_UI32, FS_NORMAL);
MkFsObject(FS_AP_HEADING, "",cbModecontrolpanel, 0x07CC, 4, TP_UI32, FS_NORMAL);
MkFsObject(FS_AP_ALTITUDELOCK, "",cbModecontrolpanel, 0x07D0, 4, TP_UI32, FS_NORMAL);
MkFsObject(FS_AP_ALTITUDE, "",cbModecontrolpanel, 0x07D4, 4, TP_UI32, FS_NORMAL);
// MkFsObject(FS_AP_ATTITUDEHOLD, "",cbModecontrolpanel, 0x07D8, 4, TP_UI32, FS_NORMAL);
MkFsObject(FS_AP_AIRSPEEDHOLD, "",cbModecontrolpanel, 0x07DC, 4, TP_UI32, FS_NORMAL);
MkFsObject(FS_AP_AIRSPEED, "",cbModecontrolpanel, 0x07E2, 2, TP_UI16, FS_NORMAL);
MkFsObject(FS_AP_MACHHOLD, "",cbModecontrolpanel, 0x07E4, 4, TP_UI32, FS_NORMAL);
MkFsObject(FS_AP_MACH, "",cbModecontrolpanel, 0x07E8, 4, TP_UI32, FS_NORMAL);
MkFsObject(FS_AP_VSHOLD, "",cbModecontrolpanel, 0x07EC, 4, TP_UI32, FS_NORMAL);
MkFsObject(FS_AP_VS, "",cbModecontrolpanel, 0x07F2, 2, TP_I16, FS_NORMAL);
// MkFsObject(FS_AP_RPMHOLD, "",cbModecontrolpanel, 0x07F4, 4, TP_UI32, FS_NORMAL);
// MkFsObject(FS_AP_RPM, "",cbModecontrolpanel, 0x07FA, 2, TP_UI16, FS_NORMAL);
// MkFsObject(FS_AP_GLIDESLOPEHOLD, "",cbModecontrolpanel, 0x07FC, 4, TP_UI32, FS_NORMAL);
MkFsObject(FS_AP_APPROACHHOLD, "",cbModecontrolpanel, 0x0800, 4, TP_UI32, FS_NORMAL);
// MkFsObject(FS_AP_BCHOLD, "",cbModecontrolpanel, 0x0804, 4, TP_UI32, FS_NORMAL);
MkFsObject(FS_AUTOTHROTTLEARM, "",cbModecontrolpanel, 0x0810, 4, TP_UI32, FS_NORMAL);
//MkFsObject(FS_NAV1OBS, "",cbModecontrolpanel, 0x0C4E, 2, TP_I16, FS_NONE);
MkFsObject(FS_FLIGHTDIRECTOR, "",cbModecontrolpanel, 0x2EE0, 4, TP_I32, FS_NORMAL);
MkFsObject(FS_ENGINE1N2, "",cbModecontrolpanel, 0x0896, 2, TP_I16, FS_NORMAL);
MkFsObject(FS_ENGINE1N1, "",cbModecontrolpanel, 0x0898, 2, TP_I16, FS_NORMAL);
}
void cbModecontrolpanel (int oid, int val, double dval)
{
int x;
switch (oid)
{
case C_RCOURSELR:
Course -= val;
while (Course > 360)
Course -= 360;
while (Course <= 0)
Course += 360;
FsWrite(FS_NAV1OBS, Course);
FsbusWrite(C_DCOURSEL, Course);
FsbusWrite(C_DCOURSER, Course);
break;
case C_RIAS:
if (MachSpeed == 0)
{
Airspeed -= val;
if (Airspeed < 100)
Airspeed = 100;
if (Airspeed > 340)
Airspeed = 340;
FsWrite(FS_AP_AIRSPEED, Airspeed);
FsbusWrite(C_DIAS, Airspeed);
}
else
{
Mach -= val;
if (Mach > 70)
Mach = 70;
if (Mach < 10)
Mach = 10;
FsWrite(FS_AP_MACH, Mach * 65536 / 100);
FsbusWrite(C_DIAS, Mach);
}
break;
case C_RHEADING:
APHeading -= val;
while (APHeading > 360)
APHeading -= 360;
while (APHeading <= 0)
APHeading += 360;
x = (APHeading % 360) * 65536 / 360 + 1;
FsWrite(FS_AP_HEADING, x);
FsbusWrite(C_DHEADING, APHeading);
break;
case C_RALTITUDE:
apalt += val*100;
if (apalt < 0)
apalt = 0;
if (apalt > 39000)
apalt = 39000;
FsbusWrite (C_DALTITUDE, apalt);
FsWrite(FS_AP_ALTITUDE, apalt*19975);
break;
/*Altitude += val * 10000 / 100;
FsbusWrite(C_DALTITUDE, Altitude);
FsWrite(FS_AP_ALTITUDE, Altitude);
break;*/
case C_RVSPEED:
Vertspeed += val * 10000 / 100;
if (Vertspeed < -7600)
Vertspeed = -7600;
if (Vertspeed > 6000)
Vertspeed = 6000;
FsbusWrite(C_DVSPEED, Vertspeed);
FsWrite(FS_AP_VS, Vertspeed);
break;
case C_SFLIGHTDIRL:
if (val == 0) {
printf("DIRL0, val=%d\n", val);
FsbusWrite(C_LFLIGHTDIRL, 1);
FsbusWrite(C_LMASTFLIGHTL, 1);
FsWrite(FS_FLIGHTDIRECTOR,1);
}
else
{
FsbusWrite(C_LFLIGHTDIRL, 0);
FsbusWrite(C_LMASTFLIGHTL, 0);
FsWrite(FS_FLIGHTDIRECTOR, 0);
}
break;
/*case C_SFLIGHTDIRL:
if (val == 0) {
printf("C_SFLIGHTDIRL event, ValFlightDir=%d\n", ValFlightDir);
if (ValFlightDir == 0)
{
// printf("DIRL0, val=%d\n", val);
FsbusWrite(C_LFLIGHTDIRL, 1);
FsbusWrite(C_LMASTFLIGHTL, 1);
FsbusWrite(C_LFLIGHTDIRR, 0);
FsbusWrite(C_LMASTFLIGHTR, 0);
FsWrite(FS_FLIGHTDIRECTOR,1);
ValFlightDir = 1;
}
else if (ValFlightDir == 1)
{
// printf("DIRL1, val=%d\n", val);
FsbusWrite(C_LFLIGHTDIRL, 0);
FsbusWrite(C_LMASTFLIGHTL, 0);
FsWrite(FS_FLIGHTDIRECTOR, 0);
FsbusWrite(C_LMASTFLIGHTR, 0);
ValFlightDir = 0;
}
else if (ValFlightDir == 2)
{
// printf("DIRL2, val=%d\n", val);
FsbusWrite(C_LFLIGHTDIRL, 1);
FsbusWrite(C_LMASTFLIGHTL, 0);
FsWrite(FS_FLIGHTDIRECTOR, 1);
ValFlightDir = 4;
}
else if (ValFlightDir == 3)
{
// printf("DIRL3, val=%d\n", val);
FsbusWrite(C_LFLIGHTDIRL, 0);
FsbusWrite(C_LMASTFLIGHTL, 0);
FsbusWrite(C_LMASTFLIGHTR, 1);
FsWrite(FS_FLIGHTDIRECTOR, 1);
ValFlightDir = 2;
}
else if (ValFlightDir == 4)
{
FsbusWrite(C_LFLIGHTDIRL, 0);
FsbusWrite(C_LMASTFLIGHTL, 0);
ValFlightDir = 2;
}
}
break;*/
/*case C_SFLIGHTDIRR:
if (val == 0) {
if (ValFlightDir == 0)
{
FsbusWrite(C_LFLIGHTDIRR, 1);
FsbusWrite(C_LMASTFLIGHTR, 1);
FsWrite(FS_FLIGHTDIRECTOR, 1);
ValFlightDir = 2;
}
else if (ValFlightDir == 1)
{
FsbusWrite(C_LFLIGHTDIRR, 1);
FsbusWrite(C_LMASTFLIGHTR, 0);
FsWrite(FS_FLIGHTDIRECTOR, 1);
ValFlightDir = 3;
}
else if (ValFlightDir == 2)
{
FsbusWrite(C_LFLIGHTDIRR, 0);
FsbusWrite(C_LMASTFLIGHTR, 0);
FsWrite(FS_FLIGHTDIRECTOR, 0);
ValFlightDir = 0;
}
else if (ValFlightDir == 3)
{
FsbusWrite(C_LFLIGHTDIRR, 0);
ValFlightDir = 1;
}
else if (ValFlightDir == 4)
{
FsbusWrite(C_LFLIGHTDIRR, 0);
FsbusWrite(C_LMASTFLIGHTR, 0);
FsbusWrite(C_LMASTFLIGHTL, 1);
ValFlightDir = 1;
}
}*/
break;
case C_SAUTOTHROTTLEARM:
CockpitATArmed = (val == 0) ? 1 : 0;
if (bSynchronised) // pass only when in sync
FsWrite(FS_AUTOTHROTTLEARM, (val == 0) ? 1 : 0);
FsbusWrite(C_LATARMED, CockpitATArmed);
if (CockpitATArmed == 0)
{
AirspeedHold = 0;
MachHold = 0;
}
break;
case C_SN1:
if ((val == 0) & (CockpitATArmed == 1)) {
EngN1 = (EngN1 == 0) ? 1 : 0;
if (MachSpeed == 0)
FsWrite(FS_AP_AIRSPEEDHOLD, EngN1);
else
FsWrite(FS_AP_MACHHOLD, EngN1);
if (EngN1 == 1)
AirspeedHold = 0;
FsbusWrite(C_LN1, EngN1);
FsbusWrite(C_LAIRSPEEDHOLD, AirspeedHold);
FsWrite(FS_ENGINE1N1, EngN1);
FsWrite(FS_ENGINE1N2, EngN1);
}
break;
case C_SSPDHLD:
if ( (val == 0) && (CockpitATArmed == 1) )
{
AirspeedHold = (AirspeedHold == 0) ? 1 : 0;
FsbusWrite(C_LAIRSPEEDHOLD, AirspeedHold);
if (AirspeedHold == 1)
{
EngN1 = 0;
FsbusWrite(C_LN1, EngN1);
if (MachSpeed == 0)
FsWrite(FS_AP_AIRSPEEDHOLD, 1);
else
FsWrite(FS_AP_MACHHOLD, 1);
}
else
{
FsWrite(FS_AP_AIRSPEEDHOLD, 0);
FsWrite(FS_AP_MACHHOLD, 0);
}
FsWrite(FS_ENGINE1N1, EngN1);
FsWrite(FS_ENGINE1N2, EngN1);
}
break;
case C_SSPDINTV:
break;
case C_SCHANGEOVER:
if (val == 0)
{
MachSpeed = (MachSpeed == 0) ? 1 : 0;
if (MachSpeed == 1)
{
DisplayOptions(C_DIAS, 3, 0, TRUE, 3);
FsbusWrite(C_DIAS, Mach);
FsWrite(FS_AP_MACHHOLD, 1);
}
else
{
DisplayOptions(C_DIAS, 4, 0, FALSE, 0); // Fsbus bug (p5=0)
FsbusWrite(C_DIAS, Airspeed);
FsWrite (FS_AP_AIRSPEEDHOLD, 1);
}
}
break;
case C_SVNAV:
break;
case C_SLNAV:
break;
case C_SLVLCHG:
if ((val == 0) &&
(abs(ActAlt - Altitude) > 200) && ((AirspeedHold == 1) || (EngN1 == 1)))
{
LvlChg = (LvlChg == 0) ? 1 : 0;
if (LvlChg == 1)
{
AltitudeLock = 0; // off
FsWrite(FS_AP_ALTITUDELOCK, LvlChg); // activate
x = Altitude * 65536 / 100 * 3048; // in meters * 65536
AltitudeSave = Altitude; // save for AltInt
FsWrite(FS_AP_ALTITUDE, x * 19975);
FsWrite(FS_AP_VSHOLD, 0);
FsbusWrite(C_LLVLCHG, LvlChg); // sync lvl change
if (ActAlt < Altitude) // climbing
{
EngN1 = 0; // force N1 off
//EventHandler(C_SN1, 0, 0); // toggle -> on
FsWrite(FS_AP_VS, 800); // default climb speed
}
else // descending
{
AirspeedHold = 0; // force IAS off
FsWrite(FS_AP_VS, -800); // default desc. speed
}
}
else // no level change
{
AltitudeLock = 1; // on
FsbusWrite(C_LLVLCHG, LvlChg); // lvl-swtch
}
FsbusWrite(C_LALTITUDELOCK, AltitudeLock); // update altitude lock
}
break;
case C_SHEADINGLOCK:
if (val == 0) // button push only
{
HeadingLock = (HeadingLock == 0) ? 1 : 0; // toggle
FsWrite(FS_AP_HEADINGLOCK, HeadingLock);
}
break;
case C_SVORLOC:
break;
case C_SAPP:
if (val == 0) // button push only
{
ApproachHold = (ApproachHold == 0) ? 1 : 0; // toggle
FsWrite(FS_AP_APPROACHHOLD, ApproachHold);
}
break;
case C_SALTHLD:
if (val == 0)
{
AltitudeLock = (AltitudeLock == 0) ? 1 : 0; // toggle
FsWrite(FS_AP_ALTITUDELOCK, AltitudeLock);
printf("C_SALTHLD AltitudeLock=%d\n", AltitudeLock);
FsbusWrite(C_LALTITUDELOCK, AltitudeLock);
}
break;
case C_SALTINTV:
if (val == 0) // button push only
{
if (AltitudeSave != Altitude) // changed by pilot
{
AltitudeSave = Altitude; // save for AltInt
x = Altitude * 65536 / 10000 * 3048; // in meters * 65536
}
else // unchanged
{
AltitudeSave = ActAlt; // save for AltInt
x = (ActAlt + 50) / 100 * 100; // round to 100
x = x * 65536 / 10000 * 3048; // in meters * 65536
AltitudeLock = 1;
FsbusWrite(C_LALTITUDELOCK, AltitudeLock);
LvlChg = 0;
FsbusWrite(C_LLVLCHG, LvlChg);
}
FsWrite(FS_AP_ALTITUDE, x); // new AP altitude
}
break;
case C_SVSPEEDHLD:
if (val == 0) // button push only
{
VertspeedHold = (VertspeedHold == 0) ? 1 : 0; // toggle
FsWrite(FS_AP_VSHOLD, VertspeedHold);
}
break;
case C_SCMDA:
if ((val==0) && (Disengage == 0)) // button push only
{
Cmda = (Cmda == 0) ? 1 : 0; // toggle
if (Cmda == 0)
FsbusWrite(C_LCMDA, 0);
else
{
FsbusWrite(C_LCMDA, 1);
FsbusWrite(C_LCMDB, 0);
FsbusWrite(C_LCWSA, 0);
FsbusWrite(C_LCWSB, 0);
FsWrite(FS_AP_MASTER, 1);
}
}
break;
case C_SCMDB:
if ((val==0) && (Disengage == 0)) // button push only
{
Cmdb = (Cmdb == 0) ? 1 : 0; // toggle
if (Cmdb == 0)
FsbusWrite(C_LCMDB, 0);
else
{
FsbusWrite(C_LCMDB, 1);
FsbusWrite(C_LCWSA, 0);
FsbusWrite(C_LCWSB, 0);
FsWrite(FS_AP_MASTER, 1);
}
}
break;
case C_SCWSA:
if ((val==0) && (Disengage == 0)) // button push only
{
Cwsa = (Cwsa == 0) ? 1 : 0; // toggle
if (Cwsa == 0)
FsbusWrite(C_LCWSA, 0);
else
{
FsbusWrite(C_LCMDA, 0);
FsbusWrite(C_LCMDB, 0);
FsbusWrite(C_LCWSA, 1);
FsbusWrite(C_LCWSB, 0);
FsWrite(FS_AP_MASTER, 1);
}
}
break;
case C_SCWSB:
if ((val==0) && (Disengage == 0))
{
Cwsb = (Cwsb == 0) ? 1 : 0; // toggle
if (Cwsb == 0)
FsbusWrite(C_LCWSB, 0);
else
{
FsbusWrite(C_LCMDA, 0);
FsbusWrite(C_LCMDB, 0);
FsbusWrite(C_LCWSA, 0);
FsbusWrite(C_LCWSB, 1);
FsWrite(FS_AP_MASTER, 1);
}
}
break;
case C_SAPDISENGAGE:
if (val==0)
{
Disengage = (Disengage == 0) ? 1 : 0; // toggle
if (Disengage == 0)
{
FsbusWrite(C_LAPDISENGAGEL, 0);
FsbusWrite(C_LAPDISENGAGER, 0);
}
else
{
FsbusWrite(C_LAPDISENGAGEL, 1);
FsbusWrite(C_LAPDISENGAGER, 1);
FsbusWrite(C_LCMDA, 0);
FsbusWrite(C_LCMDB, 0);
FsbusWrite(C_LCWSA, 0);
FsbusWrite(C_LCWSB, 0);
FsWrite(FS_AP_MASTER, 0);
}
}
break;
case FS_AP_MASTER:
break;
case FS_AP_WINGLEVELER:
break;
case FS_AP_NAV1LOCK:
break;
case FS_AP_HEADINGLOCK:
HeadingLock = val;
FsbusWrite(C_LHEADINGLOCK, val);
break;
case FS_AP_HEADING:
APHeading = (val + 1) * 360 / 65536; // (+1 for rounding)
if (APHeading == 0)
APHeading = 360;
FsbusWrite(C_DHEADING, APHeading);
break;
case FS_NAV1OBS:
Course = val;
if (Course == 0)
Course = 360;
FsbusWrite(C_DCOURSEL, Course);
FsbusWrite(C_DCOURSER, Course);
break;
case FS_AP_ALTITUDELOCK:
AltitudeLock = val;
FsbusWrite(C_LALTITUDELOCK, val);
break;
case FS_AP_ALTITUDE:
Altitude = (val / 3048 * 2500 + 8192) / 16384; // to feet
FsbusWrite(C_DALTITUDE, Altitude);
break;
case FS_ALTITUDE:
ActAlt = val * 10000 / 3048; // to feet
if ((ActAlt > 25500) && (ActAlt < 26500))
{
if ((MachSpeed == 0) && (ActAlt > 26000))
cbModecontrolpanel(C_SCHANGEOVER,0,0);
else if ((MachSpeed == 1) && (ActAlt < 26000))
cbModecontrolpanel(C_SCHANGEOVER,0,0);
}
if (abs(Altitude - ActAlt) < 10)
{
LvlChg = 0;
FsbusWrite (C_LLVLCHG , LvlChg);
FsbusWrite (C_LALTITUDELOCK , 1);
}
break;
case FS_AP_AIRSPEEDHOLD:
case FS_AP_MACHHOLD:
if (AirspeedHold == 1)
{
FsbusWrite(C_LAIRSPEEDHOLD, 1);
FsbusWrite(C_LN1, 0);
}
else if (EngN1 == 1)
{
FsbusWrite(C_LAIRSPEEDHOLD, 0);
FsbusWrite(C_LN1, 1);
}
else
{
FsbusWrite(C_LAIRSPEEDHOLD, 0);
FsbusWrite(C_LN1, 0);
}
break;
case FS_AP_AIRSPEED:
Airspeed = val;
if (MachSpeed == 0) // display in IAS mode
FsbusWrite(C_DIAS, Airspeed); // new speed
break;
case FS_AP_MACH:
Mach = (val * 100 + 50) / 65536 ;
if (MachSpeed == 1)
FsbusWrite(C_DIAS, Mach);
break;
case FS_AP_VSHOLD:
VertspeedHold = val;
FsbusWrite(C_LVSPEEDHLD, VertspeedHold);
break;
case FS_AP_VS:
Vertspeed = val;
FsbusWrite(C_DVSPEED, Vertspeed);
break;
case FS_AP_RPMHOLD:
break;
case FS_AP_RPM:
break;
case FS_AP_GLIDESLOPEHOLD:
break;
case FS_AP_APPROACHHOLD:
ApproachHold = val;
FsbusWrite(C_LAPP, ApproachHold);
break;
case FS_AP_BCHOLD:
break;
case FS_AUTOTHROTTLEARM:
break;
case FS_FLIGHTDIRECTOR:
if (bSynchronised == false)
{
if (val == 1)
{
// printf("DIRLFsAP, val=%d\n", val);
FsbusWrite(C_LFLIGHTDIRL, 1);
FsbusWrite(C_LMASTFLIGHTL, 1);
FsbusWrite(C_LFLIGHTDIRR, 0);
FsbusWrite(C_LMASTFLIGHTR, 0);
// FsWrite(FS_FLIGHTDIRECTOR,1);
ValFlightDir = 1;
}
else
{
FsbusWrite(C_LFLIGHTDIRL, 0);
FsbusWrite(C_LMASTFLIGHTL, 0);
FsbusWrite(C_LFLIGHTDIRR, 0);
FsbusWrite(C_LMASTFLIGHTR, 0);
// FsWrite(FS_FLIGHTDIRECTOR,0);
ValFlightDir = 0;
}
}
break;
case FS_ENGINE1N1:
Engine1N1 = val * 100 / 16384;
break;
case FS_ENGINE1N2:
Engine1N2 = val * 100 / 16384;
break;
}
}
Hi,
that was the complet file. ;)
I dont see any function they shutoff an engine.
That is a strange fault.
Did your code make a logfile??
Stefan
Hi Stefan,
I'm not sure if it has made a log file. Where would I find it, and do I have to set it up to make a log file or does it do it automatically anyway.
Stefan,
Could it have anything to do with this bit of the code. There is no reference to engine 2 ie:
FsWrite(FS_ENGINE1N1, EngN1);
FsWrite(FS_ENGINE1N2, EngN1);
Do I need to duplicate this for FS_ENGINE2N1 and FS_ENGINE2N2
Will that make any difference?
case C_SSPDHLD:
if ( (val == 0) && (CockpitATArmed == 1) )
{
AirspeedHold = (AirspeedHold == 0) ? 1 : 0;
FsbusWrite(C_LAIRSPEEDHOLD, AirspeedHold);
if (AirspeedHold == 1)
{
EngN1 = 0;
FsbusWrite(C_LN1, EngN1);
if (MachSpeed == 0)
FsWrite(FS_AP_AIRSPEEDHOLD, 1);
else
FsWrite(FS_AP_MACHHOLD, 1);
}
else
{
FsWrite(FS_AP_AIRSPEEDHOLD, 0);
FsWrite(FS_AP_MACHHOLD, 0);
}
FsWrite(FS_ENGINE1N1, EngN1);
FsWrite(FS_ENGINE1N2, EngN1);
}
Hello,
i donīt understand first that 2 rows.
First in the defination of this variable, it is a 0-1 "switch".
Also written nowhere in the code of other value that is a 0 or 1, with the varible.
Second, the FS_ENGINE1N1 (0x0898) and FS_ENGINE1N2 (0x0896) are usually read only values.
If you write that FSUIPC offsets (in the doc the Offset is read only) dan FSUIPC reacts , than you switch off the ENG1.
Look both offsets ENG1 the N1 and N2.
Stefan
Stefan,
The post was in German but the email I received to tell me about the post was in English (strange).
Should I try the code with these two lines deleted:
FsWrite(FS_ENGINE1N1, EngN1);
FsWrite(FS_ENGINE1N2, EngN1);
Fixed the language, sorry. :roll:
try to delet them.
Deleted them and now the engine doesn't stop.
All appears to be working as it should so far.
I have to put it through it's paces with approaches etc. ILS landings etc.
Thanks again Stefan, I'll let you know how it's all going.
David
Just completed my first ILS approach into Brisbane with my MCP and it's associated code, all went well with MCP controlling glideslope decent and runway alignment.
Just have to work on my skill from 50feet down to the runway and stopping.
My next task is to work on the stepper motor board so I can finally finish my Attitude indicator (it's complete, just haven't built the stepper board) and get the gyro compass working.
I still have to build the Altitude indicator based on Mike's designs.
Thanks for all your help Stefan, I'll sure it's not over yet though.
David
Hi Stefan,
Don't know if you can answer this one for me, but maybe someone else can if you are unable.
I am building another Servo Board and for some reason I am having trouble getting 22pf ceramic capacitors.
I have lots of 27pf caps.
Can I use these???
Thanks
David
Hi,
27pf is fine.
Stefan
Thanks Stefan,
I thought they would be, but I just wanted to be sure before I solder them in.
Regards
David
Oh, by the way, I have converted the bank portion of my attitude indicator to a servo as you suggested some time ago instead of the stepper I had put in there.
Stefan,
I am compiling after adding the code for Pitch and Bank, and I am getting warning message although it is still compiling.
Do you know where the error is? What code do you want to see?
Thanks
David
c:\documents and settings\david\my documents\visual studio 2008\projects\davids flight sim\davids flight sim\gauges.cpp(141) : warning C4244: 'initializing' : conversion from 'double' to 'int', possible loss of data
c:\documents and settings\david\my documents\visual studio 2008\projects\davids flight sim\davids flight sim\gauges.cpp(141) : warning C4244: 'initializing' : conversion from 'double' to 'int', possible loss of data
c:\documents and settings\david\my documents\visual studio 2008\projects\davids flight sim\davids flight sim\gauges.cpp(141) : warning C4244: 'initializing' : conversion from 'double' to 'int', possible loss of data
c:\documents and settings\david\my documents\visual studio 2008\projects\davids flight sim\davids flight sim\gauges.cpp(141) : warning C4244: 'initializing' : conversion from 'double' to 'int', possible loss of data
c:\documents and settings\david\my documents\visual studio 2008\projects\davids flight sim\davids flight sim\gauges.cpp(141) : warning C4244: 'initializing' : conversion from 'double' to 'int', possible loss of data
c:\documents and settings\david\my documents\visual studio 2008\projects\davids flight sim\davids flight sim\gauges.cpp(141) : warning C4244: 'initializing' : conversion from 'double' to 'int', possible loss of data
c:\documents and settings\david\my documents\visual studio 2008\projects\davids flight sim\davids flight sim\gauges.cpp(141) : warning C4244: 'initializing' : conversion from 'double' to 'int', possible loss of data
Linking...
Embedding manifest...
Please show the line 141 in the gauges.cpp file.
Hi Stefan,
Line 141 is the calibrate fields, but I have included the code for this bit.
ase FS_ATTITUDEINDICATORPITCH:
{
static CALTAB ATTITUDEINDICATORPITCHIndicator [] = {
{-85,72},{-13.8,94},{-10.4,101},{-6.7,105},{-3.6,107},{0,111},{3.9,119},{6.5,124},{10.1,129},{14,132},{80,147}
};
val = Calibrate (val,ATTITUDEINDICATORPITCHIndicator,11);
FsbusWrite (C_ATTITUDEINDICATORPITCH, val);
}
break;
Actually, is the fact I'm using numbers like -10.4
Do I have to use rounded numbers?
Thanks
David
Yes try to round the Values.
Short tip:
FsbusWrite (C_ATTITUDEINDICATORPITCH, Calibrate (val,ATTITUDEINDICATORPITCHIndicator,11));
Stefan
hey David would you be willing to Post some pics of your Boards and your MCP? Im wanting to make one as well in about 2-3 weeks
Trevor
Hi Trevor,
Happy to, as soon as my wife can find the charger for our camera. (you know, it's put somewhere safe, never to be found again:lol: )
I have only just put all the gauges and MCP back into the cockpit yesterday, so it would have been easier to have taken the photos then.
David
Hi Stefan,
Thanks for the tip.
What does this do differently to how I have it coded now?
FsbusWrite (C_ATTITUDEINDICATORPITCH, Calibrate (val,ATTITUDEINDICATORPITCHIndicator,11));
vs
FsbusWrite (C_ATTITUDEINDICATORPITCH, val);
Thanks
David
It is only 1 line, instead of 2.
Oh, ok, it replaces both these lines:
val = Calibrate (val,ATTITUDEINDICATORPITCHIndicator,11);
FsbusWrite (C_ATTITUDEINDICATORPITCH, val);
Thanks
David
Cant seem to find the offsets for the transfer switch for
Com1
Com2
Nav1
Nav2
unless i overlooked them
You can also make your own swap in your code.
The advantageous is that you donīt need to read the Values from the FSUIPC Offset. In that case the radios are Input only devices.
Stefan
k i see that in there now but i guess i dont under stand how you would put that into C++ If 3123 is the offset how you type it up for Com1 can you give me an example for Com1? so i take it since this is only a Write not a read that when the switch is in this position its val = say 2^3 to = COM1 so would it be a on/off switch to and every time it writes that one value it will swap the two freqs? can you please give me an example via code so i can get an idea?
Thanks, Trevor
Look to that thread.
There you see how to handle Bit Inputs.
Stefan
O...... ok ill try to make since of that thanks!!! I have never messed with a IO board or switches and i ordered some last week hope to get them here in the mail soon. As advice would you say this whole thing would be easier to figure out if i had a IO pcb and switches to experiment with the C++ ?
Hi Trevor,
Stefan helped me with the swap button earlier on in this thread.
He gave me an example of the ADF code and with his help, modified it for the NAV1.
Tis here: http://www.mycockpit.org/forums/show...Bus-dll/page15
David
If you like, when I get a moment, I'll post the actual code for the NAV1