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] Hang up on Motor control in pic

Status
Not open for further replies.

Mani Yuvan

Member level 1
Joined
Jan 18, 2015
Messages
41
Helped
0
Reputation
0
Reaction score
0
Trophy points
6
Location
Tamilnadu , India
Activity points
321
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<p18f452.h>
#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:

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.
 

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.
Why use LATxbits.Latxy instead of PORTxbits.Rxy for output pins.
 

Re: Hang problem on Motor control in pic

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

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top