The goal of this project is to control an 8x8 matrix of RGB LEDs. Each dot in the matrix houses a red, green, and blue LED behind a semi-opaque lens. To produce colors we need to dim the LEDs different amounts. For instance to make sky blue we need a lot of blue, some green, and a little red. Unfortunately LEDs don't dim, they are either on or off, but we can produce a similar effect by blinking them very rapidly, controlling the amount of time they are on and off to create different intensities. To do this we need a fast way to control all 192 LEDs in the matrix. The matrix provides 32 pins on it for controlling the LEDs. Eight of the pins control which row is being controlled, and the other 24 control the RGB LEDs in each column (8 columns with 3 LEDs in each). Controlling 32 IOs is a daunting task for an embedded processor which typically have only a handful of GPIOs (General Purpose IOs). The PIC32 family has the needed IOs but using 32 leaves little else for other purposes. To get around this problem I used a serial-load parallel-out shift register. Read after the break to see how it all works.
This blog acts as my own engineering journal while I explore the world of Embedded Systems development. I am also hoping that this blog helps others like me as they start their journey and design their own projects. If you have any questions or comments related to this blog please post them.
Wednesday, June 25, 2014
Thursday, May 22, 2014
Cape Cod Mini-Maker Faire

I was recently given the privilege to present one of my Embedded Projects at the Cape Cod Mini-Maker Faire. The faire was organized by the Cape Cod Makers, a group I have now happily joined. The project displayed is called SenseMesh, a ZigBee based network of sensor nodes feeding real-time data to a Windows PC.
Wednesday, March 5, 2014
MicroView Kickstarter Project
I supported another excellent KickStarter project called MicroView. The project plans to build an Arduino with a small OLED display in a ridiculously small form-factor. I can imagine using this in wearable computing, where a small form-factor would be a real boon. After the KickStarter campaign completes the MicroView will be available for purchase over at SparkFun.
Saturday, February 8, 2014
PCBGRIP Kickstarter Project
I recently supported an excellent Kickstarter project called PCBGRIP. The project plans to build a PCB vice/work-center that goes way beyond the classic Pana-Vise setup. If you are looking for a great system for holding PCBs and components as you assemble them you should check it out.
Wednesday, September 11, 2013
Simple Photosensor
The goal of this project was to create a simple light sensor that would detect whenever a certain amount of light was present. This output could be used to drive an LED or an input pin on the PIC32. To design the circuit I used the Eagle schematic editor. Eagle is made by CadSoft and is a powerful PCB CAD tool for designing PCB schematics and layouts. The Eagle light edition is provided free of charge to hobbyists and is powerful enough for most projects. In my case I only used the schematic portion of the software as I implemented the circuit on a breadboard instead of a PCB.
The circuit works by creating a voltage divider using the Photoresistor (R1) and a base resistance (R2). The output voltage of that circuit will be:
Vout = (R2/(R1+R2))*Vin
The inverter's switch-point (when it transitions from a logical 1 to a 0) is roughly half of VCC. Given this we know that the inverter will switch when R1 equals R2. We can select how much light will trigger the sensor by select the value of R2. The more light the Photoresistor receives, the lower its resistance, so a lower value of R2 means we need more light to trigger the sensor. In this schematic the output of the sensor is used to drive an NPN transistor so that a logical 0 will cause the LED to light up. The output of the inverter could just have easily been connected to one of the PIC32's input pins where software could react based on the input (with a logical 0 meaning that the sensor has triggered since we are using an inverter).
Saturday, March 24, 2012
Controlling the Explorer 16 On-board Truly LCD
The Explorer 16 board comes equipped with a small LCD display controlled by a Novatek NT7603 LCD Controller. There are four signals used to control the NT7603 from the PIC32 (marked MPU in the diagram):
- RS - Register select: Selects between the Instruction and Data registers.
- E - Enable: Asserted high to start a read/write transaction.
- RW - Read not Write: When asserted indicates a read, de-asserted indicates a write.
- DATA - Data Bus: An 8-bit bus containing the data to be read/written to the indicated register.
RS <-> RB15
E <-> RD4
RW <-> RD5
DATA <-> RE0 - RE7
The databook describes the protocol for a read and write operation and describes a basic initialization flow. The code linked below shows my implementation of that flow, along with a puts_lcd(char* string) helper function which can be used to write a string to the display.
The biggest challenge with implementing this code was figuring out what controlled the LCD screen on the Explorer 16 and finding a databook for that controller. I also found this controller a little difficult to work with as it seems to be very sensitive to the timings of the various commands. If you run into trouble use a Logic Analyzer to ensure that you are meeting the minimum delays after each command type before issuing the next command. Also ensure you are meeting the minimum timings for the write and read operations. These delays and timings are all listed in the databook.
Code:
References:
- NT7603 LCD Controller / Driver Databook
Friday, December 16, 2011
Using the UART on the PIC32 Explorer 16 Board
Using the LEDs and buttons on the Explorer 16 development board gives a user the ability to interact with a program running on the PIC32, but it is a brutally limited form of interaction. To do any serious interaction one would want some kind of console environment. An easy way to create that is to use the RS232 port on the Explorer 16 board to create a communications link with the Windows host system. Unfortunately my Windows system does not have any RS232 ports (they are becoming increasingly rare on new motherboards). To get around this I am using a USB to RS232 adapter that runs some variant of the Prolific USB to RS232 chipset. I also needed a terminal emulator to run on my Windows system so I could communicate on the RS232 port. Hyperterminal, the old terminal emulator of choice, has been removed from recent version of windows, so after some web searching I found a replacement called RealTerm. This program has some powerful features for controlling an RS232 connection and I found it very easy to use. Now armed with an RS232 connection and a terminal emulator I programmed the PIC32 with a UART demo program from the C32 compiler's peripheral library demo folder. The demo is called "uart_basic" and is found in the:
<install path>\Microchip\MPLAB C32 Suite\examples\plib_examples\uart\uart_basic
directory. The demo is supposed to present the user with a menu of commands where the user selects one by entering the number given for that command. Unfortunately, after programming the PIC32, connecting the RS232 cable, and starting the terminal emulator, nothing happened. After some debugging I tried restarting the Prolific device driver by disabling it and then enabling it in the Windows Device Manager. That solved the problem and the demo performed as expected.
Tip:
RealTerm is an excellent replacement for Hyperterminal, offering some powerful RS232 debugging tools.
Tip:
If you are having trouble using a USB to RS232 adapter, try restating its device driver by disabling and then enabling the device in the Windows Device Manager.
Friday, November 25, 2011
First Program on the Explorer 16 Board
For my first program I wanted to use the push-buttons and LEDs on the Explorer 16 development board as this would make the program easy to test. The goal is to make the lights blink when a button is pressed. Peripherals like buttons and LEDs are trivial to use on the Explorer 16 board, each are wired directly to a primary I/O pin on the PIC. The LEDs are activated by writing a logical 1 to their output pin. The buttons are active low, so a button press can be detected by seeing a logical 0 on their input pin. The code first disables the JTAG port. This is needed because one of the LEDs is wired to a pin also used for JTAG. It then configures the LED pins as outputs and the button pins as inputs. The rest of the program is an infinite loop that detects if any of the buttons are pressed, toggling the LED state if a button is pressed, and clearing the LED state if one is not pressed. The loop also contains a busy loop to cause a delay before the buttons are checked again. This delay is needed to hold the LEDs in their current state for a while so that they are clearly blinking to the human eye. Without it the LEDs would blink so fast they would just look very dimly lit.
Code:
Tip:
The Microchip peripheral library uses a lot of macro functions. The lowercase 'm' in the function name indicates that it is a really a C pre-processor macro and not a true C function. Macro calls can not have line breaks in them so the line break must be escaped with a '\' (back-slash). For example:
mPORTAClearBits(BIT_7 | BIT_6 | BIT_5 | BIT_5 | BIT_4 | \ BIT_3 | BIT_2 | BIT_1 | BIT_0 );
Wednesday, November 23, 2011
Compiling a Demo Program on the Explorer 16 Board
The C32 compiler that comes as part of the install package for MPLAB has several example projects. They can be found in <install path>\Microchip\MPLAB C32 Suite\examples. I chose the project "led_message" for my first compile job. It blinks the LEDs on the Explorer 16 development board which seemed ideal to me since it would be obvious if my program image was running on the PIC or not. The source code contains a good description of exactly what the code is trying to do:
/*
** Message in a bottle
**
** Explorer16 version (long delays)
**
** Thanks to Lucio DiJasio for letting us use this example.
**
** Run this example on Explorer-16 board with PIC32MX PIM.
** Hold the board vertically from the PICtail connector size
** and wave the board back-and-forth to see message "HELLO" on LEDs
*/
** Message in a bottle
**
** Explorer16 version (long delays)
**
** Thanks to Lucio DiJasio for letting us use this example.
**
** Run this example on Explorer-16 board with PIC32MX PIM.
** Hold the board vertically from the PICtail connector size
** and wave the board back-and-forth to see message "HELLO" on LEDs
*/
To compile the code I opened the projects MCP file and selected the PICKit3 as my programmer under the Programmer --> Select Programmer sub-menu. This caused the programmer to connect to the board and triggered an error message that the device ID read by the PICKit3 did not match the device the project was setup for. To fix this I selected the PIC processor I was using by selecting Configure --> Select Device... and choosing my device from the dialog box. After this I built the project using Project --> Build All and then programmed the device using Programmer --> Program. After programming was completed the program started running on the PIC and the LEDs started blinking. My next project is to develop my own program and run that on the PIC.
Monday, November 21, 2011
Getting Started with the PIC32 Explorer 16 Board
My initial setup is made up of a PIC32MX processor, Explorer 16 development board, and a PICKit 3 programmer/debugger. I am also using the MPLAB IDE and C32 compiler both from Microchip. After updating the software from the Microchip website I plugged in the development board and found it running a demo program that would cycle through a display on the LCD screen showing the voltage and temperature being read from the various sensors. Next I tried connecting the PICKit3 and seeing if I could communicate with the board. This is where I ran into my first snag. MPLAB was able to detect the PICKit3 but it hung at the connecting stage with the connecting status bar just filling over and over again. After doing some web searches and talking to an experienced PIC developer, I learned that my issue is a common one with the PICKits. The work-around is to swap the USB port you have the PICKit plugged into on the host system. It doesn't matter which USB port you swap it to, as long as it is a different port. Rebooting can also fix this issue. With the connection issue resolved I was prompted to download new firmware for the PICKit, and after installing that, I was able to read the current image from the board. My next project will be to change the program image running on the PIC32 and then to write and install my own image.
Materials:
Tip:
After selecting the PICKit 3 programmer, if MPLAB hangs at the "Connecting..." step, try swapping the USB port for the PICKit 3.
Subscribe to:
Posts (Atom)






