Programming a PLC through VB

Hassman

Member
Join Date
Jan 2013
Location
City
Posts
18
Hi everyone,

I am wondering how to communicate to a PLC using VB. I currently have a "Click PLC programming module", that I am communicating to through an RJ12-USB converter. I have a sample VB program that allows me to connect to the device serially, but I am unsure how to go about actually programming code to communicate to the PLC.

I have seen examples that showcase assembly language code to speak to PLCs, but I have no idea where to begin with this particular PLC. How does one figure out the assembly level language code associated with a PLC?

My goal: To read inputs (via pushbutton) into the PLC, and then send an output signal over an ethernet server. I have a background in PLCs, and in VB, but am not sure how to bring both of these systems together.

I thank you all in advance, and appreciate your support.
 
How does one figure out the assembly level language code associated with a PLC?
By getting an engineering job with a company that designs and manufactures those PLCs. This is a closed information owned by the manufacturer.

Now, many PLC brads do publish a communication protocol that allows to read and modify the data inside the PLC memory. But no one ever publishes any method to read and modify the code.
 
My goal: To read inputs (via pushbutton) into the PLC, and then send an output signal over an ethernet server. I have a background in PLCs, and in VB, but am not sure how to bring both of these systems together.

We've done one project using a Wago PLC (Codesys based programming) that talks to a computer through a Telnet connection.

Using a standard Windows command prompt one can enter commands that the PLC interprets and executes. Looking at the first Google result (http://www.teachexcel.com/excel-help/excel-how-to.php?i=433987) one can create Telnet connections using Excel.

Another option would be add a Modbus/TCP stack on the computer. I'm pretty sure there's some free things floating around for Linux for that. Windows should have something as well.
 
Use the Modbus protocol to request the state of inputs. Also use it to set internal states which would be used by a simple program within the Click PLC to direct the state of outputs.

The internal PLC program should monitor the state of communications from the controlling PC program and place the outputs into a safe state - usually off - if the communication fails.
 
Last edited:
We've done one project using a Wago PLC (Codesys based programming) that talks to a computer through a Telnet connection.

Depending on the required connection speed you could go several routes with the Wago - SQL, HTTP, File swapping, and of course ModbusTCP. I agree with keshik and others who recommend ModbusTCP because of its simplicity and and availability. If you're using any CoDeSys PLC (correct me if I'm wrong) there is a CoDeSys OPC server which is free (again, correct me if I'm wrong.) I've never used it but my son has and he says that it works well.

Good luck,

Yosi
 
Wonderful advice everyone and thank you for the links.

I believe Modbus is the best route to go, at least for what I need to get done right now. I will report back in the next couple of days, and hopefully shed some light as to my progress.

Thank you all again....great support as always
 
Hi Keshik,

Ok now I'm a little confused. When I called automation direct and spoke to the representatives they said that the click was based on the Modbus protocol, but now you're saying that it's not compatible.

Can you help clarify this for me Keshik??
 
You're using an Automation Direct PLC with two RS-232 ports by default and a USB adapter.

They are Modbus by default, your device (PC) would be serial/USB to the CLICK then Ethernet out to what ever you are doing after

Hassman, It may help if you give a little better detail of your project
 
Last edited:
Hi Keshik,

Ok now I'm a little confused. When I called automation direct and spoke to the representatives they said that the click was based on the Modbus protocol, but now you're saying that it's not compatible.

Can you help clarify this for me Keshik??

Yup, I hope I can. There are two main flavors of Modbus. One is Modbus/RTU which runs over RS-232/422/485 and is serial. The other is Modbus/TCP with runs over Ethernet. I, and I think most of the above posters, were referring to Modbus/TCP which is the Ethernet format and the Click doesn't support as far as I can tell.

So that leaves us with using serial communications with the Click (so no Modbus/TCP). That should let you use either ASCII or Modbus/RTU to your computer. I'm guessing that to integrate with Excel ASCII will probably be simpler but I could be wrong. I haven't done what you're doing before.
 
keshik in Hassman first post... "I am communicating to through an RJ12-USB converter"

To me, he is going USB (modbus) then out of the PC to something else (reporting ?) via Ethernet (not RTU)
 
keshik in Hassman first post... "I am communicating to through an RJ12-USB converter"

To me, he is going USB (modbus) then out of the PC to something else (reporting ?) via Ethernet (not RTU)

My impression was:
PC <--> USB/Serial Converter <--> Click PLC

I'm not sure that I'm correct anymore, however. I think the OP might need to clarify this. I now see the reference to an Ethernet server. The Click doesn't have Ethernet so we're going to need something in the middle.

OP, can you list what you're exactly trying to communicate from/to/with?
 
Hi guys,

First off, thank you Keshik, I did notice that the above posters were talking about the Modbus tcp/ip but I am aware that the click does not support that and was intending on communicating via Modbus/RTU

Secondly, to follow up on GeniusInTraining's post:

There is a small production line with operators. The goal is to develop a system with 6 inputs (pushbutton), and 6 respective outputs.

When one of these inputs is triggered (low to high) then it will send a signal to its corresponding output, with an error code. That error code will be sent to the local web server, and logged into the web servers database.

Basically there are 6 possible errors in the production line, and whenever an operator notices one of these errors, then they will press the corresponding pushbutton, and we need to log these errors into the database (all of this in real-time).

I hope that clarifies it.

Thirdly in regards to communication, Keshik you are correct, with one addition:

Ethernet<--> PC <--> USB/Serial Converter <--> Click PLC

So the setup is to take the Click PLCs input (pushbuttons), then to take that input signal, prepare an error code through the VB C#, and then transmit it through Ethernet to a web server.

Am I correct in presuming that I can do this, or am I missing something? Thank you all for your patience and support.

Regards,

Hassan
 
Thanks for the additional information. That all seems doable. You'll probably want some sort of method for the PC to have a heartbeat with the PLC to make sure they can talk (and you can then log that as an error). As long as the heartbeat is good you could probably just have the Click send an ASCII string on-demand whenever a button is pressed. Shouldn't be horribly complicated.
 

Similar Topics

Can you access a CompactLogix PLC for viewing and programming from the other side of an NATR module? Thanks. Bill
Replies
3
Views
2,828
Dear all, Does anyone know if it is possible to program the plc via the Siemens Series 8 control..... say from the front D25 socket, as I don't...
Replies
0
Views
2,977
Hello colleagues, Some time ago I started my adventure with programming. With your help and the courses, things are starting to come together...
Replies
13
Views
681
Dear All, I need a sample PLC program to count the output pulse of a mass flow meter so that a specific amount of mass (for example 100gm)can be...
Replies
2
Views
146
Hi Please I have zeilo smart relay #SR2A201BD but I don't have it's programming cable. Can I use any general usb/rs232 converter? Or need...
Replies
3
Views
152
Back
Top Bottom