Silicon Chip – April 2019

(Ben Green) #1

64 Silicon chip Australia’s electronics magazine siliconchip.com.au


You may find it easier to work with
the centre row of pins first, and ensure
that they are soldered and tidy before
accessing the outer rows, which have
more surrounding space to work with.
Finally, fit the 2x6 pin header. This
sits underneath the PCB, on the oppo-
site side to the other components, and
is soldered from the top.
Avoid excessive heat, as this may
melt the plastic shroud, putting the
pins out of alignment.
Check that there are no solder bridg-
es or short circuits, and plug the board
into the PMOD header of the iCEstick.
The VGA socket faces away from the
USB plug of the iCEstick.
Plug a VGA cable from the VGA
socket to a monitor or television.


Building and uploading the


code


With the “iCEstick VGA Termi-
nal.ice” file open in IceStudio, select
the iCEstick from the Select → Board
menu. To synthesise the design, click
Tools → Build, and when the green
“Build done” message appears, click
Tools → Upload.
The keyboard shortcuts for these
commands are Ctrl-B and Ctrl-U re-
spectively.


Now connect a VGA monitor and
check to see if you have a display,
similar to that shown in Screen2. If
you have a terminal program installed,
such as TeraTerm, PuTTY or even the
Arduino IDE, figure out which serial
port the iCEstick is using and open
a connection to it at 9600 baud with
eight bits, no parity (8-N-1).
Type into the terminal, and you
should see text appear on the screen.
If the ‘Enter’ key generates a CR/LF
pair in your terminal program, press-
ing Enter should cause subsequent text
to appear at the start of the next line.
Assuming your terminal program sup-
ports control codes (which most do,
except for the Arduino IDE), you can
change the colours by using control
key combinations.
ASCII control codes 1-26 corre-
spond to pressing Ctrl and one of the
letters A-Z on the keyboard; as A is
the first letter of the alphabet, Ctrl-A
sends control code 1. Press Ctrl-N or
Ctrl-O to switch between setting the
foreground or background colour, and
press Ctrl-P through to Ctrl-Z to change
that colour.
The five remaining codes between
27 and 31 map to a combination of
Ctrl plus another key, those keys being

“[“, “\”, “]”, “^” and “_”, respectively.
You can now use the iCEstick VGA
Terminal as-is, or you may wish to ex-
periment further to see what is possi-
ble with IceStudio.

Debugging the project
While the block-and-wire methodol-
ogy of creating a design does not leave
much opportunity for errors, manually
entered code blocks certainly could be
erroneous, and thus can cause a build
error. In this case, you will see a red
bar appear instead of “Build done” af-
ter attempting a build.
It’s possible to view the entire Ver-
ilog file that is generated during the
build process. IceStudio converts the
graphical design into a text-based (Ver-
ilog) HDL file, then builds that into the
binary bitstream. That’s an intensive
process which involves figuring out
which FPGA resources can be used to
create the required logic and how they
should ideally be interconnected, so
it can take some time.
To view the generated Verilog,
click on the View → Command Out-
put menu option and open the folder
shown in Screen3. In this folder, there
is a “main.v” file, which is the Verilog
code that IceStudio has generated.
If you do get a build error, scroll
towards the bottom of the Command
Output window and you should see
an error message indicating the line
number on which the error occurred
(and the nature of the error). This, in
combination with the generated Ver-
ilog, should help lead you to the source
of the error.
It’s a good idea to open “main.v”
in a text editor which displays line
numbers. When building the project,
you may also see some warnings; most
warnings can safely be ignored.

Verilog code blocks
Now that you know how to debug
the code, you may wish to dabble with
the Verilog inside the code blocks in
this project. Here are some tips to get
you started; but don’t think this is the
complete book on Verilog coding! Like
the C language, all statements end with
a semi-colon.
Some lines in the Verilog code are
direct assignments, such as the follow-
ing used to generate the HSYNC signal.
These generate simple digital logic:
assign out = ((count < stop) &&
(count >= start))? 1 : 0;

The VGA Adaptor simply plugs into
the matching socket on the iCEstick
PCB, while the socket at left connects
to the VGA screen/monitor.


WOW! A high performance, Arduino-based, digital


LC METER


that measures from


PicoFarads to Farads &


NanoHenries to Henries!


See SILICON CHIP
June 2018
(Article 11099)

Just look at these incredible features:
l Inductance measurement range 10nH – 1H (+) l Capacitance measurement range 0.1pF – 1F (+)
l Advanced calibration l Continuous drift compensation l Long-term averaging l Automatic component detection
You’ll find this advanced Digital LC Meter is one of the handiest devices you can have on your workbench!
Specialised and hard-to-get parts are available from the SILICON CHIP Online Shop:
PCB (incl. headers) 20x4 alphanumeric LCD 1nF 1% NPO/C0G capacitors Custom laser-cut Acrylic Case:

Uses Arduino Uno
(or equivalent)

Uses Arduino Uno
(or equivalent)

(SC 04106181) 7 $^50 (SC 4203) $ 1500 (SC 4273) (Pk 2): 5 $^00 (SC 4609) 7 $^50
All other components (including Arduino Uno) are commonly available from your normal parts supplier
Free download pdf