真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

vb.net上位機(jī)實(shí)例的簡(jiǎn)單介紹

用vb編寫一個(gè)上位機(jī)界面,關(guān)于指令的發(fā)送

LZ:你的想法是行的通的。1字節(jié)BYTE其值在0-255間,寫成2進(jìn)制的字符串形式為00000000-11111111

10年的萬(wàn)源網(wǎng)站建設(shè)經(jīng)驗(yàn),針對(duì)設(shè)計(jì)、前端、開(kāi)發(fā)、售后、文案、推廣等六對(duì)一服務(wù),響應(yīng)快,48小時(shí)及時(shí)工作處理。成都營(yíng)銷網(wǎng)站建設(shè)的優(yōu)勢(shì)是能夠根據(jù)用戶設(shè)備顯示端的尺寸不同,自動(dòng)調(diào)整萬(wàn)源建站的顯示方式,使網(wǎng)站能夠適用不同顯示終端,在瀏覽器中調(diào)整網(wǎng)站的寬度,無(wú)論在任何一種瀏覽器上瀏覽網(wǎng)站,都能展現(xiàn)優(yōu)雅布局與設(shè)計(jì),從而大程度地提升瀏覽體驗(yàn)。創(chuàng)新互聯(lián)公司從事“萬(wàn)源網(wǎng)站設(shè)計(jì)”,“萬(wàn)源網(wǎng)站推廣”以來(lái),每個(gè)客戶項(xiàng)目都認(rèn)真落實(shí)執(zhí)行。

事實(shí)上每BIT可代表1個(gè)項(xiàng)目的signal狀態(tài),開(kāi)或關(guān)。

你可進(jìn)行BIT運(yùn)算,來(lái)判斷某BIT是0或1從而發(fā)送控制信號(hào)。

具體的進(jìn)制轉(zhuǎn)換可參閱下列鏈接:

能給我發(fā)個(gè)VB與三菱PLC通訊的源代碼實(shí)例嗎,非常感謝啊

得說(shuō)明是什么型號(hào)的PLC啊,串口還是網(wǎng)口,VB6還是VB.NET?

算了,寫段代碼,VB.NET與Q系列以太網(wǎng)通訊的:

Imports?System.Net

Imports?System.Runtime.InteropServices

Public?Class?Form1

Dim?Handle1?As?Int32

Dim?EntLink1?As?Boolean

Dim?ScanCount1?As?Long

Dim?PLC?As?New?EntQsPlc_Asc.PlcClient'EntQsPlc_ASC.DLL是Q系列以太網(wǎng)通訊組件

Public?Declare?Function?timeGetTime?Lib?"winmm.dll"?()?As?UInt32

Private?Sub?Form1_Load(ByVal?sender?As?System.Object,?ByVal?e?As?System.EventArgs)?Handles?MyBase.Load

Me.CenterToScreen()

cmbReadMry.Items.Clear()

cmbReadMry.Items.Add("X")

cmbReadMry.Items.Add("Y")

cmbReadMry.Items.Add("M")

cmbReadMry.Items.Add("D")

cmbReadMry.Items.Add("R")

cmbReadMry.Items.Add("Z")

'

cmbWriteMry.Items.Clear()

cmbWriteMry.Items.Add("X")

cmbWriteMry.Items.Add("Y")

cmbWriteMry.Items.Add("M")

cmbWriteMry.Items.Add("D")

cmbWriteMry.Items.Add("R")

cmbWriteMry.Items.Add("Z")

'

cmbBitMry.Items.Clear()

cmbBitMry.Items.Add("X")

cmbBitMry.Items.Add("Y")

cmbBitMry.Items.Add("M")

'

cmbReadType.Items.Clear()

cmbReadType.Items.Add("INT16")

cmbReadType.Items.Add("UINT16")

cmbReadType.Items.Add("DINT32")

cmbReadType.Items.Add("HEX32")

cmbReadType.Items.Add("REAL32")

cmbReadType.Items.Add("BIN16")

'

cmbWriteType.Items.Clear()

cmbWriteType.Items.Add("INT16")

cmbWriteType.Items.Add("UINT16")

cmbWriteType.Items.Add("DINT32")

cmbWriteType.Items.Add("HEX32")

cmbWriteType.Items.Add("REAL32")

cmbWriteType.Items.Add("BIN16")

cmbReadMry.SelectedIndex?=?3

cmbWriteMry.SelectedIndex?=?3

cmbBitMry.SelectedIndex?=?2

cmbReadType.SelectedIndex?=?0

