computer interface (a/d) chung-buk hrd institute of kcci dept. of information & communication...
TRANSCRIPT
Computer Interface (A/D)
Chung-Buk HRD Institute of KCCIDept. of Information & Communication
PhD. Kang, Won-Chan
Progress Control
Computer Interface
Example 1
Make a project MFC WizardDialog basedName: ProgressTestInput Library: noneInput Function: none
Select hardwarenone
Using Commandnone
Computer Interface
IDC_EDIT1
IDC_START
IDC_EXIT
IDC_PROGRESS1
Computer Interface
Computer Interface
Computer Interface
void CProgressTestDlg::OnExit() {
MessageBox("PROGRESS TEST.");MessageBeep((WORD)-2);OnOK();
}void CProgressTestDlg::OnOutofmemoryProgress1(NMHDR* pNMHDR, LRESULT* pResult) {
*pResult = 0;}void CProgressTestDlg::OnStart() {
int temp;temp=m_input;UpdateData(TRUE);m_progress.SetPos(temp);UpdateData(FALSE);
}
Computer InterfaceBOOL CProgressTestDlg::OnInitDialog(){
CDialog::OnInitDialog();
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);if (pSysMenu != NULL){
CString strAboutMenu;strAboutMenu.LoadString(IDS_ABOUTBOX);if (!strAboutMenu.IsEmpty()){
pSysMenu->AppendMenu(MF_SEPARATOR);pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}}
m_progress.SetRange(0,100);m_progress.SetPos(100);
SetIcon(m_hIcon, TRUE); // Set big iconSetIcon(m_hIcon, FALSE); // Set small icon
return TRUE; // return TRUE unless you set the focus to a control
}
Computer Interface
CProgressTestDlg::CProgressTestDlg(CWnd* pParent /*=NULL*/): CDialog(CProgressTestDlg::IDD, pParent)
{//{{AFX_DATA_INIT(CProgressTestDlg)m_input = 0;//}}AFX_DATA_INIT// Note that LoadIcon does not require a subsequent DestroyIcon in Win32m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
Computer Interface
Computer Interface
A/D convert Interface
Computer Interface
ON
ON
Computer Interface
Computer Interface
Example 1
Make a project MFC WizardDialog basedName: ADC0809Input Library: inpout32.libInput Function: Timer()
Select hardwareSW4
Using CommandOut32(Port Address, Data)Inp32(Port Address)
Computer Interface
IDC_START
IDC_EXITIDC_PROGRESS1
IDC_EDIT1
IDC_channel0IDC_channel1
IDC_channel7
Computer Interface
Computer Interface
Computer Interface
Computer Interface
Computer Interface
#include "stdafx.h"#include "Switch1.h"#include "Switch1Dlg.h"//#include "conio.h“
short _stdcall Inp32(short PortAddress);void _stdcall Out32(short PortAddress, short data);
#define DataAdd 0x378#define StatusAdd 0x379 #define ControlAdd 0x37a
Computer Interface
void CADC0809Dlg::OnExit() { MessageBox("A/D CONVERSION TEST..");
MessageBeep((WORD)-2);OnOK();
Out32(ControlAdd, (0x0b^0x00));}
void CADC0809Dlg::OnStart() { int i;
CString temp;
i=Inp32(DataAdd);m_progress.SetPos(i);temp.Format("A/D Value= %3d, %5.3f volt",i,(float)i/51);m_Value=temp;UpdateData(FALSE);
SetTimer(1,50,NULL);}
Computer Interface
void CADC0809Dlg::OnChannel0() { Out32(ControlAdd,(0x0b^0x28));
Sleep(10); }void CADC0809Dlg::OnChannel1() { Out32(ControlAdd,(0x0b^0x29));
Sleep(10); }void CADC0809Dlg::OnChannel2() { Out32(ControlAdd,(0x0b^0x2a));
Sleep(10); }void CADC0809Dlg::OnChannel3() { Out32(ControlAdd,(0x0b^0x2b));
Sleep(10); }void CADC0809Dlg::OnChannel4() { Out32(ControlAdd,(0x0b^0x2c));
Sleep(10); }void CADC0809Dlg::OnChannel5() { Out32(ControlAdd,(0x0b^0x2d));
Sleep(10); }void CADC0809Dlg::OnChannel6() { Out32(ControlAdd,(0x0b^0x2e));
Sleep(10); }void CADC0809Dlg::OnChannel7() { Out32(ControlAdd,(0x0b^0x2f));
Sleep(10); }
Computer Interface
void CADC0809Dlg::OnOutofmemoryProgress1(NMHDR* pNMHDR, LRESULT* pResult) {
*pResult = 0;}
void CADC0809Dlg::OnTimer(UINT nIDEvent) {
CDialog::OnTimer(nIDEvent);OnStart();
}
Computer Interface
Computer Interface
Question
Input A/D Value
Output LCD display
Problem: address selection!!
END