Does anyone know about how to use java serial to communicate with plc? I needed to understand this for my project which is to with controling the output from the java .
thanks a lot
Make sure you have the javax.comm package, which is not in the standard JDK download. This will allow you to do serial comm. However, you
will then need to know what kind of data the PLC is expecting. This is pretty easy if it's a Modbus capable PLC, since modbus.org gives you
all the info. DF1 is a little tougher. As for everybody else, you'd have to ask the respective manufacturers.
thanks james, i have download and written some code for the serialPoerEventListener. Now the problem is that my program is waiting for the
output from plc which can not send to pc at the moment. is there a way to go about it
many thanks
sun
A windows version of the API is available at the sun site. I think that some one has already given the link. It is quite easy to use, but uses
native methods, though this is largely transparent with the supplied .dll.
hi there,
i've program in java already.. would it be ok for u to have a look at since i
get no input signal from plc at all (can u tell me how i can send signal from
plc to pc?) here is my program
public class ReadPorts implements SerialPortEventListener
{
private SerialPort serialp = null;
private static CommPortIdentifier comportiden ;
private InputStream inp ;
private CommPort comp ;
private Enumeration enum ;
private InputStream input = null;
private OutputStream output;
private int invalue, portnum, inputport ;
private DisplayPict2 display ;
private GetScan scan ;
// SerialPort serialPort = null;
public ReadPorts()
{
try
{
String portName = "COM2" ;
I didn't really look at the code, because I think you've already figured out that problem is on the PLC side. I don't know which PLC you're using or what it expects or what it sends, so I can't really help with that. I would say that the PLC manufacturer should supply you with all the information you need. On a good day you might even get sample code.
the plc model is mitsubishi fx1s 20mr-ds
it is expect to send data from java in serial port to plc which is then determine the output channel to be sent ( ie y0-7). Also it suppose
to do the reverse also but this time plc will send the command which tell the program to start reading another input value from java
many thanks