that is the point i canīt help. Nomaly i start the debuger than you se what happends.
I is only math, you need to find the right calculation.
Stefan
Printable View
that is the point i canīt help. Nomaly i start the debuger than you se what happends.
I is only math, you need to find the right calculation.
Stefan
Thanks Stefan. I'll battle on. I have one more question.
Using your little motor testing code, it takes 2355 to make the rose go around 360deg. Does this mean that there is 2355 steps in 360degs? If so, it changes the code I'm working on drastically.
Here's my code to turn the rose 360 just so you're clear on what I mean.
FsbusWriteFmtVar(30,80,0);
FsbusMux(2000);
FsbusWriteFmtVar(30,80,2355);
FsbusMux(8000);
FsbusWriteFmtVar(30,80,0);
FsbusMux(8000);
Thatīs right
Stefan,
I am getting this error now:
Run-Time Check Failure #2 - Stack around the variable 'buf' was corrupted.
From reading, and if I understand correctly, is this a problem with the dll, or my code.
It seems to be around the ADF needle code. When I tune the ADF, it is ok for a while, then produces this error.
Any idea what it's telling me?
Thanks
David
do you named a variable 'buf' ?
No. I have no variable "buf".
Doing a little research, this type of error seems to indicate that something is being written to the wrong address, or something is not being cleared from that address before more data is being written to the same address.
I'm probably completely off track with my understanding.
David
Ok Thanks.
On Feb. 19 i have a meeting with Dirk and Rob is will that error message to my todo list.
Please count the errors and try to find the situation to generate the error.
Stefan
Will do. I'll try to give you as much info as possible.
So it's around this piece of code
Code:case FS_ADF1RELATIVEBEARING:
printf("Data in: %d\n",val);
ADF1RelNeedleMulti = (1000 * ADF1RelNeedleDeg) / ADF1RelNeedleStep;
ADF1RelDataIn = val + 32780;
if (ADF1RelDataIn >=0)
{
ADF1RelDataIn = (ADF1RelDataIn+1);
}
ADF1RelDataDif = ADF1RelDataIn - ADF1RelDataSave;
ADF1RelNeedleDif = ADF1RelNeedleMulti / ADF1RelDataDif;
ADF1RelNeedlegoto = ADF1RelNeedleSave + ADF1RelNeedleDif;
FsbusWriteFmtVar(29,80,ADF1RelNeedlegoto/1000);
printf("Relative Bearing %d\n",ADF1RelNeedlegoto/1000);
ADF1RelNeedleSave = ADF1RelNeedlegoto;
ADF1RelDataSave = ADF1RelDataIn;
//printf("ADF1RelNeedleMulti: %d\n",ADF1RelNeedleMulti);
//printf("ADF1RelNeedleDeg: %d\n",ADF1RelNeedleDeg);
//printf("ADF1RelNeedleStep: %d\n",ADF1RelNeedleStep);
//printf("ADF1RelDataIn: %d\n",ADF1RelDataIn);
//printf("ADF1RelDataDif: %d\n",ADF1RelDataDif);
//printf("ADF1RelNeedledif: %d\n",ADF1RelNeedlegoto);
break;
This bit in particular:
FsbusWriteFmtVar(29,80,ADF1RelNeedlegoto/1000);
printf("Relative Bearing %d\n",ADF1RelNeedlegoto/1000);
With the /1000, the printf data stays at 0 to 4.
If I delete the /1000 I now get some useful figures, but it triggers the error. The error is produced even if I try /10, /100
Hope that give some useful info.
Let me know what the follow up is of the meeting.
Thanks
David
Which is the easiest to do?
Nomaly Solution two with Teamviewer and Skype.
But if you have time iīm at work, we can try it on a weekend.
Teamviewer i can all the time but no Skype Voice.
I have just installed Teamviewer, and I can set up Skype.
Give me a time and day that would suit you.
David
As you like but not tomorow.
Could we look at Thursday evening around 8.30pm (GMT+10.00 Brisbane Australia)?
This would be about Thursday 11.30am your time. Would you prefer to leave it until the weekend?
ok, lets try that.
I'll PM you my log in code for Teamview on Thursday.
Stefan,
Change in plans. (Not my choice). Can we make it sometime over the weekend?
Thanks
David
Ok no problem!
Stefan,
Can we lock in 8.30pm Brisbane time on Tuesday night? (That would be about 11.30am Tuesday your time).
Thanks
David
ok, i will be there.
David,
if you finished the code please post them.
The version here has the 2 bugs.
Stefan
Hi Stefan,
Thank you again for your time.
I'll post the code as it stands now.
I checked the number of steps in 360 deg and now have 1150. I have adjusted the code accordingly. The needle is still moving much further than the needle in FSX, so I may need to divide the final output to get the right number of steps.
Also, how does this gauges sync with FSX?
Code:static int ADF1RelDataIn;
static int ADF1RelDataSave;
static int ADF1RelDataDif;
static int ADF1RelNeedlegoto;
static int ADF1RelNeedleSave;
static int ADF1RelNeedleDif;
float ADF1RelNeedleMulti;
//static int ADF1RelNeedleMulti;
static int ADF1RelNeedleDeg = 360;
//static int ADF1RelNeedleStep = 2355;
static int ADF1RelNeedleStep = 1150;
case FS_ADF1RELATIVEBEARING:
printf("Data in: %d\n",val);
ADF1RelNeedleMulti = ADF1RelNeedleStep/ADF1RelNeedleDeg;
//ADF1RelNeedleMulti = ADF1RelNeedleDeg / ADF1RelNeedleStep;
//ADF1RelNeedleMulti = ADF1RelNeedleDeg) / ADF1RelNeedleStep;
ADF1RelDataIn = val + 32780;
if (ADF1RelDataIn >=0)
{
ADF1RelDataIn = (ADF1RelDataIn+1);
}
ADF1RelDataDif = ADF1RelDataIn - ADF1RelDataSave;
ADF1RelNeedleDif = ADF1RelDataDif / ADF1RelNeedleMulti;
ADF1RelNeedlegoto = ADF1RelNeedleSave + ADF1RelNeedleDif;
FsbusWriteFmtVar(29,80,ADF1RelNeedlegoto);
printf("Relative Bearing: %d NeedleDif: %d NeedleSave: %d\n",ADF1RelNeedlegoto, ADF1RelNeedleDif, ADF1RelNeedleSave);
ADF1RelNeedleSave = ADF1RelNeedlegoto;
ADF1RelDataSave = ADF1RelDataIn;
//printf("ADF1RelNeedleMulti: %d\n",ADF1RelNeedleMulti);
//printf("ADF1RelNeedleDeg: %d\n",ADF1RelNeedleDeg);
//printf("ADF1RelNeedleStep: %d\n",ADF1RelNeedleStep);
//printf("ADF1RelDataIn: %d\n",ADF1RelDataIn);
//printf("ADF1RelDataDif: %d\n",ADF1RelDataDif);
//printf("ADF1RelNeedledif: %d\n",ADF1RelNeedlegoto);
break;
Not devide only subtract. Is the differenc always the same?Quote:
The needle is still moving much further than the needle in FSX, so I may need to divide the final output to get the right number of steps.
You can also change float ADF1RelNeedleMulti; to static int ADF1RelNeedleMulti;.
I am getting an error message on compiling.
I'm not in front of my FSX computer, but it is something about converting int to double (or the other way around) and some data may be lost.
The difference does seem to be consistent.
What changes will occur changing the float bact to a static int?
Thanks
I would be substracting from the FsbusWriteFmtVar(29,80,ADF1RelNeedlegoto); line.
So could I write something like this just as an example:
FsbusWriteFmtVar(29,80,(ADF1RelNeedlegoto - 100));
In the devision you have a resoult with ,xxx that is not possible with int.Quote:
I am getting an error message on compiling.
I'm not in front of my FSX computer, but it is something about converting int to double (or the other way around) and some data may be lost.
The difference does seem to be consistent.
What changes will occur changing the float bact to a static int?
Thanks
Let is as flot, it is ok.
Right! But only in case that the differenz is always the same.Quote:
So could I write something like this just as an example:
FsbusWriteFmtVar(29,80,(ADF1RelNeedlegoto - 100));
Stefan
Ok i have a problem - the same that has always plagued me. I had modified 12way rotary switches for "encoders" and they worked well. BUT - what i found was that from time to time i would turn them and then suddenly they "lost" their settings and just increased the value either way it was turned so i had to go into FSBUS and digital IN settings and reset it to be a 4 tep or whatever.
I got a prompt from Stefan to change the BO bits which i did to 4v. Then i also bought some proper encoders which work GREAT! and they are smooth and are absolutely fantastic. BUT - here is the problem again!!
I will be using my MCP and it works like a charm but then at some stage i will start to change the CRS once i know which runway i will be using and i start turning the encoder then what happens - while i turn it it seems the digits "stick" and then eventually stop changing and then i have to go into FSBUS again Digital IN and set it again to an encoder!!
This happens almost all the time. SO i thought my problem was sorted and spent more money (not a problem as it is better) but my problem remains and i have to keep resetting the rotaries so they act properly.
I don't want to even think about having to constantly reset my switches etc so they work each time i want to fly.
I have even re flashed the 8535 and set the bits etc a couple of times and doesn't seem to fix this. I am lost!
Sean
Can you try a new 8535?
Hi Stefan,
I have left it as float but is producing the warning. (I will check which line the error is coming from)
Well the difference won't always be the same, for example when the difference is low numbers, it moves in very small increments as it should, but when the difference starts to get higher, say 70 plus, it moves more and more distance. If I minus, when I have small differences, the needle would probably move the wrong way.
So I think I need to change the scale, so that the go to numbers are smaller, but 0 = 0 and not a minus figure. Does that make sense.
So if I used division say divide by 2, it should halve the output, and 0 should still be 0.
FsbusWriteFmtVar(29,80,ADF1RelNeedlegoto / 2);
Would that work?
Thanks
David
Sean, I agree with Stefan, change the 8535 and see. I had a dud one that caused me grief too.
No, because you only make the half of steps but the software think it is in the right position. You donīt have a continius readback of the needle Position.Quote:
So if I used division say divide by 2, it should halve the output, and 0 should still be 0.
FsbusWriteFmtVar(29,80,ADF1RelNeedlegoto / 2);
Would that work?
What do the needle if you fly more than one 360, is there a strange moving?
If the needle in the software moves 360 degrees, the needle on the gauges will go around 3 or 4 times.
It does consistently move in the correct direction through.
I would try a direct way for testing with the Stepp and angle problem.Quote:
If the needle in the software moves 360 degrees, the needle on the gauges will go around 3 or 4 times.
FsbusWriteFmtVar(29,80,val/(Stepp/360)); //for Stepp your nummber of stepps for a 360 turn.
Maybe it shows to the opposite direction but it is importent to know the right Stepp/degree ratio.
Stefan
EDIT:
STOP, we both do a big fault. We all the time use the 360 as a Data but that is not true.
We have to use the max input value that is signed +32768 or unsigned 65536.
my try of the code:
Code:static int ADF1RelDataIn;
static int ADF1RelDataSave;
static int ADF1RelDataDif;
static int ADF1RelNeedlegoto;
static int ADF1RelNeedleSave;
static int ADF1RelNeedleDif;
float ADF1RelNeedleMulti;
//static int ADF1RelNeedleMulti;
static int ADF1RelNeedleDeg = 65536;
//static int ADF1RelNeedleDeg = 360;
//static int ADF1RelNeedleStep = 2355;
static int ADF1RelNeedleStep = 1150;
case FS_ADF1RELATIVEBEARING:
printf("Data in: %d\n",val);
ADF1RelNeedleMulti = ADF1RelNeedleDeg/ADF1RelNeedleStep;
ADF1RelDataIn = val + 32780;
if (ADF1RelDataIn >=0)
{
ADF1RelDataIn = (ADF1RelDataIn+1);
}
ADF1RelDataDif = ADF1RelDataIn - ADF1RelDataSave;
ADF1RelNeedleDif = ADF1RelDataDif / ADF1RelNeedleMulti;
ADF1RelNeedlegoto = ADF1RelNeedleSave + ADF1RelNeedleDif;
FsbusWriteFmtVar(29,80,ADF1RelNeedlegoto);
printf("Relative Bearing: %d NeedleDif: %d NeedleSave: %d\n",ADF1RelNeedlegoto, ADF1RelNeedleDif, ADF1RelNeedleSave);
ADF1RelNeedleSave = ADF1RelNeedlegoto;
ADF1RelDataSave = ADF1RelDataIn;
//printf("ADF1RelNeedleMulti: %d\n",ADF1RelNeedleMulti);
//printf("ADF1RelNeedleDeg: %d\n",ADF1RelNeedleDeg);
//printf("ADF1RelNeedleStep: %d\n",ADF1RelNeedleStep);
//printf("ADF1RelDataIn: %d\n",ADF1RelDataIn);
//printf("ADF1RelDataDif: %d\n",ADF1RelDataDif);
//printf("ADF1RelNeedledif: %d\n",ADF1RelNeedlegoto);
break;
I'll give it a try now and let you know.
Sorry i Edit my Post befor you.
Getting this error message again: Run-Time Check Failure #2 - Stack around the variable 'buf' was corrupted.
I have commented out all other lines but the write line just to make sure something else was not causing it.
I've got the stepp up to 20000 and it is moving more accurately. I know I definately don't have 20,000 steps per 360 degrees
Oh, it seems the 'buf' error happens when the val is passing through 0 at the 360 position.
With that?
FsbusWriteFmtVar(29,80,val/(Stepp/360));
or my Edit?
With this. I have the Stepp at 20,000 and the needle is moving in the right direction, and also fairly accurately with the screen gauge. The buf error message occurs when the value is passing through 0 at the top of the gauge (goes straight to error message once the needle moves to the left side as they are all negative numbers) and passing the maximum at the bottom (which is then moving into the maximum negative number)
Does that make sense?
Donīt use the 360 degrees anymore that is wrong, look to my edit ther is a new code.