nikmast Posted February 9, 2005 Report Posted February 9, 2005 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.
sparkysliderz Posted February 9, 2005 Report Posted February 9, 2005 i cant directly help with VB but if you want i can send you some Delphi code to analyse and maybe translate into VB that does what your looking for!
got Posted February 10, 2005 Report Posted February 10, 2005 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...
nikmast Posted February 15, 2005 Author Report Posted February 15, 2005 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.
got Posted February 15, 2005 Report Posted February 15, 2005 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?) ...
nikmast Posted February 15, 2005 Author Report Posted February 15, 2005 I use no handshaking (changed), and as far as I know settings are correct for a Siemens s7-200 cpu222 dc/dc/dc.
nikmast Posted February 15, 2005 Author Report Posted February 15, 2005 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.
got Posted February 17, 2005 Report Posted February 17, 2005 i think yes there is no reason for the plc to send data if you don't ask him to.. but i don't know how.. :\
sparkysliderz Posted February 17, 2005 Report Posted February 17, 2005 (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 February 17, 2005 by sparkysliderz
Guest bernd Posted February 18, 2005 Report Posted February 18, 2005 have a look at: http://www.runmode.com/delphi.htm there you can find a source code!
nagasadhu Posted February 27, 2005 Report Posted February 27, 2005 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 March 6, 2005 Report Posted March 6, 2005 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 March 6, 2005 Report Posted March 6, 2005 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 March 7, 2005 Report Posted March 7, 2005 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now