ThePLCPeon

ASCII Comms issue

7 posts in this topic

Hello,

I am having a recurring issue with a system using ascii to tranmist weighing data. The system will work but every few days there will be a random erroneous value input as the current weight reading. The plc then seems to "freeze" and can only be reset by going online and clearing the erroneous readings from the strings as well a the string reply from the terminal. This is all new to me and I think the problem lies with the structure of "write, read and extract" I think I may be picking up part of the reply string I do not want.

The following is the reply string I recieved "   0.0    27.0kg     1   54732>^M^J<000010-01-0007:08   01    2  " what this should be is " <000010-01-0007:08   01    2     0.0    27.0kg     1   54732>^M^J " The strign seems to have been split in two, this is a problem as to extract the weight I am counting "x" characters along the string and then extracting what i need. I need that string to be sent unfragmented as I think this is my problem.

I have a attached an image for the current instructions I am using to receive the string, I write a command to the terminal, check the buffer and the read in the string. I then extract data from the string.

Any help is greatly appreciated.

 

ascii.PNG

 

Edited by ThePLCPeon

Share this post


Link to post
Share on other sites

Hello,

It's been a long time since I've done anything ASCII related, but here are a few comments:

1. Try synchronising your reads and writes more logically in a sequence. Currently your trigger to Write is completely disassociated with the ACB and ARD. This might cause some timing issues if a write and a read execute simultaneously.

You could try something like:

Step 1 - issue AWT instruction.

Step 2 - wait for AWT.DN bit + ?2? second delay (delay long enough for device to reply).

Step 3 - perform ACB instruction

Step 4 - upon ACB.DN, check buffer length >= 62 and perform the ARD instruction.

Step 5 - Go back to Step 1

2. If you know your response should start with a particular pattern, you can check for that pattern using additional ASCII functions such as AEX etc - Refer to chapter 10 - http://literature.rockwellautomation.com/idc/groups/literature/documents/rm/1747-rm001_-en-p.pdf

 

Good luck!

 

Share this post


Link to post
Share on other sites

Hello again, I have made changes to the code to what I think is a more logical sequence of events. My only question now is, I want to wait until the buffer is clear before I perform my write instruction again. I am not sure how to do this, Is the a clear buffer "done bit" I can use and will that work? Or should I check the buffer for characters again before I go back to my write instruction. Here is a picutre of the current structure. Also just FYI the timer T4:14 Is flip flopping with another 1s timer so atm the write instruction will be perforemed every 2s regardless of anything else.

 

asci3.PNG

Share this post


Link to post
Share on other sites

Hello,

Please refer to attached sample code - sorry I don't have RS500 with me so have prepared sample in RS5000.

Hopefully it is descriptive enough - is uses a state machine to shuffle along the different steps, then returns to the beginning.

Regards,

vds

 

ASCII.pdf

Edited by vds
wrong info
2 people like this

Share this post


Link to post
Share on other sites

Oops typo on rung 5, EQU instruction should be comparing for 4 not 3...

Share this post


Link to post
Share on other sites

Yep I thought that was the case, this was a big help thanks again.

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