Visual Basic Code , VB.NET Code, VB Code
  Home   :  Code   :  Forums   :  Submit   :  Mailing List   :  About   :  Contact


Serial Port


Serial Port

Author
Message
mvPradeepemb
mvPradeepemb
Forum God
Forum God (12K reputation)Forum God (12K reputation)Forum God (12K reputation)Forum God (12K reputation)Forum God (12K reputation)Forum God (12K reputation)Forum God (12K reputation)Forum God (12K reputation)Forum God (12K reputation)

Group: Forum Members
Posts: 46, Visits: 85
 I am using RS232 IC to interface between the controller (ATmega16) and the PC.... I communicated only threw serial port and not the USB port.... Now i cant receive any data's from the port, but the port is opened and closed successfully by both VB and Serial Port Access software (LOOKRS 232).... Should i alter my code

Option Explicit
Private Sub Form_Load()

       MSComm1.Settings = "9600,N,8,1"
       MSComm1.CommPort = 1
       MSComm1.InputLen = 1
       MSComm1.PortOpen = True
       MSComm1.RThreshold = 1
       MSComm1.InputMode = comInputModeText
      

End Sub
   

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

End Sub


Private Sub MSComm1_OnComm()
      Dim InBuffer As String     

      InBuffer = MSComm1.Input
      If MSComm1.CommEvent = comEvReceive Then
      Text1.Text = Text1.Text & InBuffer
      End If
End Sub



CDRIVE
CDRIVE
Forum God
Forum God (103K reputation)Forum God (103K reputation)Forum God (103K reputation)Forum God (103K reputation)Forum God (103K reputation)Forum God (103K reputation)Forum God (103K reputation)Forum God (103K reputation)Forum God (103K reputation)

Group: Forum Members
Posts: 548, Visits: 2.6K
Well, you can't Dim the InBuffer As String when (InputMode = Binary) receiving Byte data. It must be declared as a Variant. But before we go there I'm concerned that something happen to your circuit because it will no longer respond to the LOOKRS 232 software either. While your troubleshooting that problem I will work up a solution to your Binary input. Do you have a Loopback Tester? We can use it to test the port to see if it got fried. If it tests OK then the controller or the Max232 may have gone west. Are you using any electromagnetic relays in this circuit?

________________________________________________________________ 

"So much to learn. So little time to do it. Wise men know it's later than one thinks"!

Mark's Syntax.Zip    Pause Sub

I don't answer programming questions via PMs. That's what the forum is for! 

mvPradeepemb
mvPradeepemb
Forum God
Forum God (12K reputation)Forum God (12K reputation)Forum God (12K reputation)Forum God (12K reputation)Forum God (12K reputation)Forum God (12K reputation)Forum God (12K reputation)Forum God (12K reputation)Forum God (12K reputation)

Group: Forum Members
Posts: 46, Visits: 85
No, my circuit does not contain any electromagnatic relay.....  The serial  port fails in the  LOOPBACK tester method, but i should try with other system.... If port fired any option to recover it....   
CDRIVE
CDRIVE
Forum God
Forum God (103K reputation)Forum God (103K reputation)Forum God (103K reputation)Forum God (103K reputation)Forum God (103K reputation)Forum God (103K reputation)Forum God (103K reputation)Forum God (103K reputation)Forum God (103K reputation)

Group: Forum Members
Posts: 548, Visits: 2.6K
mvPradeepemb (11/8/2008)
No, my circuit does not contain any electromagnatic relay.....  The serial  port fails in the  LOOPBACK tester method, but i should try with other system.... If port fired any option to recover it....   

Please post the code that you used with the Loopback tester. If the PC is a desktop then replacing the serial port card won't be a big hassle, or that expensive. If it's a Laptop I don't know what it will entail. It will probably depend on the brand.

There's an irony here. When I first received this XP laptop I was upset when I discovered that it had no serial ports but has a sh_t load of USB ports. It bristles with them like an Iowa class Battle Ship! As it turns out the USB/Serial dongles work great and add a high degree of protection to the PC. This is because errant wiring to an external device will more than likely fry the dongle and not the port. 

________________________________________________________________ 

"So much to learn. So little time to do it. Wise men know it's later than one thinks"!

Mark's Syntax.Zip    Pause Sub

I don't answer programming questions via PMs. That's what the forum is for! 

CDRIVE
CDRIVE
Forum God
Forum God (103K reputation)Forum God (103K reputation)Forum God (103K reputation)Forum God (103K reputation)Forum God (103K reputation)Forum God (103K reputation)Forum God (103K reputation)Forum God (103K reputation)Forum God (103K reputation)

