Friday, January 30, 2015

PIC Experiment Kit [for 28pin] with PCB Design




Today I will share an  Experiment Kit . Changing connections in breadboard is really disgusting and this problem can be solved by using this experiment kit.
This Experiment kit contains :
1. USB Connector
2. Serial Connector
3. 4 Push Button
4. LCD Display[16x2]
5. Female Connector for Bluetooth Device
One more thing , each pin of microcontroller is connected with female connector so that  each pin can be used  individually .We can provide power supply +5v  to breadboard from this kit .

 Required Parts List :

1. IC Base 28 pin
2.IC Base 16 pin
3. capacitor  22pf ceramic   qty=2 .
4. capacitor 220 nf  qty=2
5.capacitor  1uf 50v qty=5
6. Crystal 12MHz  qty=1
7. LM 35 [Temperature Sensor]
8. DC Socket qty=1
9.Resistor 10k ohm qty=4
10. Resistor 470 0hm qty=6
11.Variable Resistor 5kohm qty=1
12. LCD Display[16x2] qty=1
13. Seven Sigment Dispay qty=1
14.Push Button qty=4
15. USB Connector B-type qty=1
16. DB9F Connector  qty=1
17. IC-->  Max232 qty=1
18. IC-->  Pic 18f2550[or another PIC Microcontroller ,if you want]
19.Female Connector qty =3
20.L -Shaped Male Connector qty=1  & LED  qty=6 [Color depends on you] .
Those parts are required and if  you are in Bangladesh contact to TechShopBD.
  TechShopBD's Website ->> http://www.techshopbd.com/

Look at here :



Instructions are given on that picture। Position of 1uf capacitor & where to connect 470 ohm resistor etc. Be careful about that 1uf capacitor should be at least 20 volt and polar. During soldering you should be careful about [ +/- ] position .
The pcb design has been provided in the Download Link given below .






Next time in future i will show how to make PCB at home Inshaallah. Now I am describing about  how to use it.

PORT A:
Pin A0-> for LM35 [it is static and final, you cannot change it]
Pin A1->for  another adc input[]
From A2 to A5 for 4 push button , those will work with logical 0 .
[These pins are always remaining with +5v ]
nk
PORT B : B7 to B2  for LCD Display ।
LCD Configuration:

sbit LCD_RS at LATB7_bit;
sbit LCD_EN at LATB6_bit;
sbit LCD_D4 at LATB5_bit;
sbit LCD_D5 at LATB4_bit;
sbit LCD_D6 at LATB3_bit;
sbit LCD_D7 at LATB2_bit;
//////////////////////////////////////////////
Pin B1 and Pin B0 are connected with two LED .Where each led's +end is connected with  microcontroller.[If microcontroller provide '1' , Led will be ON and during 0 ,it will remain OFF]
You have to write code according to this configuration .

Experiment Kit
Experiment Kit 




One more thing,  here an option given for 7 Segment Display. But it has no connection with the microcontroller. Female Connectors have been given so that you can connect it manually.



Download Link(google drive) 

You can watch this experiment kit at Youtube. 

YouTube VideoLink 

 

Thank You!


Saturday, January 24, 2015

Usb Communication With PIC Microcontroller [step by step tutorial]



usb connection with pic microcontroller
mikroc usb tutorial

USB communication is better than serial communication. Hardware interfacing is very easier than Rs 232 . In USB 1.0 communication  Low Speed is-1.5Mbit/second  & High Speed is -12Mbit/second . The upgrade version provides more speed than older version. USB-3.0  has higher speed, 5Gbit/second and it's called super speed. For more information you can visit this page >>  Wikipedia Usb.

In this tutorial I will use pic18f2550 microcontroller & it is very popular for usb. Now you can ask a question, how do we get our MCU to work with high speed or low seed ?
At 6MHz clock we will get low speed and at 48MHz Clock we will get High speed. In this tutorial we will try to make higher speed connection. We are not going to use 48MHz clock, because it is very noisy. We will try another technique instead of it. Microchip company provides internal PLL( Phase Locked Loop ) circuit  in some of specific  products and  pic18f2550 has internal PLL Circuit. Now look at the picture :

