Practical_Electronics-May_2019

([email protected]) #1

Insert the test probe into the fi rst point
(number 2) and type SETPIN(2),DOUT
followed by the Enter key. Next type
PIN(2)=1 and again hit Enter. The test
LED should now turn on (if not, first
check for typing errors on the TeraTerm
screen and also check your test probe is
at point 2). If the LED is still off, then
you have an issue with I/O number 2
somewhere between the MKC and the
point being tested.
If your test LED successfully turned
on, then move the test probe into the next
point (number 3 in this case). The test LED
should now be off. If however it is on,
then you have a short somewhere between
the tracks for I/O number 2 (which is on)
and the tracks for I/O number 3 (which
is ‘fl oating’).
Assuming the test LED is correctly
off with the test probe in point number
3, type: SETPIN(2), OFF (Enter),
SETPIN(3),DOUT (Enter), PIN(3)=1
(Enter). This should turn on the test LED
once again.
You then need to work through the
above process that is summarised as:
● Probe into point x
● SETPIN(x),DOUT
● PIN(x)=1
● Check LED on
● Move probe to next point y
● Check LED off
● SETPIN(x),OFF
● SETPIN(y),DOUT
● PIN(y)=1
● check LED on


Replace x and y above with the relevant
pin numbers; so x would become 3, and
y becomes 4. Hopefully this is fairly
straightforward, but remember the pins
are not always the next value up, so
when checking point number 7 (for x),
y will be 9 (and not 8). Refer to J12 in
Fig.2 for the numbering sequence you
need to use. When you fi nally reach 26
(for x), the LED should turn on when you
type PIN(26)=1. If it does, then testing
is complete.


Confi guring your MKC
and TeraTerm
To make things more user-friendly, we
will tweak some settings in both the
Micromite, and in TeraTerm (refer to the
screen shots in Fig.3). Begin by connecting
your MKC to TeraTerm, (remember to
select the correct COM Port number, and
also ensure baud speed is set to 38,400)
and then press the Reset button on the
DM (top-left button). You should see the
Micromite and copyright message, as in the
two lines shown in Part 3 (Fig.9 on page
65). This means that you are successfully
connected to the PC. Now press the ‘C’ key
while holding down Ctrl and you should
see the command prompt (>).


Next, type the
following (strictly
in the sequence
shown). First,
type NEW (Enter).
This will remove
the program in
your MKC. If you
had the MKC test
software installed,
then on the next
power-up there
will be no program
to automatically
run, hence you
will just see the
screen, as shown
in Part 3, Fig.9.
Next, type in:
OPTION DISPLAY
40,125 (Enter).
This will give a
bigger screen area
to work with.
And finally, type:
OPTION BAUDRATE 115200 (Enter). Be
careful to check that you type exactly
‘115200’. This setting will speed up
the console link between the MKC and
TeraTerm (think of it as improving the
screen refresh rate in TeraTerm). Note
that when you next press Enter you will
appear to lose connection to TeraTerm –
don’t panic! We will shortly change the
baud rate in TeraTerm to match.
In TeraTerm, select the Setup tab and
work down the list making sure your
settings match those as shown in the screen
shots in Fig.3. Finally, it is important you
select ‘Save setup’; and if you followed
everything correctly then the next time you
start TeraTerm, you will see a nice blue
screen and you should be communicating
once again with your MKC but at the faster
baud rate of 115200. Press the reset button
on the DM and ensure you see the welcome
message and the cursor (>).

The basics of MMBASIC
We have previously recommended that
you download the excellent Getting
Started with the Micromite guide, and
also the Micromite User Manual. If you
have not yet done so, then please go
ahead and download them from geoffg.
net/micromite.html (scroll to bottom
of page and they are the fi rst couple of
items under the ‘Downloads’ heading).
It’s not possible in the limited space
here to cover everything about coding,
so we will be taking things easy and will
learn commands and techniques along
the way. The idea is to show working
examples with the use of some basic
(cheap) components. For those of you
interested in exploring topics at a greater
level, then please refer to the manuals –
they contain a lot of information.

That said, the following are some
essential concepts that we need to
understand before moving on.
● An electronics project/gadget can
generally be broken down into three
elements: Input – Process – Output.
The MKC is the Process element and
adds intelligence.
● The intelligence is in the form of a
program. The Micromite only ever
contains a single program – there is
no fi le system with multiple programs
stored in memory
● Flash memory is used to store this
single program, so when powering up
the Micromite, the program is already
in memory and immediately available
● A program comprises lines of code.
A line of code contains instructions
(commands) that the Micromite
executes. Commands can be typed
in upper or lower case; however, it
is generally easier to read code if it is
typed in upper case
● When a program is ‘run’, it will start at
the fi rst line of code and will generally
flow down to the next line of code.
However, some commands can cause
the program to ‘jump’, ‘branch’, or ‘loop’
to other areas of the program depending
upon a condition or test
● With MMBASIC, there are many ways
to achieve the same end result. No one
way is right or wrong; but some ways
may be better than others
● Some commands have an immediate
visible output (such as turning on an
LED), while others are ‘confi guration’;
ie, not a visible output, (such as setting
an I/O pin to a digital output type)

One of the most important things to
understand about the Micromite is

Fig.4. Summary of the three Micromite modes and how to switch
between them.

EDIT RUN
F4 Ctrl F2
+
C

F2

F1

EDIT mode RUN mode

IMMEDIATE mode
Command prompt [>] displayed

Any output from
program is displayed

Program ENDs
Program ERROR (bug)

Full-screen editor
is displayed

Configure micromite
Test a command
Paste program into memory

Enter program
Edit program
Debug program

Execute
program code
Free download pdf