Monday, December 14, 2009

Success!!!

Omg, I spent the whole Sunday doing the firmware code and the software programming.
Finally, I managed to get the A/D conversion working on the micro-controller and the software is able to display the values on the graph!! A great progress, please see screenshot:


I shorted the channel 0, AN0 to the 5 voltage, then disonnected it (see the gitter noise), then shorted back to 5 voltage. Wow, Happy :)

Saturday, December 12, 2009

USB Device

Yahoo!!! I managed to get my microcontroller detected as a USB device..I used the Microchip USB framework, WinUSB - Generic Driver Demo example with some editing.
Please see screenshot:







Arggh, I need to get back to my firmware coding again... (:

Sunday, December 6, 2009

Microchip USB Framework & Software Interface

Microchip USB Framework
I have switched to Microchip pic18f2550 as my main micro-controller now and the debugging mode in the MPLAB is working fine for this chip. To write firmware codes for the usb module of the micro-controller, I have to install and study the Microchip USB Framework. It can be downloaded from here .The examples given by the framework are quite confusing and vast as there are a lot of header files and function call. After spending quite a few days studying the firmware coding and other examples from the internet, I discovered some precaution to take note. I am using the firmware from piccoder as the base foundation.

a) In the configuration bits, VREGEN (USB voltage regulator) must be enabled so that the pull-up resistor on the D+/D- will work. (For the host to detect whether the device is a high-speed (D+) or low-speed(D-) one)
b) The lines #define USE_SELF_POWER_SENSE_IO & #define USB_USB_BUS_SENSE_IO must be commented.
c) 220nF capacitor must be tied to Vbus as recommended by the datasheet.
d) Two 15pF capacitors must be connected to the 20Mhz Crystal as recommended by the datasheet.
e) D+/D- lines must be connected closely to the micro-controller and jumper wires should be as short as possible to reduce noise and interference.

After multiple tries, I don't have much progress. I am getting "USB device is not recognized" when I plugged in the device to the computer. It is quite frustrating for the Microchip USB framework.

Software interface
Since I am stuck in the firmware coding, I decided to spend some time on the software side first as I am going to have my fyp progress interview soon on the 22-Dec. I am using Microsoft Visual Basic .Net express 2008 (with WINUSB API) with zedgraph plug-in control for plotting the graph. Zedgraph is quite a nice plug-in with well-documented faqs and coding. I am quite pleased with the progress that I have made in the software part as I have managed to design the software interface and simulate the input values and plot the values in real-time. Please see screen below for my user interface:




1) Channel A - Simulating a sine waveform in real-time
2) Channel B - Plotting the values from the 5 textboxes in real-time