• No results found

Read and Write Terms

In document GE Intelligent Platforms (Page 61-64)

Assume that after the program has been operating for awhile, a decision is made to use two different types of cans, types A and B. The operator enters the type of can after it is placed onto the conveyor. A message is sent to the screen prompting the operator to enter the type of can placed on the conveyor.

State: PowerUp

If the Can_In_Place is on,

write “Enter type of can (A or B), then <ENTER>.” and go to the Operator_Input State.

State:Operator_Input

Read Can_Type, then go to the Fill_Station_Wait State.

Enter the program changes as shown above. First the PowerUp State of the Conveyor Task is changed so that a message is sent to the screen after the Can_In_Place switch is tripped. A new State is added which reads the operator’s entry at the keyboard. This State is called Operator_Input and becomes active after the Can_In_Place switch is ON.

As soon as this input is entered at the keyboard, the State transitions to the Ready_To_Move State and the conveyor Task continues execution as before.

When adding States to a program, make sure the cursor is at the position where the new State is to appear before selecting the ADD option from the menu or merely type in the program changes as they appear above.

Define Can_Type to be a string variable. The write term is a functional term which must appear after the conditional term in the Statement. The write term sends everything that appears inside the double quote marks to the terminal, therefore the period is sent to the terminal as part of the message transmitted and does not indicate the end of the Statement.

The read term is a conditional term which is not satisfied or true until the <Enter> key is pressed signaling the end of the operator input. Therefore the read term must be used

with some care so that a time critical Task is not delayed waiting for some input from the keyboard. As soon as the <Enter> key is pressed, the conditional is satisfied and Ready_To_Move becomes the new active State.

Counter

Assume also that the decision to change the application includes keeping track of the number of each type of can that has been placed on the conveyor. A counter is created for each type of can. ECLiPS provides a complete range of mathematical functions in-cluding trigonometric and transcendental functions.

A new State is created which becomes active after the operator completes his input. This State adds 1 to one of two variables holding the number of cans of the particular type.

After the counters are set, we write the number of each can type to the screen.

Change States in the Conveyor Task as follows:

State:Operator_Input

Read Can_Type, then go to the Counter State.

State: Counter

If Can_Type = “A”, make Number_A_Cans = Number_A_Cans + 1.

If Can_Type = “B”, Add 1 to Number_B_Cans.

Write “The number of type A cans is %Number_A_Cans.”.

Write “The number of type B cans is %Number_B_Cans.”.

Go to Fill_Station_Wait.

Define the variables, Number_A_Cans and Number_B_Cans, to be integer variables.

This change demonstrates the concept of variables. Variables hold some data which may be manipulated, compared, and written to the screen.

The string variable Can_Type is compared to two different given strings. Strings are en-closed in double quote marks, so in our write Statements we are writing out strings of characters.

We manipulate the two integer variables by incrementing them by 1, if the preceding conditional is true. These variables hold the value of the counter. Notice there is a short way to perform simple addition: “Add 1 to Number_B_Cans.”

These program lines demonstrate the use of variables in write Statements. The % indi-cates that the value of the following variable is what is to be printed, not the variable name. See the reference chapter or help system for other formatting functions available for the write term.

Diagnostic

Programmed diagnostics provide alternate paths of program execution when machine

To deal with this problem a diagnostic is added to the Wait_for_Can_Removal State of the Fill_Station Task. In this State the program is waiting for the can to be moved. If the weight of the can goes over 31 pounds in this State then we know one of the valves is stuck in the open position.

When the problem is detected the process transitions to an alarm State where a message is sent to the operator’s screen and the Task halts until the operator resets the alarm condition.

To enter the diagnostic follow this procedure. Place the cursor at the end of the Wait_for_Can_Removal State. Now, choose the ADD option from the program menu and then the “Add an Analog Range Checking Diagnostic” choice from the next menu. A list displays all of the defined analog channels, only one in our case. Choose this chan-nel, which is now entered into the diagnostic form displayed on the screen. Enter 31 as the high limit value, press <Enter> and then enter alarm in the first “Branch to:” blank.

Alarm is the name of the State created to respond to our alarm condition. When com-plete press <F9> and answer yes that you want to save the entered data. A program line is entered into the text which performs this diagnostic.

Add the following States to the program:

State: Alarm

Write “Chemical valvesnot closed.”.

Write “Hit any key then <ENTER> to reset this alarm”.

Go to Reset_Alarm State.

State: Reset_Alarm

Read Alarm_Reset, then go to Wait_for_Can_Removal State.

Now when the faulty conditions occurs, the program displays the alarm message and how to reset the alarm so the process can continue. After the alarm condition is reset the process returns to the Wait_for_Can_Removal State. Assume that the problem has been corrected and the can has been removed or some of the chemicals removed so that the process does not reenter the alarm State. Note that the conveyor does not move until the Fill_Station Task is in the PowerUp State. Define Alarm_Reset to be a string variable.

This alarm diagnostic is the first instance where the States of a Task are not strictly se-quential. States can be written in any order in the Task and GO Terms may transition to any other State in a Task.

Now that you have programmed your first applications using State Logic, you have a fundamental knowledge of ECLiPS which is sufficient for many applications.

5

figure bi level 1 table_big level 1

The hints and suggestions found in this chapter have been developed by ECLiPS and State Language programmers in an effort to make the user’s first programming experi-ence as productive as possible. There are two parts to this chapter, one giving hints for programming and the other has suggestions for using the tools provided as part of ECLiPS.

In document GE Intelligent Platforms (Page 61-64)

Related documents