Exercise - Simulating a Program

From Flowcode Help
Jump to navigationJump to search

<sidebar>Sidebar: Flowcode Exercises:Ex1</sidebar> This exercise looks at testing the flowchart 'Lamp1.fcf' which you developed in the exercise Adding Devices to a Program.
The first part of this process is to simulate the flowchart. This tests the program only, and not the hardware. It is done within the Flowcode program itself, and does not require that any hardware is present. For more details about simulation, see Overview of Simulation.



Load the Flowcode Flowchart


Run the simulation

  • Click on the 'Run' icon, (or hit the F5 function key). Btn Run.png
The Simulation debugger window may open - ignore it for now!
  • Nothing happens until you switch the lamp on. To do this, click momentarily on the push switch.
The lamp comes on and the 'Simulation Delay' window opens, as Flowcode simulates the ten second delay.
At the end of this, the lamp goes off.
  • You can repeat the process as many times as you like. When you are ready, click on the 'Stop simulation' icon, (or press the Shift and F5 keys). Btn Stop.png


Step through the simulation

When things don't go according to plan, it is useful to simulate the program step-by-step, (meaning icon-by-icon.)
To do this:
  • Click on the 'Step Into' icon, (or press the F8 key). Btn Step Into.png
A red box appears around the first icon in the flowchart.
When you click on the icon again, the program executes that icon, and the red box moves onto the next icon.
In this way, you can check whether or not the expected actions happen.
  • At any point, click on the 'Stop simulation' icon to end the simulation.
For more information, see Simulating Icons Step by Step.


What next?

Once you have shown that the flowchart does what you want it to, the next step is to transfer the program to the microcontroller, and test that it runs the hardware as you want it to. That is covered in the exercise Transferring a Program to the Microcontroller.