cmbWriteType.SelectedIndex?=?0

lstRead.Items.Clear()

txtWrite.Text?=?""

'

cmbCmdType.SelectedIndex?=?0

End?Sub

Private?Sub?butLink_Click(ByVal?sender?As?System.Object,?ByVal?e?As?System.EventArgs)?Handles?butLink.Click

Dim?re?As?Short

Dim?restr?As?String?=?""

re?=?PLC.EntLink(Trim(txtLocalIP.Text),?Val(txtLocalPort.Text),?Trim(txtRemoteIP.Text),?Val(txtRemotePort.Text),?"DEMO",?Handle1,?1000,?CBool(cmbCmdType.SelectedIndex))

txtReLink.Text?=?re.ToString

If?re?=?0?Then

EntLink1?=?True

MsgBox("PLC聯(lián)接成功!?")

Else

EntLink1?=?False

MsgBox("PLC聯(lián)接失敗:?"??restr)

End?If

End?Sub???????????

Private?Sub?butClose_Click(ByVal?sender?As?System.Object,?ByVal?e?As?System.EventArgs)?Handles?butClose.Click

Dim?re?As?Short

If?Not?EntLink1?Then

MsgBox("還未與PLC建立聯(lián)接!")

Exit?Sub

End?If

re?=?PLC.DeLink(Handle1)

txtReClose.Text?=?re.ToString

End?Sub

Private?Sub?butRead_Click(ByVal?sender?As?System.Object,?ByVal?e?As?System.EventArgs)?Handles?butRead.Click

Dim?re?As?Short

Dim?i?As?Short

Dim?RD()?As?Object

ReDim?RD(Val(txtReadCnt.Text?-?1))

If?Not?EntLink1?Then

MsgBox("還未與PLC建立聯(lián)接!")

'?Exit?Sub

End?If

Dim?mry?As?EntQsPlc_Asc.PlcClient.PlcMemory?=?cmbReadMry.SelectedIndex?+?1

Dim?typ?As?EntQsPlc_Asc.PlcClient.DataType?=?cmbReadType.SelectedIndex?+?1

re?=?PLC.CmdRead(Handle1,?mry,?typ,?CInt(txtReadAdd.Text),?CUShort(txtReadCnt.Text),?RD)

txtReRead.Text?=?re.ToString

lstRead.Items.Clear()

For?i?=?0?To?UBound(RD)?Step?1

If?Not?IsNothing(RD(i))?Then?lstRead.Items.Add(RD(i))

Next?i

If?re??0?Then

Timer1.Enabled?=?False

butScan.Text?=?"Cycle?R/W"

End?If

End?Sub

Private?Sub?butWrite_Click(ByVal?sender?As?System.Object,?ByVal?e?As?System.EventArgs)?Handles?butWrite.Click

Dim?re?As?Short

Dim?i?As?Short

Dim?temp()?As?String

Dim?WD()?As?Object

If?Not?EntLink1?Then

MsgBox("還未與PLC建立聯(lián)接!")

Exit?Sub

End?If

ReDim?WD(Val(txtWriteCnt.Text)?-?1)

temp?=?Split(txtWrite.Text,?vbCrLf)

For?i?=?0?To?UBound(WD)?Step?1

If?i??UBound(temp)?Then

WD(i)?=?0

Else

WD(i)?=?Trim(temp(i))

End?If

Next?i

Dim?mry?As?EntQsPlc_Asc.PlcClient.PlcMemory?=?cmbWriteMry.SelectedIndex?+?1

Dim?typ?As?EntQsPlc_Asc.PlcClient.DataType?=?cmbWriteType.SelectedIndex?+?1

re?=?PLC.CmdWrite(Handle1,?mry,?typ,?CInt(txtWriteAdd.Text),?CUShort(txtWriteCnt.Text),?WD)

txtReWrite.Text?=?re.ToString

If?re??0?Then

Timer1.Enabled?=?False

butScan.Text?=?"Cycle?R/W"

End?If

End?Sub

Private?Sub?butScan_Click(ByVal?sender?As?System.Object,?ByVal?e?As?System.EventArgs)?Handles?butScan.Click

If?Not?EntLink1?Then

MsgBox("還未與PLC建立聯(lián)接!")

Exit?Sub

End?If

Timer1.Enabled?=?Not?Timer1.Enabled

If?Timer1.Enabled?Then

ScanCount1?=?0

butScan.Text?=?"Stop?R/W"

Else

butScan.Text?=?"Cycle?R/W"

End?If

End?Sub