Phase Locked Loop Cuit
PLL Circuit
The PLL circuit  converts 4MHz clock to 48MHz clock. So, we need 4MHz clock. We have to divide the clock in such way so that we can get  result 4MHz. Look at here, If we use 20MHz divide it by 5 and we get 4. Example : (20/5)=4 ,(12/3)=4. We have to define this in the  source code.

Now let's create a project in Proteus 8.

Proteus 8 Circuit :

Step 1:
How to Create Project in Proteus 8
How to Create Project in Proteus _1
Step 2:
How to Create Project in Proteus 8
How to Create Project in Proteus 8_2

Step3 :
How to Create Project in Proteus 8_3
How to Create Project in Proteus 8_3

 Step 4:
Usb Communication With PIC Microcontroller [step by step tutorial]


Step 5:
How to find parts in Proteus 8
How to find parts in Proteus 8
 Step 6:
How to find parts in Proteus 8_3
How to find parts in Proteus 8
Step 7:

usb interfacing with pic microcontroller Circuit
Usb  Interfacing With PIC Microcontroller Circuit

Now let's create a project in MikroC.

MikroC Code :

Step 1:
Create New Project in MikroC_1
Create New Project in MikroC_1
Step 2:
Create New Project in MikroC_2
Create New Project in MikroC_2
Step 3:
Create New Project in MikroC_3
Create New Project in MikroC_3
Step 4:
 Include All Library in mikroc
Include All Library
Step 5:
Editing MikroC project
Editing MikroC project settings_1
Step 6:
USB Communication With PIC Microcontroller
USB Communication With PIC Microcontroller


1. As we know PLL circuit takes input 4MHz clock. So we have to divide 12MHz by 3 so that we can get 4MHz clock. If we use 4MHz we have no need  this part .
2 & 3 . We are using USB 1.0 and it's High Speed clock 48MHz. So we have to devide it by 2.

4 . Here we are using 12MHz Crystal clock and the oscillator selection should be HS Oscillator.          

5 . We have to enable voltage regulator. Basically it is an internal  3.3 voltage regulator of pic18f2550. If we enable this, it is required to connect vusb pin with a 220 nf capacitor.

#Source Code :

 

unsigned char receivedata[64] absolute 0x500;  //  <--Variable Declaration  
 unsigned char senddata[64] absolute 0x580;  
 int i=0;  
 void Interrupt(){  
 USB_Interrupt_Proc();    //<--Interrupt function  
 }  
 void main()   //<--The Main Function  
 {  
 HID_Enable(&receivedata,&senddata);  //<--To Enable HID  
 while(1){             //<-- Infinity LOOP  
 while(!HID_Read());   //<--for reading  
 for(i=0;i<64;i++){  
 senddata[i]=receivedata[i];   //<--Sending received data to senddata[i] variable  
 }  
 while(!HID_Write(&senddata,64)); //<--for writting  
 }  
 }  
 

1. unsigned char receivedata[64] absolute 0x500;

    unsigned char senddata[64] absolute 0x580;


Here we have created character type two array variable senddata & receivedata. During USB Communication we must have to keep all data in USB RAM. PIC 18F2550 microcontroller's USB RAM memory address begins with 0x500 and ends with 0x7F. That's why, we kept the receivedata[64]  in 0x500 location and senddata[64] in 0x580.
2. 

void Interrupt(){


USB_Interrupt_Proc();}


void Interrupt() is one user defined function which contains USB_Interrupt_Proc()  function inside . Interrupt means restriction for something. When  interrupt is enabled, microcontrller doesn't perform main function. It will perform only interrupt function or ISR(interrupt service routine). After clearing the flag main method works.

3. HID_Enable(&receivedata,&senddata); 

This function will initialize USB. It locates receivedata variable and  send data variable.

Note : HID means "Human Interface Device"

4. char HID_Read();

This function receives data. If receiving is failed, it returns 0. Otherwise it returns character .

while(!HID_Read());

It means, this function tries to receive data until  data are being received .

char HID_Write();


