Step 3: Finish the Flow diagrams in the states.
Double click the IDLE state in the state diagram. (The flow diagram of the state will open). Double click the yellow enter-block to edit it.
Right click the yellow area and select "Insert After" from the popup -menu. (A function editor will popup).
Select "Serial Lib" from the library ring-list. Now select the "SER_Setup" function
if it is not selected yet.
Fill in the parameters for this function as shown on the right and press the Set-button. This finished the work for the IDLE state's flow diagram.
Now right-click the "Data Browser" and select "New Variable" from the popup-menu.
Change the name in the Variable Editor into "Char". Make sure the type is set to BYTE and press OK.
|
The Data browser will show the new variable under the "User Vars" section. (Double Click the "+" to open the "User Vars" section). This variable will be used to store characters received from the serial port and send them back.
Single block of flow diagram for IDLE-state.
Select "STD: MAIN" from the "Windows" menu to bring the STD diagram to the front again.
Double click the RECEIVE state in the state diagram. (The flow diagram of the state
will open). Double click the yellow enter-block to edit it (It will enlarge).
Right click the yellow area and select "Insert After" from the popup -menu.
(A function editor will popup).
Select "Serial Lib" from the library ring-list and the "SER_Get_char".
Fill in the parameters for this function as shown below.
Single block of flow diagram for RECEIVE-state.
Right-click this new function in the yellow block and select "Insert After" again.
This time select the "SER_Put_char" function from the "Serial Lib".
Fill in the parameters for this function as shown above.
In this example the flow diagrams are just single function-blocks, since no if-then or loop-constructions are required, which connect several function-blocks.
|