|
|
|
|
~: Stepper motor control program in VC++ :~ void CStepDlg::OnXit() { // TODO: Add your control notification handler code here OnOK(); }
void CStepDlg::OnClk() { // TODO: Add your control notification handler code here UpdateData(TRUE); m_str = "Motor is running colckwise"; UpdateData(FALSE); for(int j=0;j<n;j++) { _outp(0x0378,0xCC); Sleep(d); _outp(0x0378,0xC3); Sleep(d); _outp(0x0378,0x33); Sleep(d); _outp(0x0378,0x3C); Sleep(d); } }
void CStepDlg::OnAclk() { // TODO: Add your control notification handler code here UpdateData(TRUE); m_str = "Motor is running anticolckwise"; UpdateData(FALSE); for(int j=0;j<n;j++) { _outp(0x0378,0xCC); Sleep(d); _outp(0x0378,0x3C); Sleep(d); _outp(0x0378,0x33); Sleep(d); _outp(0x0378,0xC3); Sleep(d); } }
void CStepDlg::OnIncr() { // TODO: Add your control notification handler code here UpdateData(TRUE); s=s+10; s1 = s/60; d = 50/s1; m_rpm.Format("%d",s); UpdateData(FALSE);
}
void CStepDlg::OnDecr() { // TODO: Add your control notification handler code here UpdateData(TRUE); if(s>60) s= s-10; if(s==60) MessageBox("minimum speed(RPM) limit"); s1 = s/60; d = 50/s1; m_rpm.Format("%d",s); UpdateData(FALSE);
}
void CStepDlg::OnIncn() { // TODO: Add your control notification handler code here UpdateData(TRUE); if(r>1) r++; else r=r*2; n = r*5; m_rot.Format("%f",r); UpdateData(FALSE); }
void CStepDlg::OnDecn() { // TODO: Add your control notification handler code here UpdateData(TRUE); if(r>1) r--; else if(r>0.25) r=r/2; if(r==0.25) MessageBox("minimum step resolution limit");; n = r*5; m_rot.Format("%f",r); UpdateData(FALSE); }
void CStepDlg::OnRst1() { // TODO: Add your control notification handler code here UpdateData(TRUE); s = 60; m_rpm.Format("%d",s); UpdateData(FALSE); }
void CStepDlg::OnRst2() { // TODO: Add your control notification handler code here UpdateData(TRUE); r = 1; m_rot.Format("%d",r); UpdateData(FALSE); }
void CStepDlg::OnRst3() { // TODO: Add your control notification handler code here UpdateData(TRUE); m_str = "Motor is stopped"; UpdateData(FALSE); } | |
|