Showing posts with label interface. Show all posts
Showing posts with label interface. Show all posts

Thursday, January 15, 2015

Servo Motor Interfacing With PIC Microcontroller ( PIC18F2550 ) in Proteus [step by step]


Servo motor with microcontroller
Servo Motor


Servo motors are very popular in the field of robotics. In this tutorial I will show how to interface servo motor with microcontroller and I will use pic18f2550 microcontroller. Basically servo motor works on PWM(Pulse Width Modulation) signal. PWM has  great uses to produce signal  by microcontroller .
Look at the picture given below. We have to send PWM signal from 1millisecond to 2 millisecond to control the servo motor.
Remember the required frequency for operating servomotor is 50Hz and the time period is 0.02 second or 20ms. The MikroC function PWM1_Init() will not be initialized with 50Hz frequency. Actually we don't need mikroc functions to operate a servo motor. We can do it manually.

Read this

1 If we  use less or equal to 1millisecond, the motor rotates 0 degree
2 If we  use 1.5millisecond or (1500 us), the motor rotates to 90 degree
3 If we  use equal to 2millisecond, the motor rotates 180 degree
So if we like to rotate x degree, the solution becomes =[1000+{(500/90)*x}] us. I used this and it worked successfully. Now look at the picture given below .


We know that time period is 20ms. If we would like to rotate 90 degree angle, the pulse should be 1500us ON and 18500us OFF. I think it's clear.



Now let's create a project on Proteus. If you are an expert you don't need to follow instructions. But beginner can follow these.

Proteus Circuit:


Create new project in proteus
Create new project in proteus 8


How to find parts from Proteus
How to find parts from Proteus
How to find parts from Proteus Library
How to find parts from Proteus Library
Now complete the circuit as i have given below.
Servo Motor Interfacing With PIC Microcontroller (  PIC18F2550  ) in Proteus [step by step]
Servo Motor Interfacing With PIC Microcontroller (  PIC18F2550  ) in Proteus [step by step]

Now look carefully at the picture given below.
Servo Motor Interfacing With PIC Microcontroller (  PIC18F2550  ) in Proteus [step by step]
Servo Motor Interfacing With PIC Microcontroller (  PIC18F2550  ) in Proteus [step by step]
 We have completed the circuit. Now let's create a Project in MikroC because we need a program to operate the microcontroller.

MikroC Code :


#Source Code :







2:  void main() {  
3:  int i=0;  
4:  CMCON = 0x07; // To turn off comparators  
5:  ADCON1 = 0x0F;  
6:  Trisc=0x00;  
7:  delay_ms(1000);  
8:  while(1){  
9:  /////// rotate to 0 degree  
10:  for(i=0;i<49;i++){  
11:  PORTC.F0=1;  
12:  delay_us(900);  
13:  PORTC.F0=0;  
14:  delay_us(19100);  
15:   }  
16:  delay_ms(4000);  //delay for 4 sec  
17:   /////// rotate to 45 degree  
18:  for(i=0;i<49;i++)  
19:  PORTC.F0=1;  
20:  delay_us(1250);  
21:  PORTC.F0=0;  
22:  delay_us(18750);  
23:   }  
24:  delay_ms(4000);  
25:   /////// rotate to 90 degree  
26:  for(i=0;i<49;i++){  
27:  PORTC.F0=1;  
28:  delay_us(1500);  
29:  PORTC.F0=0;  
30:  delay_us(18500);  
31:   }  
32:  delay_ms(4000);  //delay for 4 sec  
33:   /////// rotate to 1350 degree  
34:  for(i=0;i<49;i++)  
35:  {  
36:  PORTC.F0=1;  
37:  delay_us(1750);  
38:  PORTC.F0=0;  
39:  delay_us(18250);  
40:   }  
41:  delay_ms(4000);  //delay for 4 sec  
42:  /////// rotate to 180 degree  
43:  for(i=0;i<49;i++)  
44:  {  
45:  PORTC.F0=1;  
46:  delay_us(2000);  
47:  PORTC.F0=0;  
48:  delay_us(18000);  
49:   }  
50:  delay_ms(4000);  //delay for 4 sec  
51:  }  
52:  }  

