Page 1 of 74 123451151 ... LastLast
Results 1 to 10 of 737
  1. #1
    300+ Forum Addict RobiD's Avatar
    Join Date
    Sep 2007
    Location
    Gold Coast, Australia
    Posts
    430
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Progamming help with FSBus dll

    Hi everyone,

    Can anyone give me an example of the coding for a servo (RPM gauge) in FSBus dll.

    If I can find an example, I should be able to replecate for the rest of my gauges.

    Need coding for: examplerpm.h, examplerpm.cpp, the entry in main cockpit.cpp and stdafx.h file.

    Any help would be appreciated.

    Thanks
    David

  2. #2
    300+ Forum Addict
    Join Date
    Feb 2008
    Location
    Krefeld, Germany
    Posts
    318
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Hi David,

    i make a untested sample for you, how to make your own Software please look to the Documentation page 22-24.
    I dont know what RPM you mean. In the sample i use APU_RPM (0B54)

    examplerpm.h
    Code:
    #ifndef __EXAMPLERPM_H
    #define __EXAMPLERPM_H
    
    #define OID_EXAMPLERPM_GROUP		(10 << OID_CONTROL_BITS)
    // any OID_xxx_GROUP should have a unique number, left shifted by OID_CONTROL_BITS 
    
    // declaration of all (max 32) objects of this group
    #define C_RPMSERVO		OID_EXAMPLERPM_GROUP + 0
    #define FS_APURPM		OID_EXAMPLERPM_GROUP + 1
    
    
    // declare the functions in the corresponding .cpp file
    void BuildEXAMPLERPMObjects();
    void cbEXAMPLERPM (int oid, int val, double dval);
    
    #endif
    examplerpm.cpp
    Code:
    #include "stdafx.h"
    
    void BuildEXAMPLERPMObjects()
    {
    	MkFsbusObject (BTP_A_OUT,C_RPMSERVO, 16, 80); //Servo ports are 80-87
    	MakeFsObject(FS_APURPM, 0x0B54, 4, TP_UI32,  FS_NORMAL);  //the TP_UI32 is maybe wrong it must be a FLT32
    }
    
    void cbEXAMPLERPM (int oid, int val, double dval)
    {
    
    	switch (oid)
    	{
    	case FS_APURPM:
             int x = val * 2,55;   //Servo need 0-255 as value, fo an other RPM you need a new caluculation
    	   FsbusWrite (C_RPMSERVO, x);
    	break;
    	}
    }
    additional to the given stdafx.h
    Code:
    examplerpm.h
    additional to the given parts of the cockpit.cpp
    in funktion _tmain
    Code:
     BuildEXAMPLERPMObjects();
    in funktion EventCallback
    Code:
    case OID_EXAMPLERPM_GROUP:
                 cbEXAMPLERPM (oid, val, dval);
    	break;
    I hope that helps a little bit.

    Regards,
    Stefan

  3. #3
    300+ Forum Addict RobiD's Avatar
    Join Date
    Sep 2007
    Location
    Gold Coast, Australia
    Posts
    430
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Hi Stefan,

    Fantastic, I really appreciate the time you have taken in this reply.

    The RPM I am referring to is the tachometer in a General Aviation plane, say a cessna or the such.

    I am using the servo board for this and it has a cid 25, RID 8

    I tried a couple of times to code this and was getting an 'object out of range' error message with '(80 - 87)' as you have indicated in the code.

    I will give your code a try and see if I can get it to work.

    Once again, I really appreciate your help.

    Regards
    David

  4. #4
    150+ Forum Groupie
    Join Date
    Jan 2007
    Location
    Netherlands
    Posts
    201
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Hi David,

    Have you tried CID 25 RID 80.
    RID 80 is the first connector and 87 the last connector of the Servo board.

    Best regards

    Jan Geurtsen

  5. #5
    300+ Forum Addict RobiD's Avatar
    Join Date
    Sep 2007
    Location
    Gold Coast, Australia
    Posts
    430
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Wow, I didn't get that in the servo board documentation.

    Thank you.

    David

  6. #6
    300+ Forum Addict
    Join Date
    Feb 2008
    Location
    Krefeld, Germany
    Posts
    318
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    hi,
    that is right. You can find it in the dll Docu part MakeFsbusObjekt.

    Regards,
    Stefan

  7. #7
    300+ Forum Addict RobiD's Avatar
    Join Date
    Sep 2007
    Location
    Gold Coast, Australia
    Posts
    430
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Of course you are right. I found it after having another good look. I don't know where I was looking before.

    I will put all the code together and see how I go. Hopefully it will compile without complaint and work beautifully.

    Thanks for the help everyone, I'll post how I go.

    David

  8. #8
    300+ Forum Addict RobiD's Avatar
    Join Date
    Sep 2007
    Location
    Gold Coast, Australia
    Posts
    430
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Ok, I have spent some time trialling and testing.

    I have it down to one error on compiling and that error is:

    davids flight sim\enginerpm.cpp(16) : error C2059: syntax error : 'constant'

    When I hold Shift + F4 the specific line is :

    int x = val * 2,55; //Servo need 0-255 as value, fo an other RPM you need a new caluculation


    I'll post the code so far.

    You will notice that I don't have this:

    in funktion EventCallback

    Code:


    case OID_EXAMPLERPM_GROUP: cbEXAMPLERPM (oid, val, dval); break;


    In the EventCallback function area as putting in the EventCallback was producing many more errors as it wasn't declared.

    So here are the files:

    cockpit.cpp


    #include
    "stdafx.h"
    #include
    #include

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

    // TODO: add functions to create the fsbus software objects
    cbLLSwitchboardBuildObjects();
    cbEngineBuildObjects();
    cbMagnetoBuildObjects();
    cbEnginerpmBuildObjects();

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

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

    CheckOut();
    return 0;
    }


    stdafx.h

    #pragma
    once
    #include
    "targetver.h"
    #include
    #include


    // TODO: reference additional headers your program requires here
    #include
    #include"fsbus.h"
    #define OID_LLSWITCHBOARD_GROUP (1 << OID_CONTROL_BITS)
    #include"switchboard.h"
    #define OID_MAGNETO_GROUP (10 << OID_CONTROL_BITS)
    #include"magneto.h"
    #define OID_ENGINE_GROUP (2 << OID_CONTROL_BITS)
    #include"engine.h"
    #define OID_ENGINERPM_GROUP (11 << OID_CONTROL_BITS)
    #include"enginerpm.h"


    enginerpm.h

    #ifndef
    __ENGINERPM_H
    #define __ENGINERPM_H
    // any OID_xxx_GROUP should have a unique number, left shifted by OID_CONTROL_BITS
    // declaration of all (max 32) objects of this group
    // declare the functions in the corresponding .cpp file
    void cbEnginerpmBuildObjects();
    void cbEnginerpm (int oid, int val, double dval);
    enum e_Enginerpm
    {
    C_RPMSERVO = OID_ENGINERPM_GROUP,
    };
    void BuildFsuipcObjects(void);
    enum _fsobjectid
    {
    FS_ENGINE1RPM,
    };
    #endif


    enginerpm.cpp


    #include
    "stdafx.h"
    staticint x;
    void cbEnginerpmBuildObjects()
    {
    MkFsbusObject (BTP_A_OUT,C_RPMSERVO,"RpmGauge",cbEnginerpm, 25, 87); //Servo ports are 80-87
    MkFsObject(FS_ENGINE1RPM,"RpmGauge", cbEnginerpm, 0x08C8, 2, TP_UI16, FS_NORMAL); //the TP_UI32 is maybe wrong it must be a FLT32
    }
    void cbEnginerpm (int oid, int val, double dval)
    {
    switch (oid)
    {
    case FS_ENGINE1RPM:
    int x = val * 2,55; //Servo need 0-255 as value, fo an other RPM you need a new caluculation
    FsbusWrite (C_RPMSERVO, x);
    break;
    }
    }


    Any help would be appreciated as I am not getting anywhere very fast.

    Thanks again,
    David


  9. #9
    25+ Posting Member xlonglife's Avatar
    Join Date
    Mar 2007
    Location
    UK
    Posts
    28
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    You have a comma in a numeric (ie 2,55)

    Shouldnt that be 2.55 or even 255?

  10. #10
    300+ Forum Addict
    Join Date
    Feb 2008
    Location
    Krefeld, Germany
    Posts
    318
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Right, 2.55 or *100/255.

    The engine need an other calculation for the rigt values. Please look to the FSUIPC SDK there you see what you need.

    regards,
    Stefan

Page 1 of 74 123451151 ... LastLast

Similar Threads

  1. Fsbus CDK
    By flyandre in forum General Builder Questions All Aircraft Types
    Replies: 4
    Last Post: 12-27-2014, 12:58 PM
  2. Need Help Getting My FSBUS NG I/O Going Again..
    By JBRoberts in forum I/O Interfacing Hardware and Software
    Replies: 14
    Last Post: 03-21-2010, 01:38 PM
  3. Fsbus ng io
    By Davral in forum I/O Interfacing Hardware and Software
    Replies: 0
    Last Post: 01-10-2009, 10:38 PM
  4. Fsbus 2.4.3
    By Anderson/SBSP in forum I/O Interfacing Hardware and Software
    Replies: 9
    Last Post: 11-30-2008, 04:25 PM
  5. Help FSBUS
    By cesarfsim in forum I/O Interfacing Hardware and Software
    Replies: 2
    Last Post: 10-26-2008, 02:23 PM

Tags for this Thread