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.

coding help in keil ???

Status
Not open for further replies.

jokester4u

Junior Member level 2
Joined
Nov 26, 2013
Messages
20
Helped
1
Reputation
2
Reaction score
0
Trophy points
1
Activity points
124
How do i set a time for a line follwing r0b0t when it start from one place and when it get reversed it should stop on the same location where its started?
 

You can keep track using timers,have a variable.After every 1 sec delay,that var is inc.This way your program will know how many secs it has taken to proceed in the forward direction and use the same count,by decrementing the variable to reach to the start position,when reversed. I guess,this should work. Let us know about the progress.
 

Can you make a simple program for it plzz ?
 


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
#include<reg2051.h> 
 
unsigned int m;
void delay()
 {for(m=0;m<=20;m++)
{
TMOD=0X01;
TL0=0xFD;
TH0=0X4B;
TR0=1;
while(TF0==0);
TR0=0;
TF0=0;}}  /// one sec delay
 
sbit L=P3^2;
sbit M=P3^3;
sbit R=P3^4;
 
 
void main ()
 { 
 P1=0x00;
 P3=0xFF;
 
 if (L==1&&M==0&&R==1)
 {P1=0x05;} // forward
 
 
else if (L==1&&M==1&&R==1)
 
{P1=0x0A;}
} // reverse


This is my progress can you help me out !!!
 
Last edited by a moderator:

Code:
    #include<p89v51rd2.h>
    unsigned int a=0,steps=0,b=0;
	void Timer(void) interrupt 1 // Interrupt No.1 for T0
	{
		TH0=0x4b; 
		TL0=0xfc;
		if(a==20)
		{
			steps++; // after 1 sec
			a=0;
			// if stop is signaled for the robot,stop the timer
		}
		a++;
	}
	void Timer1(void) interrupt 3 // Interrupt No.3 for T2
	{
		TH0=0x4b; 
		TL0=0xfc;
		if(b==20)
		{
			steps--;
			b=0;
			if(steps==0)
			{
				TR1=0; // stop timer
				// stop the robot
			}
		}
		b++;
	}
	void main()
	
	{
		unsigned int fwd=0,rev=0;
		TMOD = 0x11; // Mode1 of Timer0 & mode 1 of timer 1
		
		IEN0 = 0x8a; // Enable interrupt
		while(1) 
		{
			if(fwd==1)
			{
				TH0=0x4b; // Initial values loaded to Timer
				TL0=0xfc;
				TR0=1;
			}
			if(rev==1)
			{
				TH1=0x4b; // Initial values loaded to Timer
				TL1=0xfc;
				TR1=1;
			}
	}

You can simplify this program,I have used timer interrupts.Interface it with two switches 1.fwd 2.rev Also interface lcd to see ur final result.
 

it give me errors while running the program and yeah its hould should based on AT89c2051
 

what are the errors it's throwing. Modify the program for AT89c2051. It's just an example.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top