demo1.cpp

来自「这是在windows环境下用VC开发的MCX运动控制芯片的演示程序」· C++ 代码 · 共 42 行

CPP
42
字号
#include <conio.h>
#include <iostream.h>
#include "driver.h"

void main()
{
	clrscr();
	InitialBoard();
	ShiftPulseOut(2);

	// 定速+x方向定量驱动
	SetR(1, 8000000);
	SetSV(1, 980);
	SetV(1, 980);
	SetP(1, 2500);
	Command(1, DRIVE_P);
	cout << "Const speed drive +x..." << endl;
	WaitForStop(1);

	// 定速-y方向定量驱动
	SetR(2, 8000000);
	SetSV(2, 980);
	SetV(2, 980);
	SetP(2, 2000);
	Command(2, DRIVE_N);
	cout << "Const speed drive -y..." << endl;
	WaitForStop(2);

	// 定速-x方向连续驱动
	Command(1, DRIVE_CN);
	cout << "Continue const speed drive -x..." << endl;
	cout << "Please press any key to stop." << endl;
	getch();
	Command(1, STOP_D);

	// 定速+y方向连续驱动
	Command(2, DRIVE_CP);
	cout << "Continue const speed drive +y..." << endl;
	cout << "Please press any key to stop." << endl;
	getch();
	Command(2, STOP_D);
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?