MAin Menu

Course Synopsis

EMBEDDED SYSTEM APPLICATIONS covers the basic concept and application of microcontroller system based on Peripheral Interface Controller (PIC) microcontroller. Students will learn software and hardware development on microcontroller development system and understand how to do interfacing with external devices using suitable internal chip features. Students will be also exposed to the new Microcontroller Unit (MCU) simulation software.

Saturday, June 30, 2012

PIC18F4550

This is the pin configurations for 40 pins PIC18F4550


PIC18F4550 can use same basic circuit of PIC16F877A. All pins are similar. PGC, PGD, MCLR, VDD, VDD are use for ICSP programming port.

Important  setting in using PIC18F4550

#pragma config PLLDIV = 5 // This value has to be 5 for 20Mhz crystal
#pragma config FOSC   = HSPLL_HS // High Speed oscillator for crystal more than 4Mhz
#define _XTAL_FREQ 16000000 // Use 16Mhz although 20Mhz crystal is used  
   
Although 20Mhz crystal is used , _XTAL_FREQ 16000000 has to be define to be 16Mhz because the speed of this PIC is fix at 4Mhz, 16MHz, 48Mhz...If  _XTAL_FREQ 20000000, __delay_ms() and __delay_us() function is not accurate.  _XTAL_FREQ 16000000 is the only ways I can think to make it accurate.

**If you manage to get accurate delay with _XTAL_FREQ 20000000, please share with me...thanks

18F4550 PIR sensor with LCD display

This project is using PIC18F4550. PIR sensor is used to sense motion. When there is movement, the data pin of PIR sensor will send high signal to PIC. The PIR sensor is very easy to used with PIC as it send digital HIGH and LOW signal only as active HIGH switch. In this project, when there is movement, LCD will shows "object detected" referring to video below.





**PIR sensor needs atleast 5 minutes to be in ready mode. So, delay must be insert before any other program.




Switch controlled LED blinking

Video below shows LED light controlled by forward and reverse switch. When forward button is press, LED will shift to the right and reverse button will make the LED shift to the left. When LED is shifted until the last one, it will back to the first one again.


Programming part


//This is the desired array looks like
unsigned char _options[8]={0b00000001, 0b00000010, 0b00000100, 0b00001000,
  0b00010000, 0b00100000, 0b01000000, 0b10000000};
sel=0;  
PORTD =_options[sel]; //assign PORTD output to follow the array

//this is where button assigned to move forward or reverse
while(1)
{
if(forward==1)
{
if(sel==7) sel=0;
else sel++;
PORTD =_options[sel];
while(forward==1);         //waiting for button to be press
}


else if(reverse==1)
{
if(sel==0) sel=7;
else sel--;
PORTD =_options[sel];
while(reverse==1);
}

Friday, April 1, 2011

Monophonic birthday song

After the LED cube project with delay, ON & OFF, one new idea pop-up in my mind: "can i generate different frequency for different notes?". Then i find the frequency for the piano notes. After convert the frequency into microsecond, the program for a birthday song is here...

First try by connecting the speaker directly from the output in produced songs that barely heard. So, I add a transistor to amplified the output signal...as simple as that. See the circuit below for the simple circuit.

Tuesday, March 29, 2011

Electronic Components for PIC project

The main circuit for PIC needs the following components:
  • 1 x crystal 20.0MHz
  • 1 x resistor 10kohm
  • 1 x PIC16F877A
  • 1 x 40 pin socket
  • 1 x diode
  • 2 x ceramic capacitor 22nF
  • PCB or veroboard
Cost for this main circuit is around RM50. (worth to be tried out)


to be update soon.

Friday, March 25, 2011

3x3x3 LED cube with PIC16F877A

This is the first LED cube i made using PIC16F877A and 27 pieces of LED and 3 pieces of diodes for reverse bias pervention. The following Video is the result of 15 types of simulations:


I had assigned the LED into 9 columns and 3 layer. This means 12 output is needed for the simulation. Below is the circuit for the PIC controller and the LED cube.


PIC controller circuit


LED cube circuit

The 3 layers LEDs are sharing cathode and soldered to diode 1N4001 before fed to the PIC output pins. This is to ensure there will be no reverse bias going through the LEDs as the reverse bias threshold voltage is 5V. This will damage the LED. The connections of diodes are as shown in figure below. Normally the anode of the resistor will fed to 90 ohm - 100 ohm resistor to reduce the output voltage to approximately 3.3V. There is no resistor fed from the output pins for my LED cube because the output voltage of 4.4V seems OK for the LED.


Diode connection from cathode

The coding for this cube is basic ON & OFF plus some delay. All port B plus 1 RD7 are used as columns and RD4-6 is used as layers for example:

This is the main part of the program. For other style can be add-on with adding extra code. (I upload in JPEG form because the coding become different due to the coding conflict with .html)





LED cube for 5x5x5 will be the next target after LEDs reach... >.< limitation of PIC16F877A... Looking for ways to make it 8x8x8 or even more...