Wednesday, June 25, 2014
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.
Thursday, May 22, 2014
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
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
Wednesday, September 11, 2013
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
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.
- NT7603 LCD Controller / Driver Databook
Friday, December 16, 2011
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.