B 81507 Ecc
B 81507 Ecc
Guide
Getting Started
Guide
Introduction
Flowcode is an Integrated Development Environment (IDE) for programming
microcontrollers such as 8, 16 and 32bit PIC, Arduino and ARM devices.
It achieves this by using flowcharts instead of text based languages, thus
making programming simpler and faster.
Flowcode also contains hundreds of pre-made component libraries,
allowing users to interface with a host of sensors, inputs 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.
Flowcode supports both Matrix and 3rd party hardware. In this guide we will
create examples based on three different sets of hardware;
1. Matrix EB006 multi-programmer and EB083 development board
2. Arduino Uno and Matrix EB083 development board
3. Microchip Xpress development board
Prerequisites
A Windows based PC with a copy of Flowcode 7 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. Did you know?
As we are using an EB006 board, with the default PIC16F1937 attached, we
Flowcode can
will need to ensure Flowcode has the corresponding chip selected. When
program hundreds
using Matrix hardware, this has automatically been configured for the of different
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 EB006; If you are using the Microchip
Xpress board;
1. Select the PIC8bit devices
2. Select the PIC16F family from 1. Select PIC8bit
within the PIC8bit devices 2. Select Misc family
3. Select the 16F1937 ensure you do 3. Select Microchip MPLAB Xpress
NOT select the Low Voltage (LV) 4. Press OK
version
4. Press OK We do not need to
configure any other options at this
point
Once Flowcode has opened you will be presented with a blank IDE as seen
below;
7
1
6 5
3
4
1 3 4
2
3. Tools
In this tool box you can adjust
the configuration properties of
the simulation panel; change
background colour, snap to grid,
lighting modes and more.
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
provided information, requiring you to remember what youve
learnt in previous examples.
Template files
Flowcode comes with a selection simulation panel, and be configured
of template files which are made to correctly.
assist you with development. These
are based on popular development For our first example we will use a
boards from Matrix and 3rd party template file and in example 2 and 3
equipment such as Microchip, we will create a new blank project, to
Digikey and Arduino. The template demonstrate both processes. To use
file will have all the necessary template files, start a new project and
hardware components added to the choose Open Template.
You will be presented with the following screen. If you are using the EB006 and
EB083 board, navigate to the 16F1937 section and select EB083. Flowcode will
open and have the EB083 development board configured as standard. We are
now ready to begin example 1.
Now we will create our flowchart. To Drag a Loop over to your flowchart
make our microcontroller execute as seen below. By default the loop
code indefinitely we add a while(1) command is set to be a while(1)
loop to our flowchart. This loop loop, so it does not need any further
condition essentially means that configuration.
whatever code is placed within 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 very right allow us to manually step
finished. First we will simulate through our program. As previously
our program to check it works as mentioned microcontrollers operate
required. Then we will write it to at very high speedsmuch faster
hardware, and get a real LED flashing. than we can see! We often need to
manually step through each icon in
To simulate, we use the buttons order to check that our program is
seen in the image below. The Play working correctly.
button begins our simulation. Once
in play mode we can pause or stop
our simulation. The two icons on the
If we run our simulator we will see that our LED flashes on for 1 second, and
off for 1 second.
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 If you are using
hardware. 3rd party hardware
you must ensure
you consult the
EB006v9 8bit multi-programmer board appropriate
documentation
The datasheet for the EB006 can be found on our website. Ensure the EB006 from the
has the default PIC16F1937 microcontroller inserted. The EB006 will be both manufacturer.
powered and programmed via the USB cable.
2. Arduino hardware
If you are using an Arduino Uno you from within Flowcode you should
must ensure you have the Arduino now check that Flowcode has seen
drivers installed before you can your connected hardware. Navigate
program directly from Flowcode. to Build-> Project Options ->
Consult the Arduino website to General Options and you will see the
download the latest drivers for your image below. From the Programmer
hardware. Port drop down box you must select
the COM port used by your Arduino,
With the drivers installed, and the here COM7.
Arduino microcontroller selected
Consult the table below for connection properties relevant to the hardware
you are using;
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.
Next, add a while(1) loop to the connected to, see the table above).
flowchart, as we did in the first You must also select to save to the
LED flasher example. Then, add an variable called SwitchPressed. This
input to the flowchart within this reads the switch whenever we call
loop. Configure the input as below, this icon, and will save its state to the
ensuring that you select Single Bit; variable SwitchPressed. If the switch is
PORTA.0 (for the Arduino Uno or pressed, it will return a 1, if nothing
Xpress board you will need to select is pressed, it will return a 0.
the same pin that the switch is
Add a delay of 50ms directly after your input icon to allow for bounce.
With the value now stored in the There are several ways to achieve
variable SwitchPressed we must this, but for this one we need a
do something with it. We could just second variable, which we have
add a single output icon to turn named Flag. What we want to do is
on the LED whenever we press the toggle the value of Flag only when
switch, but thats a bit too simple. the button is pressed. To achieve
Instead we will make a latch, so this we use a Decision command.
when the switch is pressed it turns The first thing we need to do is
on the LED and holds it on until the determine whether the switch was
switch is pressed again. pressed or not. Drag a decision
command onto the flowchart, and
configure it as seen below;
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.
Create a new flowchart with the correct microcontroller selected and add an
LCD (EB005, 16x2) screen to the simulation panel. This is the screen used on
both the standalone EB005 E-block, and the EB083 development board used
in this tutorial.
With the LCD screen added to the simulation panel you should check
its connection properties. Consult the table below to check connection
properties;
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.
Once opened you will see a list of 12 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
two more component macros. The we need. We want our value of
first is to display the value of the Counter to always be displayed in
variable counter on the LCD screen. the top left corner (X,Y position; 0,0).
Add another component macro Currently our program will write the
within the while(1) loop, directly value of Counter on the LCD screen,
above the calculation box. Configure however, the cursor will move each
it to be a PrintNumber macro, time we write a value and we will end
however, you will notice that there up with something like below;
is a 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.
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.
Version control
@MatrixTSL
www.matrixtsl.com