Private?Sub?Timer1_Tick(ByVal?sender?As?System.Object,?ByVal?e?As?System.EventArgs)?Handles?Timer1.Tick

Timer1.Enabled?=?False

Dim?tim?As?Integer?=?timeGetTime

If?Not?EntLink1?Then

MsgBox("還未與PLC建立聯(lián)接!")

Exit?Sub

End?If

'

Call?butRead_Click(Nothing,?Nothing)

Call?butWrite_Click(Nothing,?Nothing)

'

If?(Val(txtReRead.Text)??0)?Or?(Val(txtReWrite.Text)??0)?Then

butScan.Text?=?"Cycle?R/W"

Exit?Sub

Else

ScanCount1?+=?1

txtScanCnt.Text?=?ScanCount1

txtScanPrd.Text?=?(timeGetTime?-?tim)??"ms"

End?If

Timer1.Enabled?=?True

End?Sub

Private?Sub?butBitTest_Click(ByVal?sender?As?System.Object,?ByVal?e?As?System.EventArgs)?Handles?butBitTest.Click

If?Not?EntLink1?Then

MsgBox("還未與PLC建立聯(lián)接!")

Exit?Sub

End?If

Dim?rd?As?Boolean

Dim?re?As?Short

Dim?mry?As?EntQsPlc_Asc.PlcClient.PlcMemory?=?cmbBitMry.SelectedIndex?+?1

re?=?PLC.Bit_Test(Handle1,?mry,?CUShort(txtBitAdd.Text),?rd)

txtBitTest.Text?=?rd

txtReBit.Text?=?re

End?Sub

Private?Sub?butBitSet_Click(ByVal?sender?As?System.Object,?ByVal?e?As?System.EventArgs)?Handles?butBitSet.Click

If?Not?EntLink1?Then

MsgBox("還未與PLC建立聯(lián)接!")

Exit?Sub

End?If

Dim?re?As?Short

re?=?PLC.Bit_Set(Handle1,?cmbBitMry.SelectedIndex?+?1,?Val(txtBitAdd.Text))

txtReBit.Text?=?re

End?Sub

Private?Sub?butBitRst_Click(ByVal?sender?As?System.Object,?ByVal?e?As?System.EventArgs)?Handles?butBitRst.Click

If?Not?EntLink1?Then

MsgBox("還未與PLC建立聯(lián)接!")

Exit?Sub

End?If

Dim?re?As?Short

re?=?PLC.Bit_Reset(Handle1,?cmbBitMry.SelectedIndex?+?1,?Val(txtBitAdd.Text))

txtReBit.Text?=?re

End?Sub

End?Class

VB.NET中如何處理串口通信接收的數(shù)據(jù)?

你可以預(yù)先約定一個(gè)截止附,讀取的字節(jié)統(tǒng)統(tǒng)放到緩存區(qū)里,直到讀到截止附再處理、顯示。

現(xiàn)在在開(kāi)發(fā)一個(gè)上位機(jī)應(yīng)用程序,使用vs2008中的vb.net開(kāi)發(fā)基于wince的應(yīng)用程序,實(shí)現(xiàn)對(duì)串口采集過(guò)來(lái)的數(shù)據(jù)

這是我配置vs2005的模擬器,你參考一下吧。

1. 在VS2005里新建項(xiàng)目中時(shí),選擇創(chuàng)建Platform builder for CE 6.0的OS Design,新項(xiàng)目可以自

命名,這里命名為“MyEmulator”。

2. 創(chuàng)建MyEmulator的向?qū)е校珺SP一定要選擇“Device Emulator: ARMV4I”,下一步;

3. 模板(Design Templates)選擇“PDA Device”,下一步;

4. 選擇“Mobile Handheld”,下一步;

5. 應(yīng)用程序(Application Media)就隨自己的需要選擇,下一步;

6. 網(wǎng)絡(luò)和通信(Networking Communications)在此只選擇“Local Area Network(LAN)”,下一步;

7. 選擇完成;

8. 選擇Acknowledge;

到此工程建完;

四.添加組件(可以根據(jù)需要添加,這里主要添加漢字相關(guān)的組件)

(1) 添加漢字字庫(kù)(這里要記得加入,很多人這里沒(méi)有加入,就出現(xiàn)漢字只看到方框的現(xiàn)象):

1. 在Catalog View添加“Core OS”--“CEBASE”--“International”--“Locale Specific support”--“Chinese (Simplified)”--“Fonts”--“SimSun NSimSum(choose 1)”--“SimSun NSimSun”或者“SimSum NSimSun (Subset 2_50)”;

