raber

Receive data by serial communication SCU-41

10 posts in this topic

Hi! I would like to ask how could I send data from PC to CJ1M PLC, by SCU-41 module and RS232 cable, in order to activate an actuator (LED)?

In my environment, I have a sensor that sends data from PLC to PC (I'm checking data, "HelloWrld" with Putty), with this configuration:

img3.PNG

And I have another section where I want to read the data from the PC in ordr to activate a LED

img4.png

I would like when I send for example a letter 'a' trough Putty, the LED activates.

How could I do that?

Thank you very much!

Edited by raber

Share this post


Link to post
Share on other sites

There are a few different ways to receive serial data. I like to create a rule in the case the received data may be variable. Generally these rules would be decided by the actual device you are reading from. In most cases, a received message may always end with a 'CR+LF'. (A Carriage Return and a Line Feed). In some other cases, the rule may be that the message will always be the same number of bytes.

Either way, Omron gives you the ability to detect these rules then turn ON a special bit to notify the PLC that data is available in the hardware buffer.

I haven't tried this yet but have a look at the settings below. I'm also not accustomed to using Putty but I think if you make the setting below Putty will send 'a'+CR+LF if you type 'a' then press Enter. The setting on the SCU41 will detect the CR+LF and turn on bit 1534.06. (n = CIO 1500 + 25 ´ unit number) (Port No. 1 = n+9). Your settings show that you are using Port 1 and the Unit No. is 1. Put contact 1534.06 in line with the RXDU instruction.

Mr_PLC_RXD_Settings.JPG.c980f0368d76c9e2

 

Edited by IO_Rack

Share this post


Link to post
Share on other sites

I am really using Port 2 but it doesn't matter, I am already able to receive data from PC and I'm saving on D40 register memory. Thank you for your answer.

If I want to use that value for example, if I write a letter 'a' on putty, I have 6100 in D40 memory register, I'm thinking on use = (equal instruction to compare with other letter 'a') in order to activate an output, but I don't know how to specify letter 'a' on equal instruction fields. (or boolean true or false values too)

 

And in the other hand, in case I use 'a' + CR+LN, the number of bytes would be 2?

Edited by raber

Share this post


Link to post
Share on other sites

If you want to compare the DM value as ASCII, use the '=$' instruction. I don't know that you can put 'a' directly in the instruction. Use another memory location then go to Memory from the project tree. Open the memory you are using then choose View > Display > Text. From here you can populate your memory with text.

Share this post


Link to post
Share on other sites

I have configured all, but it doesn't seem to work. Only save one letter on D40 memory register when I write 'abcd' + ENTER on Putty.

img6.PNG

img7.PNG

Share this post


Link to post
Share on other sites

1544.06 needs to be Normally Open.

Putty will initiate the communications. When the PLC sees 'CR+LF', then 1544.06 will turn ON. Make sure Putty is actually sending the Line Feed.

I like to use RealTerm because it will display the CR and LF.

Share this post


Link to post
Share on other sites

When I write 'asdf' + ENTER on Putty and transfer PLC memory to PC (CX-Programmer) it is only 'D' (HEX) (CR in ASCII) on D40 memory register.

Edited by raber

Share this post


Link to post
Share on other sites

I'm not sure what you are asking. Can you show what you have?

Your last post did not show an ASCII compare.

Mr_PLC_MonitorInHex.JPG.6baf486a921bacc3

Mr_PLC_MonitorInText.JPG.c704d5c3188dd84

Mr_PLC_ASCII_Cmp.JPG.3721b7dacbe910c7a44

Share this post


Link to post
Share on other sites

It is working now, I changed the number of reception bytes and I'm using RealTerm in order to send a number in ASCII + CR + LF.

And for LED activation, I have used = (equal instruction) comparing with a specific value in HEX (#0034) for example.

Thank you very much for your help!

 

Share this post


Link to post
Share on other sites

Great job! I'm glad you got it working. RealTerm can take some time to get used to but it makes the send / receive easier to understand (In my opinion). Putty is more of an Information Technology tool.

Share this post


Link to post
Share on other sites

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