Now run the MikroC project.
How to Create Hex file in mikroC
How to Create Hex file in mikroC
Now go to the proteus circuit and load the .hex file to your microcontroller .If you don't know how , follow the instructions .

How to load hex file to microcontroller in proteus
How to load source hex on  microcontroller in proteus
Now just run the project.

Result :

Servo Motor Interfacing With PIC Microcontroller Proteus Simulation

Servo Motor Interfacing With PIC Microcontroller Proteus Simulation


Download All Files

         


Thank You! 

DC Motor Interfacing with PIC Microcontroller ( PIC18F2550 ) in Proteus [step by step]


mikroc code to start and stop dc motor
DC Motor

This tutorial will describe,  how to interface a DC motor with a Microcontroller and in this tutorial, I will use pic18f2550 microcontroller. Generally, to control a DC motor we need voltage 12v with 300mA current. Basically a microcontroller works on 5v and can't provide the current follow to operate a DC motor.As we know a motor can produce back emf, we need other technique to operate .The solution will be a H-Bridge circuit or L293D ic.

H-Bridge Circuit for dc motor
H-Bridge Circuit 
L293D IC pin out
L293D


We can operate two motors through this IC. Here pin 1 is to enable input 1(pin1)&2(pin7) for input and 3&6 pins for output. Pin9 enables 3(pin 10)&4(15) as input and 14&11 pins as output. We will connect pin2 & pin7 with our microcontroller's pin RC0 and RC1 respectively. Now, look at the picture given below.
 DC Motor Interfacing with PIC Microcontroller ( PIC18F2550 ) in Proteus [step by step]
DC Motor Rotation Controlling


Now Create a new project in Proteus. If you are a beginner, just follow the instructions.

Proteus Circuit:

How to Create a New Project in Proteus 8_Step1
How to Create a New Project in Proteus 8_Step1
How to Create a New Project in Proteus 8_Step2
How to Create a New Project in Proteus 8_Step2

How to Create a New Project in Proteus 8_Step3
How to Create a New Project in Proteus 8_Step3
How to Pick parts from Proteus library
How to Pick parts from Proteus library
How to find Power ,Ground etc
Now just complete the circuit as I have given below.

 DC Motor Interfacing with PIC Microcontroller ( PIC18F2550 ) in Proteus [step by step]
Interface DC Motor with pic Microcontroller
Now we need source code to run this microcontroller. So let's create a project in MikroC.

MikroC Project :

Create a project in mikroC_Step_1
Create a project in mikroC_Step_2
Create a project in mikroC_Step_3
#Source Code :
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


