Quantcast
Channel: Motion Control and Motor Drives topics
Viewing all articles
Browse latest Browse all 1315

modify .h file

$
0
0

Hi everybody,

 

I have a problem with a .h file to control my motor from cnc-planet.

 

I don't know how to modify it.

 

For example i have the following function not recognised by Labview:

 

extern "C" CNC_ERROR CALLCONV Connect();

 

I tried with: int Connect(); int32 Connect(); int CNC_ERROR Connect() and int32 CNC_ERROR Connect() without any results.

 

Maybe it comes from declaration variable...

It is written as follow:

 

enum CNC_ERROR : int
{
    CNC_SUCCESS                =    0x00000000,
    CNC_ERROR_FAIL                =    0x00000001,
    CNC_ERROR_NOT_IMPLEMENTED        =    0x00000002,
    CNC_ERROR_NOT_INITIALIZED        =    0x00000003,
    CNC_ERROR_DEVICE_NOT_FOUND        =    0x00000004,
    CNC_ERROR_DEVICE_NOT_READY        =    0x00000005,
    CNC_ERROR_DEVICE_NOT_CONNECTED        =    0x00000006,
    CNC_ERROR_SEND_FAILED            =    0x00000007,
    CNC_ERROR_LICENSE            =    0x00000008,
    CNC_ERROR_RAWDATA            =    0x00000009,
    CNC_ERROR_DEVICE_PARAMS            =    0x0000000A,
};

 

I don't know how to change in a way that Labview undrestand...

 

Any help?

 

Thank you very much.

 

PS: The integral .h file

 

#pragma once

#ifndef __AFXWIN_H__
    #error include 'stdafx.h' before including this file for PCH
#endif

enum CNC_ERROR : int
{
    CNC_SUCCESS                =    0x00000000,
    CNC_ERROR_FAIL                =    0x00000001,
    CNC_ERROR_NOT_IMPLEMENTED        =    0x00000002,
    CNC_ERROR_NOT_INITIALIZED        =    0x00000003,
    CNC_ERROR_DEVICE_NOT_FOUND        =    0x00000004,
    CNC_ERROR_DEVICE_NOT_READY        =    0x00000005,
    CNC_ERROR_DEVICE_NOT_CONNECTED        =    0x00000006,
    CNC_ERROR_SEND_FAILED            =    0x00000007,
    CNC_ERROR_LICENSE            =    0x00000008,
    CNC_ERROR_RAWDATA            =    0x00000009,
    CNC_ERROR_DEVICE_PARAMS            =    0x0000000A,
};

enum CNC_STATUS : int
{
    CNC_STATUS_NONE            =    0x00010000,
    CNC_STATUS_CONNECTED    =    0x00010001,
    CNC_STATUS_DISCONNECTED    =    0x00010002,
    CNC_STATUS_UNPLUGED        =    0x00010003,
    CNC_STATUS_DATAERROR    =    0x00010004,
};

enum CNC_CODE : unsigned char
{
    CNC_CODE_Unknown    =    0,
    CNC_CODE_OK            =    1,
    CNC_CODE_Pos        =    2,
    CNC_CODE_Stop        =    3,
    CNC_CODE_Error        =    8,
};

enum CNC_PLANE : unsigned char
{
    CNC_PLANE_Unknown        =    0,
    CNC_PLANE_XY            =    1,
    CNC_PLANE_YZ            =    2,
    CNC_PLANE_ZX            =    3,
    CNC_PLANE_UV            =    4,
    CNC_PLANE_VW            =    5,
    CNC_PLANE_UW            =    6,
};

enum CNC_SPINDLE : unsigned char
{
    CNC_SPINDLE_Unknown        =    0,
    CNC_SPINDLE_Stopped        =    1,
    CNC_SPINDLE_CW            =    2,
    CNC_SPINDLE_CCW            =    3,
};

enum CNC_COOLANT : unsigned char
{
    CNC_COOLANT_Unknown        =    0,
    CNC_COOLANT_Off            =    1,
    CNC_COOLANT_On            =    2,
};

enum CNC_VERSION : unsigned char
{
    CNC_VERSION_Unknown        =    0,
    CNC_VERSION_MK1            =    1,
    CNC_VERSION_MK2            =    2,
};

#define CALLCONV __stdcall

//Callback for changes in UBS state
typedef void (__stdcall TStatusCallback) (CNC_STATUS status);

//Callback for changes in controller state
typedef void (__stdcall TDataCallback)(
        CNC_CODE code,                            //status code
        unsigned char bufferFree,                //amount of free buffer - do not start new command if this is lower than 4
        int numExecuting,                        //number of executing command
        unsigned char keysLimit, unsigned char keysJog,            //state of limit and jog keys
        int posA, int posB, int posC, int posD, //position of four axes in steps
        unsigned char output);                    //state of controller output (flood, mist, spindle)


