Re: Progamming help with FSBus dll
Quote:
Originally Posted by
sgaert
In the devision you have a resoult with ,xxx that is not possible with int.
Let is as flot, it is ok.
Right! But only in case that the differenz is always the same.
Stefan
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.
Re: Progamming help with FSBus dll
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?
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.
What do the needle if you fly more than one 360, is there a strange moving?
Re: Progamming help with FSBus dll
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.
Re: Progamming help with FSBus dll
Quote:
If the needle in the software moves 360 degrees, the needle on the gauges will go around 3 or 4 times.
I would try a direct way for testing with the Stepp and angle problem.
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;
Re: Progamming help with FSBus dll
I'll give it a try now and let you know.
Re: Progamming help with FSBus dll
Sorry i Edit my Post befor you.
Re: Progamming help with FSBus dll
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.
Re: Progamming help with FSBus dll
With that?
FsbusWriteFmtVar(29,80,val/(Stepp/360));
or my Edit?
Re: Progamming help with FSBus dll
Quote:
Originally Posted by
sgaert
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?
Re: Progamming help with FSBus dll
Donīt use the 360 degrees anymore that is wrong, look to my edit ther is a new code.