+ Post New Thread
Results 1 to 4 of 4
  1. #1
    Member level 1
    Points: 205, Level: 2

    Join Date
    Jan 2015
    Location
    Tamilnadu , India
    Posts
    41
    Helped
    0 / 0
    Points
    205
    Level
    2

    Hang problem on Motor control in pic

    i done the wireless control dc motor interface with pic. I check the output in Proteus successfully and also i checked in the real time.it works good but after some time it's not responding the control key example when i pressed forward direction it not responded.after some time gap it respond. i also attach my coding..here....
    Code:
    #include
    #include"H:\RECovery RObot\header files\motor.h"
    #include"H:\RECovery RObot\header files\delay.h"
    #include"H:\RECovery RObot\header files\ladder.h"
    #pragma config OSC=HS, OSCS=OFF
    #pragma config DEBUG=OFF, LVP=OFF, STVR=OFF
    #pragma config WDT=OFF
    #pragma config BOR=OFF, PWRT=OFF
    #define s1 PORTBbits.RB2
    #define s2 PORTBbits.RB3
    #define s3 PORTBbits.RB4
    #define s4 PORTBbits.RB5
    void main()
    {
    	TRISBbits.TRISB2=1;
    	TRISBbits.TRISB3=1;
    	TRISBbits.TRISB4=1;
    	TRISBbits.TRISB5=1;
    	TRISCbits.TRISC0=0;
    	TRISCbits.TRISC1=0;
    	TRISCbits.TRISC2=0;
    	TRISCbits.TRISC3=0;
    	TRISCbits.TRISC4=0;
    	TRISCbits.TRISC5=0;
    ADCON1=0X07;
    	TRISAbits.TRISA0=0;
    	TRISAbits.TRISA1=0;
    	while(1)
    {
    
    if(s1&s3)
    {
    ladder_up();
    breaks();
    	delay(200);
    }
    else if(s4&s3)
    {
    ladder_down();
    breaks();
    	delay(200);
    }
    else if(s1&s2)
    {
    pump_r();
    breaks();
    	delay(200);
    }
    else if(s4&s2)
    {
    pump_l();
    breaks();
    	delay(200);
    }
    
    else if(s1==1)
    		{
    	stop();
    			rotate_f();
    			delay(200);
    		}
    
    	else if(s2==1)
    		{
    	stop();
    			rotate_r();
    	delay(200);
    
    			}
    	else if(s3==1)
    		{
    	stop();
    			rotate_l();
    	delay(200);
    			}
    	else if(s4==1)
    		{
    			stop();
    			rotate_b();
    	delay(200);//200 ms delay
    		}
    	else
    		{
    			breaks();
    			stop();
    delay(200);
    
    			}
    			}
    }
    Last edited by Mani Yuvan; 2nd March 2015 at 01:26.

    •   AltAdvertisment

        
       

  2. #2
    Banned
    Points: 12,436, Level: 26

    Join Date
    Apr 2013
    Posts
    2,528
    Helped
    538 / 538
    Points
    12,436
    Level
    26

    Re: Hang problem on Motor control in pic

    Post full code and Zip and post complete MPLAB project files.

    As PIC18F is used, use LATxbits.Latxy instead of PORTxbits.Rxy for output pins.



    •   AltAdvertisment

        
       

  3. #3
    Member level 1
    Points: 205, Level: 2

    Join Date
    Jan 2015
    Location
    Tamilnadu , India
    Posts
    41
    Helped
    0 / 0
    Points
    205
    Level
    2

    Re: Hang problem on Motor control in pic

    Quote Originally Posted by milan.rajik View Post
    Post full code and Zip and post complete MPLAB project files.

    As PIC18F is used, use LATxbits.Latxy instead of PORTxbits.Rxy for output pins.
    Why use LATxbits.Latxy instead of PORTxbits.Rxy for output pins.



    •   AltAdvertisment

        
       

  4. #4
    Banned
    Points: 12,436, Level: 26

    Join Date
    Apr 2013
    Posts
    2,528
    Helped
    538 / 538
    Points
    12,436
    Level
    26

    Re: Hang problem on Motor control in pic

    It is answered many times in the forum. Do a search.



--[[ ]]--