Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Micro800 Ascii

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 13

Micro800-ASCII

ABL, ACL, AWA Function Blocks

Hardware & Software Versions Used to Develop This Guide

 Connected Components Workbench (CCW version 1.0.1)


 Windows XP, Service Pack 3
 Micro830 controller (2080-LC30-24QBB)
 1761-CBL-PM02
Configuring the program
We will be configuring a Micro800 program in order to enable the Micro800 controller to
communicate via ASCII.

1) Drop in a Function Block into the rung and choose the ABL Function Block from the
Instruction Block Selector. The ABL instruction counts the characters in the buffer up to
and including the first termination character.

Description 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) Double-click on the ABLinput sub-block (the smaller block with the yellow triangle on
the left side of the ABL FB) to bring up the Variable Selector screen. Create a new
variable of data type ABLACB.

3) Expand the new variable created (ABL_Input on this case) to reveal the variable settings.
Since we will be using the embedded serial port on this guide, we want to assign Channel
2 as our channel of communication.
4) After inputting the desired settings, make sure that the ABL_Input is highlighted and
click OK.

5) 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.
6) For our application, we will choose ASCII as the Driver and we will choose a Baud Rate
of 9600. Your window should look as follows:
7) While still on the Serial Port’s properties, expand the Advanced Settings options to reveal
further ASCII settings. For ABL or ARL instructions, we need to enter termination
characters to mark the end of the data.

8) 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.
· If the ASCII device is configured for XON/XOFF flow control, select the XON/XOFF
check box.
· If the ASCII device is a CRT or is pre-configured for half duplex transmission, select
the Echo Mode check box.

9) After using the ABL Function Block, we want to use an ACL Function Block in order to
clear the buffer.
Description: 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

10) 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. You can choose to set the ACL’s
clear RXBuffer and/or TXBuffer to an initial value of TRUE or you could leave this
blank and manipulate the values while in debug mode, which we will see later on in this
guide.
11) After inputting the desired settings, highlight the user defined variable (ACL_Input in
this application) and click OK. Your ladder should now look as follows:

12) Now, we will use an AWA Function Block in order to write some characters to the
HyperTerminal. The AWA instruction sends a specified number of characters of the
Source variable to a serial device and appends either one or two predefined characters.

Description: The AWA instruction does the following:


· Sends the specified number of characters (AWAInput Length) of the Source variable to
the device that is connected to the serial port of the controller.
· Adds to the end of the characters (appends) either one or two characters that are defined
in the Controller Properties windows.
13) Add a third rung into the program’s ladder, and in that rung, insert the AWA function
block. For this block, user will have to create 2 different user defined variables, one of
type AWAAWT and the other of type ASCIILOCADDR. For this application, we created
a variable called AWA_Input of data type AWAAWT and another variable called
CHAR_SOURCE of data type ASCIILOCADDR.

14) After creating the variables (either by going into Local Variables under Project Organizer,
or by Double-clicking on a sub-block), expand the AWA_Input variable and specify the
channel to be used and the amount of characters to be sent. Once done, assign the
AWA_Input variable to the AWAInput sub-block.

15) Expand the CHAR_SOURCE variable and under initial value, type the Dec equivalent of
the ASCII characters you wish to display. For this application we want to display
numbers 0-9, thus our values will look as follows:
16) Assign the CHAR_SOURCE variable to the AWA SOURCE sub-block. Then add a
Direct Contact before each function block in order to manually enable each block. The
ladder should now look as follows:

17) Since the AWA Function Block needs to have a/an appended character/s, we need to
specify these characters under the ASCII Properties settings.
18) For this application we will choose a single character to append of value “a”, thus on the
Append Chars option for ASCII settings we will type 0x61 to denote char “a” and 0xFF
to end the Append. The ASCII settings should now look as follows:

19) 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.
20) Once the program finishes downloading, go on Debug Mode by clicking on the green
play button or by pressing the F5 windows key.

21) As of now, the buffer should be empty, thus if you initialize the ABL 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_ABL box to energize the ABL Function Block, as you may see
the char count is 0:

22) Type some characters in the HyperTerminal and uncheck then recheck the start_ABL
box. The char count should now update and display the amount of char that were typed in
the HyperTerminal. (Remember that the ABL function block has the carriage return as the
termination character, so the char count will only be displayed if the carriage return was
entered).
- 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.
23) Now we will use the ACL Function Block to clear the buffer. Make sure that the
start_ABL 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
ABL Function Block again, you will see that the character count is now 0.
24) We are now going to use the AWA Function block to send characters to the
HyperTerminal. While on the Variable Monitoring screen, check the start_AWA box in
order to energize the AWA function block. The AWA NumChar should now display a
value of 11 (this is due to char 0-9 being sent plus the addition of the single termination
character). The ladder and HyperTerminal should now be displaying the following:

25) If you need to read a character count again by using the ABL Function Block, you must
clear the buffer by de-energizing the AWA Function block. To do so, expand the
ACL_Input variable and make sure that TXBuffer is checked this time then energize the
ACL Function Block again.

You might also like