This article has been provided by David Johnson, Flowcode 7 user.
Flowcode boasts an exciting new feature which is an essential de-bugging tool for optimising your projects. The “test and debugging” feature pack can be added to your Flowcode licence at www.matrixtsl.com/flowcode/buy/purchase.php. Alternatively, a free version of Flowcode 7 is available here: www.matrixtsl.com/flowcode/download/
Code profiling provides the ability for the user to check code ‘dynamically’ (whilst it is running), a feature which has only been launched this summer to coincide with the release of version 7. I am a Flowcode user and so for the past couple of months I have been exploring more of the software features and I can assure you, it’s much more than just showing “hits per icon”.
Designing executable code using Flowcode 7 requires designers to follow a train of thought to achieve your desired goal. Getting it to work efficiently requires dedicated tools which go beyond just the simulation of your projects.
With code profiling, you are able to examine how your code is behaving as it is running, allowing you to pinpoint sections of code that have become ‘redundant’ as your project develops over time. Users can then optimise the code they use.
Above is a simple example; a fixed valued has been replace by an assigned variable (83°C) which has made the section of code within the decision loop redundant. Removing it helps me to optimise my code!
I was pleased to find that Flowcode 7 has much more to offer too. What about code efficiency? Icons showing the hit percentages (%). This shows how much time (as a %), was spent during program execution at a specific point.
The above example shows the main branch checking if ‘task 0’ is to be undertaken and if so how much time as a % was spent doing the task.
This PID controller has 5 tasks, which need to be performed, one task at a time, before returning back to do the next task. Therefore, 100% divided by 5 gives us 20% available per task, which is correct. How much time spent doing the loop check – less than 1% of the available time. Brilliant, no time wasted there!
Next I looked into the inner workings of my code – the variables. When you hit a problem such as decision making or fuzzy logic parts of your program, you need a way of observing what is going on with those variables. The interaction of variables and how they change, greatly impacts on what the code will do under given conditions. In this program, it was expected that (during simulation on the display) the percentage power requirements being displayed would be updated once per second. This was not the case; it was much slower. I asked myself; was this due to the program taking longer to perform each of the tasks or has a mistake occurred in the design of the program?
Above, you can see that the display showed me the pace of change was very slow; code profiling had helped me to diagnose the problem very quickly.
So, to fix my problem; using the drop down menu (see below) you are able to select which variables you want to observe during program execution.
These displayed variables are updated in ‘real-time’ during execution of the code. The variables can be displayed in each of the available formats such as decimals; HEX or floating point values.
This revealed to me that the loop was not changing every second as intended. I was able to go straight to the offending code to correct this.
I came to the conclusion that the ‘decision’ which can be seen half way down the screenshot above, needs to be moved up so it can be performed as required.
My overall conclusion is the code profiling in Flowcode 7 has given me a tool I can use to dynamically evaluate code performance in ‘real-time’. Absolutely essential, if you wish to build good, efficient programs and minimise development time.
David Johnson, Flowcode 7 user.
5,139 total views, 2 views today