This function receive data. If receiving is failed, it returns 0. Otherwise it returns the numbers of data .while(!HID_Write());


 It means, this function tries to send data until  data are being sent. 

5.for(i=0;i<64;i++>

senddata[i]=receivedata[i];    

}

This loop will run from 0 to 63 and will keeps the received data to senddata variable from receivedata variable.  

  #Descriptor File Addition

Descriptor File : This file will make your pc understand about device's informations. Like
Manufacture Name, Product ID, Vendor ID  etc.
Now i will show you. How to create a Descriptor file .



Step 7:
Create Descriptor FIle_1
Create Descriptor File_1
Step 8:
Create Descriptor FIle_2
Create Descriptor FIle_2
Step 9:
Adding descriptor file with MikroC Project .
Adding Descriptor File
Adding Descriptor File
Step 10:
Step 11:

Usb Communication With PIC Microcontroller [step by step tutorial]
Step 12:
usb interfacing with pic microcontroller
How to upload hex file in proteus_1
Step 13:
How to upload hex file in proteus
How to upload hex file in proteus_2
Step 14:
How to upload hex file in proteus
How to upload hex file in proteus_3
Step 15:
In proteus Simulation we need to install virtual usb .
How to install Virtual USB in proteus
Install Virtual USB in proteus
Step 16:
Run Proteus Project
Run Project

Now go to the Proteus Circuit and Just Run the project .

Output:

Now go to the Tool >>HID Terminal >> click on Terminal .
HID Terminal of MikroC
HID Terminal of MikroC
HID Terminal of MikroC
HID Terminal Output




                                          Thank You!                                                           

Friday, January 23, 2015

Rs 232 , Serial Communication with PIC Microcontroller in Proteus [step by step details]



Basically a microcontroller or computer can communicate with other computer through serial communication.
  If we would like to make a successful communication between PC(Desktop) and microcontroller, we need a protocol named Rs 232 protocol. Generally we use Rs232 for long distance connection.If you have a laptop , you need a " Usb to Serial Converter ". Because laptop doesn't have serial port .Usually desktop contains a serial port but laptop doesn't .

Please Watch these :


Rs 232 , Serial Communication with PIC Microcontroller in Proteus [step by step details]
Usb to Serial Converter

Take a look on DB9 Connector's and it's Pinout.For serial communication we will need this connector .
Rs 232 , Serial Communication with PIC Microcontroller in Proteus [step by step details]
We will use only three pins (RX,TX & GND) .Here TX to transmit  data and RX to receive data. Now look at the picture given below :

                                                        RS 232 Cable Length 

Rs 232 , Serial Communication with PIC Microcontroller in Proteus [step by step details]
In this tutorial we will use baud rate 9600. You can use another rate, if you want. We need an IC named maxim 232 or max 232 for communication. Look at the picture i have given blow :
Rs 232 , Serial Communication with PIC Microcontroller in Proteus [step by step details]
Max 232
We need this ic for rs232 protocol .In this tutorial we will connect pic18f2550's Tx pin  with T1 and pic18f2550's Rx with R1out. Let's create a project in proteus 8. If you don't have proteus 8 you can download with crack  from this site.

Proteus Circuit :

If you are a beginner, Please follow the steps .

Step 1:

Step 2:

Step 3:

Step 4:

Step 5:

Step 6:


Step 7: Now complete circuit as i given below .

If you don't know how to interface LCD display and push button with microcontroller. Please follow these  :  Lcd display & Push button. You will get download link at the last end of this page .

Rs 232 , Serial Communication with PIC Microcontroller in Proteus [step by step details]
Rs 232, Serial Communication with Microcontroller 


Please Look at here  :


 Virtual Terminal in proteus
How to find Virtual Terminal
Rs 232 , Serial Communication with PIC Microcontroller in Proteus [step by step details]
DB9 Settings
Now Create a project in MikroC so that we can create hex file for the microcontroller .

MikroC Project :

Step 1:

Rs 232 , Serial Communication with PIC Microcontroller in Proteus [step by step details]

Step 2:

Rs 232 , Serial Communication with PIC Microcontroller in Proteus [step by step details]

