Results 1 to 10 of 737
Thread: Progamming help with FSBus dll
-
05-30-2009, 07:39 PM #1
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
-
05-31-2009, 04:44 AM #2
- Join Date
- Feb 2008
- Location
- Krefeld, Germany
- Posts
- 318
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
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; } }
Code:examplerpm.h
in funktion _tmain
Code:BuildEXAMPLERPMObjects();
Code:case OID_EXAMPLERPM_GROUP: cbEXAMPLERPM (oid, val, dval); break;
Regards,
Stefan
-
05-31-2009, 08:19 AM #3
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
-
05-31-2009, 10:21 AM #4
- Join Date
- Jan 2007
- Location
- Netherlands
- Posts
- 201
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
-
05-31-2009, 06:24 PM #5
Wow, I didn't get that in the servo board documentation.
Thank you.
David
-
06-01-2009, 02:37 AM #6
- Join Date
- Feb 2008
- Location
- Krefeld, Germany
- Posts
- 318
hi,
that is right. You can find it in the dll Docu part MakeFsbusObjekt.
Regards,
Stefan
-
06-01-2009, 04:18 AM #7
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
-
06-02-2009, 08:47 AM #8
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
#pragmaonce
#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
-
06-02-2009, 09:10 AM #9
You have a comma in a numeric (ie 2,55)
Shouldnt that be 2.55 or even 255?
-
06-02-2009, 09:17 AM #10
- Join Date
- Feb 2008
- Location
- Krefeld, Germany
- Posts
- 318
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
Similar Threads
-
Fsbus CDK
By flyandre in forum General Builder Questions All Aircraft TypesReplies: 4Last Post: 12-27-2014, 12:58 PM -
Need Help Getting My FSBUS NG I/O Going Again..
By JBRoberts in forum I/O Interfacing Hardware and SoftwareReplies: 14Last Post: 03-21-2010, 01:38 PM -
Fsbus ng io
By Davral in forum I/O Interfacing Hardware and SoftwareReplies: 0Last Post: 01-10-2009, 10:38 PM -
Fsbus 2.4.3
By Anderson/SBSP in forum I/O Interfacing Hardware and SoftwareReplies: 9Last Post: 11-30-2008, 04:25 PM -
Help FSBUS
By cesarfsim in forum I/O Interfacing Hardware and SoftwareReplies: 2Last Post: 10-26-2008, 02:23 PM
Search Prettys Womans from your city for night
5.Sharing an Essay about PIC16F877