Aerotech系列(0)运动控制篇

#include <stdio.h>
#include <tchar.h>

// Main include file
#include "A3200.h"

#include <QDebug>

// See the pre-build event to see the System Library dlls being copied to the output directory

#define NUM_LINES 10
#define LINE_SIZE 128

// This function will print whatever the latest error was
void PrintError();

int main(int argc, char **argv)
{
//1.generic example
//    A3200Handle handle;
//    A3200Connect(&handle);
//    A3200AcknowledgeAll(handle, TASKID_01);
//    A3200Disconnect(handle);
//    DOUBLE result;
//    if(A3200Connect(&handle)) {

//        A3200MotionDisable(handle, TASKID_01, (AXISMASK)(AXISMASK_00 | AXISMASK_01));

//        // Gets axis status and gets its first bit
//        A3200CommandExecute(handle, TASKID_Library, "AxisStatus(X, DATAITEM_AxisStatus) & 0x1", &result);
//        qDebug() << "Axis X status is: " << result;

//        A3200CommandExecute(handle, TASKID_Library, "AxisStatus(Y, DATAITEM_AxisStatus) & 0x1", &result);
//        qDebug() << "Axis Y status is: " << result;

//        A3200Disconnect(handle);

//    }

//2.Motion Examples
//2.1 enable
//    A3200Handle handle;
//    A3200Connect(&handle);
//    A3200MotionEnable(handle, TASKID_01, (AXISMASK)(AXISMASK_00 | AXISMASK_01));
//    A3200Disconnect(handle);

 //2.2 disaable
//    A3200Handle handle;
//    A3200Connect(&handle);
//    A3200MotionDisable(handle, TASKID_01, (AXISMASK)(AXISMASK_00 | AXISMASK_01));
//    A3200Disconnect(handle);

//2.3 faultAck
//    A3200Handle handle;
//    A3200Connect(&handle);
//    bool bhas_fault = A3200MotionFaultAck(handle, TASKID_01, (AXISMASK)(AXISMASK_00 | AXISMASK_01));
//    qDebug() << bhas_fault;
//    A3200Disconnect(handle);
//2.4 home
//    A3200Handle handle;
//    A3200Connect(&handle);
//    A3200MotionEnable(handle, TASKID_01, (AXISMASK)(AXISMASK_00 | AXISMASK_01| AXISMASK_02));
//    A3200MotionHome(handle, TASKID_01, (AXISMASK)(AXISMASK_00 | AXISMASK_01 | AXISMASK_02));
//    A3200Disconnect(handle);
//2.5 home conditional, this function cannot pass the test!!!!
//    A3200Handle handle;
//    A3200Connect(&handle);
//    A3200MotionEnable(handle, TASKID_01, (AXISMASK)(AXISMASK_00 | AXISMASK_01| AXISMASK_02));
//    A3200MotionHomeConditional(handle, TASKID_01, (AXISMASK)(AXISMASK_00 | AXISMASK_01| AXISMASK_02));
//    A3200Disconnect(handle);
//2.6 Linear
//    A3200Handle handle;
//    DOUBLE Distance[3];
//    Distance[0] = 10;
//    Distance[1] = 15;
//    Distance[2] = 15;
//    A3200Connect(&handle);
//    A3200MotionEnable(handle, TASKID_01, (AXISMASK)(AXISMASK_00 | AXISMASK_01 | AXISMASK_02));
//    A3200MotionHome(handle, TASKID_01, (AXISMASK)(AXISMASK_00 | AXISMASK_01 | AXISMASK_02));
//    qDebug() << "home done";
//    Sleep(4000);
//    qDebug() << "begin linear";
//    A3200MotionLinear(handle, TASKID_01, (AXISMASK)(AXISMASK_00 | AXISMASK_01 | AXISMASK_02), Distance);
//    qDebug() << "end linear";
//    A3200Disconnect(handle);
//2.7 LinearVelocity
//    A3200Handle handle;
//    DOUBLE Distance[2];
//    Distance[0] = 10;
//    Distance[1] = 15;
//    A3200Connect(&handle);
//    A3200MotionEnable(handle,TASKID_01,(AXISMASK)(AXISMASK_00 | AXISMASK_01));
//    A3200MotionHome(handle, TASKID_01, (AXISMASK)(AXISMASK_00 | AXISMASK_01));
//    A3200MotionLinearVelocity(handle, TASKID_01, (AXISMASK)(AXISMASK_00 | AXISMASK_01), Distance, 100);
//    A3200Disconnect(handle);
//2.8 MotionRapid
//    A3200Handle handle;
//    DOUBLE Distance[2];
//    DOUBLE Speed[2];
//    Distance[0] = 10;
//    Distance[1] = 15;
//    Speed[0] = 100;
//    Speed[1] = 150;
//    A3200Connect(&handle);
//    A3200MotionEnable(handle,TASKID_01,(AXISMASK)(AXISMASK_00 | AXISMASK_01));
//    A3200MotionHome(handle, TASKID_01, (AXISMASK)(AXISMASK_00 | AXISMASK_01));
//    Sleep(3000);
//    A3200MotionRapid(handle, TASKID_01, (AXISMASK)(AXISMASK_00 | AXISMASK_01), Distance, Speed);
//    A3200Disconnect(handle);
//2.9 CWAxisRadius
//    A3200Handle handle;
//    A3200Connect(&handle);
//    A3200MotionEnable(handle,TASKID_01,(AXISMASK)(AXISMASK_00 | AXISMASK_01));
//    A3200MotionHome(handle, TASKID_01, (AXISMASK)(AXISMASK_00 | AXISMASK_01));
//    A3200MotionCWAxisRadius(handle, TASKID_01, AXISINDEX_00, 20, AXISINDEX_01, 20, 20, 10);
//    A3200Disconnect(handle);
 //2.10 CWAxiscenter
//    A3200Handle handle;
//    A3200Connect(&handle);
//    A3200MotionEnable(handle,TASKID_01,(AXISMASK)(AXISMASK_00 | AXISMASK_01));
//    A3200MotionHome(handle, TASKID_01, (AXISMASK)(AXISMASK_00 | AXISMASK_01));
//    A3200MotionCWAxisCenter(handle, TASKID_01, AXISINDEX_00, 20, AXISINDEX_01, 20, 10, 10, 150);
//    A3200Disconnect(handle);
//2.11 CWAxisRadius
//    A3200Handle handle;
//    A3200Connect(&handle);
//    A3200MotionEnable(handle,TASKID_01,(AXISMASK)(AXISMASK_00 | AXISMASK_01));
//    A3200MotionHome(handle, TASKID_01, (AXISMASK)(AXISMASK_00 | AXISMASK_01));
//    A3200MotionCCWAxisRadius(handle, TASKID_01, AXISINDEX_00, 20, AXISINDEX_01, 20, 20, 10);
//    A3200Disconnect(handle);
//2.12 CWAxiscenter
    A3200Handle handle;
    A3200Connect(&handle);
    A3200MotionEnable(handle,TASKID_01,(AXISMASK)(AXISMASK_00 | AXISMASK_01));
    A3200MotionHome(handle, TASKID_01, (AXISMASK)(AXISMASK_00 | AXISMASK_01));
    A3200MotionCCWAxisCenter(handle, TASKID_01, AXISINDEX_00, 20, AXISINDEX_01, 20, 10, 10, 150);
    A3200Disconnect(handle);

//2.13 slaveoffset
//    A3200Handle handle;
//    A3200Connect(&handle);
//    A3200MotionEnable(handle,TASKID_01,(AXISMASK)(AXISMASK_00 | AXISMASK_01));
//    A3200MotionHome(handle, TASKID_01, (AXISMASK)(AXISMASK_00 | AXISMASK_01));
//    A3200MotionSlaveOffset(handle, TASKID_01, AXISINDEX_01, 10);
//    A3200MotionCCWAxisCenter(handle, TASKID_01, AXISINDEX_00, 20, AXISINDEX_01, 20, 10, 10, 150);
//    A3200Disconnect(handle);
//2.14 freerun
//    A3200Handle handle;
//    A3200Connect(&handle);
//    A3200MotionEnable(handle,TASKID_01,(AXISMASK)(AXISMASK_00));
//    A3200MotionHome(handle, TASKID_01, (AXISMASK)(AXISMASK_00));
//    Sleep(2000);
//    A3200MotionFreeRun(handle, TASKID_01, AXISINDEX_00, 15);
//    A3200Disconnect(handle);
//2.15 freerunstop
//    Sleep(4000);
//    A3200MotionFreeRunStop(handle, TASKID_01, AXISINDEX_00);
//    A3200Disconnect(handle);
//2.16 moveInc
//    A3200Handle handle;
//    A3200Connect(&handle);
//    A3200MotionEnable(handle,TASKID_01,(AXISMASK)(AXISMASK_00));
//    A3200MotionHome(handle, TASKID_01, (AXISMASK)(AXISMASK_00));
//    A3200MotionMoveInc(handle, TASKID_01, AXISINDEX_00, 50, 100);
//    A3200Disconnect(handle);
//2.17 moveAbs
//    A3200Handle handle;
//    A3200Connect(&handle);
//    A3200MotionEnable(handle,TASKID_01,(AXISMASK)(AXISMASK_00));
//    A3200MotionHome(handle, TASKID_01, (AXISMASK)(AXISMASK_00));
//    A3200MotionMoveAbs(handle, TASKID_01, AXISINDEX_00, 50, 100);
//    A3200Disconnect(handle);
//2.18 autoFocus
//    A3200Handle handle;
//    A3200Connect(&handle);
//    A3200MotionAutoFocus(handle, TASKID_01, AXISINDEX_02, ONOFF_On);
//    A3200MotionEnable(handle,TASKID_01,(AXISMASK)(AXISMASK_02));
//    A3200MotionHome(handle, TASKID_01, (AXISMASK)(AXISMASK_02));
//    A3200Disconnect(handle);
//2.19 safezone set,type, on/off,clear
//    A3200Handle handle;
//    A3200Connect(&handle);
//    A3200MotionEnable(handle, TASKID_01, (AXISMASK)(AXISMASK_00));
//    A3200MotionHome(handle, TASKID_01, (AXISMASK)(AXISMASK_00));
//    qDebug() << "wait 3 seconds ...";
//    Sleep(3000);

//    A3200MotionSafeZoneSet(handle, TASKID_01, 0, AXISINDEX_00, 20, 40);
//    A3200MotionSafeZoneType(handle, TASKID_01, 0, SAFEZONETYPE_NoEnter);
//    A3200MotionSafeZone(handle, TASKID_01, 0, ONOFF_On);
//    //    A3200MotionSafeZone(handle, TASKID_01, 0, ONOFF_Off);

//    qDebug() << "wait 4 seconds ...";
//    Sleep(4000);
//    DOUBLE distance[1];
//    distance[0] = 10;
//    A3200MotionLinear(handle, TASKID_01, (AXISMASK)(AXISMASK_00), distance);

//    A3200MotionSafeZoneClear(handle, TASKID_01, 0, AXISINDEX_00);
//    A3200Disconnect(handle);

//2.20 abort, no test
    A3200Handle handle;
    A3200Connect(&handle);
    A3200MotionEnable(handle, TASKID_01, (AXISMASK)(AXISMASK_00));
    A3200MotionHome(handle, TASKID_01, (AXISMASK)(AXISMASK_00));
    qDebug() << "wait 1 seconds ...";
    Sleep(1000);

    DOUBLE distance[1];
    distance[0] = 120;
    A3200MotionLinearVelocity(handle, TASKID_01, (AXISMASK)(AXISMASK_00), distance, 20);
    qDebug() << "wait 0.5 seconds ...";
    Sleep(500);
    qDebug() << "issue abort command ...";
   // A3200MotionAbort(handle,(AXISMASK)(AXISMASK_00));

//2.21 waitformotiondone, no test
    WAITOPTION  waitOption = WAITOPTION_MoveDone;
    DWORD  timeout = 1000;
    BOOL btimeout;
    A3200MotionWaitForMotionDone(handle,(AXISMASK)(AXISMASK_00), waitOption,timeout, &btimeout);
    A3200Disconnect(handle);

}

上面的代码是可以直接运行的,用qt创建控制台工程,

工程文件如下,

QT = core

CONFIG += c++17 cmdline

# You can make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0

SOURCES += \
        main.cpp

# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target

win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../SDK/Lib64/ -lA3200C64
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../SDK/Lib64/ -lA3200C64

INCLUDEPATH += $$PWD/../SDK/Include
INCLUDEPATH += $$PWD/../SDK/Bin64
INCLUDEPATH += $$PWD/../SDK/Bin64/ExamplesScript
DEPENDPATH += $$PWD/../SDK/Include

需要将Aerotech的头文件与库文件拷到当前工程目录下,创建SDK目录存放。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值