Jump to content

Recommended Posts

Posted
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. Thank you.

Posted
you should use MSComm1_OnComm event that occure when you receive something on the com... i think the other parameters are fine... i have no time today to write a basic code... tell us i you still have problem...
Posted
Hi. Thank you for your replays, and your help, thanks for offering Delphi code but I don't know how to use this code. I tried with the MSComm1_OnComm but it still doesn’t work, please advise.
Posted
Is your RS232 port on the S7 200 well initialize? (9600,8N,1 )? You rthreashold property of mscomm1 is to 0? the handshaking on the plc is xon xoff? (like in your code?) ...
Posted (edited)
X_GET and XPUT comm blocks work in MPI protocol or by its subset PPI protocol can read data from a Simens CPU S7-200 Another way should be implement a PPI protocol in your PC or buy a MPI driver for your PC. Hope this helps! Edited by sparkysliderz
Posted
have a look at: http://www.runmode.com/delphi.htm there you can find a source code!
Posted
hi i'm workin on infact the same project except that comm is through a modem . ( look at my post and see if u can help) .i'm also in need of a similar vb program so NIKMAST please let me know if u find one that works. as for ur problem (i'm an absolute beginner please forgive if i'm wrong) have u set the plc to freeport or multimaster ? ensure that u have similar setting for the ppi cable . also if u use freeport u can use the xmt annd rcv instructions. regards
Guest Guest_nikmast
Posted
Thank you for all your help, guys. Nagasadhu - look at my post and see if u can help - what do you mean? I would like to help you if you can tell me what is your problem. I have solved my problem by using the plc code for receiving and sending, almost solved it.
Guest Guest_nikmast
Posted
Nagasadhu - I will send you a code I am using in the next few days, sorry for being so late with the answer.
Guest Guest_nagasadhu
Posted
i meant that i had posted in the same forum and had a few details of my project there and was wondering if any of u cud help. havin a nightmare commm in s7-200.now i'm tryin to establish freeport connection between the PC and the PLC through a ppi cable . experienced users tell me to use SMB2 to recieve info and not to use RCV instruction cos it not portable and doesnt work all the time and in all comm lines.i for instance havent been able to get it workin for over a week now.moreover the VB interface still remains . if u cud post step by step procedures of ur project , it might be easier to troubleshoot and if u have solved it urself useful to everyone else. thanx-a-lot

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...