Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

serial communication - help please

Status
Not open for further replies.

nikmast

Programmer
Feb 17, 2005
5
NZ
Hi, I need help with visual basic 6 program or hardware of plc. I am trying to get vb6 program to read serial port that my plc s7-200 CPU 222 is conected to. I can not get the program to read anything at all. My code is (in vb6):


Private Sub cmdOpen_Click()
'opening the serial port

If MSComm1.PortOpen = False Then
MSComm1.CommPort = 1
MSComm1.Settings = "9600, N, 8, 1"
MSComm1.InputLen = 0 'to read the whole input buffer
MSComm1.PortOpen = True
MSComm1.Handshaking = comXOnXoff
Else
MsgBox "Connection has already been established", vbInformation, "Port opened"
End If

End Sub


Private Sub cmdDisplay_Click()
'to display the data from the receive buffer

MSComm1.InputMode = comInputModeBinary
txtDisplay.Text = MSComm1.Input
txtCharacters.Text = MSComm1.InBufferCount

End Sub

Please if anybody can tell me what is wrong with my code or give me a code that works, if posible a basic code (begginer) I would be very, very gratfull. If the code is ok, is there a problem with my connection with the plc, but I can download a code to a plc fine with the step7 template and also monitor the program how it works with the step7 program, so I do not think it is a hrdware/connection problem.


Do I have to tell or use some kind of comand (code) to make the plc to send me the information through the serial port.


Thank you.
 
You will have a better chance at an answer if this is posted in the right forum.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top