RS232 ASCII on SLC 05

Schouilette

Member
Join Date
Sep 2021
Location
Poland
Posts
4
Hi, I'm new into AB controllers and I'm trying to find how to handle rs232 communication on slc 05/4. I know that I need to configure channel 0 and check the buffer in my program. I'm not sure how to handle buffer and read/write functions. As shown in the picture, I'm continuously checking buffer with ABL function and if a new message is found then I'm copying it into my variable. When trigger appears then I send the prepared command. Is this a proper way to communicate by RS232 (I'm not able to test it online)?
Screenshot-2021-12-06-123113.png


I'm using commands with termination ^M which should be interpreted as CR.
 
Your T4:20 timer will never finish, as you're immediately unlatching B3:25/0. You'll also want a Normally Closed R6:8/EN in front of the ABL instruction or it will only execute once. The instruction only runs on a rising edge.
 
Welcome to the PLCTalk forum community !

You are correct that A-B sometimes adopts old ASCII printer control terminology, in which Carriage Return (0x0D hexadecimal) is called "Control-M" or "^M".

If you are configuring the Channel 0 serial port to recognize that as a Termination character, enter it in hexadecimal style, which in RSLogix 500 is "\d". That is also the default configuration for Channel 0.

I prefer to use the "ASCII Read Line" instruction (ARL) instead of using one of the buffer-testing instructions (ABL or ACB) or the Read Buffer instruction that doesn't care about the termination character (ARD).

ARL reads a whole "line", which includes the Carriage Return delimiter. Once you execute the instruction (the rung goes from false to true), it waits indefinitely for a "line" to arrive in the buffer. You can write a timeout to purge the buffer on startup or if it's been too long between expected inputs.

As noted, your first ASCII instruction will only execute on the first scan of the program, since it's on an unconditional rung. ASCII instructions are buffered by the SLC-500 operating system and need a false-to-true transition to execute each time.

In addition, be sure to use a unique "Control" element for each ASCII instructions. You're using R6:8 for all three in your screenshot, which will prevent them from working correctly because they will write over one another's status and control bit. Unfortunately, RSLogix 500 does not look for such conflicts and warn the programmer.
 
There are many ways to time and condition your ASCII logic, but for a simple "reply as soon as you get a string into the Channel 0 port" this should get you started:

ARL_AWA.PNG
 
Welcome to the PLCTalk forum community !

You are correct that A-B sometimes adopts old ASCII printer control terminology, in which Carriage Return (0x0D hexadecimal) is called "Control-M" or "^M".

If you are configuring the Channel 0 serial port to recognize that as a Termination character, enter it in hexadecimal style, which in RSLogix 500 is "\d". That is also the default configuration for Channel 0.

I prefer to use the "ASCII Read Line" instruction (ARL) instead of using one of the buffer-testing instructions (ABL or ACB) or the Read Buffer instruction that doesn't care about the termination character (ARD).

ARL reads a whole "line", which includes the Carriage Return delimiter. Once you execute the instruction (the rung goes from false to true), it waits indefinitely for a "line" to arrive in the buffer. You can write a timeout to purge the buffer on startup or if it's been too long between expected inputs.

As noted, your first ASCII instruction will only execute on the first scan of the program, since it's on an unconditional rung. ASCII instructions are buffered by the SLC-500 operating system and need a false-to-true transition to execute each time.

In addition, be sure to use a unique "Control" element for each ASCII instructions. You're using R6:8 for all three in your screenshot, which will prevent them from working correctly because they will write over one another's status and control bit. Unfortunately, RSLogix 500 does not look for such conflicts and warns the programmer.

Thank you for your answer, but I have still some questions.
You use R6:8/EN bit to trigger ARL function. So this R6:8/EN bit is automatically triggered when a new line is in buffer? Also if ARL waits indefinitely, my program can be stopped in this place?
If I configure termination as \d, should I use it in the same way in string variables eg. "Command1\d"?
I have auto-cycle machine and in one step I need to check the status from sensor by this rs232. So I need to send a command for status and get back this information. Soo my PLC is a master in this communication- maybe the order of my rungs is confusing.
Do you have some learning materials for using RS232 in old AB? All I found is connecting AB to PC
 
Do you have some learning materials for using RS232 in old AB? All I found is connecting AB to PC

