多谢您,上位机的程序是:
Public Const stopX = &H0
Public Const moveX = &H1
Public Const JogPX = &H2
Public Const JogNX = &H3
Public Const PosX = &H4
Public Const stopY = &H10
Public Const mo
详情回复
发表于 2012-8-24 11:59
多谢您,上位机的程序是:
Public Const stopX = &H0
Public Const moveX = &H1
Public Const JogPX = &H2
Public Const JogNX = &H3
Public Const PosX = &H4
Public Const stopY = &H10
Public Const moveY = &H11
Public Const JogPY = &H12
Public Const JogNY = &H13
Public Const PosY = &H14
Public Const moveC = &HB0
Public Const moveN = &HB1
Public Const SetPWM = &HC0
Public Const SetIO = &HC1
Public Const SetRERX = &HC2
Public Const SetRERY = &HC3
Public Const SetSonX = &HC4
Public Const SetSonY = &HC5
Public Const RstFLG = &HC6
Public Const SetHdrFlg = &HC7
Public Sub RegSetIO(ByVal port As Byte, ByVal status As Byte)
Dim sbuf(3) As Byte
sbuf(0) = SetIO
sbuf(1) = port
sbuf(2) = status
frmMain.MSComm1.Output = sbuf
End Sub
Private Sub cmdHdrGo_Click()
fraPass.Visible = False
If HeadUp = True Then
HeadUp = False
RegSetIO 9, 0 'A
RegSetIO 10, 0 'B
RegSetIO 11, 0 'C
RegSetIO 12, 0 'D
Else
HeadUp = True
If chkHeaderA.Value Then RegSetIO 9, 1 'A
If chkHeaderB.Value Then RegSetIO 10, 1 'B
If chkHeaderC.Value Then RegSetIO 11, 1 'C
If chkHeaderD.Value Then RegSetIO 12, 1 'D
End If
End Sub
下位机的程序
void Set_IO(unsigned char index,unsigned char sbit)
{ switch(index)
{
case 1:
GPIO_WriteBit(GPIOA,GPIO_Pin_4,sbit);
break;
case 2:
GPIO_WriteBit(GPIOA,GPIO_Pin_5,sbit);
break;
case 3:
GPIO_WriteBit(GPIOA,GPIO_Pin_6,sbit);
break;
case 4:
GPIO_WriteBit(GPIOA,GPIO_Pin_7,sbit);
break;
case 5:
GPIO_WriteBit(GPIOB,GPIO_Pin_0,sbit);
break;
case 6:
GPIO_WriteBit(GPIOB,GPIO_Pin_1,sbit);
break;
case 7:
GPIO_WriteBit(GPIOB,GPIO_Pin_6,sbit);
break;
case 8:
GPIO_WriteBit(GPIOB,GPIO_Pin_7,sbit);
break;
case 10: case 9:
GPIO_WriteBit(GPIOB,GPIO_Pin_8,sbit);
break;
GPIO_WriteBit(GPIOB,GPIO_Pin_9,sbit);
break;
case 11:
GPIO_WriteBit(GPIOB,GPIO_Pin_10,sbit);
break;
case 12:
GPIO_WriteBit(GPIOB,GPIO_Pin_11,sbit);
break;
case 13:
GPIO_WriteBit(GPIOB,GPIO_Pin_12,sbit);
break;
case 14:
GPIO_WriteBit(GPIOB,GPIO_Pin_13,sbit);
break;
case 15:
GPIO_WriteBit(GPIOB,GPIO_Pin_14,sbit);
break;
case 16:
GPIO_WriteBit(GPIOB,GPIO_Pin_15,sbit);
break;
case 17:
GPIO_WriteBit(GPIOA,GPIO_Pin_8,sbit);
if(sbit) srdX.error_code &=0xBF;
break;
case 18:
GPIO_WriteBit(GPIOA,GPIO_Pin_9,sbit);
if(sbit) srdY.error_code &=0xBF;
break;
}
}