Difference between revisions of "Exercise - Simulating a Program"

From Flowcode Help
Jump to navigationJump to search
(Replaced content with "For an excellent introduction guide, we recommend [https://www.flowcode.co.uk/education/ Introduction to microcontroller programming]")
Tag: Replaced
 
(24 intermediate revisions by 3 users not shown)
Line 1: Line 1:
This exercise looks at testing the flowchart 'Lamp1.fcf' which you developed in the exercises [[Exercise - Creating Your First Flowchart|Creating Your First Flowchart]] and [[Exercise - Adding Devices to Your First Flowchart|Adding Devices to Your First Flowchart]].<br />
+
For an excellent introduction guide, we recommend [https://www.flowcode.co.uk/education/ Introduction to microcontroller programming]
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]].
 
 
 
 
 
 
 
__TOC__
 
 
 
 
 
==Load the Flowcode Flowchart==
 
 
 
* Open the flowchart, called 'Lamp1.fcf' which you created in the exercise [[Exercise - Creating Your First Flowchart|Creating Your First Flowchart]].
 
:(For help with this, see the exercise [[Exercise - Opening an Existing Flowchart|Opening an Existing Flowchart]])
 
 
 
 
 
==Run the simulation==
 
* Click on the 'Run' icon, (or hit the F5 function key.)[[File:gen_exerciseSImulatingFirstFlowcode_runicon_01.png|30px]]
 
: The 'Simulation debugger window may open - ignore it for now! (For more information, see [[Simulation Debugger]])
 
* 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.)[[File:gen_exerciseSimulatingFirstFlowcode_simstopicon_01.png|30px]]
 
 
 
 
 
==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.)[[File:gen_exerciseSimulatingFirstFlowcode_stepintoicon_01.png|30px]].
 
:: 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 [[Exercise - Transferring Your First Flowchart to the Microcontroller|Transferring Your First Flowchart to the Microcontroller]].
 

Latest revision as of 13:13, 25 April 2023

For an excellent introduction guide, we recommend Introduction to microcontroller programming