Group: Forum Members
Posts: 548, Visits: 2.6K
Here's a basic Loopback routine. All other MSComm properties are left at their default values.

Option Explicit

Private Sub Form_Load()
   Command2.Enabled = False
   Command1.Caption = "Output"
   Command2.Caption = "Input"
End Sub

Private Sub Command1_Click()
   Text1.Text = ""
   MSComm1.CommPort = 1
   MSComm1.PortOpen = True
   MSComm1.Output = "Loop back test"
   Command2.Enabled = True
End Sub

Private Sub Command2_Click()
   Text1.Text = MSComm1.Input
   MSComm1.PortOpen = False
   Command2.Enabled = False
End Sub




________________________________________________________________ 

"So much to learn. So little time to do it. Wise men know it's later than one thinks"!

Mark's Syntax.Zip    Pause Sub

I don't answer programming questions via PMs. That's what the forum is for! 

Edited
11/8/2008 by CDRIVE
mvPradeepemb
mvPradeepemb
Forum God
Forum God (12K reputation)Forum God (12K reputation)Forum God (12K reputation)Forum God (12K reputation)Forum God (12K reputation)Forum God (12K reputation)Forum God (12K reputation)Forum God (12K reputation)Forum God (12K reputation)

Group: Forum Members
Posts: 46, Visits: 85
I didnt use VB code for LOOPBACK test, but i used windows method as follows:

* Shorting the RX and TX pin of the Serial Port.

* Start-Program-Accessories-Communication-Hyperterminal

* Testing the Port by typing some text in that Hyperterminal Screen.

* If Port works then the typed message will be seen in that screen...

But the text doesnt displayed....

   Thanks for your code.... Now i will test with VB code and give my feedback...

mvPradeepemb
mvPradeepemb
Forum God
Forum God (12K reputation)Forum God (12K reputation)Forum God (12K reputation)Forum God (12K reputation)Forum God (12K reputation)Forum God (12K reputation)Forum God (12K reputation)Forum God (12K reputation)Forum God (12K reputation)

Group: Forum Members
Posts: 46, Visits: 85
I also tested using the VB code, by shorting RX and TX pin, but text box remains empty.... 
CDRIVE
CDRIVE
Forum God
Forum God (103K reputation)Forum God (103K reputation)Forum God (103K reputation)Forum God (103K reputation)Forum God (103K reputation)Forum God (103K reputation)Forum God (103K reputation)Forum God (103K reputation)Forum God (103K reputation)

Group: Forum Members
Posts: 548, Visits: 2.6K
mvPradeepemb (11/9/2008)
I also tested using the VB code, by shorting RX and TX pin, but text box remains empty.... 

Things are not looking good here. You're probably going to have to replace the Serial Card. If it won't loop back on either Hyperterm or MSComm you must have killed it. I can't imagine what you did to fry it though. When you get a new card post back here and I will give you some safety tips to live by when hooking home brew circuits to the serial port. Also, if your going to do much RS232 work you may want to consider replacing the bad board with one with multiple ports.

________________________________________________________________ 

"So much to learn. So little time to do it. Wise men know it's later than one thinks"!

Mark's Syntax.Zip    Pause Sub

I don't answer programming questions via PMs. That's what the forum is for! 

CDRIVE
CDRIVE
Forum God
Forum God (103K reputation)Forum God (103K reputation)Forum God (103K reputation)Forum God (103K reputation)Forum God (103K reputation)Forum God (103K reputation)Forum God (103K reputation)Forum God (103K reputation)Forum God (103K reputation)

Group: Forum Members
Posts: 548, Visits: 2.6K
I forgot to ask... Does the DTR change state when you open the port? It should light the DTR LED on the Loopback tester.

Option Explicit

Private Sub Form_Load()
   MSComm1.CommPort = 1
   MSComm1.DTREnable = True
   MSComm1.PortOpen = True
End Sub



________________________________________________________________ 

"So much to learn. So little time to do it. Wise men know it's later than one thinks"!

Mark's Syntax.Zip    Pause Sub

I don't answer programming questions via PMs. That's what the forum is for! 

mvPradeepemb
mvPradeepemb
Forum God
Forum God (12K reputation)Forum God (12K reputation)Forum God (12K reputation)Forum God (12K reputation)Forum God (12K reputation)Forum God (12K reputation)Forum God (12K reputation)Forum God (12K reputation)Forum God (12K reputation)

Group: Forum Members
Posts: 46, Visits: 85
Ya the state is changing when the port is open....
GO


Similar Topics


Reading This Topic


Login
Existing Account
Email Address:


Password:


Social Logins

Select a Forum....

















A1VBCode Forums


Search