PDA

View Full Version : Progamming help with FSBus dll



Pages : 1 [2] 3

RobiD
01-24-2010, 07:58 AM
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

sgaert
01-24-2010, 08:02 AM
Can you post the code of the Speed Hold button?

RobiD
01-24-2010, 08:14 AM
Here's the code.

There is a lot of unecessary stuff I've commented out.



#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;

}
}

sgaert
01-24-2010, 12:21 PM
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

RobiD
01-24-2010, 06:24 PM
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.

RobiD
01-24-2010, 06:32 PM
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);
}

sgaert
01-24-2010, 06:42 PM
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

RobiD
01-24-2010, 06:53 PM
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);

sgaert
01-24-2010, 06:59 PM
Fixed the language, sorry. :roll:
try to delet them.

RobiD
01-24-2010, 09:53 PM
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

RobiD
01-25-2010, 09:08 AM
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

RobiD
02-07-2010, 11:06 PM
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

sgaert
02-08-2010, 04:31 AM
Hi,

27pf is fine.

Stefan

RobiD
02-08-2010, 04:50 AM
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.

RobiD
02-14-2010, 11:06 PM
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...

sgaert
02-15-2010, 03:07 AM
Please show the line 141 in the gauges.cpp file.

RobiD
02-15-2010, 03:14 AM
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

sgaert
02-15-2010, 03:20 AM
Yes try to round the Values.

Short tip:
FsbusWrite (C_ATTITUDEINDICATORPITCH, Calibrate (val,ATTITUDEINDICATORPITCHIndicator,11));

Stefan

388TH_A
02-15-2010, 09:17 AM
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

RobiD
02-15-2010, 05:15 PM
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

RobiD
02-16-2010, 08:13 AM
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

sgaert
02-16-2010, 09:07 AM
It is only 1 line, instead of 2.

RobiD
02-16-2010, 04:57 PM
Oh, ok, it replaces both these lines:

val = Calibrate (val,ATTITUDEINDICATORPITCHIndicator,11);
FsbusWrite (C_ATTITUDEINDICATORPITCH, val);

Thanks
David

388TH_A
02-18-2010, 10:55 AM
Cant seem to find the offsets for the transfer switch for
Com1
Com2
Nav1
Nav2

unless i overlooked them

Jan737
02-18-2010, 11:06 AM
Cant seem to find the offsets for the transfer switch for
Com1
Com2
Nav1
Nav2

unless i overlooked them

Hi
From the FSUIPC offset list:

3123 1 Radio Use/Standby swap toggles (FS2002+ only), Write bits to operate toggles. Don’t bother to read it, there’s no meaning to anything read.

2^3 COM1 swap

2^2 COM2 swap

2^1 NAV1 swap

2^0 NAV2 swap

Best regards

Jan Geurtsen

sgaert
02-18-2010, 11:27 AM
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

388TH_A
02-18-2010, 11:51 AM
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

