- Interactive Q & A - Interactive Q & A (
-   LIVE PLC Questions And Answers (
-   -   OMRON CPM2A PLC and RS-232C to the PC (

vislab April 12th, 2007 10:02 AM

OMRON CPM2A PLC and RS-232C to the PC

I hope someone can help to resolve the current issue that I have now. I am using OMRON CPM2A PLC connected to the desktop PC so that it is able to communicate through the RS-232C COM port.
And I wrote a simple PLC code which uses 2 PLC outputs to operate a simple pneumatic solenoid valves so it just works fine.
Here I also wrote a simple VB code to send "OK" signal to the PLC through the RS-232C COM port so the PLC routine is supposed to run only if it receives "OK" signal from the PC through the RS-232C COM port. I used of course RXD PLC function in the PLC code. So right now there is only one direction communication from the PC to the PLC.

But the problem I saw is this everytime after I shutdown the desktop PC and reboot it, the PLC would not run anymore it means when it receives "OK" signal it did not do anything so no output LEDs lit on. And also when the PC shuts down if I look at the PLC panel there was a COMM LED blinking once.

But if I unplug the power to the PLC and plug it back then it runs OK again. So far I don't know what is wrong and what I can do to fix this problem but it is weird everytime when I just reboot not shutdown then it still works fine.
Anyway this is the problem I see now and I really appreciate if somebody can give me solution or comment.
Then thanks for your taking your time to read this and I am looking forward to hearing from you soon.



gtsuport April 12th, 2007 10:48 AM

Check to make sure the "Settings" for the Host Link port are correct.

Next make sure the RXD instruction is set up correctly. The bottom value in the instruction is the number of bytes to receive. If this is not set properly, it can cause problems.
Also, make sure the data has been received on the port before you initiate the RXD instruction. There are "flag" bits that can be used for this purpose.

The progamming manual for the CPM2A is W353. You can download the manual from In the left menu click on Document Library. Enter W353 in the partial document number box and click search (or go?).

Good Luck. Let us know if you have any other questions.

vislab April 12th, 2007 12:31 PM

Thanks for your comment and information.
This is the PLC RS-232C communication settings that I used.

Baus: 9600
Format: 1,8,1,N
Mode: RS-232C

Start Code: 0x003E

End Code: 0x000D

And RXD is set to receive 2 bytes because "OK" is 2 bytes.

And I used the Reception Completed Flag AR0806 with RXD instruction together.
But like I said, I cannot understand why it stops running after the PC shuts down and restart.
And then it is weird but if I unplug and plug the PLC power back then it starts working again.
So the bottom line it that until I never turn off the PC, the PLC receives the "OK" from the COM port and keeps running.
Thank you again.

gtsuport April 12th, 2007 12:34 PM

Do you have the number of bytes to receive set correctly?
This can cause a problem if is is not correct.

Also the control word can cause a problem if not set properly.

Review those values to make sure they are set correctly for your application.

vislab April 12th, 2007 12:37 PM

Yes, as I edited above again, RXD is set to receive 2 bytes because the PC sends 2 bytes of "OK" to the PLC through the RS-232C COM port.
And the Control Word is set to #0000 by default.


gtsuport April 12th, 2007 12:46 PM

Pretty sure the number of bytes is the problem.

You forgot about the start and end codes. Those are also part of the number of bytes received.

Check the manual, there is an AR address that indicates the number of bytes recieved on the port. You can use that address in the instruction.

Hope this helps.

vislab April 12th, 2007 12:57 PM

Thanks but when I checked it in the W353 manual it says "Start and end codes are not included when the number of bytes to be transmitted is specified."

And also it says "AR09 which stores the number of byted received does not include the start code and end code."

So if it is true then I am lost again and I don't know what else can be the problem!

gtsuport April 12th, 2007 01:02 PM

Just try using AR9 for the number of bytes received portion of the instruction.

Another trick, just to check things out, put a normally open 253.14 (always off bit) in the enable line of the RXD. Send your data, then take a look at the value in AR9. This will verify the number of bytes being received.

Hope this will help.

All times are GMT -5. The time now is 09:06 PM.