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.

How to make 45 seconds delay in PIC ????

Status
Not open for further replies.

erfan.khalilian69

Member level 4
Joined
Feb 7, 2011
Messages
71
Helped
3
Reputation
6
Reaction score
3
Trophy points
1,288
Location
Kualalampur
Activity points
1,916
Hello everyone I have downloaded program which they defined the delay as below for their program.
//===================================================
void delay(unsigned short i);// at above the program


//==================subroutine DELAY==========================
void delay(unsigned short i)
{
for(;i>0;i--);
}
//===========================================

now I want to make 45 seconds delay and I have write it as below but error will appear as "108.28 implicit conversion of float to integer"and also "undefined identifier "i" "

I think I can't use the i as variable again as it has used in this program once but while i change the name of variable again the error will comes ?
any suggestion ? thanks




if (BUTTON1 != 0)

RC3 = 1;
delay(1.5); // delay for 1.5 milliseconds /// now servo rotate 90 degree
//pause for 45 seconds

for(i=0;i<45*5; i++) // for 45 seconds


RC3 = 0; // back to the previous position
delay(18.5)



plz help
 

Your program doesn't clear for me but your first problem (what causes compiling error) is this:
- you declared and defined the function "delay" with an unsigned short as parameter (i)
- then you invoked the function with a float parameter (twice, first with 1.5 then with 18.5)
Use integer values instead.

And ... there are some other errors, for example:
- the declared function parameter "i" is invisible outside of function
so declare it again if you want to use it
 
Last edited:
Use interrupts and timers instead of the loops. Interrupts will give you more accurate timing.
What is the type of your controller?
 

if you use mikroC compiler
you can use the function of Delay_ms() from the library directly
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top