This is only a preview of the February 2008 issue of Silicon Chip. You can view 34 of the 104 pages in the full issue, including the advertisments. For full access, purchase the issue for $10.00 or subscribe for access to the latest issues. Items relevant to "UHF Remote-Controlled Mains Switch":
Items relevant to "UHF Remote Mains Switch Transmitter":
Items relevant to "Shift Indicator & Rev Limiter For Cars":
Articles in this series:
Purchase a printed copy of this issue for $10.00. |
PICAXE VSM:
Getting It Going!
In this second part of our mini-series, Clive Seager talks us
through using the new PICAXE VSM simulation software.
L
ast month we introduced the new PICAXE VSM
software, which will allow you to simulate PICAXE
designs on the computer to see if they (or your software!) will do what you intended to do!
As well as a serious design tool, PICAXE VSM is also
a great way for beginners to experiment with PICAXEs –
without any risk of letting the smoke out! What’s more,
PICAXE VSM will help you with the circuit so that you
can actually build your PICAXE project.
Installation
To install the PICAXE VSM software download the demo
installation package (18MB) from www.picaxevsm.com
If you are on dial-up and prefer a CD your local PICAXE
distributor should be able to oblige.
The software is designed for Windows 2000, XP, and
Vista. 95, 98 and ME are not officially supported, however
many users have reported that the software does actually
run on these older Windows versions.
The software will run in restricted ‘demo’mode until
you purchase a licence key (you can still use the Rudolph
simulation sample described below in demo mode).
Registration is also carried out online, again at www.
picaxevsm.com, via secure credit card transaction, you
Overview Window
Object Selector
Design Area
Animation
Control Panel
78 Silicon Chip
siliconchip.com.au
Fig.1: you not only get the
simulation, you can also see the
program stepping through line-byline AND see the variables in another
window.
will receive an email with your key
shortly after purchase (VSM costs UK
₤49.99 (~AU$118 at press time). Use
the PICAXE VSM ‘Licence Manager’
utility to install your key and ‘unlock’
the full version.
Let’s Begin!
PICAXE VSM is a powerful piece
of software and so will naturally take
a little while to learn. To get started
the most important thing is to be
sitting comfortably with one hand
on the mouse and the other on the
keyboard!
As with most graphics packages,
the software uses keyboard shortcuts as well as the mouse.
These take a little while to get used to but you should very
quickly learn the shortcuts and appreciate how they speed
up use of the software.
So to learn basic navigation lets start by opening the
existing ‘AXE107 Rudolph.dsn’ example from the /
samples/(Demo Version Samples)/PICAXE folder. Then
move the mouse over the design and press the <Z> zoom,
<U> unzoom and <P> pan keyboard keys as you move
the mouse around the design – see how you can zoom
in and out very quickly by using keyboard and mouse at
the same time!
If you are already familiar with a different graphics/
PCB application that uses different shortcut keys, you
can easily customise ‘PICAXE VSM’ to your preferred
shortcut keys. To do this use the ‘System>Set Keyboard
Mapping’ menu.
Object Selector
While the sample design is open, let’s look at the different
parts of the screen. The main editing window is obviously
where you draw and edit your designs. To the left of this is
the ‘Object Selector’ list, that lists all objects (components)
currently used in the design. Above the ‘Object Selector’
is the ‘Overview’ window, which we will look at later.
At the top and left of the screen are menu bars, and at
the bottom of the screen is the ‘animation control panel’.
This looks like the buttons on a traditional tape recorder
(remember the days before CDs and MP3s?) – Play, Forward,
Pause and Stop.
Simulation
Click on the ‘Play’ button at the bottom left of the screen
and the Rudolph simulation will compile and start. When
you click on the animated pushbutton switch, a tune will
siliconchip.com.au
play on the piezo sounder (simulated via the computer’s
speaker) and the LEDs will flash.
The actual tune played will be decided by the resistance
of the LDR – varying light levels are simulated via the up
and down buttons beside the LDR (you may wish to zoom
in using the <Z> key).
While the simulation is playing click the pause button
at the bottom of the screen. This will pause the simulation
and open up a number of other ‘debug’ windows, which
show, for instance, the variable values and the PICAXE
program.
(Tip - you can select which PICAXE windows are automatically displayed by checking them in the ‘Debug’ menu
while the program is paused).
If so desired you can now also step through the PICAXE
program line by line, by clicking on the ‘Step into Source’
button on the Program window. You can also run at full
speed again by selecting the ‘Run’ button.
While the Program window is open, practice setting
‘break points’ by clicking at the left hand side of any program line – a red circle will appear.
This means the program will run until this particular
point and then stop – ideal for debugging those problem
programs. Try it out!
One final tip for simulation, if you want to step through
a program line-by-line right from the start, simply click
‘pause’ (rather than ‘play’) to start the simulation. This
will start the simulation and automatically break on the
first program line.
Our first circuit!
Now click File>New Design menu and select the default
template layout (this gives you a blank A4 paper size layout). It is good practice to give your design a title, so use
the ‘Design>Edit Design Properties’ menu to enter a title,
version number and your name. Also save the file now,
and remember to keep saving every so often as you work
through creating your masterpiece!
Now we need to build the design. To start with we will
February 2008 79
Fig.3: this is the list of
components you will require
for the Rudolph project.
Fig.2: use the ‘Design>Edit Design Properties’ menu to
enter a title, revision number and your name. Also save
the file now and remember to keep saving every so often as
you work through creating your masterpiece!
just create a straight copy of the existing Rudolph design
from scratch – you may find it useful to print it out to
copy.
The first thing is to add parts to our ‘Object Selector’.
To do this click on the small ‘P’ at the top of the ‘Object
Selector’ (which is a shortcut for the ‘Library>Pick Device’
menu).
We now have a list of 10,000+ components to search
through. This could be daunting but fortunately a very
powerful search facility and special ‘PICAXE’ category
enables us to quickly locate the parts you want! Start by
typing in ‘LED’, and then click on the ‘PICAXE’ category.
You will then have a much smaller list to choose from!
Double click on LED-RED and LED-GREEN. This will
add then to the Object Selector. Delete the ‘LED’ text and
change to ‘resistor’, then click on the PICAXE category
again. Double click on the 330W, 10kW and 22kW resistors.
Fig.4: there are two ways to display the PICAXE chip -– the
choice is yours (depending on which one you’re used to).
Then repeat this process for all the parts in Fig.3.
Note there are two options for the PICAXE chip, either
‘traditional’ schematic format (which has the power pins
hidden) or ‘IC’ layout. Choose whichever you prefer, then
close the ‘Pick Devices’ window.
Let’s draw!
First job is to drop the parts onto the screen, copying
the Rudolph design layout already used. Leave plenty of
space between components to start with, you can always
‘tidy up’ later.
To select the first part to drop, click on it in the ‘Object
Selector’. A preview of the item
will be shown in the ‘Overview’
window. Then move over the design and click to drop it in place.
You can then drop another of the
same component straight away, or
select a different component from
the Object Selector. When all the
components are placed click on
the ‘Selection Mode’ arrow (top
of the left hand toolbar) to move
out of ‘Component Mode’
If required components can
be rotated and mirrored to make
a neater schematic. To do this
right click over the component
and select the appropriate menu
option.
Fig.5: a very powerful search
facility and special ‘PICAXE’
category enables us to quickly
locate the wanted parts!
80 Silicon Chip
siliconchip.com.au
Your components
names (R1, R2, R3
etc) should automatically be added
as the components
are dropped. If you
just get ‘R?’ instead
of a number make
sure that ‘Tools>Real
Time Annotation’
menu is enabled.
If necessary ‘R?’
can be changed to a
number simply by
double clicking the
label and editing.
You will also need
to add a couple of
‘Ground’ and ‘Power’ terminals. To do
this right click the
mouse and select
P l a c e > Te r m i n a l >
Ground and then
P l a c e > Te r m i n a l >
Power.
The default powFig.6: components can be rotated
er
rail is always
and mirrored to make a neater
5V, if you want to
schematic. To do this, right-click
change this (e.g. to
over the component and select the
appropriate popup menu option.
4.5V to simulate
3xAA cells) use the
‘Design>Configure Power Rails’ menu.
Wiring
Finally we need to wire the components together. Make
sure no part is currently selected (a useful tip is just to click
on a blank part of the screen to clear any selection) and
then move the mouse over a component pin. The mouse
cursor will change to the ‘pencil’ shape and you can then
click to start the wire.
Move the cursor to draw the wire, clicking wherever you
want to fix a corner. Finish the wire by clicking over the
second component pin (or on to another wire).
You cannot draw wires over labels or components, so
always leave plenty of room between parts. The wires will
automatically move if you later drag a connected component, so it is easy tidy up designs at a later point.
To delete a wire simply right click and select delete.
Segments of wires can also be individually dragged when
the wire is highlighted.
Note that you must specifically wire all parts together.
Two components pins placed ‘overlapping’ each other will
not be ‘electrically’ connected within the design.
PICAXE Program
Before the simulation can run we need to allocate a
PICAXE program to the PICAXE-08M component. This is
done via the ‘Source>Add/Remove Source File’ menu
but first you have to type in and save the PICAXE BASIC file!
This can be carried out using the normal PICAXE Programming Editor software, or the simple ‘Source Editor’
siliconchip.com.au
Fig.7: type in this test program and save it as a .bas BASIC
file in the same folder as your .dsn design file.
Fig.8: make sure the PICAXE chip (eg, U1) is highlighted as
the target processor. Then click ‘New’, select your file and
then click OK.
application provided with PICAXE VSM. Type in the test
program shown in Fig.7 and save it as a .bas BASIC file in
the same folder as your .dsn design file.
I recommend that you always use the same filename
stem to avoid confusion.
Back within PICAXE VSM select the ‘Source>Add/Remove Source File’ menu and make sure the PICAXE chip
(e.g. U1) is highlighted as the target processor. Then click
‘New’, select your file and then click OK.
If you now go back to the ‘Source’ menu you will see
your program file is now listed within the menu. If you
click on the filename it will now open within the ‘Source
Editor’. This is a very useful shortcut if you want to tweak
and save modifications to your BASIC program while
simulating and testing.
Run Your First Program.
Click ‘Play’ and if all is well your two Rudolph eye LEDs
should now start flashing every second! Congratulations,
that is your first PICAXE VSM design created and simulated.
To have a play with the LDR, switch and piezo have a look
at the example BASIC file provided within the ‘AXE107
Rudolph.dsn’ sample design file.
We’ve run out of space for this month. Next month we
will look at a couple more complex designs and learn
how to use some of the virtual instruments – voltmeter,
oscilloscope and even an I2C debugger!
SC
February 2008 81
|