procedure TForm1.SpeedButton1Click(Sender: TObject);
begin
if not mscommain.PortOpen then
mscommain.PortOpen:=true;
mscommain.InBufferCount:=0;
mscommain.InputLen:=0;
mscommain.RThreshold:=1;
mscommmain.output:=chr(5)+'008710230C5';//加速21秒
sleep(300);
mscommmain.output:=chr(5)+'008810230C6';//减速21秒
sleep(300);
.........
end;
procedure form2.edit1Change(Sender: TObject);
begin
second:=second+1;
if second=60 then
begin
second:=0;
minute:=minute+1;
end;
text:=inttostr(minute)+':'+inttostr(second);//也可以在主窗体直接设置运行时间
if minute*60+second=temp then // 当达到运行时间,变频器应该减速21秒停止,但实际3秒左右停止!
begin
second:=0;
minute:=0;
close;//关闭此子窗体
Mainform.mscommain.DTREnable:=false;
Mainform.mscommain.RTSEnable:=false;
Mainform.mscommain.Output:=chr(5)+'00FD19696F9';//发复位信号
sleep(300);
Mainform.MSCommain.PortOpen:=false;
end;
end;