I think most of your questions can be answered by reading the reference manual, particularly the ARL instruction description starting on page 10-17 (this link); also pay particular attention to the timing diagram on page 10-16 (this link).

You use R6:8/EN bit to trigger ARL function. So this R6:8/EN bit is automatically triggered when a new line is in buffer?

Note that @Ken Roach's example uses an [XIO R6:8/EN] instruction, i.e. a Normally Closed test of the enable bit, to trigger the ARL instruction, as also recommended by @travispedley. The documentation states that the ARL instruction is triggered by a rising edge of its input rung, which in this code means a 1-to-0 transition of R6:8/EN, i.e. falling edge of the bit R6:9/EN. This means two things:

  1. The /EN bit will have a value 0 for at most one scan at a time, because on the first scan that it becomes 0 and Rung 0001 executes, the [XIO R6:8/EN] will evaluate to True, which the ARL instruction will detect as a rising edge of the input rung (because /EN is 0), and the ARL will immediately change the value of that /EN bit back to 1, which begins the process of queueing and then executing the read.
    1. *** N.B. this means the left-hand example in the timing diagram (this link) does not apply, because in that example on the left the input Rung Condition (top line of diagram) is held True beyond the completion of execution, but in @Ken's code that rung cannot be held True for more than one scan.
  2. From the timing diagram (this link) that /EN bit has its 1-to-0 falling edge transition on the first scan after the ARL instruction completes; see footnote 4 as it applies to the example on the right-hand side of the diagram.
Also if ARL waits indefinitely, my program can be stopped in this place?

I am not sure what you mean by "program can be stopped:"

  • If you mean the entire program, then no, a PLC program never stops, especially the continuous task. It is like a small child, always running to the next thing (instruction). Each time the program reaches Rung 0001 and it executes the ARL instruction, when the value of R6:8/EN is 1 and the read has been queued, EITHER it will check if the read is complete, in which case it will assign values to the various bits and copy the read data to the DEST string, OR it will check if the read is not yet complete, in which case it will move on to the next rung.
    • For the record, the only ways I can think of to stop a PLC program are to either
      • power it off, or
      • take it out of RUN mode, or
      • put it into an infinite loop with an LBL instruction as the target of a later JMP instruction, but even then the program is not actually stopped: it is still executing at least those LBL and JMP instructions continuously (until the watchdog times out and the PLC faults).
  • If you mean the ARL instruction will be stopped, or rather waiting, until either enough ("String Length") ASCII data or a carriage return arrive on the serial lines and the read completes, then yes, that would be correct, except for Rungs 0002 and 0000:
    • When the R6:8/EN bit becomes 1, Rung 0002 starts a 500cs (five-second) timer.
    • IFF (if and only if) that timer completes, it is because the value of R6:8/DN has been 1 for five seconds, at which point the value of T4:0/DN becomes 1, and on the next scan (remember: the PLC is a busy child ;)), when Rung 0000 executes, the ACL instruction will clear all buffers, and the instruction [OTL R6:8/UL] will latch the value of R6:8/UL to 1, both of which will stop the execution of, and de-queue, the ARL instruction, and also assign a 1 to the value of the error bit R6:8/ER (see this link).
If I configure termination as \d, should I use it in the same way in string variables eg. "Command1\d"?

If you prefer. However, note that the write instruct AWA can be configured to append a one- or two-character string to any string to be written, and a single carriage return is the default string to append.
 
Last edited:

Similar Topics

Hi to everybody. I need to read the first 12 characters of the message that a barcode reader sends to the ascii card (1734-rs232 ascii) and I...
Replies
8
Views
729
Hello, I have a linear actuator set up (2 Ewellix linear actuators with hall effect sensor encoders) and an SCU control unit with RS232...
Replies
4
Views
2,117
Hi, Guys I'm trying to upgrade a device witch comms is thru a RS232. The PLC is a Compactlogix L16ER to a remote PIO 1734-AENT then on this PIO a...
Replies
22
Views
8,236
Hello, I am an apprentice and ee student and I have been trying get a slc 5/03 to report temperature data and system status history at a fixed...
Replies
6
Views
3,664
Hi, i need your help with rs232 communication. On the table i have PLC-5/30 (1785-L30B) and pc (in the future i want make little app - like...
Replies
3
Views
2,558
Back
Top Bottom