So far so good, you've been able to setup your Jaluino environment, let's now dive into this "Blink a LED" experiment. This will ensure your Jaluino board is working properly. At least to blink a LED...
How do you say "Hello" ?
Blinking a LED is somewhat the equivalent of a "Hello World" example, if you're familiar with software computing and programming language. "Hellow World" is supposed to be the simplest program, ever, which basically prints "Hello World", claiming to the whole world it's alive.
Printing something on a screen with a microcontroller isn't that simple.
In microcontrollers world, there's also a hardware part. So this "Hello World" example also has to be very simple on that side too. Blinking a LED seems to fit both hardware and software requirements of simplicity: not much parts, easy to build, easy to program, easy to check. Claiming to the world it's alive isn't as explicit as printing "Hello World" but watching a blinking LED should be enough.
Careful though: even blinking a LED can be a hair-pulling generator1. I hope you'll find enough information to pass this exam without getting bald.
You have two options here:
- Option 1: use a breadboard and connect parts to Jaluino with wires
- Option 2: use Crumboard shield and plug it over Jaluino board
Option 1 will require several parts:
- a breadboard
- a LED, a red one is good
- a resistor, from 330 to 1K
Basically, as simple as it can be, we'll plug a LED and a resistor to one of PIC outputs, as shown in the following schematic2.
Figure 1. Blinking a LED.
When assembling Jaluino and all these components on a breadboard, you should get something like this:
Figure 2. Option 1: blinking a LED, assembling the whole using a breadboard
Double check LED pin layout, be sure it's not inverted. Longest pin is the anode, it must be connected to pin RA0. Pin on the flat side is the cathode, it must be connected to the ground.
As option 2, if you're a lucky Crumboard shield owner, you can simply plug it over Jaluino and enable LEDs by putting jumpers on JP1 and JP2. You'll get two blinking LEDs for the same price...
Figure 3. Option 2: blinking two LEDs, using Crumboard shield
Compiling and uploading software
Hardware is ready, let's compile some code to actually blink that LED (or those LEDs, lucky Crumboard owner). Launch Editra with JaluinoIDE and open one of the following program, available in samples
Select Jaluino without bootloader in compiling options, and compile sample. You should get the following output, notably "Exit Code: 0" which basically means "success" !
Figure 4. Compilation output from Jaluino IDE
Amongst several files produced by jalv2 compiler is a file having *.hex extension. This file has to be uploaded to Jaluino. You'll need to use a programmer for this step. As there are many PIC programmers out there, not all are described in this documentation. Because it's widely used in jalv2 community3, uploading with Wisp648 programmer is explained in the following content4.
First plug your programmer to the ICSP connector on Jaluino board. ICSP has the following pin layout:
This pin layout is rather common and is at least used by widely used PICKit2 and Wisp648. If your programmer shows the same pin layout, you can directly plug it. If not, you'll need to use wires in order to connect correct pins together.
Figure 5. Wisp648 programmer directly plugged to Jaluino
Use software which comes with your programmer and upload HEX file.
With Wisp648, we'll use xwisp5 (GUI graphical frontend). You can also use xwisp2 (command line tool), you'll have to bypass Jaluino IDE and type commands from within a terminal or console.
Using xwisp through Jaluino IDE, just select "XWisp programmer" and click on "Upload". XWisp interface will show up.
Figure 6. Selecting XWisp programmer
Figure 7. XWisp application opened, HEX file loaded
In the opened XWisp window, press "Go" button, your HEX file will get programmed.
Figure 8. HEX file has been uploaded to Jaluino
Few words about XWisp2. If you're a command line guy, or if you just want to give a try, you can also use XWisp2. Usage is simple. Open a console/terminal, nagivate to your Jaluino installation directory, and go to bin
directory. You'll see different XWisp2 binaries:
- xwisp2u: Linux binary
- xwisp2w.exe: Windows binary (note the letter "w" as Windows)
- xwisp2.exe: OS/2 binary
Select XWisp2 binary according to your platform, and type (eg. Linux):
$ ./xwisp2u PORT /dev/ttyS0 GO ../samples/jaluino_medium_blink.hex
xwisp2 version 1.9.6 for Linux (Dec 11 2008, Open Watcom C/C++ 1.70)
File ../samples/jaluino_medium_blink.hex loaded and is Intel Hex format conforming
Detected programmer: Wisp648, firmware version 1.29
Target: 18F4550 revision 06 (ID=1206)
Transferring program to 18F4550 via Wisp648
Transferring program memory...100%
Verifying program memory......100%
Transferring data memory......100%
Verifying data memory.........100%
Transferring ID memory........100%
Verifying ID memory...........100%
Transferring fuses memory.....100%
Verifying fuses memory........100%
Write-Verify operation terminated successfully in 1.63 seconds
Putting target in run mode
xwisp2 terminated successfully in 2.00 seconds
Replace /dev/ttyS0 with your serial device file path, like /dev/ttyUSB0 if using a USB-to-serial adapter undex Linux, or COM1 if under Windows. If XWisp2 complains about not being able to detect target, or ends with some timeouts, unplug Wisp648 power supply for ~10secs, plug it and try again.
So HEX file has been uploaded to Jaluino, now can you see the LED blinking ? Is it alive ? Congratulations, you've been able to correctly setup your Jaluino board !