Step 3:
Rs 232 , Serial Communication with PIC Microcontroller in Proteus [step by step details]

MikroC Uart Library :

Here we use x=1;

  • UARTx_Init
  • UARTx_Data_Ready
  • UARTx_Tx_Idle
  • UARTx_Read
  • UARTx_Read_Text
  • UARTx_Write
  • UARTx_Write_Text
  • UART_Set_Active

Visite the link to get all details about Uart Library
  #Source Code :
   





  sbit LCD_RS at RB7_bit;   
  sbit LCD_EN at RB6_bit;   
  sbit LCD_D4 at RB5_bit;   
  sbit LCD_D5 at RB4_bit;   
  sbit LCD_D6 at RB3_bit;   
  sbit LCD_D7 at RB2_bit;   
  sbit LCD_RS_Direction at TRISB7_bit;   
  sbit LCD_EN_Direction at TRISB6_bit;   
  sbit LCD_D4_Direction at TRISB5_bit;   
  sbit LCD_D5_Direction at TRISB4_bit;   
  sbit LCD_D6_Direction at TRISB3_bit;   
  sbit LCD_D7_Direction at TRISB2_bit;   
  void main() {   
  int i=0,ck=0;   
  char dat[13];   
  CMCON = 0x07; // To turn off comparators   
  ADCON1 = 0x00;   
  TRISA=0x01;   
  CMCON = 0x07; // To turn off comparators   
  ADCON1 = 0x0F;   
  Lcd_Init();   
  Uart1_Init(9600);   
  delay_ms(1000);   
   UART1_Write_Text("Please Press The Start Button");   
    Lcd_Cmd(_LCD_CLEAR);    // Clear display   
   Lcd_Cmd(_LCD_CURSOR_OFF);   
   Lcd_Cmd(_LCD_CLEAR);   
   Lcd_out(1,1,"Press Start Btn");   
   Lcd_out(2,1,"Press Enter");   
   delay_ms(100);   
  while(1){   
  if(PORTA.f0==0){   
  ck=3 ;   
   UART1_Write_Text("  A=led1,B=led2,C=led3,D=led4,E=led5 \n Enter-:");   
    Lcd_Cmd(_LCD_CLEAR);   
   Lcd_out(1,1,"A ,B ,C, D, E");   
   Lcd_out(2,1,"Press Enter");   
   delay_ms(100);   
  }   
  while (ck==3) {   
     if (UART1_Data_Ready()) {   
      UART1_Read_Text(dat, "\r", 8);   
      for (i=0; i<strlen(dat); i++) {   
       dat[i] = toupper(dat[i]);  //this function make all the char Capital   
              // If you enter smal or Capital leter ,it doesn't matter   
      }   
      if (!strcmp(dat, "A")) {   
      PORTA=0x03;   
   UART1_Write_Text("Led1 is On Enter Here-:");   
   Lcd_Cmd(_LCD_CLEAR);   
   Lcd_out(1,1,"Led1 is On");   
   Lcd_out(2,1,"Press Enter");   
   delay_ms(100);   
      } else if (!strcmp(dat, "B")) {   
       PORTA=0x05;   
       UART1_Write_Text("Led2 is On Enter Here-:");   
        Lcd_Cmd(_LCD_CLEAR);   
   Lcd_out(1,1,"Led2 is On");   
   Lcd_out(2,1,"Press Enter");   
   delay_ms(100);   
      }   
      else if (!strcmp(dat, "C")) {   
       PORTA=0x09;   
        Lcd_Cmd(_LCD_CLEAR);   
   Lcd_out(1,1,"Led3 is On");   
   Lcd_out(2,1,"Press Enter");   
   delay_ms(100);   
       UART1_Write_Text("Led3 is On Enter Here-:");   
      }   
      else if (!strcmp(dat, "D")) {   
       PORTA=0x21;   
        Lcd_Cmd(_LCD_CLEAR);   
   Lcd_out(1,1,"Led4 is On");   
   Lcd_out(2,1,"Press Enter");   
   delay_ms(100);   
       UART1_Write_Text("Led4 is On Enter Here-:");   
      }   
       else{   
       PORTA=0x01;   
   Lcd_Cmd(_LCD_CLEAR);   
   Lcd_out(1,1,"Something Wrong");   
   Lcd_out(2,1,"Press Enter");   
   delay_ms(100);   
   UART1_Write_Text("Something is Wrong!!! \n A=led1,B=led2,C=led3,D=led4,E=led5 \n Enter-: ");   
      }   
     }   
    }   
    }   
     }

