[FORM] rs232 ile haberleşme
#1
elimde rs232 bağlantılı bir terazi var burdan gelen veriyi tabloya , forma veya txt dosyasına nasıl gönderebilirim. bilgisi olan varmı acaba
şimdiden teşekürler...



  Alıntı
Bu mesajı beğenenler:
#2
Merhaba, ben network özelliği olan bir teraziden bilgi almayı başarmıştım. Ama terazinin örnek kodları vardı. Tavsiyem hyper terminal ile öncelikle terazi çıkış veriyor mu onu kontrol edin.
"Gönül deniz, dil kıyıdır. Denizde ne varsa kıyıya o vurur"



  Alıntı
Bu mesajı beğenenler:
#3
Terazinin kendi programi var onunla denedim sorunsuz calisiyor



  Alıntı
Bu mesajı beğenenler:
#4
Siz yinede hyper terminal ile com porttan bir deneme yapın. Ve ekrana gelen bilgiyi kontrol edin.
Sonrasında Formun kod sayfasına aşağıdaki kodları ekleyin.

Visual Basic
  1. Private Sub MSComm1_OnComm()
  2. Dim InBuff As String
  3.  
  4. Select Case MSComm1.CommEvent
  5. ' Handle each event or error by placing
  6. ' code below each case statement.
  7.  
  8. ' This template is found in the Example
  9. ' section of the OnComm event Help topic
  10. ' in VB Help.
  11.  
  12. ' Errors
  13. Case comEventBreak ' A Break was received.
  14. Case comEventCDTO ' CD (RLSD) Timeout.
  15. Case comEventCTSTO ' CTS Timeout.
  16. Case comEventDSRTO ' DSR Timeout.
  17. Case comEventFrame ' Framing Error.
  18. Case comEventOverrun ' Data Lost.
  19. Case comEventRxOver ' Receive buffer overflow.
  20. Case comEventRxParity ' Parity Error.
  21. Case comEventTxFull ' Transmit buffer full.
  22. Case comEventDCB ' Unexpected error retrieving DCB]
  23.  
  24. ' Events
  25. Case comEvCD ' Change in the CD line.
  26. Case comEvCTS ' Change in the CTS line.
  27. Case comEvDSR ' Change in the DSR line.
  28. Case comEvRing ' Change in the Ring Indicator.
  29. Case comEvReceive ' Received RThreshold # of chars.
  30. InBuff = MSComm1.Input
  31. Call HandleInput(InBuff)
  32. Case comEvSend ' There are SThreshold number of
  33. ' characters in the transmit buffer.
  34. Case comEvEOF ' An EOF character was found in the
  35. ' input stream.
  36. End Select
  37.  
  38. End Sub
  39.  
  40. Sub HandleInput(InBuff As String)
  41. ' This is where you will process your input. This
  42. ' includes trapping characters, parsing strings,
  43. ' separating data fields, etc. For this case, you
  44. ' are simply going to display the data in the TextBox.
  45.  
  46.  
  47. On Error GoTo HandleInput_Error
  48.  
  49. text1.SelStart = Len(text1.text)
  50. text1.SelText = InBuff
  51.  
  52.  
  53.  
  54. On Error GoTo 0
  55. Exit Sub
  56.  
  57. HandleInput_Error:
  58.  
  59. MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure HandleInput of VBA Document Form_Form2"
  60.  
  61. End Sub




Formun Yüklendiğinde olayına aşağıdaki kodu yazın.
Visual Basic
  1. Private Sub Form_Load()
  2.  
  3. ' Form1.Caption = "App2"
  4. With MSComm1
  5. .CommPort = 2
  6. .Handshaking = 2 - comRTS
  7. .RThreshold = 1
  8. .RTSEnable = True
  9. .Settings = "1200,n,8,1"
  10. .SThreshold = 1
  11. .PortOpen = True
  12. ' Leave all other settings as default values.
  13. End With
  14.  
  15. End Sub


Kaldırıldığında olayına aşağıdaki kodu,
Visual Basic
  1. Private Sub Form_Unload(Cancel As Integer)
  2. On Error GoTo Form_Unload_Error
  3.  
  4. MSComm1.PortOpen = False
  5.  
  6. On Error GoTo 0
  7. Exit Sub
  8.  
  9. Form_Unload_Error:
  10.  
  11. MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure Form_Unload of VBA Document Form_Form2"
  12. End Sub



Yukarıdaki kod sayesinde tex1 metin kutusuna terazideki değeri vermesi gerekir.Ben sertlik ölçme cihazından bu şekilde bilgi almıştım.
"Gönül deniz, dil kıyıdır. Denizde ne varsa kıyıya o vurur"



  Alıntı
Bu mesajı beğenenler:
#5
Tabi kodları kullanabilmek için MS Comm active x eklemeniz gerekiyor.
"Gönül deniz, dil kıyıdır. Denizde ne varsa kıyıya o vurur"



  Alıntı
Bu mesajı beğenenler:
#6
SAYIN dreamt ilgin için teşekürler

.CommPort = 0

bu satırda hata veriyor ne yapabilirim acaba...



  Alıntı
Bu mesajı beğenenler:


Benzer Konular...
Konu: Yazar Cevaplar: Gösterim: Son Mesaj
  Rs232 Haberleşme adnnfrm 11 1.086 28-08-2021, 21:14
Son Mesaj: adnnfrm
  [VBA] rs232 - com port bağlantı için yardım hedefkaya 2 2.309 08-10-2015, 11:28
Son Mesaj: karakabus

Foruma Git:


Bu konuyu görüntüleyen kullanıcı(lar): 1 Ziyaretçi