This is only a preview of the April 2010 issue of Silicon Chip. You can view 32 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 "FAQs On The Web Server In A Box (WIB)":
Items relevant to "Capacitor Leakage Adaptor For DMMs":
Items relevant to "A 1000:1 EHT Probe":
Items relevant to "Digital Audio Signal Generator, Pt.2":
Purchase a printed copy of this issue for $10.00. |
WIB
FAQs
The Web Server In a Box (WIB) project has been very popular
and lots of kits have been built. Here we collect a number of
frequently asked questions that may help anyone experiencing
difficulties in building and setting up the WIB. We also provide
the answers to some common technical questions and feature
requests.
By MAURO GRASSI
Software Releases
At the time of writing, the released
firmware for the WIB includes versions between 5.30 and 5.40. Most
questions in this article relate to
versions 5.30, 5.31 and 5.32.
Version 5.40 is the latest and fixes
two problems with earlier versions
(see later). It has been made available to the kit suppliers and is also
available for free download from
the SILICON CHIP website. Future
batches of kits should contain the
new firmware version (5.40) or later.
This FAQ compilation refers to the
original hardware of the WIB, which
used the dsPIC33FJ64GP802 microcontroller. However, it is now possible to use the dsPIC33FJ128GP802
chip as well. This device is pin for
pin compatible but has double the
program memory.
By using this new chip, it would
now be possible to incorporate many
new features, including an ethernetbased bootloader. This and other
features will be considered for a
future upgrade to the WIB.
Common Setting-Up Questions & Problems
Q
I have changed a setting in the
settings.txt file using a text
editor but the setting does not seem
to have changed in the WIB. Why
is that?
This can be confusing at first
and is one of the most common
traps that constructors can fall into.
Basically, the settings are stored
A
20 Silicon Chip
in binary form in the values.dat file.
The settings.txt file is only for the
default values (if there is no values.
dat file), as happens on the very first
boot up.
The WIB creates the values.dat
file from the settings.txt file if it does
not exist. If it does exist, it uses the
settings stored in the values.dat file.
This scheme made the firmware
simpler because changes to settings
can be stored easily in binary form
but are more difficult to store in a
human-readable file like the settings.txt file. However, the humanreadable file is useful for setting up
the default values.
In order to change the settings
siliconchip.com.au
to those in the settings.txt file, you
need to first delete the values.dat
file and then reboot the WIB. A new
values.dat will then be created, with
the settings taken from the settings.
txt file. This is done by clicking the
“Restore Defaults” button in the supplied default website (ie, you don’t
have to switch the WIB off and then
on again in order to reboot it).
Q
There is a csettings.txt file in
the supplied default website,
as well as the default settings.txt
file. What is the csettings.txt file for?
The csettings.txt file is generated by the WIB and should not
be modified, as it has no effect on the
settings of the WIB. The csettings.txt
file is created by the WIB at runtime
to store the current settings in a
human readable form. This is used
in the “Create Defaults” function,
where the csettings.txt file is copied
to the settings.txt file.
A
Q
Should I retain the directory
information when I unzip the
contents of ewswebsite.zip to obtain
the supplied website (available from
the January 2010 downloads section
of the SILICON CHIP website)?
No, the files should all be unzipped into the root folder of
the memory card disregarding any
original path information stored in
the zip archive.
A
Q
A
There is a file named 0711109A.
hex in the supplied default
website, what is this file for?
This file contains the firmware
image for the latest version of
the WIB. It can be left on the memory
card and will not affect the operation
of the WIB or it can be deleted. It is
a small file, so it will not take up
much space on the memory card.
Note that if it is left on the memory
card, it can then be accessed like
other pages served by the WIB.
Q
I am having trouble logging in
to the WIB with the username
and password as set in the settings.
txt file. Alternatively, some setting
in the settings.txt file does not seem
to be being parsed properly. Why
is that?
There could be a number of reasons for not being able to log on
A
siliconchip.com.au
to the WIB using the username and
password as stored in the settings.
txt file. First, as explained earlier,
the settings.txt file contains the default values, not the actual values
of the WIB. The actual settings are
stored in binary form in a file called
values.dat.
If you wish to revert to the settings
in the settings.txt file, you should
delete the values.dat file and reboot
the WIB as explained earlier.
Additionally, when the WIB reads
the values from the settings.txt file,
it will only parse a line if it finds a
newline at its end. So a setting may
not be being parsed simply because
there is no newline at the end of
the line (this happened to a reader).
Remember every entry in the settings.txt file should be on a separate
newline-terminated line.
So if you can’t log on with the
username and password in the
settings.txt file, it may be because
the last line in the settings.txt file
does not contain a newline. In the
default settings.txt file supplied, the
password setting is last. While the
file supplied has a newline, if you
change this line, the last line may
no longer have a newline and so the
password will not be set.
Q
The WIB seems to be working
correctly but it cannot send
emails. There is an entry in the log.
txt file with a hexadecimal error
code. What does this mean?
The hexadecimal error codes
shown in the log.txt file relating to sending emails are standard
SMTP (Simple Mail Transfer Protocol) error codes. These are returned
by the SMTP server that the WIB is
connecting to.
For example, if your ISP is Telstra,
you would be receiving an error
code from the Telstra SMTP server
and likewise with Optus and other
providers. The list of SMTP error
codes can be found online.
The “Email From” may also need
to be set if you are using your ISP’s
SMTP server and are sending the
email to a foreign email address, specially to a Gmail or Hotmail address.
If not set correctly, an additional
error may occur because of some
SMTP server anti-relaying rules to
do with spam reduction.
A
The relevant error is 0x0227 (Error 551). We found this during testing with the Telstra SMTP server,
for example. Changing the “Email
From” field may solve this problem.
Remember the “Email From” field is
simply what is shown as the Sender
when you receive an email from the
WIB, so it is not a crucial setting.
Note that SMTP settings for
“Email Server User” and “Email
Server Password” are only used if
the SMTP server you are sending
to requires authorisation. Most ISP
SMTP servers don’t require this (so
you can send anonymous emails
when you have an internet account)
but some do require authorisation.
If the Email User and Password
settings are set, the WIB starts an
SMTP session by trying to authenticate with the server. If the SMTP
server doesn’t require this, then it
may terminate the SMTP connection
before the email is sent, returning
an 0x01F7 error (Error 503), even if
the username/password is correct.
To avoid this problem, remove the
two settings from the settings.txt file,
delete the values.dat file and reboot
the WIB.
Q
When I try to log on to the WIB
using its IP address from the
address bar of my web browser, it
loops continually without loading
the home page. Why is that?
When you type the IP address
into a browser, without qualifying any extra path information,
it assumes as default that you are
requesting the index.htm file. The
index.htm file provided with the
default website for the WIB uses
the refresh metatag to redirect to the
home page, which is the home.cgi
page.
On some web browsers or on some
versions of those browsers, this has
the effect of looping continually
without loading the page. Specifying
the complete path (eg, 192.168.0.34/
home.cgi) rather than only the IP
address should solve this problem.
Alternatively, changing the contents
of the index.htm page can solve the
problem.
A
Q
Can the microcontroller in the
WIB be programmed using the
dsPIC/PIC Programmer described in
April 2010 21
the May 2008 issue? If not, how can
it be programmed?
No, the dsPIC/PIC Programmer
cannot program the dsPIC33
FJ64GP802. The latter microcontroller was not available at the time
the programmer was designed and
so is not supported. Instead, it is best
to use a programmer like the PICkit3
from Microchip together with their
free MPLAB software.
A
Q
Can you give an example of
what values are needed for
connecting a straight 0-5V sensor to
the analog inputs of the WIB rather
than a 3.3V sensor as described in
the original article?
You will need to connect your
sensor to a voltage divider to
bring its output within a 0-3.3V
range. This can be done by connecting a divider that divides by 5/3.3 =
1.52 (eg, 10kΩ and 20kΩ).
You will then need to calculate
the correct values for your sensor
and enter them in the gradient and
Y-intercept fields in the variables.cgi
page of the default website.
The instructions to calculate these
values are in the original articles.
A
Q
The LM317 voltage regulator
used to derive the 3.3V rail for
the WIB runs hot to the touch. Is
this normal and how can the heat
be reduced?
It is normal for the regulator to
get hot and so the original de-
A
sign specifies a heatsink. The higher the input voltage delivered by
the plugpack the more heat that
will be dissipated. To reduce the
heat dissipation, you should use a
6V plugpack.
Q
Can the WIB take digital inputs?
Can the WIB send an email
notification when a digital input
changes? For example, can the WIB
send an email notification when a
reed switch closes or opens?
While nominally the WIB only
accepts four analog inputs, they
can also be used to accept digital
inputs. If the digital input swings
between 0V and 3.3V, it is easy to set
the minimum and maximum values
at about the middle of this range.
However, the minimum should be
below the maximum to allow for
hysteresis.
The WIB can then send emails
when the state of the digital input
changes. If using a reed switch, you
do the same but use a pull-up resistor to the 3.3V rail or a pull down to
0V. If the digital input is not within
a 0-3.3V range, you will have to implement some kind of level translation. This can sometimes be easily
achieved by using an open collector
output and a pull-up resistor to the
3.3V rail.
A
Q
Can the digital outputs of the
WIB be pulsed for a determinate
amount of time?
A
Not with the current versions
of the firmware, although this
could easily be incorporated if
sufficient program memory were
available. You could have an extra
variable (or four extra variables for
independent control) to hold the
pulse time in milliseconds and new
commands to pulse the outputs.
These are easy additions to the
firmware but there is not enough program memory to make the modification with the original hardware. It is
certainly possible with the 128KB
version chip and may be incorporated in a new design in the future.
If readers really want this function,
they could delete parts of the code
to make room for it.
Q
Can the WIB be used with
Windows based FTP programs?
In particular, can it be used with
programs such as FileZilla?
With versions of the firmware
before 5.40 some FTP programs
like FileZilla did not like the WIB’s
response to the PWD command.
This was fixed in firmware version
5.40 in response to a reader’s report. In any case, versions without
this fix should still work with the
recommended FTP command line
Windows client, as explained in the
original article.
Note that the WIB is not guaranteed to work with other FTP clients
because it does not support the full
FTP command set.
A
USB Support & File System Storage
Q
A
Are there any plans to make
the WIB work with an NTFS
file system?
No, there are no plans to make
the WIB support file systems
other than FAT. As NTFS is primarily a Windows file system, you would
lose the portability that FAT offers.
Note that you can read FAT with
either a Windows or Linux PC and
with a Mac. Also, there is little appreciable gain in performance in
going from FAT to NTFS for the WIB
project (there is for a PC though).
FAT is perfectly adequate for the
WIB (it is limited to 2TB but there is
not going to be an MMC/SD/SDHC
22 Silicon Chip
memory card that can store 2TB any
time soon!) It is true that there is also
a single file size limit with FAT that
would be much less restrictive with
a newer file system like NTFS. However, the limit is around 4GB and we
think this is more than adequate for
the application.
If you are going to serve a page of
that size it will take a considerable
amount of time using the WIB – it
is a huge amount of data.
There are also licencing issues
with NTFS that are avoided with a
FAT file system as used in the WIB
(there are issues with FAT too). The
FAT code used in the WIB is open
source and the NTFS code would
also certainly have a larger memory
footprint.
NTFS is suitable for modern
operating systems running on PCs
with abundant resources but it is
much less suitable for embedded
systems with few resources like the
WIB. For all these reasons, FAT is a
good choice as a file system for the
WIB and for many other embedded
systems.
Q
Can a USB flash drive be used
to store website files for the WIB
instead of using an MMC/SD/SDHC
memory card? If not, are there any
siliconchip.com.au
plans to modify the WIB to do this?
To interface to a USB flash drive
would require implementing
a USB host interface, including a
supply to power the USB. The WIB
does not have the hardware to do
this. For this reason, it would not be
viable to modify the WIB to support
a USB flash drive.
We believe a memory card is adequate for the application and has the
advantage of being quite compact.
USB flash drives are perhaps more
easily transported and removed but
in this application, we assume that
the memory card will be seldom
removed.
A
Q
Are there any plans to make
the WIB work with an external
hard drive, either via a USB port or
natively?
No, there are no plans to change
the WIB’s mass storage from its
current medium. We believe that
the current capacities that can be
purchased in SDHC cards (up to
32GB) are more than sufficient for
the applications that the WIB will
be used for.
While hard drives offer cheaper
and larger storage capacities, the
complexity of the interface rules it
out for the WIB. The microcontroller
has no native USB host support
and there is no other hardware on
the WIB to support connection to a
USB device. Adding a native hard
drive interface would be even more
complex.
A
Added to this, a memory card uses
less power and is more compact,
reliable and faster than a hard drive.
Q
A
Can the WIB be used with 3G
wireless modems with a USB
port (dongles)?
No, since the WIB does not
implement a USB host, it cannot be used with such 3G modems.
The WIB can only be used with an
ethernet connection.
To be able to use a USB modem,
you would need a USB host and the
WIB has no such hardware support
as it stands. However, there are 3G
wireless modems which have an
ethernet connection and you should
be able to use such a modem with
the WIB.
Miscellaneous Questions
Q
Is it possible to put a slot in
the external case so that the
memory card can be removed or
inserted without having to take the
case apart to get at the card?
When the design was conceived,
we assumed that the memory
card would only infrequently be
inserted or removed, as files can be
uploaded or downloaded using an
FTP client. It would be possible to
house the WIB in a different case
with a slot that would allow easier
access to the memory card. In fact,
you could even use it in a freestanding manner without a case, or leave
out one of the side panels if you use
it with the originally specified case.
A
Q
The RJ45 connector from
Amphenol used in the WIB
(CON2) has pins 4 & 5 and pins 7 &
8 each internally shorted and then
connected via 75Ω resistors to a
single 1nF capacitor connected to
0V. Would this cause problems if it
were connected to a PoE (Power over
Ethernet) system? Wouldn’t some of
the 75Ω resistors be destroyed?
The termination used in the
WIB is the one recommended
in the datasheet for the ENC28J60
ethernet controller (obtained from
the Microchip website). The 75Ω
resistors and the 1nF capacitor are
for EMI reduction and ESD protection and the 1nF (2kV) capacitor
connects to the metal shield of CON2
for this purpose.
The RJ45 connector used in the
WIB is not designed for PoE applications and it would be a problem if the
PoE host simply applied power. But
that doesn’t happen – PoE hosts test
the resistance between the terminals
before doing so.
In other words, a device configured for PoE must have the correct
resistance before it is supplied
with power. Since the WIB doesn’t
present the correct resistance, the
PoE host will not (or should not)
apply power to it (an RJ45 connector for PoE would add capacitors in
series with the 75Ω resistors).
A
example, you could have the WIB
send an email every time a certain
sequence of serial data is received
or send the serial data received in
an email.
When the firmware was written,
program memory was at a premium and some features had to be
dropped. The serial port functions
for sending data and now taking up
memory could perhaps be replaced
with code for receiving data.
A
Serial Port Questions
Q
A
Can data be logged from the
serial port of the WIB?
You cannot log data from the
serial port using the current versions of the WIB firmware. However,
you can log data from the four analog
inputs to the SD card and email them
to a nominated account.
Q
Is it possible to communicate
in both directions with the onboard serial port of the WIB?
siliconchip.com.au
No, it is not possible with current versions of the firmware
to receive serial data with the WIB.
It would not be difficult to modify
the source code to allow the WIB
to receive data into a buffer or to
write it to a file on the memory card,
perhaps with network time information as well. You could also build in
a serial server that would listen to
serial commands and run functions,
depending on the received data. For
April 2010 23
Website Functionality Questions
Q
A
Can the WIB firmware be easily
modified to include support for
PHP and ASP server-side scripting?
No, it is not possible – the
WIB supports only client side
scripting. Server-side scripting is
intended for more powerful PCbased or embedded servers but is
not really suitable for the WIB. We
cannot rule out some kind of serverside scripting for a future upgrade
but it may not be on the scale of
a full-featured language like PHP,
simply because the hardware is not
powerful enough.
Q
A
Is it possible to use a typical
LAMP (Linux, Apache, MySQL,
PHP) installation with the WIB?
No, it is not possible. Such installations are for full-featured
PC-based or embedded servers that
are much more powerful than the
WIB. The WIB is not a full-featured
server, nor does it have the speed or
memory (or even hardware archi-
tecture) to run such an installation.
Q
A
Can the WIB support a website
for online shopping using a
shopping cart?
No, the WIB does not support
a shopping cart application.
There are a number of reasons.
First, it does not support server side
scripting and second, it would not
be ideal from a security point of
view as the WIB does not support
encryption either.
Feature Requests
Q
A
Does the WIB respond to ping
requests? Does the WIB implement a DHCP client?
No, the WIB does not support
ICMP and will not reply to
ping requests. Early versions of the
firmware supported ping but that
was dropped to make room for other
features due to limited memory.
DHCP client support was also
dropped for the same reason.
Q
A
How can the firmware be updated if there are future changes?
Currently, the only way to do
this is to use a PICkit3 programmer. This is because the WIB doesn’t
have a bootloader which would allow its program memory to be rewritten with an upgraded version of the
firmware via an ethernet connection.
The microcontroller supports RTSP
(Run Time Self Programming) but
there was simply not enough program memory to implement such
a feature.
However, as stated at the beginning of this article, it is possible to
use the dsPIC33FJ128GP802 chip
instead of the original microcontroller. This latter device is pin-forpin compatible but has double the
program memory. By using this chip,
it would be possible to incorporate
many new features, including an
ethernet-based bootloader and we
may make this feature available in
a later version of the project.
Q
What are some of the feature
requests that have been submit-
24 Silicon Chip
ted by readers? Will they be implemented in the future?
Several readers have modified
the firmware so that it does
not delete the variable log files on
reboot and to immediately log the
variables on reboot, without waiting
for the first log interval to elapse.
Some readers have also added extra
digital outputs and inputs via extra
hardware, although the four analog
inputs can also be used as digital
inputs.
There are no plans at the moment
to incorporate these features in the
standard firmware for the WIB.
A
Q
What are some of the feature
requests that you have received
from readers and which of those
are viable? What other add-ons are
possible?
We have had many requests
from readers for features. Among
these are:
(1) Better security, using encryption
at least for the HTTP headers;
(2) Support for server-side scripting
like PHP;
(3) Connection of additional sensors,
including perhaps digital interfaces
for sensors (eg, 1-wire Dallas);
(4) Battery backed-up power supply,
including a mechanism to monitor
mains voltage;
(5) Using the WIB for controlling a
number of mains powered appliances (eg, to power cycle computers
through the web server);
(6) A bootloader to allow for easy
firmware updates;
A
(7) Faster ethernet connection and
WiFi (wireless) connection.
The ones that we think are viable
are (1), (3), (5), (6) and we could
also add DHCP client support and
ICMP support. Server-side scripting
of some form could be incorporated
but almost certainly not in the form
of PHP, so we think that (2) is not
viable.
We think that (4) is too specialised and thus not viable. Note that
many computers can be woken up
using their LAN interface remotely
(wake-on-LAN), so (5) would really
only be for controlling mains devices
other than PCs with a wake-on-LAN
feature.
Note that the Microchip TCP/IP
stack is also fully integrated with
WiFi support and Microchip also
supplies the hardware for WiFi. As
such, WiFi is also possible but would
depart from the original design substantially.
Again, although Microchip also
now provide a 100Mbps ethernet
controller, it comes in an SMD package which would thus also depart
from the original design substantially, so (7) is probably not viable (it
would be a new hardware project).
When you exclude firmware
features, there are also many other
hardware add-on boards that could
be designed. The WIB Time Display
Module published in the February
2010 issue of SILICON CHIP is one
such item and one reader has used
an LCD rather than a LED display,
with good results.
siliconchip.com.au
Source Code Requests
Q
I want to experiment with the
source code. Are you going to
make it available on your website?
What software is required to compile
the source code? What hardware is
required to reprogram the microcontroller with a newer firmware
version?
The source code for the WIB was
written in C and was compiled
using the full version of the Microchip C30 compiler (kindly donated
by Microchip). The full version allows all optimisations and makes the
A
code fit with the original hardware.
The code will not fit if using the
free version of the Microchip C30
compiler (at least at time of writing, with current versions of the
compiler). The source code will not
be made available on the SILICON
CHIP website but has been released
to many readers on a case-by-case
basis with certain conditions (ie, the
code can only be used for personal,
non-commercial use).
The free MPLAB software suite
from Microchip (www.microchip.
com) can be used as an IDE (Integrated Development Environment)
and to program the microcontroller
in-circuit using a programmer like
the PICkit3 (also available online
from Microchip). MPLAB also supports other programmers.
The microcontroller can also be
programmed on a breadboard or in
a ZIF socket. Future versions of the
firmware may include an ethernet
bootloader to allow the firmware to
be easily updated without using a
programmer.
correctly ask for login information
for file extensions set to private, exposing a security risk. For example,
the settings.txt file can be viewed
without logging in (the settings cannot be changed, however). Version
5.40 fixes this problem.
This problem can also be fixed by
changing the default file permission
to private (the default is public).
This workaround works except that
all files will then be private. If you
want some to be public and some
private, you will have to update the
firmware.
The other problem is more minor
and is also fixed in version 5.40. It
simply adds quotes around the PWD
command reply of the WIB’s FTP
server. This is necessary to prevent
some FTP programs from reporting
errors with the WIB’s response. Note
that the command-prompt FTP client supplied with Windows can still
be used with the WIB to transfer files
to and from a PC.
check your ISP’s terms to ensure
that the WIB can be used with your
account.
In some cases, it may be necessary
to get a business account or a static
SC
IP address.
Known Bugs & Errata
Q
A
Are there any known bugs and
workarounds for the WIB?
Yes there are two known problems with firmware versions
that are fixed in version 5.40.
The first problem occurs when
using an IP address for the WIB
other than 192.168.0.x, eg, a 10.1.1.x
address. Most people will be using
a 192.168.0.x address so this issue
will not be apparent.
If you assign an IP address other
than 192.168.0.x, the WIB does not
ISP Terms Of Use
Please be aware that serving web
pages may contravene your internet
plan’s terms of use. You should
Are Your Issues
Getting Dog-Eared?
REAL
VALUE
AT
$14.95
PLUS P
&
P
Are your SILICON CHIP copies getting damaged or dog-eared just
lying around in a cupboard or on a shelf? Can you quickly find
a particular issue that you need to refer to?
Keep your copies of SILICON CHIP safe, secure and
always available with these handy binders
Available Aust, only. Price: $A14.95 plus $10 p&p per order (includes GST). Just fill in and mail the handy
order form in this issue; or fax (02) 9939 2648; or call (02) 9939 3295 and quote your credit card number.
siliconchip.com.au
April 2010 25
|