|
~: DC motor control program in VC++ :~
void CTest2Dlg::OnXit() { // TODO: Add your control notification handler code here int r; r = _outp(0x0378,0x00); OnOK(); } void CTest2Dlg::OnUp() { // TODO: Add your control notification handler code here UpdateData(TRUE); if(a<45) a+=5; else MessageBox("Maximum speed limit"); m_speedfact.Format("%d", a); UpdateData(FALSE); } void CTest2Dlg::OnDwn() { // TODO: Add your control notification handler code here UpdateData(TRUE); if(a>-45) a-=5; else MessageBox("Minimum speed limit"); m_speedfact.Format("%d", a); UpdateData(FALSE); } void CTest2Dlg::OnFwd() { // TODO: Add your control notification handler code here int p; int z = 5000/(2*m_sf); for(int i=0;i<z;i++) { p = _outp(0x0378,0x03); Sleep(m_sf + a); p = _outp(0x0378,0x00); Sleep(m_sf - a); } } void CTest2Dlg::OnRew() { // TODO: Add your control notification handler code here int p; int z = 5000/(2*m_sf); for(int i=0;i<z;i++) { p = _outp(0x0378,0x0C); Sleep(m_sf + a); p = _outp(0x0378,0x00); Sleep(m_sf - a); } }
void CTest2Dlg::OnFwrd() { // TODO: Add your control notification handler code here int r; r = _outp(0x0378,0x03); } void CTest2Dlg::OnRe() { // TODO: Add your control notification handler code here int r; r = _outp(0x0378,0x0C); } void CTest2Dlg::OnStop() { // TODO: Add your control notification handler code here int r; r = _outp(0x0378,0x00); }
void CTest2Dlg::OnLButtonDown(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default int p; if((nFlags & MK_LBUTTON) == MK_LBUTTON) { p = _outp(0x0378,0x03); Sleep(50); p = _outp(0x0378,0x00); } CDialog::OnLButtonDown(nFlags, point); } void CTest2Dlg::OnRButtonDown(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default int p; if((nFlags & MK_RBUTTON) == MK_RBUTTON) { p = _outp(0x0378,0x0C); Sleep(50); p = _outp(0x0378,0x00); } CDialog::OnRButtonDown(nFlags, point); } void CTest2Dlg::OnMouseMove(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default int p; if((nFlags & MK_LBUTTON) == MK_LBUTTON) { p = _outp(0x0378,0x03); Sleep(m_sf + a); p = _outp(0x0378,0x00); Sleep(m_sf - a); } else if((nFlags & MK_RBUTTON) == MK_RBUTTON) { p = _outp(0x0378,0x0C); Sleep(m_sf + a); p = _outp(0x0378,0x00); Sleep(m_sf - a); } CDialog::OnMouseMove(nFlags, point); } |