📄 multint.cpp
字号:
/////////////////////////////////////////////////////////////////////
//
// 两轴直线圆弧多段定速插补DEMO (中断方式)
//
/////////////////////////////////////////////////////////////////////
#include "driver.h"
int n = 0;
unsigned int flag;
void Line1()
{
SetP(1, 3000);
SetP(2, 3000);
Command(0, CMD_LINE);
}
void Line2()
{
SetP(1, 2000);
SetP(2, 6000);
Command(0, CMD_LINE);
}
void Circle()
{
SetC(1, 5000);
SetC(2, 0);
SetP(1, 5000);
SetP(2, -5000);
Command(0, CMD_CW);
}
void interrupt newint(...)
{
disable();
flag = GetRR0();
if (flag & 0x200)
n++;
if (n == 1)
Line1();
else if (n == 2)
Circle();
else if (n == 3)
Line2();
ClearInt();
enable();
}
void main()
{
clrscr();
InitialBoard();
HookInt(newint);
ShiftPulseOut(2);
SetIntMode(3, INT_DEND); // D15 = 1 驱动结束时中断发生
EnableCSpeed(); // 两轴线速恒定
SetM(1, 2);
SetM(2, 2.828);
SetSV(3, 1000);
SetP(1, 4500);
SetP(2, 0);
ClearInt();
Command(0, CMD_LINE); // 直线插补
n = 0;
printf("Start n = %d\n", n);
do
{
if (n > 3)
break;
}
while (!bioskey(1));
printf("End n = %d\n", n);
UnhookInt();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -