Hello,
I´ve got a problem with my written program for a stepper Motor, which i want to control with the K8097.
The program is written in c++ with Microsoft Visual Studio 2010.
Thats the code:
[code]#include
#include <windows.h>
#include
#include <stdlib.h>
using namespace std;
HINSTANCE MyDll;
int main(int argc, char** argv[]) {
MyDll= LoadLibrary(L"mtrapi32.dll");
typedef bool (WINAPI *Connect_t) (char *cPort, unsigned long ulMotorCnt);
typedef void (WINAPI *Disconnect_t)(void);
typedef int (WINAPI *GetMoving_t)(unsigned long ulMotorIndx);
typedef bool (WINAPI *Connected_t) ();
typedef void (WINAPI *Move_t)(unsigned long ulMotorIdx, unsigned long ulSteps, unsigned long ulDirection, unsigned long Speed);
typedef int (WINAPI *GetMotorCount_t) ();
int connect;
int motorCount;
Connect_t Connect = (Connect_t)GetProcAddress(MyDll, “SMCConnect”);
GetMoving_t GetMoving = (GetMoving_t)GetProcAddress(MyDll, “SMCGetMoving”);
Connected_t Connected = (Connected_t)GetProcAddress(MyDll, “SMCConnected”);
Move_t Move = (Move_t)GetProcAddress(MyDll, “SMCMove”);
Disconnect_t Disconnect = (Disconnect_t)GetProcAddress(MyDll, “SMCDisconnect”);
GetMotorCount_t GetMotorCount = (GetMotorCount_t)GetProcAddress(MyDll, “SMCGetMotorCount”);
connect = Connect(“COM4”, 4);
motorCount = GetMotorCount();
if (connect)
{
cout << “Connected with Board” << endl;
}
else
{
cout << “Not connected with Board” << endl;
}
if (Connected())
{
Move(0, 200, 1,8000); // 8000 Maximale Geschwindigkeit
}
printf("%i\n",motorCount);
Disconnect();
FreeLibrary(MyDll);
return 0;
}
[/code]
One Problem is, that the value to check how many stepper motors are connected, is always 4?
My other problem is that when i try to use the GetMoving function i alway get a True.
So i hope that you can help me.
With best regards M. Vornholt