Flowcode8 GettingStartedGuide
Flowcode8 GettingStartedGuide
Guide
Getting Started
Guide
Introduction
Flowcode is an Integrated Development Environment (IDE) Flowcode supports both Matrix and 3rd
for programming microcontrollers such as 8, 16 and 32bit PIC, party hardware. In this guide we will create
Arduino and ARM devices. It achieves this by using flowcharts examples based on three different sets of
instead of text based languages, thus making programming hardware;
simpler and faster. 1. Matrix BL0011 multi-programmer and BL0114 combo
Flowcode also contains hundreds of pre-made component board
2. Arduino Uno and Matrix BL0114 combo board
libraries, allowing users to interface with a host of sensors, inputs 3. Microchip Xpress board
and outputs and electro-mechanical components with ease.
Despite its simplicity and ease of use, Flowcode is a powerful tool
allowing users to develop even the most complex of embedded
systems.
Prerequisites
• A Windows based PC with a copy of Flowcode 8 installed
Creating a project
When you first launch Flowcode you will be presented with the following splash screen. For
the first run through we want to start a new project as this gives us a blank canvas to go over
the IDE. Later we will look at the use of pre-configured template files.
Once a new project is started, you need to select the correct microcontroller. As we are Did you know?
using an BL0011 board, with the default PIC16F18877 attached, we will need to ensure Flowcode can program
Flowcode has the corresponding chip selected. When using Matrix hardware, this has hundreds of different
automatically been configured for the correct config properties and clock speed etc. microcontrollers. All are
slightly different, and as
such, it is essential that
you select exactly the
right microcontroller you
are using.
If you are using the BL0011; If you are using the Microchip
1. Select FREE thenBL0011 Xpress board;
OR
1. Select FREE then Microchip MPLABEpress
1. Select PIC
OR
2. Select ‘PIC’ Family (dropdown)
1. Select PIC
3. Select 16F18877
2. Select ‘Misc’ Family (dropdown)
3. Select Microchip MPLABXpress
If you are using the Arduino Uno; For any other Arduino devices;
1. Select FREE then Arduino 1. Select ARD
OR 2. Select ‘Misc’ Family (dropdown)
1. Select ARD 3. Select relevant device from the list
2. Select ‘Misc’ Family (dropdown)
3. Select Arduino Uno R3 PDIP
Once Flowcode has opened you will be presented with a blank IDE
as seen below;
7
1
6
5 3
4
2
4. Command Toolbox
Drag and drop programming icons onto
the Flowchart window (5) to construct your
program.
1 3 4
Section 2: Flowcode
Examples
We will now run through several examples; LED
flasher, creating a latch and finally the use of an
LCD screen to create a counter. Each will increase
in complexity and at the same time reduce in pro-
vided information, requiring you to remember what
you’ve learnt in previous examples.
Template files
Flowcode comes with a selection of For our first example we will use a template
template files which are made to assist you file and in example 2 and 3 we will create
with development. These are based on a new blank project, to demonstrate both
popular development boards from Matrix processes. To use template files, start a
and 3rd party equipment such as Microchip new project and choose ‘Open Template’.
and Arduino. The template file will have
all the necessary hardware components
added to the simulation panel, and be
configured correctly.
You will be presented with a choice of templates where you can select the most
appropriate board for your use . For example, if you’re using the BL0011 and BL0114
combo board, navigate to E-blocks2 section and select BL0011_Combo. We are now
ready to begin example 1.
Now we will create our flowchart. To You can drag the Loop over to your
make our microcontroller execute code flowchart, yet using Templates create
indefinitely we use a while(1) loop in our the Loop for you. By default the loop
flowchart. This loop condition essentially command is set to be a while(1) loop, so it
means that whatever code is placed within does not need any further configuration.
our loop will execute, forever.
To make an LED flash we must turn it on and off. Place another output icon on your
flowchart, below the original, and configure it as before. Although this time you should
write a value of ‘0’ instead to turn our LED off.
Currently we turn our LED on for 1 second, then we turn it off. However, we do not hold
the LED off and so it will turn on again very fast. It would therefore appear that the LED is
always on. We must add another delay icon after we turn the LED off, which can be seen
in the final flowchart below.
The simple LED flasher is now finished. step through our program. As previously
First we will simulate our program to check mentioned microcontrollers operate at
it works as required. Then we will write it to very high speeds…much faster than we
hardware, and get a real LED flashing. can see! We often need to manually step
through each icon in order to check that
To simulate, we use the buttons seen in
our program is working correctly.
the image below. The ‘Play’ button begins
our simulation. Once in play mode we
can pause or stop our simulation. The two
icons on the very right allow us to manually
If we run our simulator we will see that our LED flashes on for 1 second, and off for 1
second.
Now that our program has been simulated Depending on the hardware used, we will
and is working as required we will now provide some information below to
download our program to hardware. check that it is connected and configured
correctly and you are following the correct
procedure for programming.
We will now cover the configurations needed for the three types of
hardware covered in this guide:
1. Matrix hardware
2. Arduino Uno hardware
3. Microchip Xpress hardware
1. Matrix hardware
In this section we will briefly discuss the Matrix hardware.
2. Arduino hardware
If you are using an Arduino Uno you must hardware. Navigate to Build-> Project
ensure you have the Arduino drivers Options -> General Options and you
installed before you can program directly will see the image below. From the
from Flowcode. Consult the Arduino ‘Programmer Port’ drop down box you
website to download the latest drivers for must select the appropriate COM port for
your hardware. your Arduino (COM’s is shown in the image
With the drivers installed, and the Arduino below but this might be different on your
microcontroller selected from within PC). Note that the COM port will only be
Flowcode you should now check that shown if your Arduino is connected and the
Flowcode has seen your connected drivers are installed.
3. Microchip
Xpress hardware
If you are using the Microchip Xpress have programmed your board, you will see
hardware, ensure you have the correct the name of your program saved as a .HEX
microcontroller selected from the Project file on your board
Options menu. As with other hardware,
Once your flowchart is complete you
press compile to chip, and Flowcode will
create a hex file by pressing the button
program the Xpress board.
seen below;
Note; There are no drivers to install for
the Xpress board, however, check it has
been seen correctly by navigating to my
computer and the Xpress board should be
seen as a mass storage device. After you
With your appropriate hardware connected icon compiles the Flowchart into a .Hex
and configured correctly, you must now file. These two options are useful if
program the device. you are using Flowcode to create your
program, but 3rd party hardware to
In Flowcode it is easy to download our
flash your microcontroller. With these
program to hardware. When downloading
examples we are using Flowcode to flash
code to our device we again have a
our microcontroller, and as such we use
shortcut toolbar. There are 3 icons in the
the right hand icon. This compiles and
programming section of the toolbar, as
programs our microcontroller in one button
seen below. The left icon compiles our
press.
flowchart into a .C file, while the middle
Once we select to program the device a new window will appear on the screen detailing
the compilation and programming progress. When complete you should see the
program working as desired on hardware. If it is not, ensure that you have followed every
step in this tutorial, and that the flowchart is correctly configured.
Example 2:
Creating a latch
In the next two examples we will assume First we will add our components to the
you are now getting to grips with Flowcode simulation panel. We need;
and will provide you with a few less details.
We’ll still walk you through any new • LED (5mm, PCB)
• Switch (Push, Panel)
features though, so do not worry.
In this example we will look at adding
a switch to the simulation panel, and
creating a latching system from a simple
momentary push-to-make switch. First you
must create a new program and select the If you double click on a component in the
appropriate microcontroller as discussed System Panel you can access its Properties
earlier in this guide. where you can change port connections of
the component if required.
We will create a program that reads the
switch and lights up an LED when pressed.
When the user releases the switch the
LED should stay on until the switch is
pressed again. This will introduce us to two
new programming concepts; inputs and
variables.
LED A0 A0 A0
Switch B0 D0 A5
We will now create a variable. When reading inputs we must have a variable to save the
state of the switch press. To create a variable click on the down arrow next to ‘Variables’ in
the Project Explorer and click ‘Add new’.
The ‘Edit variable name’ window will appear. There are 4 sections we should fill out.
Although the description is optional, it is good practice to do so.
a. Here we’ve called our variable SwitchPressed. purely a visual hint, and has no bearing on function-
Note you cannot have spaces in variable names. ality.
b. We have initialised our variable to zero to ensure no d. We are selecting this as a type ‘byte’, therefore it
old values remain in memory can save any value between 0-255.
c. We added a brief description so that later we can
remember exactly what this variable does. This is
Next, add a while(1) loop to the flowchart, table above). You must also select to save
as we did in the first LED flasher example. to the variable called SwitchPressed. This
Then, add an input to the flowchart reads the switch whenever we call this
within this loop. Configure the input as icon, and will save its state to the variable
below, ensuring that you select Single Bit; SwitchPressed. If the switch is pressed, it
PORTA.0 (for the Arduino Uno or Xpress will return a ‘1’, if nothing is pressed, it will
board you will need to select the same pin return a ‘0’.
that the switch is connected to, see the
With the value now stored in the variable which we have named ‘Flag’. What we want
‘SwitchPressed’ we must do something to do is toggle the value of Flag only when
with it. We could just add a single output the button is pressed. To achieve this we
icon to turn on the LED whenever we use a ‘Decision’ command. The first thing
press the switch, but that’s a bit too simple. we need to do is determine whether the
Instead we will make a latch, so when the switch was pressed or not. Drag a decision
switch is pressed it turns on the LED and command onto the flowchart (underneath
holds it on until the switch is pressed again. the delay icon), and configure it as seen
below;
There are several ways to achieve this, but
for this one we need a second variable,
Since we are creating a latch we only want to modify the value of Flag when the switch
has been pressed. Therefore, we will only place code in the ‘Yes’ branch of the decision.
We leave the ‘No’ branch empty. Once the switch has been pressed we want to toggle
the value of Flag from 0-1 or vice versa.
Place a calculation box within the Yes branch. The statement here Flag = !Flag will toggle
the value of Flag between 1 and 0 each time it is executed.
Our final command is to output the status of Flag to the LED. We do this with an output
command, as we did in the first example. However, rather than writing a 1 or 0 in the
‘Variable or Value’ box we write the variable name Flag.
You should now both simulate and download your code to hardware for verification. As
you press the switch on your board, the appropriate LED should illuminate, and stay
that way until you press the switch again. Once confirmed working, move onto the final
exercise.
Example 3: LCD
screen and
counter
In the final example we will step through As with example 2, we will step through
creating a simple counter, and displaying familiar concepts with less detail, but any
that value on an LCD display. (If you are new features will be carefully explained.
using the Xpress board, this exercise can
Create a new flowchart with the correct
only be performed in simulation mode).
microcontroller selected and add an LCD
In this exercise you will be introduced to a (Generic, 20 x 4) screen to the simulation
new flowchart command; the component panel. This is the screen used on both the
macro. A component macro is how standalone BL0169 E-blocks2, and the
we interface with the more complex BL0144 combo board used in this tutorial.
components in Flowcode. For simple
With the LCD screen added to the
things like switches and LEDs we can use
simulation panel you should check its
inputs and outputs. However, if we want
connection properties. Consult the table
to talk to an LCD screen we may need to
below to check connection properties;
execute a series of commands back and
forth. Component macros are libraries of
code that we have developed that simplify
such things. A component macro therefore
is a sub-routine, and is a block of code that
can be called by a single flowchart icon.
We will now quickly progress through a few steps where we are doing familiar coding. If you
struggle to keep up you can check the code listing at the end of this section.
If we were to run this program now it would Despite having a counter we do not
simply count up from 0-255. Since we are yet have a method of displaying this
using a variable type of Byte for ‘Counter’ it information on the LCD screen. We will
will reach 255 and roll back around to zero now introduce component macros. Add a
where it will continue counting again. component macro to the very start of your
flowchart, above the while(1) loop, as seen
below;
Open its configuration properties, as usual, by double clicking on the component macro.
You will see the box below. Press the + button next to the LCD_4x20 component to
access the available component macros.
Once opened you will see a list of 13 component macros available for the LCD screen.
These are all pre-written sub routines, developed by Matrix, to assist you with using the
LCD screen. The first we want to use is ‘Start’. Select Start and press ‘OK’.
With the screen initialised we need There is one final component macro we
two more component macros. The first need. We want our value of Counter to
is to display the value of the variable always be displayed in the top left corner
‘counter’ on the LCD screen. Add another (X,Y position; 0,0). Currently our program
component macro within the while(1) will write the value of Counter on the LCD
loop, directly above the calculation box. screen, however, the cursor will move each
Configure it to be a ‘PrintNumber’ macro, time we write a value and we will end up
however, you will notice that there is a with something like below;
parameter box that you must now fill in,
called ‘Number’. Here we must write the
name of our variable; Counter. Each time
this command is now executed it will
display whatever value we currently have
saved in counter.
What we need to do is clear the LCD screen each time we write a new value. Luckily
for us executing a clear screen routine also moves the cursor position back to (0,0). Add
another component macro above the PrintNumber macro, and configure it to ‘Clear’.
We have now finished our third and final example. You should first test your program
is right by comparing it to the code listing below. Simulate, before downloading to
hardware to confirm it works.
Did you know?
The BL0114 combo board
has small slide switches
used to turn the LCD
screen and the 7SEG
LCD screen on and off.
Make sure that this switch
in in the ‘on’ position for
the LCD screen when
using.
We have now introduced you to the most basic principles within Flowcode. These
principles are the foundation of all microcontroller development. There are more
complex features that we have not covered, but at this point you should have an
understanding of how Flowcode works, and be able to begin experimenting for yourself
as to other features.
@MatrixTSL
www.matrixtsl.com