Step 4:
Rs 232 , Serial Communication with PIC Microcontroller in Proteus [step by step details]

Result Output:

Now load the hex file to the microcontroller .
Rs 232 , Serial Communication with PIC Microcontroller in Proteus [step by step details]
Rs 232 , Serial Communication with PIC Microcontroller in Proteus [step by step details]
Output : Press the Start Button .
Rs 232, Serial Communication
Rs 232, Serial Communication 
Rs 232 , Serial Communication with PIC Microcontroller in Proteus [step by step details]
Rs 232, Serial Communication 


                                   Download Proteus File & MikroC File

Thank You!

Share and Bookmark this Blog

Tags

: (1) 18F2550 (1) 36KHz (3) and (1) Based (1) battery (1) Bipolar (1) Blinking (1) blinks (1) Bluetooth (1) bluetooth device interfacing (1) bluetooth module (1) button (1) circuit (1) clock (1) control (1) crystal oscillator (3) Db9 (1) DC Motor (2) digital (2) Digital Voting Machine (1) digital voting machine using pic (1) display (2) DS1307 (1) electronic (1) embedded c programming tutorial (11) embedded c tutorial (11) experiment kit (4) external interrupt (4) flash (1) flashing (1) Gas Leakage detector (1) HC-06 (1) home (1) how (1) How to (10) i2c tutorial (1) in (1) indicator (1) infrared Connection (3) interface (8) interfacing (3) Interrupt (3) Introduction (1) IR Connection (3) IR Receiver (4) IR Transmitter (4) key pad (1) keypad (1) lavel (1) Lcd 16x2 (2) lcd 2x16 (2) led (1) lm35 (2) LPG (1) machine (1) make (1) Make bootloader (1) making (1) matrix (1) max232 (1) membrane keyboard (1) meter (2) Micocontroller (1) microchip (4) microchip pic (2) microchips (3) microcontroller (9) microcontroller based (3) microcontroller programming (3) Microcontroller Project (4) Microcontroller Projects (1) microcontroller_project (2) microcontrollers (4) Microprocessor (2) mikroC (5) mikroc code to start and stopstart and stop dc motor (1) mikroc pro for pic (2) Motion detector (1) MQ-9 Gas Sensor (1) musical (1) NEC Protocol (4) pcb (5) PIC (3) pic controller (11) pic microcontroller (11) pic microcontroller tutorial (11) pic programming (1) pic programming in c (12) pic proteus (1) Pic Tutorial (12) pic18 (2) pic18f2550 (11) picmicrocontroller (4) picRFモジュール (1) PIR Motion Sensor (1) printed circuit board (1) proteus (6) pulse width modulation (1) push (1) push button (1) PWM (1) real (1) rf transmitter (3) Rs 232 (1) Rs232 (1) scroll (1) scrolling (1) Serial communication (1) Serial Connection (1) Serial Port (1) serial port rs232 (1) Servo Motembedded c programming tutorial (1) simulation (2) Soil Moisture Meter (1) speed control (1) step by step (7) step bystep (1) Stepper Motor (2) text (2) Thief Detector (1) time (1) timer (4) timer0 (4) tone (1) TSOP38236 Receiver (4) tutorial (2) Unipolar (1) USART Connection (1) USB (1) usb 1.0 (1) USB bootloadere (1) USB HID (1) using (9) voltmeter (1) voting (1) water level indicator (3) with (2) work (1)

Live Traffic Feed


Live Traffic Feed
Live Traffic Feed

Comment Option isn't working properly

Comment option isn't working properly. If you have anything to say, you are requested to use the "Contact Form" below here.

Leave Your Message Here

Name

Email *

Message *

Google+ Followers

Like on Facebook