sgaert
02-18-2010, 12:10 PM
Look to that thread (http://www.mycockpit.org/forums/showthread.php?18976-Help-with-FSbus-C-software).
There you see how to handle Bit Inputs.

Stefan

388TH_A
02-18-2010, 05:08 PM
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++ ?

RobiD
02-18-2010, 05:19 PM
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/showthread.php?16227-Progamming-help-with-FSBus-dll/page15

David

If you like, when I get a moment, I'll post the actual code for the NAV1

388TH_A
02-20-2010, 07:17 AM
Thanks ill have to try that and if im understanding look at posts #136 and #137 and change it some over to the COM and NAV swap buttons?

sgaert
02-20-2010, 03:58 PM
The post you mean are only ADF and XPNDR.
I can write you a code sample from my cockpit, but that dont base on the FS Swap offset.

case C_COM1Trans:
FsWrite (FS_COM1FREQUENCY, COM1S);
FsWrite (FS_COM1STANDBY, COM1);
FsbusWrite (C_COM1DisplayS, BCD2Int(COM1)+10000);
FsbusWrite (C_COM1DisplayA, comstby+10000);
x1 = COM1;
x2 = COM1S;
COM1 = x2;
COM1S = x1;

break;

388TH_A
02-20-2010, 11:34 PM
Sure that would be great and i have the code for all the COM1 + COM1 stby and so on just dont have the Swap button in there. Was thinking of trying to put it all into C++ before i get my IO pcbs in the mail but almost think i should wait for them so i can learn and teach my self on how the IO board works. then that way i can also play with the code and the switch at the same time.

RobiD
02-21-2010, 03:52 AM
Hi Trevor,

It is definately better to have the boards wired up and ready to test your code, otherwise you won't know if it is working properly. Having the boards also lets you problem solve any issues.

Here is the code that I am grateful to Stefan's help with (this is a working code that I am using for my cockpit so it should work fine for you):
(If you are still having trouble working it out, let me know and I'll post the entire radios .cpp file for you)
Don't forget to define the int at the top:
David

static int nav1mode=0;


/*----------------------- NAV1 Events ---------------------*/

case FS_NAV1FREQUENCY:
Nav1Fr = 10000 + BCD2Int(val);
FsbusWrite(C_DNAV1, Nav1Fr);
break;
case FS_NAV1STANDBY:
Nav1FrStb = 10000 + BCD2Int(val);
FsbusWrite(C_DNAV1STB, Nav1FrStb);
break;

case C_NAV1Push:
if(val==0)
{
nav1mode+=1;
if (nav1mode>1)
nav1mode=0;
}
break;
case C_RNAV1:
if (nav1mode==0)
{
x = Nav1FrStb % 100; // behind dec point
x = x + 5 * val; // in steps of 0.05
if (x > 95)
x = 0 ;
else if (x < 0)
x = 95;
Nav1FrStb = Nav1FrStb / 100 * 100 + x; // units: 0.01
FsbusWrite(C_DNAV1STB, Nav1FrStb);
x = Int2BCD(Nav1FrStb % 10000);
FsWrite(FS_NAV1STANDBY, x);
break;
}
if (nav1mode==1)
{
x = Nav1FrStb / 100;
x = x + val; // in steps of 1.00
if (x > 117)
x = 108;
else if (x < 108)
x = 117;
Nav1FrStb = x * 100 + Nav1FrStb % 100; // units: 0.01
FsbusWrite(C_DNAV1STB, Nav1FrStb);
x = Int2BCD(Nav1FrStb % 10000);
FsWrite (FS_NAV1STANDBY, x);
break;
case C_SNAV1SWAP:
if (val == 0)
FsWrite(FS_RADIOUSESTBYTOGGLE, 0x02); // toggle bit 1 (NAV1)
break;
}

388TH_A
02-21-2010, 12:32 PM
Thank You David for your post that helped out alot. Also Stefan Sent me a file of a sample project and that has also helped out alot. Thanks guys

388TH_A
02-21-2010, 05:55 PM
0x08 toggle bit 3 (COM1)
0x04 toggle bit 2 (COM2)
0x02 toggle bit 1 (NAV1)
0x01 toggle bit 3 (NAV2)

So if the bits are that above how do you get that out of

2^3 = COM1
2^2 = COM2
2^1 = NAV1
2^0 = NAV2

Jan737
02-22-2010, 03:53 AM
0x08 toggle bit 3 (COM1)
0x04 toggle bit 2 (COM2)
0x02 toggle bit 1 (NAV1)
0x01 toggle bit 3 (NAV2)

So if the bits are that above how do you get that out of

2^3 = COM1
2^2 = COM2
2^1 = NAV1
2^0 = NAV2


Hi Trevor,

Don't know exactly what your mean with your question, but:

2^3 = 2 x 2 x 2 = 8 = 0x08 bit3
2^2 = 2 x 2 = 4 = 0x04 bit2
2^1 =1 x 2 = 2= 0x02 bit1
2^0 = 1 = 0x01 bit0

and so on



Best regrards

Jan Geurtsen

RobiD
02-22-2010, 06:20 AM
I'm not quite sure about what you are trying to work out either.

The swap is done with the Nav1mode part of the code. I haven't used any offsets for the swap, just Nav1mode==0 and Nav1mode==1.

Stefan showed me how to use this and it works perfect.

Do you want my entire .cpp code for the radios so you can see how it's put together without using offsets for the swap? (I'm more than happy for you to use the whole thing in it's entireity or just bits of it)

David

sgaert
02-22-2010, 06:28 AM
Hi David,

yes we both and Rob in the Sample File use the Radioīs ase Input Only devices.
We swap the frequenzies self.
If you donīt need the FS default Swap Offset, you also dont need to read out the frequenzies from the FS.

Stefan

388TH_A
02-22-2010, 10:01 AM
Hi Trevor,

Don't know exactly what your mean with your question, but:

2^3 = 2 x 2 x 2 = 8 = 0x08 bit3
2^2 = 2 x 2 = 4 = 0x04 bit2
2^1 =1 x 2 = 2= 0x02 bit1
2^0 = 1 = 0x01 bit0

and so on



Best regrards

Jan Geurtsen

(Light goes on in head) O.... ok thanks that makes since now! Yeah I understood that A=B but just didnt understand on why it did but i get it now. It was almost like in Math in school where i understood that this = this but didnt see the work for it to prove on why it did. I get it now thanks again Jan!

And David i think im ok now just was wondering on why above was why it was thats all, but thanks anyways. I might take you up on your offer later down the road for the mcp maybe but well see.

Trevor

RobiD
02-22-2010, 05:14 PM
My MCP code is working perfectly for my setup, so just let me know when you want it.

It may require some modification to suit your set up though.

Regards
David

388TH_A
02-22-2010, 09:36 PM
For sure for sure thanks ill keep you in mind. I hope to have my pcbs from Rob here soon but there still showing that there in the Netherlands still so not sure when ill get them but hoping soon so i can finish my radio stack and start the MCP.

RobiD
02-23-2010, 06:37 AM
This one is open to anyone to answer:

I have done a clean re-install on my second hard drive (with a dual boot) and this is the disc I want to run FSX from. The other HD is my working drive which I do all my programming and testing on.

I have installed FSUIPC, FSBUSdll and copied the fsbus.dll file to windows/system32/ folder, I have installed the Microsoft Visual C++ redistributable package (as I don't want to install the whole studio software).

I have copied my cockpit.exe file from my projects on the other disc.

There's the background, here's the problem:
When I double click the actual cockpit.exe file, I get an error message saying

This application failed to start because the application is configured incorrectly. Reinstalling the program may fix this problem.


What have I missed in setting this up on my clean hard drive?

Thanks all.

David

sgaert
02-23-2010, 06:40 AM
Hi,
that is normal.
Usualy it is enought to install the Microsoft Visual C++ redistributable package 2008, but not in case of our projekts.
I have installed VS C++ on my second PC, but i dont use them.

Stefan

RobiD
02-23-2010, 06:45 AM
Hi Stefan,

So it is necessary to install VStudio on my Sim hard drive?

David

sgaert
02-23-2010, 06:48 AM
Where you whant to run the exe from the Project, it looks like that you need the Studio.

RobiD
02-23-2010, 08:18 AM
Thanks Stefan.

Works now.

David

RobiD
03-02-2010, 03:22 AM
Another little problem.

I have now put the MCP and all the gauges back into the sim with the new DIO, DISP 6pac, and the new servo board in.

If I fly straight without any turbulance, all works great. 'It appears' that when I turn or hit turbulance, the boards all reset and I've got to stop fsbus and restart it for everything to coordinate again ie: lighting on the mcp and displays.

It will work perfectly for hours if I don't turn or hit bumps.

Could this have something to do with my turn rate/coordinator.

I will try it all without the turn rate/coordinator connected and see if it makes any difference.

Have you seen this before?

Thanks
David

sgaert
03-02-2010, 03:30 AM
do you drive the Servos with a extra powersupply or use the 5V from the Bus?

RobiD
03-02-2010, 03:38 AM
I run the power to the servo boards from the 5vdc on a seperate ATX powersupply. I also run the 5vdc to the Com board from this powersupply as well.

sgaert
03-02-2010, 03:40 AM
Ok, an ATX powersupply has enough power for both.

RobiD
03-05-2010, 10:26 PM
Stefan,

Finally got time to test various things to try to isolate what is causing the reset problem.

It is only when I have the second Servo board connected with the 10 pin cable. There is only the 2 servos for the attitude indicator running off this board at present.

When it's disconnected, I have no problems.

Before I posted, I did a couple of more tests.

I connected one of the gauges I have had running for some time without problem to the new servo board, and it worked without problem. I am thinking it may be the type of servo I'm using.

What servos do you use?

Thanks
David

sgaert
03-06-2010, 01:22 AM
i donīt know what i use, they are the cheapest i can buy.
They dont have a company or product lable.

Sorry

RobiD
03-06-2010, 01:50 AM
I've used the cheapest I can find as well and I thought that might be my problem, but it appears that you have not had any problems with your's.

David

Jan737
03-06-2010, 08:37 AM
Stefan,

Finally got time to test various things to try to isolate what is causing the reset problem.

It is only when I have the second Servo board connected with the 10 pin cable. There is only the 2 servos for the attitude indicator running off this board at present.

When it's disconnected, I have no problems.

Before I posted, I did a couple of more tests.

I connected one of the gauges I have had running for some time without problem to the new servo board, and it worked without problem. I am thinking it may be the type of servo I'm using.

What servos do you use?

Thanks
David


Hi ,
I've had the same problems, every time the servo move, the controller was reseting it's self.
I've separated the power supply for the servo's and the PCB, that solved my problems with reseting the controller.

Hope it helps.


Best regards

Jan Geurtsen

RobiD
03-06-2010, 09:56 AM
I am running the same power supply for the 5vdc to the com board and to the two servo boards.

Is this what you did have and now you run a seperate power supply for the servos?

Also, it's not resetting just the servo board, it's resetting the entire FSBus system so I lose all settings on my other boards. I have to restart the FSBus exe file to get everything to sync up again.

David

Jan737
03-06-2010, 10:19 AM
I am running the same power supply for the 5vdc to the com board and to the two servo boards.

Is this what you did have and now you run a seperate power supply for the servos?

Also, it's not resetting just the servo board, it's resetting the entire FSBus system so I lose all settings on my other boards. I have to restart the FSBus exe file to get everything to sync up again.

David


Hi David,

Yes, that's the problem.

Use a separate 5 Volt PSU to feed the servo's and your problems are solved http://www.mycockpit.org/forums/images/icons/icon7.gif

Jan

iwik
03-06-2010, 01:54 PM
Hi David,
Not running Fsbus now,but from the early days it was recommended to have a seperate supply for the servos.The motors in the servos can generate some real noise pulses and can do real strange things.Its not a good practice in electronics to mix Digital supplies with ones feeding noisey devices like motors.Jan had the right answers and obviously fixed his problems.
Rgds
Les

RobiD
03-06-2010, 10:59 PM
Thanks guys.

I have high hopes this does solve my problem. I will get to it and test this out and let you all know the results.

David

RobiD
03-07-2010, 01:11 AM
Thank you.

This has solved my problem.

I have done a return trip from Gold Coast to Bris International without 1 reset. Before I couldn't go more than a minute or so without a reset.

Very Grateful.

David

RobiD
03-08-2010, 08:06 AM
Ok, on to the next bit of programming.

I have built a Servo based VOR/GS indicator as in Mike's book. Works great. I have almost everything working but now it is time to get all of it's bits working.

Mike has used 3 seven segment Displays at the top and 3 at the bottom of the gauge as the to/from instead of the large resolver ring.

The offset for this is 0C4E for the top display and the bottom needs to be 180 degrees opposite.
I am using a rotary encoder on the gauge to change it.

Using FSInterrogate, 0C4E is the right offset for the 'Omnibearing Selector Knob'

I have some basic programming for the top display and for some reason, it is displaying the same as the last 3 digits of the ADF and changes when I change the ADF.

Stefan, I'd love your assistance in writing the correct code to acheive what I have written above.

This is what I have for the OBS display so far (less all the other bits in the gauges.cpp file):

MkFsbusObject (BTP_DISPLAY,C_OBS_DISPLAY,"OBS Display",cbGauges,15,0);
DisplayOptions (C_OBS_DISPLAY, 3, 0, TRUE, 0);

MkFsObject(FS_NAV1OBS,"OBS",cbGauges,0x0C4E,2,TP_I16,FS_NORMAL);


case FS_NAV1OBS:
//int x;
//x = val;
//static int OBS;
//OBS = Int2BCD(x);
FsbusWrite (C_OBS_DISPLAY, val);
break;

---------------------------------------------------

This is the code I have for the ADF perhaps it is clear to someone else why this is coming through CID 15 instead of the OBS 0x0C4E offset.

MkFsbusObject (BTP_ROTARY, C_RADF,"",cbNav, 27,44);
MkFsbusObject(BTP_DISPLAY, C_DADF_1,"",cbNav, 11, 0);
DisplayOptions(C_DADF_1,5,0,TRUE,2);
MkFsObject(FS_EXTENDEDADF1,"",cbNav,0x0356, 2,TP_UI16,FS_NORMAL);
MkFsObject(FS_ADF1FREQUENCY,"",cbNav,0x034C, 2,TP_UI16,FS_NORMAL);


case FS_ADF1FREQUENCY:
ADF1 = (ADF1 / 10000) * 10000 + BCD2Int(val) * 10 + ADF1 % 10;
FsbusWrite(C_DADF_1, ADF1);
if (bSynchronised == false)
{
ADF1Stb = ADF1;
FsbusWrite(C_DADF_1, ADF1Stb);
}
break;
case FS_EXTENDEDADF1:
ADF1 = BCD2Int(val >> 8) * 10000 + ((ADF1/10)%1000)*10 + BCD2Int(val & 0x00FF);
FsbusWrite(C_DADF_1, ADF1);
if (bSynchronised == false)
{
ADF1Stb = ADF1;
FsbusWrite(C_DADF_1, ADF1Stb);
}
break;

case C_ADFPush:
if(val==0)
{
adfmode+=1;
if (adfmode>2)
adfmode=0;
}
break;

case C_RADF:
if (adfmode==0)
{
x = ADF1Stb / 1000; // hundreds
x = x + val; // update 100s
if (x > 17)
x = 1; // wrap
else if (x < 1)
x = 17; // wrap
ADF1Stb = x * 1000 + ADF1Stb % 1000; // new 100s
FsbusWrite(C_DADF_1, ADF1Stb);
x = Int2BCD(ADF1Stb);
FsWrite(FS_EXTENDEDADF1, ((x & 0x0F0000) >> 8) | (x & 0x00000F));
FsWrite(FS_ADF1FREQUENCY, (x & 0x00FFF0) >> 4);
}
if (adfmode==1)
{
x = (ADF1Stb % 1000) / 10; // tens + units
x = x + val; // update 10s
if (x > 99)
x = 0; // wrap
else if (x < 0)
x = 99; // wrap
ADF1Stb = (ADF1Stb / 1000) * 1000 + x * 10 + ADF1Stb % 10; // new 10s
FsbusWrite(C_DADF_1, ADF1Stb);
x = Int2BCD(ADF1Stb);
FsWrite(FS_EXTENDEDADF1, ((x & 0x0F0000) >> 8) | (x & 0x00000F));
FsWrite(FS_ADF1FREQUENCY, (x & 0x00FFF0) >> 4);
}
if (adfmode==2)
{
x = ADF1Stb % 10; // .1 units
x = x + val; // update 10s
if (x > 9)
x = 0; // wrap
else if (x < 0)
x = 9; // wrap
ADF1Stb = (ADF1Stb / 10) * 10 + x;
FsbusWrite(C_DADF_1, ADF1Stb);
x = Int2BCD(ADF1Stb);
FsWrite(FS_EXTENDEDADF1, ((x & 0x0F0000) >> 8) | (x & 0x00000F));
FsWrite(FS_ADF1FREQUENCY, (x & 0x00FFF0) >> 4);
}
break;

RobiD
03-09-2010, 07:13 AM
I've managed to program this my self (very proud) and it works perfect.

Just can't figure the last bit.
The second group of 3 x 7segment Leds should show the from course which is '180' degrees the opposite of the 'to'.

I have tried dividing the val by 2. At compass 030, I get 015
Tried minus 180 with no luck.

Here is the code I've done. Can someone please tell me what I need to add to show the 'from' heading.


case FS_NAV1OBS:
int x;
x = val;
static int OBS;
OBS = Int2BCD(x);
FsbusWrite (C_OBS_DISPLAY, val);
FsbusWrite(C_DCOURSEL, val); // to cockpit display
FsbusWrite(C_DCOURSER, val);
val = val >> 1; // this is where I've tried to display the from heading
FsbusWrite(C_OBS_FROM_DISPLAY, val);
break;

case C_OBS_ROTARY:
Obsknob -=val;
while (Obsknob >360)
Obsknob -= 360;
while (Obsknob <= 0)
Obsknob += 360;
FsWrite(FS_NAV1OBS, Obsknob); // to FS
FsbusWrite(C_DCOURSEL, Obsknob); // to cockpit display
FsbusWrite(C_DCOURSER, Obsknob);
FsbusWrite(C_OBS_DISPLAY, Obsknob);
break;

Thanks as usual.
David

RobiD
03-10-2010, 07:30 AM
Worked it out finally.

For anyone else who wants to know how to do this, here is the code:



case FS_NAV1OBS:
int x;
x = val;
static int OBS;
OBS = Int2BCD(x);
FsbusWrite (C_OBS_DISPLAY, val);
FsbusWrite(C_DCOURSEL, val);
FsbusWrite(C_DCOURSER, val);
val = val - 180;
while (val >360)
val -= 360;
while (val <= 0)
val += 360;
FsbusWrite(C_OBS_FROM_DISPLAY, val);
break;

case C_OBS_ROTARY:
Obsknob -=val;
while (Obsknob >360)
Obsknob -= 360;
while (Obsknob <= 0)
Obsknob += 360;
FsWrite(FS_NAV1OBS, Obsknob);
FsbusWrite(C_DCOURSEL, Obsknob);
FsbusWrite(C_DCOURSER, Obsknob);
break;

RobiD
03-14-2010, 12:38 AM
Stefan, you still there?

I don't know if you can help me here but here goes.

I am about to tackle building and programming the Altimeter and using a stepper motor.

On the pcb stepper.lay file, do you have the capacity to remove all the black around the outside of the pcb layout. Reason being, when trying to print using the toner transfer method, this enormous amount of toner is causing problems printing. I thought that you would possible have access to the original file. (If you have a look at the file in Sprint, you will see what I mean)

Secondly, do you have an example of how to code for a stepper specific to the altimeter.

Also, when I make the MkFSBusObject is it an analogue or digital out ie: BTP_D_OUT or BTP_A_OUT


Hope you are able to help me out with this.

Thanks
David

388TH_A
04-21-2010, 05:10 AM
Here is the File i have stepperfet.lay (http://ttd.g11.us/uploads/fsbus_pics/stepperfet.lay) and when you go into Sprint go to the bottom left side of the program and click on http://ttd.g11.us/uploads/fsbus_pics/Stepper.JPG "Enable/disable ground plane" and that will take that away so you may then print it with out the extra black. And the MkFSBusObject is BTP_V_OUT = Stepper controller the first channel begins with r = 80, the 8th channel is r = 87. Says that on page 17 of the fsbusreference.pdf if.... you.... have a copy of that....


Stefan, you still there?

I don't know if you can help me here but here goes.

I am about to tackle building and programming the Altimeter and using a stepper motor.

On the pcb stepper.lay file, do you have the capacity to remove all the black around the outside of the pcb layout. Reason being, when trying to print using the toner transfer method, this enormous amount of toner is causing problems printing. I thought that you would possible have access to the original file. (If you have a look at the file in Sprint, you will see what I mean)

Secondly, do you have an example of how to code for a stepper specific to the altimeter.

Also, when I make the MkFSBusObject is it an analogue or digital out ie: BTP_D_OUT or BTP_A_OUT


Hope you are able to help me out with this.

Thanks
David

RobiD
04-21-2010, 05:19 AM
Thanks Trevor.

Dirk made contact and helped me a little. I still have no idea how to code for the stepper.

I have made the altitude indicator from Mikes book with the 3 optical interupters for zero point. So I'm not sure how to account for this either.

Have you made and are using the stepper? If so, is it possible to see the code you have made to run it so I can get some idea.
Dirk hasn't gone far with testing or using the stepper but has also offered help if needed.

Thanks

David

388TH_A
04-21-2010, 06:20 AM
Sorry im Still Stuck on the Radio Stack

sgaert
04-21-2010, 06:23 AM
Hi David,

i also never get the Stepper working.
But i seen it on Dirks Setup a year ago. Strange.

Stefan

RobiD
04-21-2010, 06:28 AM
Yes, he said that. Here's part of what Dirk wrote back:

"THe tricky part
will be the zero position decoding. I got it working once, but i know somebody who failed at that point. So far i
haven't investigated that flaw."

It seems a hard choice to go down the road with this controller when it seem no one has got it working yet. (But I guess, someone has to get it going at some point)

So you can see that I would appreciate any help or advice anyone can give.

Regards
David

388TH_A
04-21-2010, 06:29 AM
was it hard to solder that LITTLE chip onto the PCB

RobiD
04-21-2010, 08:09 AM
I haven't populated the board yet but I'm imagining it will have it's challenges. I'll let you know how it goes.

388TH_A
04-21-2010, 08:24 AM
if i ever do one i was thinking about getting one of thoughs things that makes it go from small to the normal size so it would be easy to solder it.

RobiD
04-21-2010, 05:12 PM
Trevor,

What little device do you mean?

If it makes it easier to solder, I'm in.

----

Is there any other alternative for my stepper driven gauges that anyone else has used?

388TH_A
04-21-2010, 07:04 PM
Like these... http://www.futurlec.com/SockPLCC.shtml
OR these http://www.futurlec.com/PLCC_Adapters.shtml



Trevor,

What little device do you mean?

If it makes it easier to solder, I'm in.

----

Is there any other alternative for my stepper driven gauges that anyone else has used?

388TH_A
04-24-2010, 08:34 AM
The IO picture shows that the BTP_A_IN is 00-07 but there 72-79 like David said! Would be nice to get this picture fixed for others lol i spent awhile trying to get my throttle going and it wouldnt work didnt know if it was the code or what so i started looking in here and it was the CID that was wrong. I was putting in 7 and it wouldnt work so i tried 79 and it works. O and not sure if i ever told you guys butmy name is Trevor LOL

Thanks,
Trevor

Stefan,

Where do I find the RID numbers for J5 on the DIO. I can find the 0-63 for keys and 72-79 for J3 in the DIO manual but I can't find J4 and J5.

David


It is to easy, 0-15.
http://www.rvdijk.nl/images/RVD_PCB_FSBUS_IO_Connectors.JPG

RobiD
04-26-2010, 05:05 AM
Hey Trevor,

Yes, I picked your name up a while ago on another thread.

The RID's here had me stumped for a while too.

Thanks for the links. Looking at the sockets, wouldn't they be just as difficult to solder in (not the through board ones)?
The board would have to be modified to suit the through board configuration. I did have a quick look at the possibility of redesigning the board with the standard ATmega168 with the DIP 'through board' configuration. May still have a go at it yet.

David

388TH_A
04-26-2010, 09:16 AM
when able i try to make my own PCBs and that way i can make them how i want them to be. So yeah you might be able to take the lay out of it and change it up some. Just seems like it wouldnt be as hard to solder it if the holes are farther away from each other. Just looking at the Controller just seems like the holes are really close to each other and would be harder to solder vs the sockets i showed you.

Just an idea,
Trevor

sgaert
04-26-2010, 03:11 PM
Hi guys,

that is my Stepper testboard. I dislike SMD on PCBīs, they i donīt know.
That is the reason, why i build that.

http://lh3.ggpht.com/_B8czH7apyHE/S9Xjq_KCg0I/AAAAAAAAHcQ/781FUCpDI3Q/s400/P1030147.JPG

http://lh6.ggpht.com/_B8czH7apyHE/S9XjtGEYPvI/AAAAAAAAHcU/kB0ObFl3-YE/s400/P1030149.JPG

Stefan

388TH_A
04-26-2010, 10:18 PM
O so the ATMEGA168 is two shapes not just one. Never mind yeah this shouldnt be that hard to do. in fact it should be the easiest PCB to do. So is that the ATMEGA168-20PU instead of the ATMEGA168-20AU?

sgaert
04-27-2010, 01:36 AM
Yes the ATMEGA168-20PU is easy to use.
But attention, you have to rework the pinning from the controller. You need the function of the pin not the number.

388TH_A
04-27-2010, 01:47 AM
Yeah that would make since just to make sure the wires are going to the right pin. And how do you know what kind of stepper motor to get?

Trevor

388TH_A
04-27-2010, 01:49 AM
Do you Stefan or David have skype?

sgaert
04-27-2010, 01:52 AM
You get a PM.

RobiD
04-27-2010, 04:08 AM
My wife does, but I can join, no problems.

I'll PM when I'm done.

David

388TH_A
04-27-2010, 06:44 AM
I think i found both of your User names for sype and i already added both of you

Trevor

RobiD
04-27-2010, 07:05 AM
Hi Trevor,

Just sent you and Stefan a PM.

David

388TH_A
04-30-2010, 03:05 AM
My C++ i can only use with FS2004 right now. for what ever reason im not able to use it with FSX. Would you guys be willing to post your code of your main CPP so i can compare it with mine. And also can i have one C++ exe and use it for both FS2004 and FSX? I mostly use FS2004 but also would like to use my stuff with FSX for when i do Multiplayer Pilot/Copilot. Here is the code im using right now, what do i need to change so i can use it with both?



#include "stdafx.h"
#include "rvdb737ng.h"



/* ------------ global variables ------------- */

extern BOOL bSynchronised = false; // cockpit not in sync with FS


/* ========================== */
/* M A I N L I N E */
/* ========================== */

int _tmain(int argc, _TCHAR* argv[])
{
int KeyboardInput = -1; // Input from keyboard
short PauseState; // FS in Pause state (if 1)

int V = GetFsbusDLLVersion();
printf("Detected Fsbus version %d.%d.%d\n",
V/100, (V%100)/10, V%10);
if (V < 200)
{
printf ("Program requires Fsbus DLL version 2.0.0 or higher\n");
return 1;
}

// signal(SIGINT, SIG_IGN); // Ignore Ctrl-Break
// signal(SIGBREAK, SIG_IGN); // and Ctrl-C

OpenLog(); // start log function

CheckIn(); // Connect to FSbus.dll

FsbusOpen("Com1"); // start communications with Fsbus

GlareshieldBuildObjects(); // )
MainpanelBuildObjects(); // )
AftoverheadBuildObjects(); // )
FwdoverheadBuildObjects(); // ) Create objects by group
PedestalBuildObjects(); // )
SoundBuildObjects(); // )
ThrottlequadrantBuildObjects(); // )

FsConnect(); // start communications with FS

WriteLog(0,0,0);
FsbusWriteFmt2(0,128,0); // Fsbus reset
WriteLog(0,0,0);
FsbusMux(3000); // time to process Fsbus events
WriteLog(0,0,0);
GlareshieldSync(); // )
MainpanelSync(); // )
AftoverheadSync(); // )
FwdoverheadSync(); // ) Sync cockpit with FS
PedestalSync(); // )
ThrottlequadrantSync(); // )

bSynchronised = true; // we are in sync now

printf("Hit Escape key to terminate Fsbus program....\n");

FsReadDirect(0x0264, 2, &PauseState); // get FS pause-state
if (PauseState == 1) // paused
{
PauseState = 0;
FsWriteDirect(0x0262, 2, &PauseState); // un-pause
}

/* - - - - wait for Escape (termination) by user - - - - */

while (KeyboardInput != VK_ESCAPE) // not 'Esc' key
KeyboardInput = ReadKeyboard(1000); // check keyboard

/* - - - - - - - - - - - - - - - - - - - - - - - - - - - */

CloseLog(); // stop logging
CheckOut(); // disconnect FSbus.dll

// signal(SIGBREAK, SIG_DFL); // Restore Ctrl-C default
// signal(SIGINT, SIG_DFL); // and Ctrl-Break default

return 0; // terminate program
}


// -------------------------------------------------------------- */
// Function called by fsbus.dll with every event. */
// Can also be called by other modules of this project */
// for example with synchronisation of cockpit with FS. */
// -------------------------------------------------------------- */
extern void EventHandler(int oid, int val, double dval)
{
WriteLog(oid, val, dval); // log event

switch (oid / OBJECTS_PER_GROUP) // select group
{
case GROUP_MAINPANEL:
MainpanelEventHandler(oid, val, dval);
break;
case GROUP_GLARESHIELD:
GlareshieldEventHandler(oid, val, dval);
break;
case GROUP_AFTOVERHEAD:
AftoverheadEventHandler(oid, val, dval);
break;
case GROUP_FWDOVERHEAD:
FwdoverheadEventHandler(oid, val, dval);
break;
case GROUP_PEDESTAL:
PedestalEventHandler(oid, val, dval);
break;
case GROUP_SOUND:
SoundEventHandler(oid, val, dval);
break;
case GROUP_THROTTLEQUADRANT:
ThrottlequadrantEventHandler(oid, val, dval);
break;
default:
printf("%cError: Object %d (%d:%d) in unknown group.\n",
7, oid, oid / OBJECTS_PER_GROUP, oid % OBJECTS_PER_GROUP);
}
}

RobiD
04-30-2010, 04:43 AM
Hey Trevor,

Good to have a chat the other night. I'm more than happy to post any of my code, but as requested, here is my main .cpp file.

Speak soon,
David


// Davids Flight sim.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <windows.h>
#include <stdio.h>

extern BOOL bSynchronised = false;

int _tmain(int argc, _TCHAR* argv[])
{
int v = GetFsbusDLLVersion ();
if (v < 100)
{
printf ("Program requires Fsbus DLL version 1.0.0 or higher\r\n");
return 1;
}

CheckIn();
FsConnect();
FsbusOpen("COM1");


cbLLSwitchboardBuildObjects();
cbMagnetoBuildObjects();
//cbEngineBuildObjects();
cbEnginerpmBuildObjects();
cbGaugesBuildObjects();
cbSwitchesBuildObjects();
cbVoltmetersBuildObjects();
cbNavBuildObjects();
cbIndicatorlightsBuildObjects();
//cbMcpBuildObjects();
cbModecontrolpanelBuildObjects();


FsbusWriteFmt2(9,128,0); // Fsbus reset CID 9
FsbusMux(350); // time to process Fsbus events
FsbusWriteFmt2(10,128,0); // Fsbus reset CID 10
FsbusMux(350);
FsbusWriteFmt2(11,128,0); // Fsbus reset CID 11
FsbusMux(350); // time to process Fsbus events
FsbusWriteFmt2(12,128,0); // Fsbus reset CID 12
FsbusMux(350);
FsbusWriteFmt2(13,128,0); // Fsbus reset CID 13
FsbusMux(350); // time to process Fsbus events
FsbusWriteFmt2(14,128,0); // Fsbus reset CID 14
FsbusMux(350);
FsbusWriteFmt2(15,128,0); // Fsbus reset CID 15
FsbusMux(350); // time to process Fsbus events
FsbusWriteFmt2(16,128,0); // Fsbus reset CID 16
FsbusMux(350);
FsbusWriteFmt2(17,128,0); // Fsbus reset CID 17
FsbusMux(350); // time to process Fsbus events
FsbusWriteFmt2(18,128,0); // Fsbus reset CID 18
FsbusMux(350);
FsbusWriteFmt2(19,128,0); // Fsbus reset CID 19
FsbusMux(350); // time to process Fsbus events
FsbusWriteFmt2(20,128,0); // Fsbus reset CID 20
FsbusMux(350);
FsbusWriteFmt2(21,128,0); // Fsbus reset CID 21
FsbusMux(350); // time to process Fsbus events
FsbusWriteFmt2(22,128,0); // Fsbus reset CID 22
FsbusMux(350);
FsbusWriteFmt2(23,128,0); // Fsbus reset CID 23
FsbusMux(350); // time to process Fsbus events
FsbusWriteFmt2(24,128,0); // Fsbus reset CID 24
FsbusMux(350);


bSynchronised = true;


printf ("press any key to exit ...\r\n");

while (!_kbhit())
FsbusMux(500);

CheckOut();
return 0;
}

sgaert
04-30-2010, 05:03 AM
FSbus only know FSUIPC.
There is no differance between FS9 or FSX.

RobiD
04-30-2010, 05:16 AM
Hi Stefan,

This is what I thought too, so thanks for the confirmation.

David

RobiD
04-30-2010, 09:19 AM
Stefan or Trevor,

Do you guys want to take a look at this layout and tell me if I'm even close. Since I can't attach the .lay file here, I'll put a link to download it to have a look.

I'm open to any suggestions or even if you want to play around with what I have to make it better.

http://www.safeweightloss4kids.com/dontlookhere/StepperDIPedited.LAY

David

sgaert
04-30-2010, 10:21 AM
Hi David,

that lookīs like my hand made board, with some good improvments.

Stefan

RobiD
04-30-2010, 07:20 PM
Hi Stefan,

I used the pictures you posted as a rough guide on the best place to put the components, so I guess it does look like your board.

If you have had a chance to look over it, can you see anything I have connected incorrectly or have missed. (edit: found a couple of mistakes already so have changed these and uploaded the new file at the link on the previous post)

Thanks
David

Oh, have you started any programming for your board yet, and if so, can you give me a bit of an idea how to do it ie: zero point, do I use calibrate function or a code sample would be better still. Thanks

388TH_A
05-01-2010, 02:32 AM
K so i have ver 4.5.2.0 of FSUIPC installed for FSX but yet FSBUS doesnt work for me for FSX... Could there be another reason on why it wont work?

And that Stepper lay LOOKS GREAT! Way better then any thing i have made on it, Good job. And is the updated file the one on post #341 ?

Trevor

RobiD
05-01-2010, 05:26 AM
Hi Trevor,

Yes, I've just overwritten the old one on the server.

Hmm, I have no idea why FS9 and FSX are not interchangable with FSBus. I've used both with FSBus (Classic with FS9 but NG only with FSX).

Perhaps you could drop Dirk an email and ask him. I won't post his email here, just go to his site and send an email throught there, but make the subject something that he'll notice. I'm sure he gets lots of junk mail.

David

388TH_A
05-01-2010, 09:19 AM
I talked to Stefan last night via Skype and he was able to fix my problem and now it works with both. Guess my ver of FSUIPC was to old and when i got the newest ver it worked just fine. Then we talked about some of my other problems in C++ and lol most of it was a fix like o well that should say "com2 not com1" lol. So yeah David you should try to talk to Stefan Via Skype. And your right he knows his stuff.

I was looking at your lay last night and noticed that R1-3 are close to each other are they SMDs? Also there are some lines that go under them 2 times when it could be cleaner and be one line. Is that made like that for a reason? Also i noticed that the 20PU has 5 pins not being used and the other one has 6 pins. Should there be 6 pins on that one as well not being used? Theres my 2 cents for now lol

Trevor

388TH_A
05-01-2010, 02:25 PM
Working on my Announcer panel i have noticed that the Oil Press light will come on at around 60 PSI on the B350 but on the 737-800 it turns on at around 13 PSI. So there for if i set the Oil Press light to come on for the B350 at 60 PSI on the 737-800 they will always stay on. is there a way to make this some kind of and/if so that it will work for more then one aircraft? Or do you have to pick ONE aircraft and base every thing around that.

Trevor

RobiD
05-01-2010, 06:17 PM
Trevor,

I have found that you have to make a seperate .exe file for any variations. For example, my flight sim has all the analogue gauges for the cessna plus it has the 777 overhead and MCP. I can use the 777 MCP for the cessna and some of the switches in the overhead for lights etc but most of the other functions are not relevant. Then there is the ASI which requires different Calibrate arrays for it to be accurate. It is possible, but you won't have 100% accuracy for all craft.

David

388TH_A
05-01-2010, 09:09 PM
yeah thats kinds what i was thinking of doing to fix it. Was thinking about making one for the King Air 350 and then another one for the 737-800. Also are the R1-3 on your lay for the stepper SMDs?

Thanks,
Trevor

RobiD
05-01-2010, 11:36 PM
No SMD's at all. Don't like working with them. My hands arn't that steady for that level of fine work (thank god I'm not a brain surgeon huh!)

David

388TH_A
05-02-2010, 04:28 AM
So would the hols on R1-3 be to close to each other then? also why does 1 line break into 2 lines and run under them and then back to 1 line then back to 2 line then back to 1? Why not keep it at 1 line?

Trevor

RobiD
05-02-2010, 04:53 AM
Hi Trevor,

It's that Auto-route function. It's all the same trace, it just did something weird when I used the auto-route. I figured, it's not doing any harm so don't mess with it.

If you can get it to drop all the secondary lines, go for it. Just share the final product.

Ah, the resistors. You could mount them vertically. It's just the size of the resistor I chose from the macro library and it's not until you print it that you see how big it is (if you know what I mean). Than can be changed too if you wish.

David

388TH_A
05-02-2010, 05:03 AM
that was a fast reply to bad your not on skype

RobiD
05-02-2010, 05:08 AM
Just checked the thread before I settled down the watch the MotoGP. Can't get caught up talking Flight Sim when there's motorbike racing on. lol

David

388TH_A
05-02-2010, 06:44 AM
i know that


If (x == 10)
DoSomething(x);

But can i do something where you have 2 things like a x and y? for example can you do



If (x == 10 and y == 10)
DoSomething(x);

Was thinking about putting 2 values from FS for example batt switch and Gen switch when there both turned off then a light would turn on, on the Announcer. Or something like that. I made a Low Voltage light but not sure on what offsets to send to it. Was thinking of maybe 1 or 2 not sure.

O and P.S. THANKS alot guys..... now im kinda getting into the mood of make some gauges with Stepper Motors lol

Trevor

sgaert
05-02-2010, 07:31 AM
look to that site.
C++ operators (http://www.cplusplus.com/doc/tutorial/operators/)

RobiD
05-02-2010, 07:35 AM
i know that


If (x == 10)
DoSomething(x);

But can i do something where you have 2 things like a x and y? for example can you do



If (x == 10 and y == 10)
DoSomething(x);

Was thinking about putting 2 values from FS for example batt switch and Gen switch when there both turned off then a light would turn on, on the Announcer. Or something like that. I made a Low Voltage light but not sure on what offsets to send to it. Was thinking of maybe 1 or 2 not sure.

O and P.S. THANKS alot guys..... now im kinda getting into the mood of make some gauges with Stepper Motors lol

Trevor

You should be able to assign diffent values dependent on a switch position. ie: if switch is in up position = 0, or is switch is in down position =1

if x=0
then... the value for one aircraft;

if x=1
then.... the value for the other aircraft

Don't know how to code it but I would think it's possible.
Stefan should be able to put this into the right context.

David

PS Just a quick break between the Moto2 and the MotoGP races.

388TH_A
05-02-2010, 08:47 AM
Well im on Skype if any of you wana hang out and chat

Trevor

388TH_A
05-02-2010, 09:43 AM
So can i do


case FS_L_LOW_FUEL:
FsReadDirect(0x0B7C, 4, &L_LOW_FUEL_MAIN);
FsReadDirect(0x0B84, 4, &L_LOW_FUEL_AUX);
if (L_LOW_FUEL_MAIN + L_LOW_FUEL_AUX >1069672)
FsbusWrite (C_L_LOW_FUEL, 0);
if (L_LOW_FUEL_MAIN + L_LOW_FUEL_AUX <1069670)
FsbusWrite (C_L_LOW_FUEL, 1);
break;

What im wanting to do is add up both tanks and when the get to lass then say 13% total the low fuel light will come on.

Trevor

388TH_A
05-02-2010, 02:12 PM
fixed it

Trevor

RobiD
05-02-2010, 06:21 PM
Should put the fix up Trevor. It may benefit someone else.

David

388TH_A
05-02-2010, 11:48 PM
here is the cpp and you should know where to put each of these


static int L_LOW_FUEL_MAIN;
static int L_LOW_FUEL_AUX;

---------------------------------------------------------------

MkFsbusObject(BTP_D_OUT, C_L_LOW_FUEL, "OID", EventHandler, 30, 15);

---------------------------------------------------------------


MkFsObject(FS_L_LOW_FUEL_MAIN, "OID", EventHandler, 0x0B7C, 4, TP_I32, FS_QUICK);
MkFsObject(FS_L_LOW_FUEL_AUX, "OID", EventHandler, 0x0B84, 4, TP_I32, FS_QUICK);


---------------------------------------------------------------

case FS_L_LOW_FUEL_MAIN:
L_LOW_FUEL_MAIN=val;
lowFuel();
break;

case FS_L_LOW_FUEL_AUX:
L_LOW_FUEL_AUX=val;
lowFuel();
break;



---------------------------------------------------------------

extern void lowFuelr()
{
int fuelsummeryr;

fuelsummeryr=(R_LOW_FUEL_MAIN+R_LOW_FUEL_AUX);
if (fuelsummeryr >= 1069672)
FsbusWrite (C_R_LOW_FUEL, 0);
else
FsbusWrite (C_R_LOW_FUEL, 1);

}




the h


C_L_LOW_FUEL,
FS_L_LOW_FUEL,
FS_L_LOW_FUEL_MAIN,
FS_L_LOW_FUEL_AUX

-----------------------------------

extern void lowFuel(void);

PS Stefan did help me out on this one

Trevor

RobiD
05-05-2010, 05:58 AM
Stefan,

How are you going with the testing of your stepper board?

Have you found any problems yet?

David

sgaert
05-05-2010, 06:23 AM
Hi,

since Sep. 2009 my Steppercard is in a box. I donīt need them anymore.
Some days ago i talked to Trevor about the same, if i have time i will make some tests.

Stefan

RobiD
05-05-2010, 07:31 AM
Thanks Stefan.

Can you clarify some of the components for me. The image in the pdf is not very clear.

R1 47k
R2 3k3
R3 100R
R4 220R
D1 1N4148
C1 100n
C2 100pf radiolytic
C3 100u
C4 22pf
C5 22pf
Q1 8mhz

On the optical interrupter, is it possible to wire three of these either in series or parallel? The Altimeter design requires 3 of them for 100's 1000's and 10,000's needles.

Thanks

David

388TH_A
05-05-2010, 08:22 AM
not sure if it helps but there is a wireing diagram in the pdf

Trevor

RobiD
05-05-2010, 08:27 AM
Hi Trevor,

That's what I'm talking about. The image is low res and I am having trouble seeing the p's and n's on the caps and a couple of the resistors. The more I magnify it the worse it gets, so I thought I'd put them all down just to check.

388TH_A
05-05-2010, 08:31 AM
o ok NM yeah i have done that and long behold, I was wrong on some of them so yeah it wouldn't be a bad idea to double check. And you should get on skype more.

Trevor

sgaert
05-05-2010, 12:44 PM
My Values.

C2 100uf
C3 100nf

Stefan

RobiD
05-06-2010, 07:15 AM
Thanks Stefan.

Ok, now here is a challange (or maybe not)

With my altimeter gauge, there are three needles and the design allows for 3 optical interupers in order for the gauge to return to zero statefor all three needles. The stepper board only shows one interuper.

I have a little jpg I've done up with the three interupers and the one set of 4 pins on the stepper board. Can anyone show how I can wire this so that 3 interupers will work.

I've thought that if they were wired in parallel, the signal would not be complete untill all 3 had been interrupted if you know what I mean. If my understanding is correct, parallel would be wiring all three to the 4 pins ie: all pin 1 from the interupers goes to pin 1 on the stepper board and so on.

Your help is appreciate as always.

David

sgaert
05-06-2010, 07:45 AM
Hi David,

what is your plan???
You canīt connect 3 Sensors to 1 Connector, how you know which needle is the 0 on the line?

My main Question is, how many steppers you what to use??
1 than you need a synchronous gear, if you have a synchronous gear you only need 1 Sensor on the fastest needle.
3 than you can us from every Stepperboard the sensor connector.

Stefan

RobiD
05-06-2010, 07:56 AM
I'll try to explain in detail.

I am using Mike's Flightdeck book on building simulated instruments. I've used all Mikes designs with some modification.

The altimeter is driven by one stepper. The one stepper drives the 3 needles through a series of gears. As the 100 needles goes up past 1000, the 1000 needle shows 1000, just as it would in a real gauge.

Now lets say you have a mid air crash and the gauge has to reset. I you have only 1 interupter, you can't use the hundreds needle or the 1000ths needle. You may be able to use the 10000th's needle but there would be very little movement on it if you were less then 10000 feet. So the ideal would be that the stepper rotates to the left until the zero point is reached when all 3 needles are back in the zero point.

Does that make any sense.

I can explain it perfectly in my head, just hard to get it down in print.

David

sgaert
05-06-2010, 08:19 AM
ok, with 1 connector you have only 1 signal. How you whant deside that all, 2 or 1 needle generate the signal???
In your case i dont would use the input on the Stepperboard. I would use the IO Board with 3 inputs.

RobiD
05-06-2010, 08:34 AM
Can you give me an idea of how that would look, or a link to the type of IO board you mean.

Thanks
David

sgaert
05-06-2010, 08:37 AM
the normal FSBus IO board. That all are normal switches.

388TH_A
05-06-2010, 09:38 PM
I think im Still going to let you guy battle this one out as i dont know whats going on. For me never working with the Stepper motors or PCBs i dont under stand whats going on. Buti do have one question why would you use the IO PCB with the Steppers?

Trevor

sgaert
05-07-2010, 01:36 AM
I would use the IO Board for the sensors, not for the Stepper.
For Davids idea with the 3 Sensors for 3 needels, you need 3 input. The easy is the IO Board.

@David: If you do that all with gears, than it is also possible to use only 1 Sensor on the slowest needle (10000). If your gears work well than the other needels are in the right possition when the 10000 is on 0.

RobiD
05-07-2010, 05:44 AM
I thought you meant some type of Break Out Board where there are three connectors for the three optical interrupters (OI's) and one connection out to the stepper board.

Is this possible? If it is, any idea of where to go to get the info to build one. Something that would read all three OI's and send the signal to the stepper board only when all three are closed (interrupted).

I probably could use the 10000 needle for the OI but I feel it may not produce the result of all needles being zero'd. Trial and error I guess.

Thanks for the help
David

sgaert
05-07-2010, 06:04 AM
You can do it with a break out board or what ever. But you cant deside which sensor generat the input.
The software is the problem not the hardware.

RobiD
05-07-2010, 07:12 AM
Ok, I'll try it with the single OI on the 10000 needle and see how it goes.

Then it's down to getting the code started.

Thanks for your input Stefan.

David

RobiD
05-08-2010, 02:23 AM
Here is the way that I was thinking about. This arrangement won't send a signal until all three OI's are switched.

Thanks Mike (Mikes Flightdeck), hope you don't mind me using this part of your wiring diagram.

David

sgaert
05-08-2010, 06:18 AM
Ok that will work.

But please explain me 1 think.
Why you need 3 of them.
Like you said, you whant to use 1 Stepper with gears.
The gears are static. From the first moment to the next 1000 years the gear has the same translation ratio. There are no dynamic components where it is necessary that you synconise the 3 needels. Would you use 3 Steppers than you need 3 sensor.
In case of 1 Stepper with gears you need 1 sensor on the slowest part (10000 needle).

Btw. how you calculate the translation ratio, do you have a tool an X of different gears?
I would make it with 3 steppers and the rest are software. I dislike to rebuild anything for only a small change.

Stefan

RobiD
05-08-2010, 06:42 AM
Hi Stefan,

I am using the design directly out of Mike's book. He has done all the hard work with the ratios. My understanding with 3 OI's is that it ensures that all 3 needles are zero'd in case there is any play in the gears (I know, there shouldn't be any). I intend to follow his design as every other design I've used from his book has worked perfectly, only difference is that I have chosen to drive them using FSBus and in his book, Mike has given controller schematics and his coding for PIC based controllers.

David

388TH_A
05-14-2010, 02:26 PM
Confused some, so on the Autopilot MCP the NAV, HDG, ALT, SPD and so on are they on-on push buttons or on-off, Mon on-off, or even on-Mon off ?

Trevor

RobiD
05-14-2010, 07:23 PM
Hey Trevor, been a little while since I've been able to post anything. Interesting thing happened last week. I've started building the altitude indicator so I'm using the cnc machine and generating G-code, all that stuff I havent done for a while and I had a catestrophic failure of the two hard discs in my main machine (dual boot, one disc for the sim and the other for the development work) and the hard disc on the machine that controls the cnc machine. Hmm interesting.

I use only monentary switches for MCP, Radio stack etc but use toggle for lights etc and I use some of the actual rocker switches out of a cessna for the battery, alt master, avionics etc.

http://www.futurlec.com.au/Switches/TACT001.jsp

388TH_A
05-14-2010, 10:47 PM
Yeah same here been busy with Family, so the Switch use a off and then when you push it its Mon on? So can i use this? http://search.digikey.com/scripts/DkSearch/dksus.dll?WT.z_header=search_go&lang=en&site=us&keywords=EG2041-ND&x=0&y=0 And then today i was thinking about adding a LED over each button so you know when its on.

Trevor

RobiD
05-15-2010, 12:41 AM
I have made my own Korry design which has the momentary switch inside at the bottom, I have the 'barrel' part (for want of a better name) seperated into two halve with alfoil (to keep the light seperated) and then I have two leds, green in one half, to know when the switch is turned on the amber in the other to light up the legend. I have used the DIO board digital out to light these up.

From what I can tell of the switch you want to use, it's not a latching switch so it should be straight forward. But you can use a latching switch anyway if you wanted.

David

388TH_A
05-15-2010, 01:47 AM
kinda got what your saying but im using a metal box and so i picked thoughs switches because they should fit into the box real well so im hoping. And then i was just thinking about putting one of thoughs kinda dim 5mm LEDs right above each switch.

Trevor

RobiD
05-18-2010, 06:37 AM
Ok, time to buy the atmega168's.

Either Stefan or Trevor (or anyone else who knows) is this the right version in DIP package?

http://cgi.ebay.com.au/ws/eBayISAPI.dll?ViewItem&item=260444805644&ssPageName=STRK:MEWAX:IT

Thanks as always.
David

sgaert
05-18-2010, 07:13 AM
Yes, they are right.

RobiD
05-18-2010, 07:19 AM
Great, thanks Stefan.

388TH_A
05-21-2010, 03:17 AM
David would you be willing to Post all of your code for your Autopilot

Thanks in Advance
Trevor

RobiD
05-21-2010, 06:45 AM
Absolutely.

If feel it's been a community effort. My plan alway was to share it with whoever needs it so I can pay it forward so to speak for all the help I've received.

I'm on my laptop at present and when I get to my work horse computer, I'll post it up for you.

I also intent to cut some parts for the altimeter tomorrow so I wanted to take some photos and post them up for you to see the cnc machine (my little humble one) in action.

David

388TH_A
05-21-2010, 09:17 PM
nice thanks and im working on my Autopilot and hace been taking pics as well and will post here in a couple of days or day

Trevor

RobiD
05-22-2010, 06:02 AM
David would you be willing to Post all of your code for your Autopilot

Thanks in Advance
Trevor

Hey Trevor,

Went to take a couple of photos of the cnc in action, and the battery in the camera was flat and I couldn't find the charger. No digs, but it's a wonder sometimes that we don't have to remind women to breathe.

Ok, here's the code. Let me know if there is anything else you would like. Opps, have to break it into pieces.
Here is part 1 of the .cpp

David

.cpp file

#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:
//EventHandler(S_RHEADING, 0, 0); // sound rotary
Course -= val; // val can be >1 or <-1
while (Course > 360) // wrapped forward
Course -= 360; // full circle back
while (Course <= 0) // wrapped backward
Course += 360; // full circle forward
FsWrite(FS_NAV1OBS, Course); // to FS
FsbusWrite(C_DCOURSEL, Course); // to cockpit display
FsbusWrite(C_DCOURSER, Course);
FsbusWrite(C_OBS_DISPLAY, Course);
break;

case C_RIAS:
//EventHandler(S_RHEADING, 0, 0); // sound rotary
if (MachSpeed == 0)
{
Airspeed -= val;
if (Airspeed < 100) // minimum 100 knts
Airspeed = 100;
if (Airspeed > 340) // maximum 340 knts
Airspeed = 340;
FsWrite(FS_AP_AIRSPEED, Airspeed); // to FS
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 range: 1..360
//EventHandler(S_RHEADING, 0, 0); // sound rotary
APHeading -= val; // val can be >1 or <-1
while (APHeading > 360) // wrapped forward
APHeading -= 360; // full circle back
while (APHeading <= 0) // wrapped backward
APHeading += 360; // full circle forward
x = (APHeading % 360) * 65536 / 360 + 1; // (+1 is for rounding)
FsWrite(FS_AP_HEADING, x); // to FS
FsbusWrite(C_DHEADING, APHeading); // to cockpit display
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;
//EventHandler(S_RHEADING, 0, 0); // sound rotary
/*Altitude += val * 10000 / 100;// // val can be >1 or <-1
// printf("Altitude %d\n", Altitude);
FsbusWrite(C_DALTITUDE, Altitude);
FsWrite(FS_AP_ALTITUDE, Altitude); // to Fs
break;*/
case C_RVSPEED:
//EventHandler(S_RHEADING, 0, 0); // sound rotary
Vertspeed += val * 10000 / 100; // update
if (Vertspeed < -7600)
Vertspeed = -7600; // Max decend
if (Vertspeed > 6000)
Vertspeed = 6000; // Max climb
FsbusWrite(C_DVSPEED, Vertspeed);
FsWrite(FS_AP_VS, Vertspeed); // to FS
break;

case C_SFLIGHTDIRL:
if (val == 0) //here you write if 1 active or 0
{
printf("DIRL0, val=%d\n", val);
FsbusWrite(C_LFLIGHTDIRL, 1);
FsbusWrite(C_LMASTFLIGHTL, 1);
FsWrite(FS_FLIGHTDIRECTOR,1);
}
else
{
// printf("DIRL1, val=%d\n", val);
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)
{
// printf("DIRL4, val=%d\n", val);
FsbusWrite(C_LFLIGHTDIRL, 0);
FsbusWrite(C_LMASTFLIGHTL, 0);
ValFlightDir = 2;
}
}
break;*/
/*case C_SFLIGHTDIRR:
if (val == 0) {
printf("C_SFLIGHTDIRR event, ValFlightDir=%d\n", ValFlightDir);
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);
printf("C_SAUTOTHROTTLEARM event, CockpitATarmed %d\n", CockpitATArmed);
if (CockpitATArmed == 0)
{
AirspeedHold = 0;
MachHold = 0;
}
break;
case C_SN1:
if ((val == 0) & (CockpitATArmed == 1)) // button push only
{ // AT on
//EventHandler(S_SADFSWAP, 0, 0); // sound small switch
EngN1 = (EngN1 == 0) ? 1 : 0; // toggle
if (MachSpeed == 0)
FsWrite(FS_AP_AIRSPEEDHOLD, EngN1); // to FS
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) ) // button push only
{
//EventHandler(S_SADFSWAP, 0, 0); // sound small switch
AirspeedHold = (AirspeedHold == 0) ? 1 : 0; // toggle
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:
//EventHandler(S_SADFSWAP, 0, 0); // sound small switch
if (val == 0) // button push only
{
MachSpeed = (MachSpeed == 0) ? 1 : 0; // toggle
if (MachSpeed == 1) // Mach indication
{
DisplayOptions(C_DIAS, 3, 0, TRUE, 3);
FsbusWrite(C_DIAS, Mach);
FsWrite(FS_AP_MACHHOLD, 1);
}
else // IAS indication
{
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:
//EventHandler(S_SADFSWAP, 0, 0); // sound small switch
if ((val == 0) && // button push
(abs(ActAlt - Altitude) > 200) && // delta in ft
((AirspeedHold == 1) || (EngN1 == 1)))
{
LvlChg = (LvlChg == 0) ? 1 : 0; // toggle
if (LvlChg == 1) // level change
{
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
//EventHandler(C_SSPDHLD, 0, 0); // toggle -> on
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
{
//EventHandler(S_SADFSWAP, 0, 0); // sound small switch
HeadingLock = (HeadingLock == 0) ? 1 : 0; // toggle
FsWrite(FS_AP_HEADINGLOCK, HeadingLock);
}
break;

case C_SVORLOC:
break;
case C_SAPP:
//EventHandler(S_SADFSWAP, 0, 0); // sound small switch
if (val == 0) // button push only
{
ApproachHold = (ApproachHold == 0) ? 1 : 0; // toggle
FsWrite(FS_AP_APPROACHHOLD, ApproachHold);
}
break;
case C_SALTHLD:
if (val == 0)
{
//EventHandler(S_SADFSWAP, 0, 0); // sound small switch
AltitudeLock = (AltitudeLock == 0) ? 1 : 0; // toggle
FsWrite(FS_AP_ALTITUDELOCK, AltitudeLock);
printf("C_SALTHLD AltitudeLock=%d\n", AltitudeLock);
FsbusWrite(C_LALTITUDELOCK, AltitudeLock);
}
break;

RobiD
05-22-2010, 06:04 AM
Part 2 of the .cpp


case C_SALTINTV:
//EventHandler(S_SADFSWAP, 0, 0); // sound small switch
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:
//EventHandler(S_SADFSWAP, 0, 0); // sound small switch
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
{
//EventHandler(S_SADFSWAP, 0, 0); // sound small switch

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
{
//EventHandler(S_SADFSWAP, 0, 0); // sound small switch
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
{
//EventHandler(S_SADFSWAP, 0, 0); // sound small switch
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)) // button push only
{
//EventHandler(S_SADFSWAP, 0, 0); // sound small switch
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) // button push only
{
//EventHandler(S_SADFSWAP, 0, 0); // sound small switch
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 ; // round to 0.01
// printf("FS_AP_MACH event, Mach=%d.%02d\n", Mach / 100, Mach % 100);
if (MachSpeed == 1) // display in Mach mode
FsbusWrite(C_DIAS, Mach); // new 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("C_SFLIGHTDIRL event, ValFlightDir=%d\n", ValFlightDir);
// 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;
// printf("FS_Engine1N1 %d%%\n", Engine1N1);
break;

case FS_ENGINE1N2:
Engine1N2 = val * 100 / 16384;
// printf("FS_Engine1N2 %d%%\n", Engine1N2);
break;

//default:
// printf("%cError: object %d (%d:%d) unserviced in group Glareshield (%d).\n",
// 7, oid, oid / OBJECTS_PER_GROUP, oid % OBJECTS_PER_GROUP,
// GROUP_GLARESHIELD);
// break;
}
}

RobiD
05-22-2010, 06:05 AM
Now the .h file. This code was derived from Rob's code with Stefan's input, it all works perfectly so you will probably notice that it's quite messy.


#ifndef __MODECONTROLPANEL_H__
#define __MODECONTROLPANEL_H__

void cbModecontrolpanelBuildObjects();

void cbModecontrolpanel (int oid, int val, double dval);

#define C_DCOURSEL OID_MODECONTROLPANEL_GROUP +0
#define C_DCOURSER OID_MODECONTROLPANEL_GROUP +1
#define C_DIAS OID_MODECONTROLPANEL_GROUP +2
#define C_DHEADING OID_MODECONTROLPANEL_GROUP +3
#define C_DALTITUDE OID_MODECONTROLPANEL_GROUP +4
#define C_DVSPEED OID_MODECONTROLPANEL_GROUP +5

#define C_RCOURSELR OID_MODECONTROLPANEL_GROUP +6
#define C_RIAS OID_MODECONTROLPANEL_GROUP +7
#define C_RHEADING OID_MODECONTROLPANEL_GROUP +8
#define C_RALTITUDE OID_MODECONTROLPANEL_GROUP +9
#define C_RVSPEED OID_MODECONTROLPANEL_GROUP +10

#define C_SFLIGHTDIRL OID_MODECONTROLPANEL_GROUP +11
#define C_SFLIGHTDIRR OID_MODECONTROLPANEL_GROUP +12
#define C_SAUTOTHROTTLEARM OID_MODECONTROLPANEL_GROUP +13
#define C_SN1 OID_MODECONTROLPANEL_GROUP +14
#define C_SSPDHLD OID_MODECONTROLPANEL_GROUP +15
#define C_SSPDINTV OID_MODECONTROLPANEL_GROUP +16
#define C_SCHANGEOVER OID_MODECONTROLPANEL_GROUP +17
#define C_SVNAV OID_MODECONTROLPANEL_GROUP +18
#define C_SLNAV OID_MODECONTROLPANEL_GROUP +19
#define C_SLVLCHG OID_MODECONTROLPANEL_GROUP +20
#define C_SHEADINGLOCK OID_MODECONTROLPANEL_GROUP +21
#define C_SVORLOC OID_MODECONTROLPANEL_GROUP +22
#define C_SAPP OID_MODECONTROLPANEL_GROUP +23
#define C_SALTHLD OID_MODECONTROLPANEL_GROUP +24
#define C_SALTINTV OID_MODECONTROLPANEL_GROUP +25
#define C_SVSPEEDHLD OID_MODECONTROLPANEL_GROUP +26
#define C_SCMDA OID_MODECONTROLPANEL_GROUP +27
#define C_SCMDB OID_MODECONTROLPANEL_GROUP +28
#define C_SCWSA OID_MODECONTROLPANEL_GROUP +29
#define C_SCWSB OID_MODECONTROLPANEL_GROUP +30
#define C_SAPDISENGAGE OID_MODECONTROLPANEL_GROUP +31


#define C_LFLIGHTDIRL OID_MODECONTROLPANEL_GROUP +32
#define C_LFLIGHTDIRR OID_MODECONTROLPANEL_GROUP +33
#define C_LMASTFLIGHTL OID_MODECONTROLPANEL_GROUP +34
#define C_LMASTFLIGHTR OID_MODECONTROLPANEL_GROUP +35
#define C_LATARMED OID_MODECONTROLPANEL_GROUP +36
#define C_LN1 OID_MODECONTROLPANEL_GROUP +37
#define C_LAIRSPEEDHOLD OID_MODECONTROLPANEL_GROUP +38
#define C_LMACHHOLD OID_MODECONTROLPANEL_GROUP +39
#define C_LVNAV OID_MODECONTROLPANEL_GROUP +40
#define C_LLNAV OID_MODECONTROLPANEL_GROUP +41
#define C_LLVLCHG OID_MODECONTROLPANEL_GROUP +42
#define C_LHEADINGLOCK OID_MODECONTROLPANEL_GROUP +43
#define C_LVORLOC OID_MODECONTROLPANEL_GROUP +44
#define C_LAPP OID_MODECONTROLPANEL_GROUP +45
#define C_LALTITUDELOCK OID_MODECONTROLPANEL_GROUP +46
#define C_LATTITUDEHOLD OID_MODECONTROLPANEL_GROUP +47
#define C_LVSPEEDHLD OID_MODECONTROLPANEL_GROUP +48
#define C_LCMDA OID_MODECONTROLPANEL_GROUP +49
#define C_LCMDB OID_MODECONTROLPANEL_GROUP +50
#define C_LCWSA OID_MODECONTROLPANEL_GROUP +51
#define C_LCWSB OID_MODECONTROLPANEL_GROUP +52
#define C_LAPDISENGAGEL OID_MODECONTROLPANEL_GROUP +53
#define C_LAPDISENGAGER OID_MODECONTROLPANEL_GROUP +54

#define FS_AP_MASTER OID_MODECONTROLPANEL_GROUP +55
#define FS_AP_WINGLEVELER OID_MODECONTROLPANEL_GROUP +56
#define FS_AP_NAV1LOCK OID_MODECONTROLPANEL_GROUP +57
#define FS_AP_HEADINGLOCK OID_MODECONTROLPANEL_GROUP +58
#define FS_AP_HEADING OID_MODECONTROLPANEL_GROUP +59
#define FS_AP_ALTITUDELOCK OID_MODECONTROLPANEL_GROUP +60
#define FS_AP_ALTITUDE OID_MODECONTROLPANEL_GROUP +61
#define FS_AP_ATTITUDEHOLD OID_MODECONTROLPANEL_GROUP +62
#define FS_AP_AIRSPEEDHOLD OID_MODECONTROLPANEL_GROUP +63
#define FS_AP_AIRSPEED OID_MODECONTROLPANEL_GROUP +64
#define FS_AP_MACHHOLD OID_MODECONTROLPANEL_GROUP +65
#define FS_AP_MACH OID_MODECONTROLPANEL_GROUP +66
#define FS_AP_VSHOLD OID_MODECONTROLPANEL_GROUP +67
#define FS_AP_VS OID_MODECONTROLPANEL_GROUP +68
#define FS_AP_RPMHOLD OID_MODECONTROLPANEL_GROUP +69
#define FS_AP_RPM OID_MODECONTROLPANEL_GROUP +70
#define FS_AP_GLIDESLOPEHOLD OID_MODECONTROLPANEL_GROUP +71
#define FS_AP_APPROACHHOLD OID_MODECONTROLPANEL_GROUP +72
#define FS_AP_BCHOLD OID_MODECONTROLPANEL_GROUP +73
#define FS_AUTOTHROTTLEARM OID_MODECONTROLPANEL_GROUP +74
#define FS_ALTITUDE OID_MODECONTROLPANEL_GROUP +75
#define FS_FLIGHTDIRECTOR OID_MODECONTROLPANEL_GROUP +76
#define FS_ENGINE1N2 OID_MODECONTROLPANEL_GROUP +77
#define FS_ENGINE1N1 OID_MODECONTROLPANEL_GROUP +78
//#define FS_NAV1OBS OID_MODECONTROLPANEL_GROUP +79



#endif

388TH_A
05-22-2010, 10:50 PM
Thanks ill have to try that and I have built a IO before with no problems but now with this 2nd one that i built there is a switch connected to ID 63 and in FSBUS Admin it shows that ID 63 and 47 as been pushed. And then i checked the other RIDs and there also doing the same thing. I cant seem to find any Solder touching and ecen went over it with a tester and cant find any thing. here is a Picture of what IDs are showing when you push a Button. http://ttd.g11.us/FSPics/FSBUS/IO_Connectors%20touching.JPG Do you guys any ideas. I have also tried reflashing the Controller but no change. O and the Rids that are going off at the same time are 63,47 62,46 and so on for everyone.

Trevor

388TH_A
05-22-2010, 11:05 PM
O and also the Autopilot on /off switch is that wired as a on/off or on/on? So do i need 1 or 2 RIDs for it? And same question for the FD, NAV/GPS, and the Auto Throttle switches

Trevor

RobiD
05-22-2010, 11:30 PM
Hey Trevor,

Whenever I've had wierd things like this happening, it's always been a short somewhere. I use a multimeter, and when I can't make sense of that, I use a magnifying glass and hold the board up to the light to see if there is any copper (even a tiny amount) between where tracks pass really close to each other.

I would imaging that it could only be a short somewhere. Keep looking!

David

RobiD
05-22-2010, 11:34 PM
Autopilot on/off is momentary switch. It only requires 1 rid on the IO board as there are only 2 wires coming from the switch.
FD is a toggle on/off so only 2 wires and 1 rid
NAV is also a momentary switch 1 rid.
Auto throttle arm switch is toggle still 1 rid

David

388TH_A
05-23-2010, 01:48 PM
Autopilot on/off is momentary switch. It only requires 1 rid on the IO board as there are only 2 wires coming from the switch.
FD is a toggle on/off so only 2 wires and 1 rid
NAV is also a momentary switch 1 rid.
Auto throttle arm switch is toggle still 1 rid

David

And that NAV, are you talking about the NAV/GPS switch? flip one side and its NAV and ther side for GPS. So there all 1 rid? next question is do i need to use a on/on switch for any of them and wire the 2 common polls together? if that makes since.....

Trevor

388TH_A
05-23-2010, 05:54 PM
I am getting this error when i try to build it

glareshield.cpp(6) : error C2144: syntax error : 'int' should be preceded by '}'
glareshield.cpp(6) : error C2144: syntax error : 'int' should be preceded by ';'

Here is the Code but i dont see any thing wrong! I compare it to other cpp files and there the same so not sure what this is asking of me to fix when there isnt any thing.



#include "stdafx.h"
#include "glareshield.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;


Trevor

RobiD
05-24-2010, 08:14 AM
This should be line 6

static int ActAlt = 0; // actual altitude

But I don't see anything wrong with it. The syntax is the same as my file.

Perhaps Stefan can spot it.

Oh, did you sort out the problem on the DIO board?

sgaert
05-24-2010, 08:20 AM
There is no error. Rebuild the complet Project.

388TH_A
05-24-2010, 06:10 PM
Well i took out your code David and put back the original code and i was able to build it. So now im going to compare both codes and try to make it so that it works for me and what im doing. I got this and that to work on it just need to narrow it down and make it all work. And as far as the IO PCB i wasnt able to find the problem so i just left it. Im not using enough switches for it to matter so instead of 64 ill just be able to hook up 32 but thats ok i have less then that in the Autopilot box any ways. Well here are some pics of what i have done on the Autopilot. I put this together last night. http://ttd.g11.us/fsbus/autopilot.html Also i am using F/D, A/T, AP, Nav, App, HDG, IAS, Mach, Alt, BC, Y/D, Nav2. So there for i dont need All of these right?


MkFsObject(FS_ALTITUDE, "OID", EventHandler, 0x0574, 4, TP_I32, FS_NORMAL);
MkFsObject(FS_AP_MASTER, "OID", EventHandler, 0x07BC, 4, TP_UI32, FS_NORMAL);
MkFsObject(FS_AP_WINGLEVELER, "OID", EventHandler, 0x07C0, 4, TP_UI32, FS_NONE);
MkFsObject(FS_AP_NAV1LOCK, "OID", EventHandler, 0x07C4, 4, TP_UI32, FS_NORMAL);
MkFsObject(FS_AP_HEADINGLOCK, "OID", EventHandler, 0x07C8, 4, TP_UI32, FS_NORMAL);
MkFsObject(FS_AP_HEADING, "OID", EventHandler, 0x07CC, 4, TP_UI32, FS_NORMAL);
MkFsObject(FS_AP_ALTITUDELOCK, "OID", EventHandler, 0x07D0, 4, TP_UI32, FS_NORMAL);
MkFsObject(FS_AP_ALTITUDE, "OID", EventHandler, 0x07D4, 4, TP_UI32, FS_NORMAL);
MkFsObject(FS_AP_ATTITUDEHOLD, "OID", EventHandler, 0x07D8, 4, TP_UI32, FS_NORMAL);
MkFsObject(FS_AP_AIRSPEEDHOLD, "OID", EventHandler, 0x07DC, 4, TP_UI32, FS_NORMAL);
MkFsObject(FS_AP_AIRSPEED, "OID", EventHandler, 0x07E2, 2, TP_UI16, FS_NORMAL);
MkFsObject(FS_AP_MACHHOLD, "OID", EventHandler, 0x07E4, 4, TP_UI32, FS_NORMAL);
MkFsObject(FS_AP_MACH, "OID", EventHandler, 0x07E8, 4, TP_UI32, FS_NORMAL);
MkFsObject(FS_AP_VSHOLD, "OID", EventHandler, 0x07EC, 4, TP_UI32, FS_NORMAL);
MkFsObject(FS_AP_VS, "OID", EventHandler, 0x07F2, 2, TP_I16, FS_NORMAL);
MkFsObject(FS_AP_RPMHOLD, "OID", EventHandler, 0x07F4, 4, TP_UI32, FS_NORMAL);
MkFsObject(FS_AP_RPM, "OID", EventHandler, 0x07FA, 2, TP_UI16, FS_NORMAL);
MkFsObject(FS_AP_GLIDESLOPEHOLD, "OID", EventHandler, 0x07FC, 4, TP_UI32, FS_NORMAL);
MkFsObject(FS_AP_APPROACHHOLD, "OID", EventHandler, 0x0800, 4, TP_UI32, FS_NORMAL);
MkFsObject(FS_AP_BCHOLD, "OID", EventHandler, 0x0804, 4, TP_UI32, FS_NORMAL);
MkFsObject(FS_AUTOTHROTTLEARM, "OID", EventHandler, 0x0810, 4, TP_UI32, FS_NORMAL);
MkFsObject(FS_NAV1OBS, "OID", EventHandler, 0x0C4E, 2, TP_I16, FS_NONE);
MkFsObject(FS_FLIGHTDIRECTOR, "OID", EventHandler, 0x2EE0, 4, TP_I32, FS_NORMAL);
MkFsObject(FS_ENGINE1N2, "OID", EventHandler, 0x0896, 2, TP_I16, FS_NORMAL);
MkFsObject(FS_ENGINE1N1, "OID", EventHandler, 0x0898, 2, TP_I16, FS_NORMAL);

388TH_A
05-24-2010, 07:16 PM
Like this im thinking about taking this out just seems like i dont need it all just for one switch.


case C_SCMDA:
if ((val==0) && (Disengage == 0)) // button push only
{
//EventHandler(S_SADFSWAP, 0, 0); // sound small switch

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
{
//EventHandler(S_SADFSWAP, 0, 0); // sound small switch
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
{
//EventHandler(S_SADFSWAP, 0, 0); // sound small switch
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)) // button push only
{
//EventHandler(S_SADFSWAP, 0, 0); // sound small switch
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) // button push only
{
//EventHandler(S_SADFSWAP, 0, 0); // sound small switch
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;

Also when i flip my master autopilot switch on or off i get this error and same thing with when ever i flip my flight dir switch. Dont get me wrong it works fine but also when ever i flip the switch and get that error my PC speaker makes a beep and i dont really wana hear it beep every time.
http://ttd.g11.us/FSPics/FSBUS/ERROR.JPG

RobiD
05-25-2010, 05:14 AM
Good work on the MCP.

It's a lot of work but worth it when it does what it should.

Let me know what the problem with the code was when you find it.

David

Oh, found the charger for the camera. I've cut out the decks for the altimeter (bezel, motor deck, gear deck etc), and I'm about to cut and engrave the 10000 needle so I'll try to take a couple of pics of that and post them.

388TH_A
05-25-2010, 09:48 PM
Nice well take them soon i wana see your cockpit and everything

RobiD
05-27-2010, 07:33 AM
Ok, here's some pics.

First one is of the cnc close up cutting the engraving the 10000 needle.

http://www.safeweightloss4kids.com/dontlookhere/2010_05262010May0008.jpg


Second is of the whole cnc set up. Of the two computer cases, top is the computer and the bottom houses the driver boards and break out board for the cnc which is parallel driven.

http://www.safeweightloss4kids.com/dontlookhere/2010_05262010May0009.jpg

Third is the cut out 10000 needle.

http://www.safeweightloss4kids.com/dontlookhere/2010_05262010May0010.jpg

Fourth is the 10000 needle inside the front of the gauge. I have cut all the pieces but have not painted or fitted the lighting. Also, just a black and white printout of the face of the gauge, but it gives you an idea of how the 10000 needle looks.

http://www.safeweightloss4kids.com/dontlookhere/2010_05262010May0014.jpg


I'll try to get some photos of the inside of the sim ie: mcp, glideslope indicator etc. oh, not to mention the aircore fuel level, fuel pressure, oil pressure, amps etc gauges.

David

388TH_A
05-27-2010, 11:07 PM
when i flip my master autopilot switch on or off i get this error and same thing with when ever i flip my flight dir switch. Dont get me wrong it works fine but also when ever i flip the switch and get that error my PC speaker makes a beep and i dont really wana hear it beep every time.
http://ttd.g11.us/FSPics/FSBUS/ERROR.JPG


Do you oguys have any ideas?

RobiD
05-27-2010, 11:54 PM
Stefan will know, but it seems that it's object 72 in group 2 (just an uneducated guess). I'm not clear on what is meant or referred to with the statement 'Unserviced'

RobiD
05-28-2010, 05:56 AM
More Photos of the inside of my cockpit with gauges MCP and backlighting.

First one is sitting in the pilots seat looking down. MCP front middle, ADF left, xponder right. You can see that I have modified the cockpit to fit the size for 1 person motion sim. Bottom left is the key ignition switch, above that are the avionics switches, and to the right are the aircore gauges, fuel, fuel pressure etc. Above that are all the standard Cessna gauges except the Altitude indicator which you can see that I'm still building from the pictures in the earlier post below and the RMI/ADF gauge. Flaps lever is on the right of the radio stacks (which I have still to build the display boards for COM1 & 2 and NAV2. I have the right hand side removed in this photo for extra light but when it's on, it's quite immersive. Oh, Throttle, mixture and prop controls are above and to the right of the radio stacks.

http://www.safeweightloss4kids.com/dontlookhere/2010_03142010March0321.jpg

Next is a close up of the MCP (excuse the unfinished wood look). The Korry switch legends light up when I turn on the Avionics switch and the amber part obviously turns on when I press the switch or do something that disengages the A/P.

http://www.safeweightloss4kids.com/dontlookhere/2010_03142010March0319.jpg

This one is a more distant look at the MCP and the gauges, as you can see, I'm on the glideslope but need to stop taking pictures so I can press the APP button.


http://www.safeweightloss4kids.com/dontlookhere/2010_03142010March0317.jpg


Last one: I haven't begun to work on this yet, the only bits working is the Lights switches and the dimming control for the cockpit backlighting. You can see that my cnc skills had improved when I got to cutting and engraving these panels. It also gives you an idea of the quality of the backlighting. (lots of Korries to build to finish this)


http://www.safeweightloss4kids.com/dontlookhere/2007_07100052.jpg

Will post some more when I can.

David

388TH_A
05-30-2010, 06:28 PM
That error i was getting Stefan was able to help me out and was able to fix it. the problem was that i didnt have a case for that obj

Trevor

RobiD
05-30-2010, 07:05 PM
The one thing about C++ is that when you get error messages, it always something logical you have forgotten. The difficult part is remembering what you have forgotten.

David

388TH_A
05-30-2010, 07:20 PM
Thats for sure. But this one didnt even know i had to create a case for every objbut now i know.

Trevor

388TH_A
05-31-2010, 05:10 AM
OK so i have my Autopilot almost done would either of you be willing to post just your code for the Spd and Mach button? im trying to gut out all the extra code that i dont need for it. also i noticed where there is code for engine 1 and 2 for spd and mach, do i need thoughs? Also what if it was a 4 Engine aircraft would it only work the 1st and 2nd Eng. Just wanting to talk about it and throw ideas back and forth about the SPD and MACH code and also wanted to get mine working. And also i just dont understand the whole spdmach buttons right now. Thanks

Trevor

RobiD
06-03-2010, 05:26 AM
Do you mean the Speed hold button and the Mach/IAS buttons?

I've gone through the code and picked out the bits and pieces. You will probably know that I've just copied and pasted the bits here so it won't work without being coded properly (I know you know that but it's also for the sake of others that may copy it too).

David
PS sorry for the delay in getting it posted.

static int AirspeedHold = 0; // 0 off, -1 on

MkFsbusObject(BTP_ROTARY, C_RIAS, "",cbModecontrolpanel, 28, 34);

MkFsbusObject(BTP_D_IN, C_SSPDHLD, "",cbModecontrolpanel, 28, 56);

MkFsbusObject(BTP_D_IN, C_SVSPEEDHLD, "",cbModecontrolpanel, 28, 5);
MkFsbusObject(BTP_D_IN, C_SCHANGEOVER, "",cbModecontrolpanel, 28, 58);
MkFsbusObject(BTP_D_OUT, C_LAIRSPEEDHOLD, "",cbModecontrolpanel, 28, 9);

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);


case C_RIAS:
//EventHandler(S_RHEADING, 0, 0); // sound rotary
if (MachSpeed == 0)
{
Airspeed -= val;
if (Airspeed < 100) // minimum 100 knts
Airspeed = 100;
if (Airspeed > 340) // maximum 340 knts
Airspeed = 340;
FsWrite(FS_AP_AIRSPEED, Airspeed); // to FS
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_SAUTOTHROTTLEARM:
CockpitATArmed = (val == 0) ? 1 : 0;
if (bSynchronised) // pass only when in sync
FsWrite(FS_AUTOTHROTTLEARM, (val == 0) ? 1 : 0);
FsbusWrite(C_LATARMED, CockpitATArmed);
printf("C_SAUTOTHROTTLEARM event, CockpitATarmed %d\n", CockpitATArmed);
if (CockpitATArmed == 0)
{
AirspeedHold = 0;
MachHold = 0;
}
break;
case C_SN1:
if ((val == 0) & (CockpitATArmed == 1)) // button push only
{ // AT on
//EventHandler(S_SADFSWAP, 0, 0); // sound small switch
EngN1 = (EngN1 == 0) ? 1 : 0; // toggle
if (MachSpeed == 0)
FsWrite(FS_AP_AIRSPEEDHOLD, EngN1); // to FS
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) ) // button push only
{
//EventHandler(S_SADFSWAP, 0, 0); // sound small switch
AirspeedHold = (AirspeedHold == 0) ? 1 : 0; // toggle
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_SCHANGEOVER:
//EventHandler(S_SADFSWAP, 0, 0); // sound small switch
if (val == 0) // button push only
{
MachSpeed = (MachSpeed == 0) ? 1 : 0; // toggle
if (MachSpeed == 1) // Mach indication
{
DisplayOptions(C_DIAS, 3, 0, TRUE, 3);
FsbusWrite(C_DIAS, Mach);
FsWrite(FS_AP_MACHHOLD, 1);
}
else // IAS indication
{
DisplayOptions(C_DIAS, 4, 0, FALSE, 0); // Fsbus bug (p5=0)
FsbusWrite(C_DIAS, Airspeed);
FsWrite (FS_AP_AIRSPEEDHOLD, 1);
}
}
break;

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 ; // round to 0.01
// printf("FS_AP_MACH event, Mach=%d.%02d\n", Mach / 100, Mach % 100);
if (MachSpeed == 1) // display in Mach mode
FsbusWrite(C_DIAS, Mach); // new Mach
break;

rusdex
06-04-2010, 03:13 PM
Hi!
I also made modules for fsbus dll 2009, but the stepper motor module works only from the "Admin". What is the problem? How to solve it?

Sorry for my English =)

RobiD
06-04-2010, 06:37 PM
Rusdex,

Can you show us the code your using to control the stepper board (C++ code).

Thanks
David

rusdex
06-04-2010, 06:43 PM
Rusdex,

Can you show us the code your using to control the stepper board (C++ code).
Thanks
David

1)
MkFsObject(F_VS, "", cbGauges, 0x02C8,4, TP_I32, FS_NORMAL);
MkFsbusObject (BTP_V_OUT, C_STEP1,"",cbGauges, 5, 80);
//

int ifvs = 0;
case F_VS :
ifvs = (val/19 + 400)/2;
FsbusWrite(C_STEP1, ifvs);
break;


and

2)
case F_VS :
FsbusWriteFmtVar(5, 80, (val/19 + 400)/2);
break;

rusdex
06-05-2010, 04:36 PM
Stepper works only in the format BTP_A_OUT. I think that the problem in "dll". Firmware of the stepper module does not understand the additional 2 bytes, which sends the C++ router (total lenght - 5).
For example - value "316"; CID - "11" : "dll" send AD 50 1E 02 CC, but admin send AC 50 1E 42
:sad:

Also do not work DISPLAY_BLANK, DISPLAY_BAR parameters for the display controllers
:cry:

388TH_A
06-05-2010, 08:53 PM
There are still some bugs that i need to work out but as far as the C++ i think that is done for now thanks David for your help. My C++ was and wasnt the same as your but was able to take mine out and put yours in and then add some extra in it and it works fine for me thanks again for your help.

Trevor

RobiD
06-06-2010, 01:09 AM
Hi Trevor,

You are welcome. It's all made to go around.

Do you have any thoughts on Rusdex's problem with the stepper. I haven't even began to look at the coding yet, but when I do, I'm going to need lots of input.

Even Dirk said he would take a look at the code once I've got something done.

David

388TH_A
06-06-2010, 07:19 AM
I havent messed with the Stepper at all so i dont know Sry

rusdex
06-08-2010, 06:49 AM
My Stepper work only in the AdminTool in my C code i nevver had a movement.
Stefan

I have the same problem. You solved it?

RobiD
06-10-2010, 06:41 AM
Rusdex,

How did Stefan solve the problem??

I am not far off of starting the code for my stepper board and if you've solved it, I'd love to know how.

David

RobiD
06-10-2010, 06:54 AM
Rusdex,

Just stumbled across your videos on Youtube and it does appear as though you have got the stepper card working.

Are you willing to share the code with us so we can see how it is coded.

Thanks
David

sgaert
06-10-2010, 07:29 AM
How did Stefan solve the problem??

I never solved the problem, i did test the stepper board a year ago without luck.

Maybe you write a neu Output Funktion they send with the right format.
@rusdex, do you report the results of your search to Dirk?

Stefan

RobiD
06-10-2010, 07:48 AM
I've sent Dirk an email with some questions and I have inlcuded your (Rusdex's) code for him to have a look at.

I'll let you know what the outcome is. My hope is that Dirk can put us on the right track and we can all work on it together and come up with a solution that works.

David

RobiD
06-13-2010, 12:08 AM
Rusdex,

Dirk has sent me a reply. He is on holidays at the moment but when he gets home, he has promised to look into the code to sort it out.

He did give me this bit of info that may be of help until then:
please try to send the position commands with
BOOL FsbusWriteFmtVar(int cid, int rid, int v)
> Don't use the other FsbusWrite.. commands.
The BTP_A_OUT is the right object for stepper


Hope that helps a little. Please keep us informed of how you are going with it and as soon as I hear from Dirk, I will write it up on this thread.

Regards
David

RobiD
07-20-2010, 04:03 AM
Just to keep everyone updated on the progress of the Stepper issue.

Heard from Dirk last night and he has the problem on the desk in front of him actively working on the solution.

When he has sorted it, he will email me some demo code so we can all adapt it and test it.

Thanks Dirk, greatly appreciated.

David

RobiD
07-21-2010, 05:47 PM
Dont' know what's going on in this thread, I've left a post as #432 regarding making contact again with Dirk and I keep getting notification of a post by shearder regarding his MCP code in this thread and when I click the link in my email to view the post, mine are missing and shearder's first post is #432 and now #433.

With a bit if fiddling around with logging out then in and coming to this thread another way, my post is now visible #432 and shearder's are not.

Very curious.

David

shearder
07-22-2010, 01:10 PM
I am wondering - am i having a problem with FSBUS due to FSX? Offsets seem to be the same...

sgaert
07-22-2010, 01:48 PM
i use the FSX. The most Offsets are the same.
Look to Interogate to find the difference.

shearder
07-22-2010, 02:20 PM
Hey Stefan

Yeah i installed FS9 to test and i get the same problems. I also notice N1 hold also sets Speed hold - which still kills engine. I was going to start building my structure today but i decided against it. Think i should take up knitting LOL cos i don't have tghe time i used to have for building and the programming is going to kill me...

sgaert
07-22-2010, 02:31 PM
HAHA the Speed Hold kills the engin, i know that from a freeware Fokker 50. I think that is an error in a gauge file of the Aircraft. I never fixed that.

RobiD
07-22-2010, 06:18 PM
Shearder,

Looks like we are all posting in the same thread now.

I changed to FSX without any problems so I agree with Stefan.
I did have an engine killing problem when I was setting up my MCP, whenever I pressed the Autothrottle speed set button.

I will have to go through this thread to find the problem as Stefan helped me with that one too.

David

RobiD
08-29-2010, 05:41 PM
Update on the stepper board and code.

Dirk emailed my some test code and if needed, a replacement fsbus.dll file to use and test with.

I will spend the next couple of weeks building the board and testing the code sample without the new dll file (as Dirk requested) then if that fails, with the new dll

Let me know if anyone else is interested in doing some of this testing.

David

sgaert
08-30-2010, 01:29 AM
Hello David,

can you mail me the new DLL?
Than i can also do some testīs with my stepper board.

Stefan

RobiD
08-30-2010, 03:54 AM
Dirk has suggested testing the code before using the replacement .dll file.
I'll PM you the .dll file.

Here is the email in it's entirity from Dirk:

Hi David,

I recently finished my stepper example. Please test the following simple program, replace COM5 and CID 23 by your values.
It will set the stepper to position 0, then to 100 (steps) and after a delay of 2s back to zero.

I've tested this successfully without change. If it doesn't work, please try the attached dll.

Your question concerning the switches:
The resistors are well dimensioned vor pics and atmels.
The circuit works, if the zero position obscures the light from led to transistor.




int _tmain(int argc, _TCHAR* argv[])
{
CheckIn();
BOOL b = FsbusOpen("COM5");
FsbusWriteFmtVar(23, 80, 0);
FsbusMux(2000);
FsbusWriteFmtVar(23, 80, 100);
FsbusMux(2000);
FsbusWriteFmtVar(23, 80, 0);
FsbusMux(2000);
CheckOut();
return 0;
}


regards Dirk

RobiD
08-30-2010, 05:25 AM
Stefan,

Let me know if you didn't get the PM. It did something strange when I pressed send so I'm not sure if it went or not.

David

sgaert
08-30-2010, 05:31 AM
Hi David,

the PM is there, thank you.
I will check that file and code tonight.

Stefan

sgaert
08-30-2010, 11:11 AM
The "old" Version donīt work, "new" Version workīs.

The new one is Version 1.2.0, strange.

Stefan

RobiD
09-02-2010, 06:34 AM
How did you go Jan?

Did you get it to work for you?

David

shearder
09-04-2010, 08:11 AM
I would love to test the new DLL.

ALSO: I sometimes need to reprogram the IO board because it loses the fact that i have rotaries (12way modified) and then i get on off. I have to go into the admin program and set the switches again as a rotary!! Anyone had that issue? It is tiresome - having to constantly set switches as rotaries. I do not know why and I am doing nothing wierd - just switchin power on and oiff anmd starting the interface program. I haven't progressed at all with this because I just can't get my altitude to work it only works if i adjust it IN FSX with the mouse ALSO all rotaries are setting the digits backwards etc. I just can't see myself building any further panels and wasting more money. I have 5 cards build and the COm board and at the moment they are gathering dust. Just no enthusiasm anymore after battling for more than a year.

Probably cheaper in the long run to go OC - and less head aches.

RobiD
09-04-2010, 08:21 AM
Hi shearder,

I had a similar problem with my DIO board some time ago. It kept resetting the CID to 27 and losing all the preference for rotaries etc. Stefan helped with the suggestion regarding the board being reset due to the Brown out settings in the fuse bits. He offered me a solution that has not been fully varified as yet but I tried it and have not had another problem since.

With the altitude indicator, look back in this thread and my altitude indicator code is there. Dig through it and see if you can use some of mine to fix the problems.

I am having no problems with any of my gauges, switches, rotaries, displays, aircore gauges, etc etc etc. I have had an enormous amount of help from a lot of people to get to this point, but the greatest input and assistance has been from Stefan (thanks again Stefan).

Are you working on a stepper board at present, as the .dll is being tested only for the stepper.


Stefan or Jan, have you tried the test .dll on all of the other boards. Does everything else still function?

David

shearder
09-04-2010, 08:28 AM
Thanks dude. No, no stepper boards as yet. Planned and i have 2 small stepper motors to test with but, as i said, i can't even get the Altitude to change pfff... I will look through the thread. Thanks.

RobiD
09-04-2010, 08:31 AM
Also, see if Stefan will PM you the solution regarding the fuse bits. It's not for general publication just incase everyone fries their ATMEGA chips (yes, it is a possibility but it hasn't happened to me).

David

sgaert
09-06-2010, 01:00 PM
everything else still function?[/QUOTE]
I checked that in the last houre, the DLL is the very old 1.2 version and is not working with the V2 code.
@David did you report our results to Dirk?

@shearder because of your erasing problem. Look to the ATMEL 8535 Manual on page 39 the part about BOD.
There you see what that do and how you can enable that, i use 4V configuration.
manual (http://robopoly.epfl.ch/webdav/site/robopoly/users/166872/public/Datasheet/aTmega8535.pdf)

Stefan

RobiD
09-22-2010, 05:29 AM
Just a stepper update.

Stefan, I have given Dirk an update on findings todate, but have not heard back from him yet. I will contact him again shortly to see where he is at with modifying the v2 dll.

The stepper board that I redesigned to take the ATMEGA168-20PU DIP package works fine. Have built the board, set up the zero point indicator and all is working. Just have to test the code Dirk gave me then wait until we have an answer. Altimeter and Radio ADF completed now.

David

sgaert
09-22-2010, 05:31 AM
Good News, David.

thank you

RobiD
09-25-2010, 08:24 AM
Just finished my ADF/RMI gauge so I thought I'd attach some pics and show off a little.

Hope you all like. Note the DIP designed FSBus stepper boards on the back of the gauge.

David


4302 43014300 4303

sgaert
09-25-2010, 08:27 AM
WOW, good Job.

RobiD
09-25-2010, 08:39 AM
Thanks Stefan, I'll attach some pics of my altitude indicator when I'm finished. Just have to redesign the Optical interupters so the zero point works properly, but otherwise, it's finished too.

David

RobiD
09-26-2010, 07:49 PM
Hi Stefan,

I am trying to test Dirk's code and I'm a bit stuck.

Can you walk me through step by step how to set up this code.

Do I start a new project?

Do I just use existing project, start a new .ccp file for this code.

Appreciate your help.

David

sgaert
09-27-2010, 01:38 AM
Hi David,

you have to generate a new project.
The Code from Dirk you write to the main *.cpp file.
Next is the include the fsbus.h file and that is all.

Iīll send you a link to my Sample file, you need to adjust the Com Port and CID of the Stepperboard.

Stefan

RobiD
09-27-2010, 03:40 AM
Great, thanks Stefan.

RobiD
09-27-2010, 06:17 AM
Stefan,

Loaded the project into Visual C++ express and ran it. Worked fine except I didn't change the Com3 to Com1 so I made the change and then ran it again, this time I got a whole host of errors.

Does it mean anything to you? Sorry about the long post. Thought the more info, the easier to debug.


1>Compiling...
1>Stepper.cpp
1>c:\program files\microsoft visual studio 9.0\vc\include\codeanalysis\sourceannotations.h(47) : error C2011: 'vc_attributes::YesNoMaybe' : 'enum' type redefinition
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\codeanalysis\sourceannotations.h(47) : see declaration of 'vc_attributes::YesNoMaybe'
1>c:\program files\microsoft visual studio 9.0\vc\include\codeanalysis\sourceannotations.h(57) : error C2011: 'vc_attributes::AccessType' : 'enum' type redefinition
1>Build log was saved at "file://c:\Documents and Settings\All Users\Documents\stepper\Stepper\Debug\BuildLog.htm"
1>Stepper - 25 error(s), 0 warning(s)

sgaert
09-27-2010, 06:25 AM
Do you make a rebuild of the project? (Ctrl+Alt+F7)

RobiD
09-27-2010, 06:26 AM
Yes, I pressed the green arrow to recompile.

Oh, I'll try the Cntl+Alt+F7

RobiD
09-27-2010, 06:28 AM
Yes, that did the trick.

shearder
09-30-2010, 01:48 AM
everything else still function?
@shearder because of your erasing problem. Look to the ATMEL 8535 Manual on page 39 the part about BOD.
There you see what that do and how you can enable that, i use 4V configuration.
manual (http://robopoly.epfl.ch/webdav/site/robopoly/users/166872/public/Datasheet/aTmega8535.pdf)

Stefan[/QUOTE]

Hey Stefan

Due to work i haven't touched my sim in almost 3 weeks. I did some tests with Davids stuff and with a bit of SLIGHT mods i have my MCP working the way it should. My next question is around the BOD for the 8535. Can this be set using Pony? Or do i need something else?

Thanks again!

Sean

sgaert
09-30-2010, 02:07 AM
You can set BOD with the Fuse in Pony.

shearder
09-30-2010, 02:11 AM
Hey Stefan

Sorry, another question: when the 8535 is set to 4v will normal on and off of the power affect it? I assume not?

Thanks again.

sgaert
09-30-2010, 02:34 AM
Everything is normal.
It only makes a reset when the Vcc is lower then 4V.
Without that it is possible that he erease the EEPROM.

RobiD
10-11-2010, 03:25 AM
Images of my newly completed Altitude indicator gauge.

Hi guys, as promised, here are a couple of images of my stepper driven altitude indicator.

Pretty happy with how it's come out.

Just have to get the code together to get it working with FSX..

http://www.safeweightloss4kids.com/dontlookhere/Picture 005.jpg
Front view

http://www.safeweightloss4kids.com/dontlookhere/Picture 006.jpg
Side view

http://www.safeweightloss4kids.com/dontlookhere/Picture 007.jpg
Close up of the three optical interupters needed for zeroing gauges on startup


http://www.safeweightloss4kids.com/dontlookhere/Picture 008.jpg
Needles gaining altitude

sgaert
10-11-2010, 05:33 AM
Good Job.
Can you make a movie with the working gauge, inside and outside?

RobiD
10-11-2010, 07:20 AM
Never done that before, but I guess I could give it a go.

I'd love to get the code working though. I tested the code Dirk gave me with the current .dll file and it did what it was supposed to.

Dirk says that according to this test, it indicates that it should work as is in FSBus.

Have no idea where to begin with the code though. I've asked Dirk if he has a sample code for the stepper and I'm just waiting to hear back.

I'll try and get some video this weekend. It will just be through either FSBus admin or through the test code that Dirk sent.

David

sgaert
10-11-2010, 07:24 AM
ok, no problem.
On FSweekend i will talk to Dirk.
At the moment i have follows themes/topics.
- Stepper bug in the V2 DLL
- Display bug in the DLL (blank, bar,... option)

Do you or anybody have additional topics?

Stefan

RobiD
10-11-2010, 07:39 AM
Not sure what you mean by themes?

sgaert
10-11-2010, 07:42 AM
Topics, problems i donīt have on my list.

RobiD
10-11-2010, 08:00 AM
Oh right.

My only concern to date has been the issue everyone else has had with the stepper, but that would appear to be ok now (although would love some sample code on how to use it)

Shearder has told me that with the MCP code I gave him (lots of help from you and Rob) aircraft locks on to Glideslope to line up with runway, but does not follow GS down. This is probably more to do with the coding rather than a problem with the .dll

So far, everything I've wanted to interface has worked (excluding stepper to this point). I cannot think of anything that I personally think should be added or changed.

Thank you for asking for my input.

sgaert
10-11-2010, 08:04 AM
Ok, we have some weeks, maybe we have some ideas for improvements or any other.

iwik
10-12-2010, 04:27 PM
Hi David,
Nice job, been thinking about making this myself, where did you source your gears from?.
Thanks
Les

RobiD
10-13-2010, 07:29 AM
Hi Les,

http://www.servolink.com/ in the US.

They have a minimum order of $30 USD plus postage of around $15, so I order extra bits and pieces to make it up.

Fast postage.

I followed the ratio recommendations in Mikes Flightdeck 'Building Simulated Aircraft Instrumentation' http://www.mikesflightdeck.com/ (very worthwhile purchase)

Cheers
David

iwik
10-13-2010, 01:40 PM
Thanks David,
I was just checking in case you found a local source. Was going to buy from them, yes i have Mikes book and have already built the Turn Coordinator.

Regards
Les

RobiD
10-14-2010, 04:15 AM
The Turn Coordinator was my first build too.

Mike's book makes it so much easier.

I build my own little cnc machine, used all of Mike's dimensions in Coreldraw, made the toolpaths then cut out all of the parts. Then assembled and modified as needed.

Chose to interface with FSBus as I have travelled a long journey with FSBus, so I stayed loyal.

It is great when you make all the parts then assemble, and it all works as it should. Very rewarding.

David

iwik
10-14-2010, 04:27 AM
Looks like we are doing something similar. I too built a small cnc machine and cut my bits with it. I started out with Fsbus but gave up because i could not get Dirk to fix some very basic things. I didnt want to use multiple i/fs. I now use o/c, much better supported.
How did you drill a hole in the centre of rod which attaches the pointer and connects to the shaft of the stepper.
Les

RobiD
10-14-2010, 05:00 AM
In Mike's book, he outlines (well actually he details) the use of various diameter brass hobby tubing. So they are all hollow.

Hence it is soooo easy to have three pointers running from the centre (as in the altitiude indicator)

iwik
10-14-2010, 01:20 PM
Sorry David,
I was thinking of the Compass, where you stick a rod in the center of the Faceplate and this has to be drilled.
Les

RobiD
10-14-2010, 06:20 PM
Oh, got ya.

Umm, although this was my first gauge build, it will probably be my last to finish as the Stepper part of FSBus is only looking like it's sorted now. My compass rose is loose in the gauge.

What I may do is re-cut the compass rose with the cnc machine and make the centre hole at the same time. At least I know it will be centered.

RobiD
10-15-2010, 07:19 AM
Stefan,

Have some questions, hoping you can help.

I am having a go at getting the altitude indicator programed.

I have a 200 step stepper motor 360 deg = 1,000 ft. on the gauge
720 deg = 2000 ft etc.

I am using the offset 0x3324 Altitude feet.
In FSInterogate 0=0 (on the ground), and at 10000 feet = 10000 in FSInterogate

I have made the objects and declared them.
MkFsbusObject (BTP_A_OUT, S_ALTIMETERFEET,"Altimeter Feet", cbGauges, 8,80);

MkFsObject(FS_ALTIMETERFEET,"Altimeter Feet", cbGauges, 0x3324, 4, TP_I32, FS_NORMAL);


The way I'm looking at it is that Dirk is suggestion using the FsbusWriteFmtVar(30, 80, 0); to write the position to the stepper
0 in the (30,80,0) being the position of the stepper (number of steps), if it was 200 it should have done a 360 deg movement.

So can I make the 0 a variable, and give the value of the offset to this variable, but also do it in a way so that each 1000 on the variable = 200 steps

Look forward to your thoughts.
Thanks
David

sgaert
10-15-2010, 07:34 AM
ok short idea.

case FS_ALTIMETERFEET:
val= val/5; // 1000feet for 360° are 200 steps (1000/200)
FsbusWriteFmtVar(8, 80, val);
break;

how you connect the 3 Sensors to the Stepper card? in a row?

Stefan

RobiD
10-15-2010, 07:56 AM
Thanks Stefan,

I put the 3 interupters in a row one on the 100 feet, one on the 1000 ft and one on the 10000 ft gears
This way, when it needs to zero, it won't stop going to the left until all 3 needles are on zero.

case FS_ALTIMETERFEET:
val= val/5; // 1000feet for 360° are 200 steps (1000/200)
FsbusWriteFmtVar(8, 80, val);
break;

So how do I get the offset value to be val?

David

sgaert
10-15-2010, 08:00 AM
I put the 3 interupters in a row one on the 100 feet, one on the 1000 ft and one on the 10000 ft gears
This way, when it needs to zero, it won't stop going to the left until all 3 needles are on zero.

that is the perfect solution.


case FS_ALTIMETERFEET:
val= val/5; // 1000feet for 360° are 200 steps (1000/200)
FsbusWriteFmtVar(8, 80, val);
break;

So how do I get the offset value to be val?
The value of an object (oid) is all the time val.

RobiD
10-15-2010, 08:15 AM
Oh, ok. So in this instance, val will be the value of FS_ALTIMETERFEET

When ever you have the case then object, val will be the value of the object.

RobiD
10-15-2010, 09:07 AM
I'm not getting any action in the Altitude indicator.

What syntax do I use to view the value of val, ie: printf(........);

Any other suggestions to try?

Also, Shouldn't I be writing to S_ALTIMETERFEET
MkFsbusObject (BTP_A_OUT, S_ALTIMETERFEET,"Altimeter Feet", cbGauges, 8,80);

sgaert
10-15-2010, 09:32 AM
Also, Shouldn't I be writing to S_ALTIMETERFEET
MkFsbusObject (BTP_A_OUT, S_ALTIMETERFEET,"Altimeter Feet", cbGauges, 8,80);
that object you can delete.

Sample for a printf
printf("input %d trimL %d trimR %d\n", val, trimL, trimR);
%d is the space where the variable is shown.
in my sample 3 %d for the 3 variable.
\n is new line.

RobiD
10-15-2010, 09:41 AM
Would that object be having any effect on 'no movement' on the gauge.

Should I also see the green led on the Stepper board lighting up quite a bit. It is not receiving any data at all (not lighting up, other than when FSBus starts)

sgaert
10-15-2010, 09:44 AM
Would that object be having any effect on 'no movement' on the gauge.
no, it only needīs some ms. That is a time that nobody see.

You use the V1.2 DLL? Do the board work with the sample Project?

RobiD
10-15-2010, 09:54 AM
Yes, the board worked with Dirks code that you sent me.

I will test it again tomorrow to make sure nothing has changed.

Can you give me the exact syntax for print function, should it be printf(val %d);

sgaert
10-15-2010, 11:02 AM
should it be printf(val %d);
no
print("here you can write what you like %d\n",val);

http://www.cplusplus.com/reference/clibrary/cstdio/printf/

The code i mailed is for Version 1.2 that donīt work with V2.
So you have to make a new projekt for the Steppers with a own Com Board.
Or you go completly back to V1.2.
Or you wait till the steppers are fixed in V2. Hopefully that happend in the future.

RobiD
10-15-2010, 05:23 PM
Stefan,

I used your code, but the .dll in the windows folder was the current one. I did not replace it with the old version.

I let Dirk know this and his reply was:

Hi David,

you are right, the DLL in the internet is the one and only. The reaseon I sent you another DLL was, to be sure you have exactly the one, which I had tested with.

best regards

Dirk

So from what I can figure out, your code worked with the latest version .dll from the website.

Feeling a little confused.

I will do some more testing today with your code.

sgaert
10-16-2010, 02:06 AM
With my hardware the V2 DLL (from the website) donīt work.
The DLL you mailed work for the stepper, but that is V1.2.
In the projekt the is the V1.2 Dll includet.

On Fsweekend i will go with all my Stepper stuff to Dirk. Then we will see.

RobiD
10-16-2010, 02:26 AM
With my hardware the V2 DLL (from the website) donīt work.
The DLL you mailed work for the stepper, but that is V1.2.
In the projekt the is the V1.2 Dll includet.

On Fsweekend i will go with all my Stepper stuff to Dirk. Then we will see.

Hi Stefan.

I used the project you sent me but used the .dll from the latest version. I placed the fsbus.dll file in C:windows/system32 folder

I have not used the version that Dirk sent me. I am trying to get a couple of minutes away from my little 3 year old to test again, but not having much luck. Maybe tonight when she goes to bed.

FSWeekend is only a couple of weeks away isn't it?

David

sgaert
10-16-2010, 02:43 AM
Interessting, if you start the Sample Prject than it shows V2 in the first line of the Dos box?

RobiD
10-16-2010, 04:25 AM
Now I'm more confused.

Just tested again.

Did as it should, but at the top of the DOS box said 1.2.0
I don't have this version (I mean I have it, but it is not in the windows directory where it is supposed to be, only V2 is in the directory.

So where is it getting Version 1.2.0 from?

RobiD
10-16-2010, 06:39 AM
Stefan,

Rebuilt the sample code from scratch in order to make sure it used version 2.0.0 and it didn't work. Then tested your code again which uses 1.2.0 and it worked.

Hmmmm. I have sent Dirk an email to explain this as I had told him that it was working.

David

PS this would also explain why the code for the Altitude indicator didn't work. It was using version 2.0.0

sgaert
10-16-2010, 10:04 AM
that sounds good, at morning i think iīm stupid.

The exe file looks as first to his own source folder than to Windows/system32 and in the source folder i put the V1.2 DLL.
As you know i only publish all in one packs.

Now we both have the same error situation. (That what we have, i told Dirk last year at FSweekend.)
This year i will show Dirk that all. I have a second Com Boad with USB Powersupply, Stepper, Stepper Board.