The data flow diagram (DFD) of the program encoder for Arduino Motor Encoder Project is as follows.

Fig-1: Data Flow Diagram of the Arduino Motor Encoder

In figure 1, the function RQ_0 in the middle represents the loop function of the Arduino source code. The functions surrounding it are the functions representing interrupts those count the turn of the motor. The functions are, A_RISE, A_FALL, B_RISE, B_FALL. A_RISE calls A_Fall within its definition and is called by the loop function. Similarly, B_FALL is embedded within the function body of B_RISE. B_RISE itself is called by the loop function as well.

Necessaries for Reverse Modeling

Arduino source code, Embetics software.

Procedure of Reverse Modeling using Embetics

Step-1: Setup the Environment

Open Embetics. Then from file menu, open new project. Specify the folder and click “Ok” button. Open “Project Configuration” from the view menu or by right clicking the name of the project from the “Architecture” tab of the “Model Management” menu. Select Arduino as platform. There is no need to change anything else.

Fig-2: Environment Setup

Then from file menu, import the appropriate model of Arduino.

Step-2: Implementing Setup Function

In the “Project Configuration” menu, select “Start Process” tab. A form will appear. Write down the contents of setup() function from the source code in this form. 

Fig-3: Implementing setup() function

Step-3: Implementing Logic

Open “Context Diagram”. 

Fig-4: Implementing logic – 1

Clicking “Feature Requirement” button will create a box like shown in figure 4. Create logic by right clicking on the box. A window like following figure will appear.

Fig-5: Implementing logic – 2

Add the variables by clicking the “Add” button and editing the variables as shown in the following figure.

Fig-6: Declaring variables

Then edit the empty form and write the contents of loop function from the Arduino source code in it.

The variables can be called by right clicking and selecting insert from the pull down menu and then selecting data and the category as “Process Local Data”.  

Fig-7: Implementing loop() function

Create DFD from the “Context Diagram”.

By double clicking on the function under DFD in the “Model Management” window, following window can be opened.

Fig-8: Creating functions

Right click on the white part of the form. Insert process. Double click the process and write the content similarly to the procedure of creating loop().

Step-4:Code Generation

At this point, source code can be generated by using “Generate” menu from the menu bar.