computer interface (a/d) chung-buk hrd institute of kcci dept. of information & communication...

27
Computer Interface (A/D) Chung-Buk HRD Institute of KCCI Dept. of Information & Communicatio n PhD. Kang, Won-Chan

Upload: robert-matthews

Post on 17-Jan-2016

215 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Computer Interface (A/D) Chung-Buk HRD Institute of KCCI Dept. of Information & Communication PhD. Kang, Won-Chan

Computer Interface (A/D)

Chung-Buk HRD Institute of KCCIDept. of Information & Communication

PhD. Kang, Won-Chan

Page 2: Computer Interface (A/D) Chung-Buk HRD Institute of KCCI Dept. of Information & Communication PhD. Kang, Won-Chan

Progress Control

Page 3: Computer Interface (A/D) Chung-Buk HRD Institute of KCCI Dept. of Information & Communication PhD. Kang, Won-Chan

Computer Interface

Example 1

Make a project MFC WizardDialog basedName: ProgressTestInput Library: noneInput Function: none

Select hardwarenone

Using Commandnone

Page 4: Computer Interface (A/D) Chung-Buk HRD Institute of KCCI Dept. of Information & Communication PhD. Kang, Won-Chan

Computer Interface

IDC_EDIT1

IDC_START

IDC_EXIT

IDC_PROGRESS1

Page 5: Computer Interface (A/D) Chung-Buk HRD Institute of KCCI Dept. of Information & Communication PhD. Kang, Won-Chan

Computer Interface

Page 6: Computer Interface (A/D) Chung-Buk HRD Institute of KCCI Dept. of Information & Communication PhD. Kang, Won-Chan

Computer Interface

Page 7: Computer Interface (A/D) Chung-Buk HRD Institute of KCCI Dept. of Information & Communication PhD. Kang, Won-Chan

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);

}

Page 8: Computer Interface (A/D) Chung-Buk HRD Institute of KCCI Dept. of Information & Communication PhD. Kang, Won-Chan

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

}

Page 9: Computer Interface (A/D) Chung-Buk HRD Institute of KCCI Dept. of Information & Communication PhD. Kang, Won-Chan

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);

}

Page 10: Computer Interface (A/D) Chung-Buk HRD Institute of KCCI Dept. of Information & Communication PhD. Kang, Won-Chan

Computer Interface

Page 11: Computer Interface (A/D) Chung-Buk HRD Institute of KCCI Dept. of Information & Communication PhD. Kang, Won-Chan

Computer Interface

Page 12: Computer Interface (A/D) Chung-Buk HRD Institute of KCCI Dept. of Information & Communication PhD. Kang, Won-Chan

A/D convert Interface

Page 13: Computer Interface (A/D) Chung-Buk HRD Institute of KCCI Dept. of Information & Communication PhD. Kang, Won-Chan

Computer Interface

ON

ON

Page 14: Computer Interface (A/D) Chung-Buk HRD Institute of KCCI Dept. of Information & Communication PhD. Kang, Won-Chan

Computer Interface

Page 15: Computer Interface (A/D) Chung-Buk HRD Institute of KCCI Dept. of Information & Communication PhD. Kang, Won-Chan

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)

Page 16: Computer Interface (A/D) Chung-Buk HRD Institute of KCCI Dept. of Information & Communication PhD. Kang, Won-Chan

Computer Interface

IDC_START

IDC_EXITIDC_PROGRESS1

IDC_EDIT1

IDC_channel0IDC_channel1

IDC_channel7

Page 17: Computer Interface (A/D) Chung-Buk HRD Institute of KCCI Dept. of Information & Communication PhD. Kang, Won-Chan

Computer Interface

Page 18: Computer Interface (A/D) Chung-Buk HRD Institute of KCCI Dept. of Information & Communication PhD. Kang, Won-Chan

Computer Interface

Page 19: Computer Interface (A/D) Chung-Buk HRD Institute of KCCI Dept. of Information & Communication PhD. Kang, Won-Chan

Computer Interface

Page 20: Computer Interface (A/D) Chung-Buk HRD Institute of KCCI Dept. of Information & Communication PhD. Kang, Won-Chan

Computer Interface

Page 21: Computer Interface (A/D) Chung-Buk HRD Institute of KCCI Dept. of Information & Communication PhD. Kang, Won-Chan

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

Page 22: Computer Interface (A/D) Chung-Buk HRD Institute of KCCI Dept. of Information & Communication PhD. Kang, Won-Chan

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);}

Page 23: Computer Interface (A/D) Chung-Buk HRD Institute of KCCI Dept. of Information & Communication PhD. Kang, Won-Chan

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); }

Page 24: Computer Interface (A/D) Chung-Buk HRD Institute of KCCI Dept. of Information & Communication PhD. Kang, Won-Chan

Computer Interface

void CADC0809Dlg::OnOutofmemoryProgress1(NMHDR* pNMHDR, LRESULT* pResult) {

*pResult = 0;}

void CADC0809Dlg::OnTimer(UINT nIDEvent) {

CDialog::OnTimer(nIDEvent);OnStart();

}

Page 25: Computer Interface (A/D) Chung-Buk HRD Institute of KCCI Dept. of Information & Communication PhD. Kang, Won-Chan

Computer Interface

Page 26: Computer Interface (A/D) Chung-Buk HRD Institute of KCCI Dept. of Information & Communication PhD. Kang, Won-Chan

Computer Interface

Question

Input A/D Value

Output LCD display

Problem: address selection!!

Page 27: Computer Interface (A/D) Chung-Buk HRD Institute of KCCI Dept. of Information & Communication PhD. Kang, Won-Chan

END