MPC08䖤
4ẔࡼࠊிඣՈᓔথ
4.1ᓔথWindowsϟՈẔࡼࠊிඣ
⫼MPC08ⱘ 䫒 ˄DLL˅ˈ 㗙 ҹ Windows ϟⱘ䖤 ㋏㒳DŽMPC08 䫒 ⱘWindows32ԡ 䫒 ˈ䗝⫼ⱘ Windows ⱘ32ԡDLL䇗⫼DŽ
ҹϟҟ㒡 ԩ ⫼ϸ⾡ ⫼ⱘ Microsoft Visual Basic Microsoft Visual C++ ѢWindows ⱘ䖤 DŽ
4.1.1ᓔথVisual Basicࠊ࣏ᑣ
˄ϔ˅ ὖ䗄
Ўњ ѢWindowsⱘ䖤 ˈ⫼ ҹՓ⫼VB5.0 催⠜ ˈ ϔϾㅔ ⱘVisual B asic 䴲 DŽ ✻ ϟℹ偸 ҹ 䗳 ϔϾㅔ ⱘ DŽ
1ˊ 㺙MPC08偅 ˗
2ˊ⫼V isual Basic ϔϾ⬠䴶 ˗
3ˊ MPC08.bas ӊ⏏ VB ProjectЁ ˗
4ˊ ⫼ Ё䇗⫼䖤 DŽ
Visual Basicⱘ 䛑ҟ㒡њ ԩ ҟ䴶 ˈ 䪂ǃ 䆱Ḛҹ 㦰 ㄝDŽ Ѣ❳ Visual Basic MPC08䖤 ⱘ 㗙 䇈ˈϔϾ⬅䕧 Ḛ Ҹ 䪂㒘 ⱘ ѢWindowsⱘㅔ 䖤 ˈ ҹ 䩳 ҹ DŽ
˄Ѡ˅ 䫒 䇗⫼ ⊩
VBЁ䇗⫼ 䫒 ˄DLL˅Ё ϸ䚼 ˖
↣ϔϾ 䫒 ˄DLL˅Ёⱘ VBЁⱘ 㒣 MPC08.bas ӊЁњˈ䆹 ӊ MPC08 ⫼ 㺙Ⳃ Ā\MPC08SP\Develop\VBā ӊ ϟ ˈ⫼ 䳔㽕 䆹 ӊ⏏ 䖯VB Ё DŽ
䇗⫼
㢹䇗⫼ ⱘ䖨 Ўぎ ϡ䳔㽕䖨 ˈ ϟ ⊩䇗⫼˖
con_pmove1,2000
Call con_pmove(1,2000)
4䖤 ㋏㒳ⱘ
㢹㽕 ⱘ䖨 ˈ ϟ ⊩䇗⫼˖vb软件开发
Dim rtn As Long
rtn=con_pmove(1,2000)
⊼ᛣ˖Ӵ䗦ⱘ ㉏ 䖨 ⱘ 䞣㉏ Ϣ ⱘ ㉏ ϔ㟈ˈ Ϩ 䆂 䗄Ё int ˄C䇁㿔Ёⱘ ˅ long ˄C䇁㿔Ёⱘ䭓 ˅ 䖨 㒳ϔ䞛⫼Long ˄VBЁⱘ䭓 ˅ ㉏ ˗ ⱘfloat ˄C䇁㿔Ёⱘ ㊒ ⍂⚍ ˅ double˄C䇁㿔Ёⱘ ㊒ ⍂⚍ ˅ 䖨 㒳ϔ䞛⫼Double ˄VBЁⱘ ㊒ ⍂⚍ ˅ ㉏ ˈ 㛑ѻ⫳ ⊩乘 ⱘ㒧 DŽ
˄ϝ˅ⓨ⼎⼎՟ ⱘՓ⫼
MPC08 ⫼ 㺙Ⳃ Ā\MPC08SP\Demo\VBDemoā ӊ ϟ ϸϾ VB6.0ϟ ⱘ䖤 ㋏㒳ⓨ⼎⼎՟ DŽ⫼ ✻ ϟℹ偸㓪䆥 䖤㸠䆹⼎՟ˈ ❳ њⳌ 㓪 ⊩ ˈ⫼ ḍ 䳔㽕 㞾 ⱘ䖤 ㋏㒳DŽ ˄1˅ ✻MPC08䕃ӊⱘ 㺙ℹ偸䖯㸠ℷ⹂ 㺙DŽ
˄2˅ ⹀ⲬϞ ゟϔϾ ӊ DŽ
˄3˅ MPC08 ⫼ 㺙Ⳃ Ā\MPC08SP\Demo\VBDemo\Demo1ā ӊ Ё˄ ϔϾ⼎՟ ӊ ˅ ӊ 䋱 ⹀ⲬϞ ӊ
ЁDŽ
˄4˅ VB6.0䲚 ⦃ ˈ DŽ
˄5˅ ⹂ 㒣ℷ⹂䆒㕂 䅵ㅫ ЁDŽ
˄6˅ 㓪䆥䆹 ⫳ EXE ӊDŽ
˄7˅ 䖤㸠⫳ ⱘEXE ӊDŽ
4.1.2ϬVisual C++ᓔথࠊ࣏ᑣ
˄ϔ˅ ⦃
⫼ ҹՓ⫼VC5.0 催⠜ ˈ 䖯㸠Windows ϟ䖤 ㋏㒳 DŽ
˄Ѡ˅ 䫒 䇗⫼ ⊩
VCЁ䇗⫼ 䫒 DLLЁ ϸ⾡ ⊩˖
䱤 䇗⫼
䱤 䇗⫼䳔㽕 ϟ ӊ˖
˄1˅ DLL ӊMPC.h˗
˄2˅ 㓪䆥䖲 ⫼ⱘ ӊMPC08.lib˗
MPC08䖤
˄3˅ 䫒 ӊMPC08.dll˗
˄4˅ 䆒 偅 MPC08.sys˗
ҹϞ ӊЁⱘ˄1˅˄2˅ϸ乍 MPC08 ⫼ 㺙Ⳃ Ā\MPC08SP\ Develop\VCā ӊ ϟ DŽ˄3˅ 㒣⬅ 㺙 㺙 C:\WINDOWS\ SYSTEM32 ӊ ϟDŽ˄4˅ 㒣⬅ 㺙 㺙 C:\WINDOWS\SYSTEM32\ DRIVERS ӊ ϟ˄ Windows 㺙 C:\WINDOWS ӊ ϟ˅DŽ ゟ П ˈ VC䲚 ⦃ Ё⚍ Ā/project/settings…ā㦰 Āproject settingsā 䆱ḚDŽ䗝ĀLinkā䗝乍 ˈ Āobject/library modulesā 䕧 ӊ MPC08.libˈ ĀOKā 䪂DŽ 䇗⫼DLL ⱘ⑤ҷⷕ ӊ MPC.h ӊDŽП ҹ ✻䇗⫼ 䚼 ϔḋ䇗⫼DLL DŽ ԧ 㾕ⓨ⼎⼎՟˖\Demo\VCDemo\Demo1DŽ
䇗⫼
䇗⫼ 䳔㽕 ϟ ӊ˖
˄1˅ 䫒 ӊMPC08.dll˗
˄2˅ 䆒 偅 MPC08.sysDŽ
ҹϞ ӊЁ˄1˅ 㒣⬅ 㺙 㺙 C:\WINDOWS\SYSTEM32 ӊ ϟˈ˄2˅ 㒣⬅ 㺙 㺙 C:\WINDOWS\SYSTEM32\DRIVERS ӊ ϟ˄ Windows 㺙 C:\WINDOWS ӊ ϟ˅DŽ
䇗⫼ ⊩䳔㽕䇗⫼Windows API 䕑 䞞 䫒 DŽ ⊩ ϟ˖˄1˅ 䇗⫼Windows API LoadLibrary() 䕑DLL˗
˄2˅ 䇗⫼Windows API GetProcAddress() 㽕䇗⫼ⱘDLLЁ ⱘ 䩜˗
˄3˅ ⫼ 䩜䇗⫼DLLЁ Ⳍ 㛑˗
˄4˅ 㒧 ϡ Փ⫼DLLЁ ˈ䇗⫼Windows API FreeLibrary()䞞 䫒 DŽ
䆹 ⊩↨䕗⚺⧤DŽMPC08䕃ӊЁ 㒣 ⫼ⱘMPC08.dllЁDLL 㺙 ㉏CLoadDllˈ կ䆹㉏ⱘ⑤ҷⷕDŽ䆹㉏ Ϣ䖤 Ҹ Ⳍ ⱘ DŽ⑤ҷⷕ MPC08 ⫼ 㺙Ⳃ Ā\MPC08SP\Develop\VCā ӊ ϟ ˈ ӊ ЎLoadDll.cpp LoadDll.hDŽ Ҏ ⏏ 䖯 ˈ 䗖 ⏏ 䆹㉏ⱘ 䈵ˈ䗮䖛 䇗⫼DLLЁⱘ DŽ ԧ 㾕ⓨ⼎⼎՟˖\Demo\VCDemo\Demo2DŽ
ҹϞ ϸ⾡ ⊩ ЎVCЁ䇗⫼ 䫒 ⱘ ⊩ˈ㢹㽕㦋 ԧⱘ䇗⫼ ⊩ ˈ䇋 㗗 䕃Visual Stutio ḷMSDN Ⳍ VC 㗗к㈡ЁⳌ 䚼 DŽ
4䖤 ㋏㒳ⱘ
˄ϝ˅ⓨ⼎⼎՟ ⱘՓ⫼
MPC08 ⫼ 㺙Ⳃ Ā\MPC08SP\Demo\VCDemo\ā ӊ ϟ ϝϾ VC6.0ϟ ⱘ䖤 ㋏㒳ⓨ⼎⼎՟ DŽĀ\Demo\VCDemo\Demo1āЎ䱤 䇗⫼⼎՟˗Ā\Demo\VCDemo\Demo2āЎ 䇗⫼⼎՟DŽ⫼ ✻ ϟℹ偸㓪䆥 䖤㸠⼎՟ˈ ❳ њⳌ 㓪 ⊩ ˈ⫼ ḍ 䳔㽕 㞾 ⱘ䖤 ㋏㒳DŽ˄1˅ ✻MPC08䕃ӊⱘ 㺙ℹ偸䖯㸠ℷ⹂ 㺙DŽ
˄2˅ ⹀ⲬϞ ゟϔϾ ӊ DŽ
˄3˅ MPC08 ⫼ 㺙Ⳃ Ā\MPC08SP\Demo\VCDemo\ā ӊ ϟDemo1 ӊ Ё ӊ Demo2 ӊ Ё ӊ 䋱 ⹀ⲬϞ
ӊ ЁDŽ
˄4˅ VC6.0䲚 ⦃ ˈ demo1.dsw demo2.dswDŽ
˄5˅ ⹂ 㒣ℷ⹂䆒㕂 䅵ㅫ ЁDŽ
˄6˅ 㓪䆥䖲 䆹 ⫳ EXE ӊDŽ
˄7˅ 䖤㸠⫳ ⱘEXE ӊDŽ
ˈ \Demo\VCDemo\ ӊ ϟ䖬 կњϔϾMPC08 ⌟䆩 \Demo\VCDemo\Demo3ˈ կњ 㸠 ӊˈ ⌟䆩MPC08 DŽ
MPC08䖤
5ߑ᭄ᦣẴ
ゴ䆺㒚 䗄њMPC08䖤 Ёⱘ↣ϔϾ DŽ Ёˈ ЁՓ⫼ⱘ ԡ 䖨 㑺 䗮 ϟ˖
ऩԡ
ԡ⿏˄ 䎱⾏˅ⱘ ԡЎP˄Pulse˅ˈ 㛝 ˗
䗳 ⱘ ԡ PPS˄Pulse/sec˅ˈ 㛝 /⾦˗
䗳 䗳 ⱘ ԡ PPSS˄Pulse/sec2˅ˈ 㛝 ˋ⾦2DŽ
ߑ᭄ẘಲؐ
䖤 Ёⱘ DŽϔ㠀 ϟˈ ϡ⡍⅞䇈 ˈ Ӏⱘ䖨 НЎ˖
0 㸠ℷ⹂˗
-1 㸠䫭䇃DŽ
5.1ࠊवḸ᪂าߑ᭄
䆹㉏ Џ㽕⫼Ѣ䆒㕂MPC08 ⱘՓ⫼ 䞣ǃ 䕈 ҹ ↣䕈ⱘ䕧 ˈ䗳 ǃ 䗳 ㄝⱘ䆒㕂 䇏 ㄝㄝDŽⳌ ˖
int auto_set(void)˗/*㞾 Ẕ⌟ 㞾 䆒㕂 */
int init_board˄void˅˗/* ⹀ӊ 䕃ӊ */
int get_max_axe˄void˅˗/*䇏 䕈 */
int get_board_num˄void˅˗/*䇏 */
int get_axe˄int board_no)˗/*䇏 Ϟ䕈 */
int set_outmode˄int chˈint modeˈint outlogic˅˗/*䆒㕂 䕈䕧 */
int set_home_mode˄int chˈint home_mode˅˗/*䆒㕂 ⚍ */
int set_conspeed˄int chˈdouble conspeed˅˗/*䆒㕂 䕈 䗳䖤 䗳 */
double get_conspeed˄int ch˅˗/*䇏 䕈 䗳䖤 䗳 */
int set_profile˄int chˈdouble lsˈdouble hsˈdouble acc˅˗/*䆒㕂 䕈 䗳䖤 ẃ 䗳 */
int get_profile˄int chˈdouble&lsˈdouble&hsˈdouble &acc˅˗/*䇏 䕈 䗳䖤 ẃ 䗳 */
int set_vector_conspeed˄int con_speed˅˗/*䆒㕂 䗳䖤 ⶶ䞣䗳 */
int set_vector_profile˄double vec_flˈdouble vec_fhˈdouble vec_ad˅˗
/*䆒㕂 䗳䖤 ẃ ⶶ䞣䗳 */
double get_vector_conspeed˄void˅˗/*䇏 䗳䖤 ⶶ䞣 䗳 */
int get_vector_profile˄double *vec_flˈdouble *vec_fhˈdouble *vec_ad˅˗/*䇏 䗳䖤 ⶶ䞣ẃ 䗳 */
double get_rate˄int ch˅˗/*䇏 䕈 䰙䖤 䗳 */
ߑ᭄ৡ˖auto_set
Ⳃⱘ˖⫼auto_set 㞾 Ẕ⌟MPC08 ⱘ 䞣ǃ Ϟⱘ䕈 ˈ 㞾 䆒㕂↣ MPC08 DŽ
5 䗄
䇁⊩˖int auto_set˄void˅˗
䇗⫼՟ ˖auto_set˄˅˗/*㞾 Ẕ⌟ 㞾 䆒㕂䖤 */
䗄˖ ҹ䇗⫼auto_set ⱘ 䞣ǃ䕈 ⱘ㞾 Ẕ⌟ˈ 㞾 䆒㕂䖭ѯ DŽ䆹 Ё 㛑䇗⫼ϔDŽ
䖨 ˖ 䇗⫼ ˈauto_set 䖨 䕈 ˗㢹Ẕ⌟ϡ ˈ䖨 0˗䇗⫼ 䋹䖨 䋳 DŽ
㋏㒳˖WINDOWS98ǃWINDOWS 2000ǃWINDOWS XP
⊼䞞˖
㾕˖
ߑ᭄ৡ˖init_board
Ⳃⱘ˖⫼init_board DŽ
䇁⊩˖int init_board˄void˅˗
䇗⫼՟ ˖init_board˄˅˗
䗄˖ ⫼auto_set㞾 Ẕ⌟ 䆒㕂П ˈ 乏䇗⫼init_board 䖯㸠 DŽinit_board Џ㽕 ⱘ Ͼ ǃ 䕈ⱘ㛝
䕧 ˄㛝 / ˅ǃ 䗳 ˄2000pps˅ǃẃ 䗳 ˄ 䗳2000ppsˈ
催䗳8000ppsˈ 䗳80000ppss˅ǃⶶ䞣 䗳 ˄2000pps˅ǃⶶ䞣ẃ 䗳
˄ 䗳2000ppsˈ催䗳8000ppsˈ 䗳80000ppss˅ㄝㄝDŽ䆹
Ё 㛑䇗⫼ϔDŽ
䖨 ˖ 䇗⫼ ˈinit_board 䖨 ⱘ ˗㢹Ẕ⌟ϡ ˈ䖨 0˗䋳 㸼⼎ 䫭DŽ
㋏㒳˖WINDOWS98ǃWINDOWS 2000ǃWINDOWS XP
⊼䞞˖ ϡ䇗⫼init_board ˈ ϡ㛑ℷ DŽ㢹䳔 㛝 䕧 ǃ䗳 ㄝ ˈ 䇗⫼ DŽ
㾕˖auto_set
ߑ᭄ৡ˖get_max_axe
Ⳃⱘ˖get_max_axe⫼Ѣ䇏 ⱘ 䕈 DŽ
䇁⊩˖int get_max_axe˄void˅˗
䇗⫼՟ ˖max_axe_num=get_max_axe˄˅˗
䖨 ˖get_max_axe䖨 䕈 DŽ
㋏㒳˖WINDOWS98ǃWINDOWS 2000ǃWINDOWS XP
㾕˖
ߑ᭄ৡ˖get_board_num
Ⳃⱘ˖get_board_num⫼Ѣ䇏 㺙ⱘMPC08 DŽ
䇁⊩˖int get_board_num˄void˅˗
䇗⫼՟ ˖card_num=get_board_num˄˅˗
䖨 ˖get_board_num䖨 DŽ
㋏㒳˖WINDOWS98ǃWINDOWS 2000ǃWINDOWS XP
㾕˖
ߑ᭄ৡ˖get_axe
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论