You are on page 1of 9

448488 - How to read ASCII in Micro800 controller https://rockwellautomation.custhelp.

com/app/answers/detail/a_id/448488

Email this page Subscribe to Updates

Question
How do I receive an ASCII string using the Micro800 controller?

Answer
In this guide we will be configuring a Micro800 controller program to read characters via ASCII.

Note:
Make sure you have the correct cable. Use 1761-CBL-PM02 to connect the computer to the controller.

1. Drop in a Function Block into the rung and choose the ACB Function Block from the Instruction Block Selector. The ACB instruction counts the total number
of characters in the buffer. You can also use ABL instruction, instead of ACB. The ABL instruction counts the characters in the buffer up to and including the first
termination character.

How ACB works: The ACB instruction searches the buffer for all characters.

How ABL works: The ABL instruction searches the buffer for the first set of termination characters. If the instruction finds the termination characters, it counts
the characters in the buffer up to and including the first set of termination characters.
2. Right click on the ACBinput sub-block to bring up the Variable Selector screen. Create a new variable of data type ABLACB.

3. Expand the new variable created (ACB_input on this case) to reveal the variable settings. Since we will be using the embedded serial port, we want to assign
Channel 2 as our channel of communication.

1z9 2015-10-06 14:54


448488 - How to read ASCII in Micro800 controller https://rockwellautomation.custhelp.com/app/answers/detail/a_id/448488

4. After inputting the desired settings, make sure that the ACB_input is highlighted and click OK.

5. Right click on the Characters output of ACD to bring up the Variable Selector screen. Create a new variable called Received_characters of data type UINT.

6. Drop in a Function Block into the rung and choose the MOV Function Block from the Instruction Block Selector.

7. Drop in a Function Block into the rung and choose the ARD Function Block from the Instruction Block Selector. The ARD instruction reads characters from

2z9 2015-10-06 14:54


448488 - How to read ASCII in Micro800 controller https://rockwellautomation.custhelp.com/app/answers/detail/a_id/448488

buffer and stores them in byte array.


8. Right click on the ARD input sub-block to bring up the Variable Selector screen. Create a new variable of data type ARDARL.

9. When reading the receive buffer you will need to populate the .Length input. This can be done via the ACB and MOV instructions.

10. Expand the new variable created (ARD_input on this case) to reveal the variable settings. Since we will be using the embedded serial port, we want to assign
Channel 2 as our channel of communication.

3z9 2015-10-06 14:54


448488 - How to read ASCII in Micro800 controller https://rockwellautomation.custhelp.com/app/answers/detail/a_id/448488

11. After inputting the desired settings, make sure that the ARD_input is highlighted and click OK.

12. Right click on the Destination sub-block to bring up the Variable Selector screen. Create a new variable of data type ASCIILOCADDR.

13. Now, we need to set the communications protocol so that we can read out of a device. For this guide, we will be reading out of a PC's HyperTerminal program.
Go to the Micro800's property windows, expand Communications, and select Serial Port.
14. For our application, we will choose ASCII as the Driver and we will choose a Baud Rate of 19200. Your window should look as follows:

4z9 2015-10-06 14:54


448488 - How to read ASCII in Micro800 controller https://rockwellautomation.custhelp.com/app/answers/detail/a_id/448488

15. While still on the Serial Port's properties, go to Protocol Control options to reveal further ASCII settings. For ABL or ARL instructions, we need to enter
termination characters to mark the end of the data.

16. If we want to use the ABL Function Block in order to read the characters up to, and including the first Carriage Return (Enter key). Thus we will need to set the
first termination character to 0x0D and the second termination character to 0xFF. This will conclude the settings for the ABL Function Block.
17. If the ASCII device is configured for XON/XOFF flow control, select the XON/XOFF check box.
18. If the ASCII device is a CRT or is pre-configured for half duplex transmission, select the Echo Mode check box.
19. After using the ARD or ARL Function Block we want to use an ACL Function Block in order to clear the buffer.

How ACL works: The ACL instruction immediately performs one or both of the following actions:
Clears the buffer of characters and clears the ASCII queue of read instructions
Clears the ASCII queue of write instructions
20. In the controller code when ACL instruction is used to clear the Transmit (TX) and Receive (RX) buffers, make sure you set the appropriate input tags to true. So
in the example below the base name of the input tag of the ACL instruction is ACL_input. So if I want to clear both the RX and TX buffers, I must first set the
channel number as well as set the .RXBuffer and .TXBuffer tags to true.
21. Add an ACL Function Block into a new rung in the ladder. Create a variable of data type ACLI to be used by the ACL input sub-block. In this case, we will call it
ACL_input and the channel assigned to this block will also be channel 2.

