Re: Progamming help with FSBus dll
Did you write a small programm to test your steppers wih the stepper board?
Here my programm:
Code:
#include "stdafx.h"
#include "fsbus.h"
int _tmain(int argc, _TCHAR* argv[])
{
CheckIn();
BOOL b = FsbusOpen("COM3");
FsbusWriteFmtVar(29, 80, 0);
FsbusMux(2000);
FsbusWriteFmtVar(29, 80, 2000);
FsbusMux(2000);
FsbusWriteFmtVar(29, 80, 0);
FsbusMux(2000);
CheckOut();
return 0;
}
Re: Progamming help with FSBus dll
I tested the stepper boards when Dirk sent through some sample code some time ago (He used v1 of the dll to test it though, I think you pointed that out).
So, I know the boards work.
This was what I used (pretty well just minor changes to your code)
Code:
#include "stdafx.h"
int _tmain(int argc, _TCHAR* argv[])
{
CheckIn();
BOOL b = FsbusOpen("COM1");
FsbusWriteFmtVar(29, 80, 0);
FsbusMux(2000);
FsbusWriteFmtVar(29, 80, 100);
FsbusMux(2000);
FsbusWriteFmtVar(29, 80, 0);
FsbusMux(2000);
CheckOut();
return 0;
}
So, how am I doing with the code I've written so far for the ADF.
I am getting 1 compiling error though: steppergauges.cpp(22) : error C2447: '{' : missing function header (old-style formal list?)
This is the code exactly to this minute that is producing the error:
Code:
#include "stdafx.h"
#include "fsbus.h"
void cbSteppergauges(int oid, int val, double dval);
#define FS_ADF1RELATIVEBEARING 1
#define FS_ADF1DIALBEARING 2
//#define C_ADFCOMPASSCARD 3
//#define C_ADFBEARINGNEEDLE 4
#define C_RADFROSEADJUST 5
static int ADFroseadjust = 0;
void cbSteppergaugesBuildObjects()
{
MkFsObject(FS_ADF1RELATIVEBEARING,"ADF Needle", cbSteppergauges, 0x0C6A, 2, TP_I16, FS_NORMAL,0);
MkFsObject(FS_ADF1DIALBEARING,"ADF Compass Card", cbSteppergauges, 0x0C6C, 2, TP_I16, FS_NORMAL,0);
//MkFsbusObject(BTP_V_OUT, C_ADFCOMPASSCARD,"",NULL,30,80,0);
//MkFsbusObject(BTP_V_OUT, C_ADFBEARINGNEEDLE,"",NULL,29,80,0);
MkFsbusObject(BTP_ROTARY, C_RADFROSEADJUST, "",cbModecontrolpanel, 27, 26, 0);
}
void cbSteppergauges(int oid, int val, double dval);
{
int x;
switch(oid)
{
case FS_ADF1RELATIVEBEARING:
FsbusWriteFmtVar(29,80,val);
break;
case FS_ADF1DIALBEARING:
FsbusWriteFmtVar(30,80,val);
break;
case C_RADFROSEADJUST:
ADFroseadjust -= val;
while (ADFroseadjust > 360)
ADFroseadjust -= 360;
while (ADFroseadjust <=0)
ADFroseadjust += 360;
x = (ADFroseadjust % 360);
FsWriteInt(FS_ADF1DIALBEARING,x);
break;
}
}
Once I get it to compile, should I just test it with the gauge and see what happens?
David
Re: Progamming help with FSBus dll
try that test with the V3 dll. that works in my sample.
Edit: donīt!!!
void cbSteppergauges(int oid, int val, double dval);
has to be
void cbSteppergauges(int oid, int val, double dval)
Re: Progamming help with FSBus dll
Great, compiles now.
So looking back at some code you worked with me on for my Altitude gauge, I can see how 'val' is worked out.
Code:
case FS_ALTIMETERFEET:
val=val/5; // 1000feet for 360° are 200 steps (1000/200)
//printf("Altimeter Feet %d\n", val);
FsbusWriteFmtVar(8, 80,val);
break;
So for the 'val' in the ADF code, I need to work out the number of steps to 360 deg, and divide the value by that as in the sample above. Am I correct?
Thanks
Re: Progamming help with FSBus dll
sounds perfect. if you have a gear dont forget it.
A 200step neadle on a 360° scale donīt perfect.
Re: Progamming help with FSBus dll
I do have gears so I will work it out.
I am trying to print the value of the ADF needle and the ADF rose face, and I don't seem to be getting anything.
Here's what I have (I have the same for the altitude and it prints it fine):
case FS_ADF1RELATIVEBEARING:
val=val/1; // 360° are ? steps
printf("ADF relative bearing %d\n", val);
FsbusWriteFmtVar(29,80,val);
break;
Re: Progamming help with FSBus dll
Quote:
I am trying to print the value of the ADF needle and the ADF rose face, and I don't seem to be getting anything.
if i understand that right, you whant to have a output like:
Input value: 12345 Needle Position: 67890
right??
Re: Progamming help with FSBus dll
Well, it's not really important to have as I can get these figures from FSInterrogate. I was just wondering why it isn't printing any value at all when I move the needle or the dial face.
Also, the ADF Dial heading works on a simple 0 - 360, but the Needle works on -179.9 to 0 to 179.9 0 being at the top, -179 being to the left and +179 to the right. Will I need to write the needle differently?
Re: Progamming help with FSBus dll
Yes, but i woudl try somethink like
case that with the -179 to 179:
val = val + 179;
than you have your 0 in the -179 positon.
but!!
if (val >=0)
{
val = ( val+1);
}
Re: Progamming help with FSBus dll
Ah ha, then I can use the 360degress divided by how many steps the motor has in 360deg. I would never have thought of that.
Thank you.
So now I have:
case FS_ADF1RELATIVEBEARING:
val = val + 179;
if (val >=0)
{
val = (val+1);
}
printf("ADF relative bearing %d\n", val);
FsbusWriteFmtVar(29,80,val);
break;
Any idea why it's still not showing anything is the DOS box for the print function?