void main() {
CMCON = 0x07; // To turn off comparators
ADCON1 = 0x0F;
Trisc=0x00;
delay_ms(1000);
while(1){
/////// Step1: Rotate Motor Clockwise
PORTC.F0=1;
PORTC.F1=0;
delay_ms(4000);   //delay for 4 sec
/////// Step2: Stop the Motor
PORTC.F0=0;
PORTC.F1=0;
delay_ms(4000);   //delay for 4 sec
 /////// Step3: Rotate Motor Anti-Clockwise
PORTC.F0=0;
PORTC.F1=1;
delay_ms(4000);   //waiting for 4 sec
  /////// Step4: Again Stop The Motor
PORTC.F0=1;
PORTC.F1=1;
delay_ms(4000);   //delay for 4 sec
}
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Now run the program and save the hex file on your computer .
Run project in mikroC
Now go to the proteus circuit and load the hex to microcontroller
Load hex to microcontroller
Run the proteus project.
Run Proteus Project

Result :

 mikroc code to start and stop dc motor
DC motor in Clockwise direction
 DC Motor Interfacing with PIC Microcontroller ( PIC18F2550 ) in Proteus [step by step]
DC motor in Anti-Clockwise direction


      Download Proteus File & Hex file

                          Just Click on  '' SKIP ADD '' and You will get the download link

Thank You!



Wednesday, January 14, 2015

Bipolar Stepper Motor Interfacing With PIC Microcontroller (PIC18F2550) in Proteus [step by step]

                                            

Stepper Motor (animation source : wikipedia)

Stepper Motors and It's Working Principles :

In this tutorial I will show , how to interface stepper motor with microcontroller and in this case I will use pic18f2550 microcontroller .Basically stepper motor works step by step .It can rotate 360 degree by the movements of equal steps.They are available stepper motor with steps 200, 180, 144, 72, 24 with rotation angles 1.8°, 2°, 2.5°, 5°, 15° respectively. Stepper motor moves each step at a time where every steps are equal .
Generally stepper motor works on the principle of electromagnetic induction. A internal rotor is surrounded by electromagnetic stators where rotor and stator like to be stable by achieving different poles.In this way the stepper motor rotate .If one stator gets power , thetab stator attracts the rotor .At this situation the rotor rotates so that the stable state can be achieved .If next stator is on and others are off .The motor will complete the next step .

Generally Stepper Motors are Divided into Three Types :



1.Hybrid Stepper Motor
2.Permanent Magnet Stepper Motor
3.Variable Reluctance  Stepper Motor

[Note : If you would like to learn more about Stepper motor with more details ,please follow the link  wikipedia  ]

According to the arrangement of windings the stepper motors are divided into two types :

1.Unipolar Motor
2.Bipolar Motor

Unipolar : 

This type of stepper motor is very popular and  most preferable for the hobbyists .Unipolar stepper motor contains centre tapped  windings inside .In this case coils are connected through a common wire and the poles can be changed without changing the direction of current .That's why the commutation circuit is very simple for unipolar stepper motor .To control a motor through microcontroller we need H-bridge circuit and we use L293D IC  as a replacement of h-bridge circuit . You know motor is one kind generator of electricity  .Due to the effect of magnetic field the rotation makes back emf  and we shouldn't use a MCU to interface directly with motor.That's why we will use L293D .

Bipolar :

This types of motor have no centre taped windings .For achieving reverse magnetic poles the current should be reversed in direction .In order to control this motor we need L293D ic because it is more complex to control .Basically L293D is used  as the alternative of H-bridge circuit .H-bridge circuit is also used to controlling dc motor .


[Note : If you would like to see "How to Interface Unipolar Stepper Motor " ,Please follow the link]

Now at this situation , we have got necessary information  to create a Project .

Proteus Circuit for Bipolar Stepper Motor:

Let's Create a Project on Proteus .Please Follow the instructions given in the pictures .



Please Complete the circuit as Given below . This Circuit is for Unipolar Stepper Motor
 Bipolar Stepper Motor Interfacing With PIC Microcontroller (PIC18F2550) in Proteus [step by step]
 Bipolar Stepper Motor Interfacing With PIC Microcontroller (PIC18F2550) in Proteus [step by step]

Now Create a Project in MikroC .If you are a beginner , you can follow the instruction :

MikroC Code  for Bipolar Stepper Motor:


Source Code :


\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
void main() {
CMCON = 0x07;
ADCON1 = 0x0F;
Trisb=0x00;
delay_ms(1000);
while(1){
PORTB.F0=0;
PORTB.F1=0;
PORTB.F2=0;
PORTB.F3=1;
delay_ms(1000);
PORTB.F0=0;
PORTB.F1=1;
PORTB.F2=0;
PORTB.F3=0;
delay_ms(1000);
PORTB.F0=0;
PORTB.F1=0;
PORTB.F2=1;
PORTB.F3=0;
delay_ms(1000);
PORTB.F0=1;
PORTB.F1=0;
PORTB.F2=0;
PORTB.F3=0;
delay_ms(1000);
}
}

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

How to run the MikroC and save hex file .

Now go to the proteus circuit to load the hex file
Run the Project

Result :

 Bipolar Stepper Motor Interfacing With PIC Microcontroller (PIC18F2550) in Proteus [step by step]
 Bipolar Stepper Motor Interfacing With PIC Microcontroller (PIC18F2550) in Proteus [step by step]



                                                      Download Proteus File

                                                       Download Source Hex



                      Just Click on  '' SKIP ADD '' and You will get the download link




Thank You !



Please Share and Bookmark posts.

Tags

: (1) 18F2550 (1) 36KHz (3) and (1) arduino (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) keyboard (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 (2) 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)

Traffic Feed


Live Traffic Feed
Visitor Tracking

Leave Your Message Here

Name

Email *

Message *

Like on Facebook