Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[PIC] hi, i want help in my project using pic16f877A

Status
Not open for further replies.

rooh

Newbie level 1
Newbie level 1
Joined
Nov 11, 2013
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Visit site
Activity points
11
hi ,, i musing pic16f877a,, for driving a
dc motor....... right lift farward back...
can any one help me to provide me asm code , hex file . and make file in proteus......plzzz
 

hi ,, i musing pic16f877a,, for driving a
dc motor....... right lift farward back...
can any one help me to provide me asm code , hex file . and make file in proteus......plzzz


Hi,

This tutorial will teach you how to drive a simple dc motor.
It refers to the 876 chip but that is the same as the 877a chip apart from its bigger memory and extra ports, just change the references of 876 to 877a.

http://www.winpicprog.co.uk/pic_tutorial8.htm


Just try proteus, select the chip and a motor, its not that hard to master, plenty of examples on ytube.
 

Hi Rooh, try this code with MikroC

Code:
void main() {
    short duty  = 0; //initial value for duty
  TRISC = 0x00; //PORTC as output
  TRISB = 0x00; //PORTB as output
  portb = 0x00; // init
  PWM1_Init(5000);  //Initialize PWM1
  PWM1_Start();  //start PWM1
  PWM1_Set_Duty(duty); //Set current duty for PWM1
  while (1)        // endless loop

  {
        PORTB = 0x01;  // 1st direction given through RB0
        Delay_ms(10);
        duty = 255;  //max duty
        PWM1_Set_Duty(duty);
        delay_ms(5000);
        PWM1_STOP();
        
        portb=0;
        delay_ms(5000); //wait until Motor stop before changing direction..
        
        PORTB = 0x02;  // 2nd direction given through RB1
        Delay_ms(10);
        duty = 255;  //max duty
        PWM1_Set_Duty(duty);
        delay_ms(5000); 
        PWM1_STOP();
  }
}
 

Attachments

  • Sans 2.jpg
    Sans 2.jpg
    50.7 KB · Views: 111
Last edited by a moderator:
Hi, could some one helpe me pleaaase, how to use 2 buttons in portA to invert motor direction
 

You need one button to change direction.


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
void main(){
 
  unsigned char duty  = 0, toggle = 0, duty = 255;  //max duty; //initial value for duty
 
  TRISA = 0x01;
  PORTA = 0x00;
 
  TRISC = 0x00;
  PORTC = 0x00; 
  TRISB = 0x00; 
  PORTB = 0x00;
 
  CMCON = 0x07;
  //ADCON1 = ;  //Disable Analog inputs here 
 
  PWM1_Init(5000);  
  PWM1_Set_Duty(duty); 
  PWM1_Start();  
 
  while (1)        // endless loop
 
  {
    if(PORTA.F1){
        Delay_ms(50);
        if(PORTA.F1){
            toggle = ~toggle;
        }
    }
 
    if(!toggle){
        PORTB = 0x01;  // 1st direction given through RB0       
 
    }
    else if(toggle){
        PORTB = 0x02;  // 2nd direction given through RB1
            
    }        
  }
}

 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top