2. 在Catalog View添加“Core OS”--“CEBASE”--“International”--“Locale Specific support”--“Chinese (Simplified)”--“GB18030 Data Vonverter”和“Monotype Imaging AC3 Font Compression”;

(2)添加中文輸入法:

在Catalog View添加“Core OS”--“CEBASE”--“International”--“Locale Specific support”--“Chinese (Simplified)”--“Input Method Editor”--“MSPY 3.0 for Windows Embedded CE”;

(3) VS2005中菜單“項(xiàng)目”--“MyEmulator(項(xiàng)目名)屬性”,配置選擇“所有配置”,配置屬性--“Build Options”,在“Build Options”中去掉“Enable KITL (no IMGNOKITL=1)” (這里如果加入了KITL功能的話,可能在模擬器運(yùn)行的時(shí)候,會(huì)一直是黑屏的);

(4) “Locale”中,Locales先Clear All,然后選擇“中文(中國(guó))”,Default local選擇“中文(中國(guó))”;

(5) 運(yùn)行VS2005菜單“生成”--“生成MyEmulator”;

五.構(gòu)建SDK:

1. 運(yùn)行VS2005菜單“項(xiàng)目”--“Add New SDK…”,在SDK屬性頁(yè)中填寫必要的信息,屬性“Emulation”中Configuration 選擇Debug,可以設(shè)置模擬器的顯示屏大小及色深,還有內(nèi)存大小,在此設(shè)置為240 x 320,16色深,128M內(nèi)存,然后“應(yīng)用”,“確定”。。

2. 然后運(yùn)行VS2005菜單“生成”--“Build All SDK…”,順利的話,就會(huì)在%WINCEROOT\OSDesigns\ \MyEmulator\MyEmulator\SDKs\SDK1\MSI\下會(huì)有MyEmulator.msi;

六.配置VS2005:

1、先安裝生成好的MyEmulator.msi。運(yùn)行Visual Studio 2005,選擇菜單“工具->選項(xiàng)”,打開(kāi)選項(xiàng)設(shè)置對(duì)話框,從左邊的樹(shù)型列表中選擇“設(shè)備工具->設(shè)備”,右邊的下拉列表框拉到底可以看到 “MyEmulator”,這就是剛剛生成的那個(gè)模擬器。下面的設(shè)備列表里有兩項(xiàng),雙擊MyEmulator,設(shè)定傳輸為DMA傳輸,再點(diǎn)擊“仿真器選 項(xiàng)”,在“顯示”選項(xiàng)卡里設(shè)定好模擬器屏幕尺寸,顏色深度等,全部保存。

2、用VS2005新建一個(gè)智能設(shè)備項(xiàng)目,向?qū)нx擇平臺(tái)時(shí),先刪除Pocket PC 2003,選擇MyEmulator,完成。然后按F5運(yùn)行程序,順利的話定制的模擬器就會(huì)出來(lái)了(不過(guò)這個(gè)過(guò)程比較慢,需要等待一段時(shí)間)。

你好,我想用VB做一個(gè)上位機(jī),來(lái)控制PLC,然后再實(shí)現(xiàn)控制步進(jìn)電機(jī)和氣缸

下位機(jī)是誰(shuí)寫的?讓他幫你就好了。

上位機(jī)和下位機(jī)從來(lái)都是一塊兒調(diào)的,離了誰(shuí)都不行。

VB.NET做上位機(jī) serialport控件問(wèn)題

要用委托的形式(界面上拖一個(gè)txt_Rect文本框)

Delegate?Sub?SetTextCallback(ByVal?InputString?As?String)

Private?Sub?ShowString(ByVal?comData?As?String)

txt_Rect.Text?+=?comData???'將收到的數(shù)據(jù)入接收文字框中

txt_Rect.SelectionStart?=?txt_Rect.Text.Length

txt_Rect.ScrollToCaret()

End?Sub

Private?Sub?SerialPort1_DataReceived(ByVal?sender?As?Object,?ByVal?e?As?System.IO.Ports.SerialDataReceivedEventArgs)?Handles?SerialPort1.DataReceived

Dim?inData?As?String?=?SerialPort1.ReadExisting

Dim?d?As?New?SetTextCallback(AddressOf?ShowString)

BeginInvoke(d,?inData)

End?Sub


網(wǎng)頁(yè)題目:vb.net上位機(jī)實(shí)例的簡(jiǎn)單介紹
本文鏈接:http://weahome.cn/article/hpsjhg.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部