|
|
Topic: P131 |
ASCII In (AIN) Instruction |
|
Icon / Button = ![]()
Receive Raw ASCII Strings in the Serial Ports of the CPU and place the data in a String Tag.
|
Parameter |
Parameter Type |
Requirements |
Description |
|
Enable |
Ladder Input |
Must Have |
Level-driven. When Enable is ON, the instruction will operate every scan. When Enable is OFF, the instruction is not solved and it's outputs are not updated. |
|
Serial Port |
Drop Down Selection |
Must Have |
The Serial Port where ASCII data is received. |
|
Fixed Length |
Selectable Option |
Must select Fixed Length or Variable Length |
A specified String Length to be received. Requires a value for Number of Characters. |
|
Number of Characters |
Constant |
Must Have when using Fixed Length |
The Number of Characters to be received in a string when using Fixed Length. |
|
Variable Length |
Selectable Option |
Must select Fixed Length or Variable Length |
Specifies the Strings may have Variable Lengths. Enables Max Number of Characters, 1 Character and 2 Characters. A Termination Code MUST be specified. |
|
Max Number of Characters |
Constant |
Must Have when using Variable Length |
The Maximum Number of Characters allowed to be received in a string when using Variable Length. |
|
1 Character |
Selectable Option |
Must select 1 Character or 2 Characters |
Enables Termination Code 1 field where Termination Character must be specified. |
|
2 Characters |
Selectable Option |
Enables Termination Code 1 and Termination Code 2 fields where Termination Character must be specified for both. |
|
|
Termination Code 1 |
Selectable Option |
Must have one or both when Variable Length is enabled based on 1 or 2 Characters. |
Used to mark the end of a message. Must be configured using Hexadecimal format. When the Termination Code is received, the CPU moves the received ASCII characters into the specified string. Note: Termination Codes are not placed into the Destination String. |
|
Termination Code 2 |
Selectable Option |
Used in conjunction with Termination Code 1 to mark the end of a message. Must be configured using Hexadecimal format. When Termination Code 1 and Termination Code 2 are received (consecutively), the CPU moves the received ASCII characters into the specified string. Note: Termination Codes are not placed into the Destination String. |
|
|
First Character Timeout Interval (sec) |
Constant |
Optional |
Amount of Time (in seconds) by which a Character MUST be received after Enable is turned ON. If Time is exceeded, First Character Timeout bit will become True. |
|
Inter Character Timeout Interval (msec) |
Constant |
Optional |
Amount of Time (in milliseconds) that is allowed between Characters of a String. If this Time is exceeded, Inter Character Timeout bit will become True. |
|
Do Not Clear Buffer on Input |
Selectable Option |
Optional |
If not selected (default), any data already received will be cleared from the buffer when the instruction is started. If selected, any data already received will be used by the instruction. |
|
Byte Swap Option |
Selectable Option |
Must Have No Byte Swap, All Characters, or All But NULL Characters selected. |
No Byte Swap: No Bytes will be Swapped. All Characters: Every 2 Characters will be Swapped when placing the data into the Destination Tag Name. All But Null Characters: Every 2 Characters will be Swapped except Null Characters when placing the data into the Destination Tag Name. |
|
Convert NULL to 0x |
Selectable Option |
Optional |
Convert NULL Character to the Character specified to avoid early termination of a string. |
|
Destination |
String Tag |
Must Have |
The Tag to place the String data. |
|
Use Structure |
Selectable Option |
Optional |
If selected (not default), the selected Structure data type from the drop menu will be used for the instruction. |
|
Number of Characters Received |
Numerical Tag |
Optional |
Value of Total Characters received. |
|
In Progress |
Boolean Tag |
Optional |
If "Do Not Clear Buffer" is NOT selected, this bit is ON until the Enable is removed. If "Do Not Clear Buffer" is selected, then this bit will go low in certain conditions (see timing charts below). |
|
Complete |
Boolean Tag |
Optional |
Enabled when CPU has received data into the specified serial port that meets the criteria (size or termination received) of the Enabled instruction. Turns OFF when instruction is Re-enabled or if the user manually clears the tag while the instruction is still Enabled. |
|
Success |
Boolean Tag |
Optional |
Enabled when Complete has occurred with no Error bits. Turns OFF when instruction is Re-enabled or if the user manually clears the tag while the instruction is still Enabled. |
|
First Character Timeout |
Boolean Tag |
Optional |
A Character MUST be received within the specified Time period after instruction Enable is turned ON or 1st Character Timeout bit will turn ON. |
|
Inter Character Timeout |
Boolean Tag |
Optional |
Each Character MUST be received within the specified Time period up until the Complete bit is turned ON or the InterCharacter Timeout bit will turn ON. |
|
Overflow |
Boolean Tag |
Optional |
Turns ON if the CPU receives more Characters than specified in the Max Number of Characters before seeing the Termination Character(s) specified. The Overflow Error bit will turn OFF again when new data is received. |
Note: When Enable turns ON, the buffer of the specified Serial Port is Cleared.
Note: If any incoming string contains Extended ASCII characters, the Extended ASCII characters will be discarded.
When ASCII In Instruction is selected the window shown below opens.
In this example, a Barcode String is transferred into the Communications Port of the CPU. The String is terminated with a carriage return (0x0D).