View Single Post
Old 06-12-2008, 10:32 AM   #4
dvkkt
Đệ tử 3 túi
 
dvkkt's Avatar
 
Tham gia ngày: Oct 2007
Nơi Cư Ngụ: TPHCM
Bài gửi: 55
:
Send a message via Yahoo to dvkkt
Tôi không dùng VC++ nên chỉ giải thích vắn tắt cái hàm.
Code:
void CTest2Dlg::OnXit()
{
// TODO: Add your control notification handler code here
int r;
r = _outp(0x0378,0x00); // xuất data 0x00 ra cổng LPT
OnOK();
}
Code:
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);
}
nút OnUp này giống như chỉnh tốc độ cho motor, nếu đạt giới hạn thì sẽ hiện thông báo "Maximum speed limit"

Code:
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);
}
Ngược với hàm ở trên.

Code:
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);               // giống như hàm delay tính bằng milisecond
p = _outp(0x0378,0x00);
Sleep(m_sf - a);
}
}
nút điều khiển motor quay thuận.

Code:
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);
}
}
quay ngược.
dvkkt vẫn chưa có mặt trong diễn đàn   Trả Lời Với Trích Dẫn