Jump to content
cyber

Vb6.0 Serial Communication

Recommended Posts

salam..ade sape2 tau x cm mne nk wat program pkai vb6 komunikasi ngan serial port rs232?

software ni akan send command n dapatkan feedback data serta papar kat jadual..

[img]http://img689.imageshack.us/img689/1966/clipboard01pd.jpg[/img]

Share this post


Link to post
Share on other sites
menda nih keh ?
[img]http://www.simplesat.co.uk/images/rs%20232.jpg[/img]

[code] Private Sub Form_Load()
Form1.Caption = "App1"
With MSCOMM1
.Handshaking = 2 - comRTS
.RThreshold = 1
.RTSEnable = True
.Settings = "9600,n,8,1"
.SThreshold = 1
.PortOpen = True
' Leave all other settings as default values.
End With
Command1.Caption = "&Send"
Text1.Text = "Test string from App1 "
End Sub

Private Sub Command1_Click()
MSComm1.Output = Text1.Text
End Sub

Private Sub Form_Unload(Cancel As Integer)
MSComm1.PortOpen = False
End Sub[/code]



[code]Private Sub Form_Load()
Form1.Caption = "App2"
With MSComm1
.CommPort = 2
.Handshaking = 2 - comRTS
.RThreshold = 1
.RTSEnable = True
.Settings = "9600,n,8,1"
.SThreshold = 1
.PortOpen = True
' Leave all other settings as default values.
End With
Text1.Text = ""
End Sub

Private Sub Form_Unload(Cancel As Integer)
MSComm1.PortOpen = False
End Sub

Private Sub MSComm1_OnComm()
Dim InBuff As String

Select Case MSComm1.CommEvent
' Handle each event or error by placing
' code below each case statement.

' This template is found in the Example
' section of the OnComm event Help topic
' in VB Help.

' Errors
Case comEventBreak ' A Break was received.
Case comEventCDTO ' CD (RLSD) Timeout.
Case comEventCTSTO ' CTS Timeout.
Case comEventDSRTO ' DSR Timeout.
Case comEventFrame ' Framing Error.
Case comEventOverrun ' Data Lost.
Case comEventRxOver ' Receive buffer overflow.
Case comEventRxParity ' Parity Error.
Case comEventTxFull ' Transmit buffer full.
Case comEventDCB ' Unexpected error retrieving DCB]

' Events
Case comEvCD ' Change in the CD line.
Case comEvCTS ' Change in the CTS line.
Case comEvDSR ' Change in the DSR line.
Case comEvRing ' Change in the Ring Indicator.
Case comEvReceive ' Received RThreshold # of chars.
InBuff = MSComm1.Input
Call HandleInput(InBuff)
Case comEvSend ' There are SThreshold number of
' characters in the transmit buffer.
Case comEvEOF ' An EOF character was found in the
' input stream.
End Select

End Sub

Sub HandleInput(InBuff As String)
' This is where you will process your input. This
' includes trapping characters, parsing strings,
' separating data fields, etc. For this case, you
' are simply going to display the data in the TextBox.
Text1.SelStart = Len(Text1.Text)
Text1.SelText = InBuff
End Sub[/code]

# http://support.microsoft.com/kb/194922

Share this post


Link to post
Share on other sites
[quote name='cyber' timestamp='1298003858' post='1062370']
salam..ade sape2 tau x cm mne nk wat program pkai vb6 komunikasi ngan serial port rs232?

software ni akan send command n dapatkan feedback data serta papar kat jadual..

[/quote]
ko buat fyp ke?

Share this post


Link to post
Share on other sites
[img]http://www.simplesat.co.uk/images/rs%20232.jpg[/img]

benda ni la.. :lol:
coding tu untuk rs232 je kan..klau nk display data yg diterima dari rs232 dan papar dekat table frexgrid 2 cm mne ye?


[quote name='NeoLogy' timestamp='1298096773' post='1062442']
ko buat fyp ke?
[/quote]
fyp tu ape ye? xfhm

program ni ade dua button..cuma xletak je lg :lol:
satu read & satu lg program

bila read di tekan.. dia akan send data (byte / 8bit) lepas 2 tunggu feedback data (120byte) n store dlm table flexgrid...
bila prog di tekan.. dia akan send data (byte / 8bit) diikuti 120 byte data dalam table flexgrid

susah btul nk wat vb ni klau xde basic..huhu

Share this post


Link to post
Share on other sites
[quote name='masokis' timestamp='1298768772' post='1063350']
FYP = Final year pojek :P
nak baca input apa ni ?
[/quote]

oo..xde la..ni projek sndri..
blajar pun cos len :3:

baca input dari serial comm port..dh jd pun..
skrg ni nak isi data kat dalam kotak..nombor msti dlm 0.25 increment/decrement..
cm mne nk wat coding ye?

