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

Saturday, November 21, 2009

Follow up of Microchip pic18lf13k50

Oh ya, I promise to talk more on the Microchip pic18lf13k50 micro-controller. I got to know from the Google search here that it require a header kit (processor extension pak) in order for the debugging section to work. It cost around S$80. Thus, I decide to abandon this model and switch to pic18f2550. I double-check in the MPLAB software (in the device options) that no header kit is required for this chip.

Wa, the chips came in the next day. I ordered on Sunday and it was delivered on Monday (Amazing service). Feeling with hope that I will succeed this time, I tested it out in the evening time. =.= :(, the same error message occurred again (unable to enter debug mode when I did the 'program'). Sad man, what is wrong? I consulted my supervisor on Wednesday evening and hope that my connection is wrong so that the problem can be easily rectified. My supervisor suspected the problem is due to the ICD2 device thus he bought back my hardware and the ICD2 to check.

On Friday evening, I collected my hardware and a new ICD2 from my supervisor. On Saturday morning, I tried again my hardware with the ICD2. Again, it is showing the "unable to enter debug mode"... I am frustrated!!! Why is it still not working! 

I tried and tried and tried... I think let try internal oscillator mode (INTOSC) in the configuration bits setting in the MPLAB. Yes, it is able to program and enter debug mode. I clicked on the RUN button, and the target controller is able to run. Finally, I am to get my hardware enter debug mode!!! After reading the datasheet of the model, I discovered that I have the select the wrong oscillator mode all the while. XT(1MHz to 4Mhz) mode is for low frequency crystal/resonator. HS (above 4MHz)) is for high frequency crystal/resonator. I changed in the configuration bits again to HS and it work! Yahoo, finally I can start on my firmware coding...

Please see the following on the MPLAB configuration bits:

Sunday, November 15, 2009

Final Year Project

Hello Everyone,
I will be using this to update on my fyp progress...hopefully, it will be interesting for my readers.
 It is also a way to update my supervisors(especially overseas supervisor) and for myself to check on my progress and maybe a page for me to reference so that I can write my final report. My graduate engineering friends are welcome to comment.

So, my final year project is on designing a USB oscilloscope. It is a hardware and software project. The hardware is to build a circuit with micro-controller to convert the analog signals to digital. As for the software part, I will be using Visual Basic Express with WINUSB API. Sound simple, right??

Okay, I will talk more on details of my micro-controller, I have decided to use Microchip micro-controller as it is cheap and easy to buy in the market (Farnell). It has built-in support analog to digital (with free C compiler to convert the C codes into the assembly code), C library function to call to initialize the A/D, convert, check status of conversion. Wow, nice, right? I am adverting for Microchip, man.. They need to give me free chips.. :)  .. Ok, from the list of micro-controller, I decided to use Microchip pic18lf13k50 as my main microcontroller as it is the *cheapest* of all... (thinking that I will not go wrong)..... BUT, I AM WRONG!!!!!! I tell more in my next post... :(