Society of Robots - Robot Forum

Software => Software => Topic started by: rajsekhar291 on July 19, 2010, 10:10:04 AM

Title: manual delay function and how to take the input frm sensors
Post by: rajsekhar291 on July 19, 2010, 10:10:04 AM
please can anyone tell me how to write manual delay function?
and also please tell me  how to take input from the sensors
Title: Re: manual delay function and how to take the input frm sensors
Post by: waltr on July 19, 2010, 12:43:33 PM
Which processor and programming language?

A software delay is pretty simple.

set a variable to a value
decrement the variable
test the variable for equal to zero
if not = 0 then go back and decrement again.
if = 0 exit
Title: Re: manual delay function and how to take the input frm sensors
Post by: rajsekhar291 on July 19, 2010, 01:12:20 PM
Which processor and programming language?

A software delay is pretty simple.

set a variable to a value
decrement the variable
test the variable for equal to zero
if not = 0 then go back and decrement again.
if = 0 exit
i want to write in c and i'm using atmega32
i want a delay of 1 second and the _delay_ms() function is not working please help me
Title: Re: manual delay function and how to take the input frm sensors
Post by: waltr on July 19, 2010, 03:15:17 PM
void delay_1sec (void) {
   int i, j;
 
   for( i=0; i<X; i++) {
     for( j=0; j<Y; j++) {
          ;
     }
   }
}
Is how I would do a generic long delay.
X and Y are constants that need adjustment to get 1 second for your processor speed and compiler's code.
     
Title: Re: manual delay function and how to take the input frm sensors
Post by: dunk on July 19, 2010, 03:41:04 PM
void delay_1sec (void) {
   int i, j;
 
   for( i=0; i<X; i++) {
     for( j=0; j<Y; j++) {
          ;
     }
   }
}
Is how I would do a generic long delay.
X and Y are constants that need adjustment to get 1 second for your processor speed and compiler's code.
     
as long as your compiler's optimisation is switched off.


dunk.
Title: Re: manual delay function and how to take the input frm sensors
Post by: rajsekhar291 on July 19, 2010, 04:07:21 PM
void delay_1sec (void) {
   int i, j;
 
   for( i=0; i<X; i++) {
     for( j=0; j<Y; j++) {
          ;
     }
   }
}
Is how I would do a generic long delay.
X and Y are constants that need adjustment to get 1 second for your processor speed and compiler's code.
     
as long as your compiler's optimisation is switched off.


dunk.
pls tell me how to take input frm sensors