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?
Printable View
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?
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.
Code: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;
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.
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;
Code:/*----------------------- 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;
}
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
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
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
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
(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
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
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.
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
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
Hi Stefan,
So it is necessary to install VStudio on my Sim hard drive?
David
Where you whant to run the exe from the Project, it looks like that you need the Studio.
Thanks Stefan.
Works now.
David
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
do you drive the Servos with a extra powersupply or use the 5V from the Bus?
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.
Ok, an ATX powersupply has enough power for both.
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
i donīt know what i use, they are the cheapest i can buy.
They dont have a company or product lable.
Sorry
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
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
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
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
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
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;
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.
Thanks as usual.Code: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;
David
Worked it out finally.
For anyone else who wants to know how to do this, here is the code:
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;
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
Here is the File i have 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....
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
Sorry im Still Stuck on the Radio Stack
Hi David,
i also never get the Stepper working.
But i seen it on Dirks Setup a year ago. Strange.
Stefan
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
was it hard to solder that LITTLE chip onto the PCB