Hardware Reference
In-Depth Information
Programming and Troubleshooting Tools for
Embedded Modules
You may have hit a number of problems when making the connections in the last
section. Probably the most challenging thing about troubleshooting them was that
neither the Ethernet shield nor the microcontroller gave any indication that a problem
occurred. This is the norm when you're working with embedded modules that you build
yourself. This section covers a few things you should always check, and a few tools that
will help you solve problems. These principles apply whether you're using the Ethernet
modules or some other network or communications module. You'll use these methods
over and over again in the rest of the topic and beyond.
The Three Most Common Mistakes
Diagnostic Tools and Methods
Once you know the device is working, you have to program
the sequence of messages that constitutes your application.
Depending on the application's needs, this sequence can
get complex, so it's useful to have a few simple programs
around to make sure things work as desired.
Check Power and Ground
Always check whether you have made the power and
ground connections correctly. This is less of an issue when
you've got a nice plug-in module like the Ethernet shield
that can connect only one way. But even with plug-in
modules, you can get a pin misaligned and not notice. If
you're lucky, the module you're using will have indicator
LEDs that light up when it's working properly. Whether it
does or not, check the voltage between power and ground
with a meter to make sure you've got it powered correctly.
It's a good idea to test your module first using sample
code—if it's provided. Every good communications module
maker gives you a starting example. Use it, and keep it
handy. When things go wrong, return to it to make sure
that basic communications still work.
Check the Connections
When you're wiring a module to a microcontroller by hand,
it's fairly common to get the wires wrong the first time.
Make sure you know what each pin does, and double-
check that the pin that one transmits on connects to
the pin that the other receives on, and vice versa. If it's
a synchronous serial connection, make sure the clock is
connected.
Physical Debugging Methods
Writing code makes things happen physically. It's easy to
forget that when you're working on an exchange of infor-
mation like the examples shown here. So, it's helpful to put
in physical actions that you can trigger; this way, you can
see that your code is working. In the last project, you saw
LEDs turn on when the client connected or disconnected,
when it made a successful request, and when it reset. Trig-
gering an LED is the most basic and reliable thing you can
do from a microcontroller—even more basic than sending
a serial debugging message—so use LEDs liberally to
help make sure each part of your code is working. You can
always remove them later.
Check the Configuration
If you're certain about the hardware connections, check
the device's configuration to make sure it's all correct.
Did you get the IP address correct? Is the router address
correct? Is the netmask?
Serial Debugging Methods
Besides their physical form factor, the Ethernet shield and
Arduino Ethernet make a number of things easy for you.
For example, the fact that they use synchronous serial
Search WWH ::




Custom Search