lg satu masalah coding untuk read data dari serial, klau xde data yg diterima, software ni looping smpai hang
cm mne ye nk elak benda ni? cm mne klau nk wat "time out, data not receive"..pastu skip untuk read serial

[img]http://img821.imageshack.us/img821/3021/vbprogram.jpg[/img] Edited by cyber

Share this post


Link to post
Share on other sites
ko gune teknik 'check event'

[code]
Private Sub MSComm1_OnComm()
Dim InBuff As String

Select Case MSComm1.CommEvent
Case comEvReceive ' Received RThreshold # of chars.'
InBuff = MSComm1.Input
' your code here -- InBuff is your input value'
End Select
End Sub
[/code]

bergantung pada setting..ko bleh set buffer untuk terima certain number of character sblm event comEvReceive raised..selagi buffer tak penuh..comEvReceive xkan raised.. Edited by NeoLogy

Share this post


Link to post
Share on other sites
[quote name='NeoLogy' timestamp='1298832322' post='1063479']
ko gune teknik 'check event'

[code]
Private Sub MSComm1_OnComm()
Dim InBuff As String

Select Case MSComm1.CommEvent
Case comEvReceive ' Received RThreshold # of chars.'
InBuff = MSComm1.Input
' your code here -- InBuff is your input value'
End Select
End Sub
[/code]

bergantung pada setting..ko bleh set buffer untuk terima certain number of character sblm event comEvReceive raised..selagi buffer tak penuh..comEvReceive xkan raised..
[/quote]

oo..ok2..ade masa nnti try code ni plak..
lagi satu cm mne ye nk wat graf carta garis? sbb tgk kat component mschart xcantik..bleh ke nk ubah jd lebih cantik? mcm graph kat vb.net :3:

Share this post


Link to post
Share on other sites
Huyoh.. programkan CDI?...

cyber, ko ni pakar permotoran ke? kalo dah siap nanti, boleh la share code ni untuk orang lain belajar pulak... boleh ke?

Share this post


Link to post
Share on other sites
[quote name='ApOgEE' timestamp='1299119658' post='1063823']
Huyoh.. programkan CDI?...

cyber, ko ni pakar permotoran ke? kalo dah siap nanti, boleh la share code ni untuk orang lain belajar pulak... boleh ke?
[/quote]

ye..program cdi..insyaAllah nnti siap aku pos kat cni :)
skrg stop dlu..bz wat benda len..huhu

link code separuh siap
[URL=http://hotfile.com/dl/110194751/448f5f6/CDI_Programmer.zip.html]http://hotfile.com/dl/110194751/448f5f6/CDI_Programmer.zip.html[/URL]

Share this post


Link to post
Share on other sites
[quote name='cyber' timestamp='1300107940' post='1064817']
ye..program cdi..insyaAllah nnti siap aku pos kat cni :)
skrg stop dlu..bz wat benda len..huhu

link code separuh siap
[URL=http://hotfile.com/dl/110194751/448f5f6/CDI_Programmer.zip.html]http://hotfile.com/dl/110194751/448f5f6/CDI_Programmer.zip.html[/URL]
[/quote]

Cool... terima kasih kerana berkongsi.

Ini DIY CDI ke, atau yang dah sedia ada? Untuk motor apa ni? Motor 125z aku boleh masuk tak? Boleh share sumber CDI yang programmable ni?

Share this post


Link to post
Share on other sites
[quote name='ApOgEE' timestamp='1300113034' post='1064833']
Cool... terima kasih kerana berkongsi.

Ini DIY CDI ke, atau yang dah sedia ada? Untuk motor apa ni? Motor 125z aku boleh masuk tak? Boleh share sumber CDI yang programmable ni?
[/quote]

DIY CDI...klau std sdi mmg xleh program pkai software ni..boleh tgk kat link forum MBC di bawah..
test kat 135LC..klau magnet n pickup sensor 125z same ngn 135lc, bleh nk pakai..
biasenye setiap moto lebih kurang je.. :D

http://malaysianbikers.com.my/forum/index.php/topic,77147.0.html

Share this post


Link to post
Share on other sites
[quote name='cyber' timestamp='1300429421' post='1065102']
DIY CDI...klau std sdi mmg xleh program pkai software ni..boleh tgk kat link forum MBC di bawah..
test kat 135LC..klau magnet n pickup sensor 125z same ngn 135lc, bleh nk pakai..
biasenye setiap moto lebih kurang je.. :D

http://malaysianbikers.com.my/forum/index.php/topic,77147.0.html
[/quote]

Wow, cool... terima kasih!

Share this post


Link to post
Share on other sites
jap aku x paham.

cdi ani ada serial port ke?

mcm mn ko cucuk dr serial port komputer ke serial port cdi tu?

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...