extern "C" CNC_ERROR CALLCONV About(BSTR* result);
//HID
extern "C" CNC_ERROR CALLCONV HidInitialize();
extern "C" CNC_ERROR CALLCONV HidFinalize();
extern "C" BOOL CALLCONV CheckHidInitialized();
extern "C" CNC_ERROR CALLCONV GetHidDeviceList(BSTR* deviceList);
extern "C" CNC_ERROR CALLCONV GetHidDeviceInfo(int vid, int pid, BSTR* vendorName, BSTR* productName, BSTR* serialNumber);
extern "C" CNC_ERROR CALLCONV GetHidDeviceInfoByName(BSTR device, BSTR* vendorName, BSTR* productName, BSTR* serialNumber);

//Controller
extern "C" CNC_ERROR CALLCONV Connect();
extern "C" CNC_ERROR CALLCONV Disconnect();
extern "C" BOOL CALLCONV IsConnected();
extern "C" CNC_ERROR CALLCONV GetDeviceInfoEx(BSTR* vendorName, BSTR* productName,
                                                           BOOL* diy, int* serialNumber,
                                                           unsigned char* ver_year,    unsigned char* ver_month, unsigned char* ver_day);
extern "C" CNC_ERROR CALLCONV GetDeviceInfo(BSTR* vendorName, BSTR* productName, BOOL* diy);
extern "C" CNC_ERROR CALLCONV RegisterStatusCallback(TStatusCallback *statusCallback);
extern "C" CNC_ERROR CALLCONV RegisterDataCallback(TDataCallback *dataCallback);


extern "C" CNC_ERROR CALLCONV GetState(
          CNC_CODE *code,
          char *bufferFree,
          int *numExecuting,
          char *keysLimit, char *keysJog,
          int *posA, int *posB, int *posC, int *posD,
          char *output);
extern "C" CNC_ERROR CALLCONV SetDeviceParams(
        int axis1StepsPerMM, int axis2StepsPerMM, int axis3StepsPerMM, int axis4StepsPerMM,
        unsigned char axisLimitSwitch,
        double axis1Backlash, double axis2Backlash, double axis3Backlash, double axis4Backlash,
        double axis1Accel, double axis2Accel, double axis3Accel, double axis4Accel,
        double axis1InitSpeed, double axis2InitSpeed, double axis3InitSpeed, double axis4InitSpeed);

extern "C" CNC_ERROR CALLCONV CmdInfo(int* num);
extern "C" CNC_ERROR CALLCONV CmdWrite(int* num);
extern "C" CNC_ERROR CALLCONV CmdMoveAxes(int* num, double posA, double posB, double posC, double posD, double speed, BOOL startAccel, BOOL endAccel);
extern "C" CNC_ERROR CALLCONV CmdMoveAxesDelta(int* num, double posDeltaA, double posDeltaB, double posDeltaC, double posDeltaD, double speed, BOOL startAccel, BOOL endAccel);
extern "C" CNC_ERROR CALLCONV CmdPos(int* num, double posA, double posB, double posC, double posD);
extern "C" CNC_ERROR CALLCONV CmdDwell(int* num, double seconds);
extern "C" CNC_ERROR CALLCONV CmdEStop(int* num);
extern "C" CNC_ERROR CALLCONV CmdStop(int* num);
extern "C" CNC_ERROR CALLCONV CmdPause(int* num);
extern "C" CNC_ERROR CALLCONV CmdPauseNow(int* num);
extern "C" CNC_ERROR CALLCONV CmdResume(int* num);
extern "C" CNC_ERROR CALLCONV CmdResumeNow(int* num);
extern "C" CNC_ERROR CALLCONV CmdOut(int* num, unsigned char output);
extern "C" CNC_ERROR CALLCONV CmdOutNow(int* num, unsigned char output);
extern "C" CNC_ERROR CALLCONV CmdSpindle(int* num, CNC_SPINDLE direction, double speed);
extern "C" CNC_ERROR CALLCONV CmdSpindleNow(int* num, CNC_SPINDLE direction, double speed);
extern "C" CNC_ERROR CALLCONV CmdCoolant(int* num, CNC_COOLANT flood, CNC_COOLANT mist);
extern "C" CNC_ERROR CALLCONV CmdCoolantNow(int* num, CNC_COOLANT flood, CNC_COOLANT mist);
extern "C" CNC_ERROR CALLCONV CmdNothing(int* num);

 


Viewing all articles
Browse latest Browse all 1315

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>