5z9 2015-10-06 14:54


448488 - How to read ASCII in Micro800 controller https://rockwellautomation.custhelp.com/app/answers/detail/a_id/448488

22. Expand the new variable created (ACL_input in this case) to reveal the variable settings. Since we will be using the embedded serial port, we want to assign
Channel 2 as our channel of communication.

23. After inputting the desired settings, make sure that the ACL_input is highlighted and click OK.

24. Then add a Direct Contact before each function block in order to manually enable each block. The ladder should now look as follows:

6z9 2015-10-06 14:54


448488 - How to read ASCII in Micro800 controller https://rockwellautomation.custhelp.com/app/answers/detail/a_id/448488

25. Make sure that the controller is plugged into the PC and that the 1761-CBL-PM02 cable is connected between the embedded port of the controller and the PC.
Build and Save the program then download it to the controller.
26. Once the program finishes downloading, go on Debug Mode.
27. As of now, the buffer should be empty, thus if you initialize the ACB Function Block the Char count will display 0 (It is common to use the ACL function block at
startup in order to delete any old char that were left in the buffer). To initialize a function block, double click on a contact or function block sub-block to bring up the
Variable Monitoring windows. Check the start_ACB box to energize the ACB Function Block, as you may see the char count is 0.

28. Type some characters in the HyperTerminal and uncheck then recheck the start_ACB box. The char count should now update and display the amount of char
that were typed in the HyperTerminal. In our application, we typed Micro800 then pressed the carriage return, thus our char count value will be of 9, one count per
char plus the carriage return.

29. Now we will use the ACL Function Block to clear the buffer. Make sure that the start_ACB box is unchecked and expand the ACL_input variable. Check the
RXBuffer box and then check the start_ACL to energize the ACL Function Block, and once energized, uncheck the start_ACL box so that the buffer is cleared. If
you energize the ACB Function Block again, you will see that the character count is now 0.

7z9 2015-10-06 14:54


448488 - How to read ASCII in Micro800 controller https://rockwellautomation.custhelp.com/app/answers/detail/a_id/448488

Attachments
Micro800_ASCII.docx (/ci/fattach/get/833244/0/filename/Micro800_ASCII.docx) (907.83 KB) Micro800ASCII_instruction_tips.doc (/ci/fattach
/get/866468/0/filename/Micro800ASCII_instruction_tips.doc) (207 KB)

DISCLAIMER
This knowledge base web site is intended to provide general technical information on a particular subject or subjects and is not an exhaustive treatment of such
subjects. Accordingly, the information in this web site is not intended to constitute application, design, software or other professional engineering advice or services.
Before making any decision or taking any action, which might affect your equipment, you should consult a qualified professional advisor.

ROCKWELL AUTOMATION DOES NOT WARRANT THE COMPLETENESS, TIMELINESS OR ACCURACY OF ANY OF THE DATA CONTAINED IN THIS WEB SITE
AND MAY MAKE CHANGES THERETO AT ANY TIME IN ITS SOLE DISCRETION WITHOUT NOTICE. FURTHER, ALL INFORMATION CONVEYED HEREBY IS
PROVIDED TO USERS "AS IS." IN NO EVENT SHALL ROCKWELL BE LIABLE FOR ANY DAMAGES OF ANY KIND INCLUDING DIRECT, INDIRECT, INCIDENTAL,
CONSEQUENTIAL, LOSS PROFIT OR DAMAGE, EVEN IF ROCKWELL AUTOMATION HAVE BEEN ADVISED ON THE POSSIBILITY OF SUCH DAMAGES.

ROCKWELL AUTOMATION DISCLAIMS ALL WARRANTIES WHETHER EXPRESSED OR IMPLIED IN RESPECT OF THE INFORMATION (INCLUDING
SOFTWARE) PROVIDED HEREBY, INCLUDING THE IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, AND
NON-INFRINGEMENT. Note that certain jurisdictions do not countenance the exclusion of implied warranties; thus, this disclaimer may not apply to you.

This page is best viewed in Internet Explorer 10, Firefox 31, Chrome 37, Safari 6 or newer.

8z9 2015-10-06 14:54


448488 - How to read ASCII in Micro800 controller https://rockwellautomation.custhelp.com/app/answers/detail/a_id/448488

9z9 2015-10-06 14:54

You might also like