/*************************************************************************
FunctionBlockName: ZL_M_0_1
Version: 1.0.0
Author: luck張
UpdateTime: 2022-04-24 08:59:45
Comment:
把D1000开始的寄存器,分配给M0起始的继电器;
D1000 = 1 ,M0 = 1;
= 2 ,M1 = 1;
= 3 ,M2 = 1;
D1125 = 1 ,M1250 = 1;
= 2 ,M1251 = 1;
= 3 ,M1252 = 1;
子程序 外部调用 1次
**************************************************************************/
void ZL_M_0_1 ( WORD W, BIT B )
{
#define SysRegAddr_HD_D_HM_M
int mid = 0;
int i = 0;
for ( i = 0; i < 125; i++ ) //遍历表格总步数;
{
if ( D[i + 1000] == 1 )
{
M[mid] = 1;//第一给M,M0置位1;=》判断指令
M[mid + 1] = 0; //其它复位 =》结束判断指令
M[mid + 2] = 0; // =》置位指令
M[mid + 3] = 0; // =》复位
M[mid + 4] = 0; // =》延时
M[mid + 5] = 0; // =》等待
M[mid + 6] = 0; // =》轴运动
M[mid + 7] = 0; // =》跳转
}
if ( D[i + 1000] == 2 )
{
M[mid] = 0;
M[mid + 1] = 1; //=》结束判断指令
M[mid + 2] = 0;
M[mid + 3] = 0;
M[mid + 4] = 0;
M[mid + 5] = 0;
M[mid + 6] = 0;
M[mid + 7] = 0;
}
if ( D[i + 1000] == 3 )
{
M[mid] = 0;
M[mid + 1] = 0;
M[mid + 2] = 1; // =》置位指令
M[mid + 3] = 0;
M[mid + 4] = 0;
M[mid + 5] = 0;
M[mid + 6] = 0;
M[mid + 7] = 0;
}
if ( D[i + 1000] == 4 )
{
M[mid] = 0;
M[mid + 1] = 0;
M[mid + 2] = 0;
M[mid + 3] = 1; // =》复位
M[mid + 4] = 0;
M[mid + 5] = 0;
M[mid + 6] = 0;
M[mid + 7] = 0;
}
if ( D[i + 1000] == 5 )
{
M[mid] = 0;
M[mid + 1] = 0;
M[mid + 2] = 0;
M[mid + 3] = 0;
M[mid + 4] = 1; //复位
M[mid + 5] = 0;
M[mid + 6] = 0;
M[mid + 7] = 0;
}
if ( D[i + 1000] == 6 )
{
M[mid] = 0;
M[mid + 1] = 0;
M[mid + 2] = 0;
M[mid + 3] = 0;
M[mid + 4] = 0;
M[mid + 5] = 1;//延时
M[mid + 6] = 0;
M[mid + 7] = 0;
}
if ( D[i + 1000] == 7 )
{
M[mid] = 0;
M[mid + 1] = 0;
M[mid + 2] = 0;
M[mid + 3] = 0;
M[mid + 4] = 0;
M[mid + 5] = 0;
M[mid + 6] = 1;//轴运动
M[mid + 7] = 0;
}
if ( D[i + 1000] == 8 )
{
M[mid] = 0;
M[mid + 1] = 0;
M[mid + 2] = 0;
M[mid + 3] = 0;
M[mid + 4] = 0;
M[mid + 5] = 0;
M[mid + 6] = 0;
M[mid + 7] = 1;//跳转
}
mid += 10;
}
}
/*************************************************************************
FunctionBlockName: JUMP_NP
Version: 1.0.0
Author: luck張
UpdateTime: 2022-04-26 07:55:05
Comment:
执行跳转功能
在当前步内执行,跳转到参数1指定的步【P】;
在子程序 内部调用
**************************************************************************/
void JUMP_NP ( WORD W, BIT B )
{
#define SysRegAddr_HD_D_M
int id = 0;
int a = 0;
int i = 0;
for ( i = 0; i < 125; i++ )
{
if ( a == 0 )
{
if ( D[i + 500] == 1 ) //当前步开始,=1的认为是在执行的S
{
D[i + 500] = 0; //当前S复位
id = * ( INT16U * ) &D[2000 + i];//当前步对应的参数1;
D[i + 500 + id] = 1; //置位要跳转的步S号;
a++;//限制执行次数1次;
continue;
}
}
}
}
/*************************************************************************
FunctionBlockName: BU_ZL
Version: 1.0.0
Author: luck張
UpdateTime: 2022-04-26 07:55:05
Comment:
遍历表格地址的0+8
返回每一步对应的指令
分配给D1000起始;代表当前步使用的指令
1=判断
2=结束pd
3=置位
4=复位
5
6
7
8=跳转
在子程序 外部调用
**************************************************************************/
void BU_ZL ( WORD W, BIT B )
{
#define SysRegAddr_HD_D_M
int i = 0;
int p = 0;
for ( i = 0; i < 999; i += 8 )
{
if ( * ( INT16U * ) &W[i] == 53445 && * ( INT16U * ) &W[i + 1] == 53174 && * ( INT16U * ) &W[i + 2] == 0 )
{
D[p + 1000] = 1;//判断指令,
p++; //寄存器地址+1,
}
if ( * ( INT16U * ) &W[i] == 53445 && * ( INT16U * ) &W[i + 1] == 53174 && * ( INT16U * ) &W[i + 2] == 47574 )
{
D[p + 1000] = 2;//结束判断
p++;
}
if ( * ( INT16U * ) &W[i] == 50134 )
{
D[p + 1000] = 3;//置位指令
p++;
}
if ( * ( INT16U * ) &W[i] == 46264 )
{
D[p + 1000] = 4;//复位位指令
p++;
}
if ( * ( INT16U * ) &W[i] == 54225 )
{
D[p + 1000] = 5;//延时指令
p++;
}
if ( * ( INT16U * ) &W[i] == 51381 )
{
D[p + 1000] = 6;//等待
p++;
}
if ( * ( INT16U * ) &W[i] == 57814 )
{
D[p + 1000] = 7;//轴移动
p++;
}
if ( * ( INT16U * ) &W[i] == 63692 )
{
D[p + 1000] = 8;//跳转
p++;
}
}
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)