Hi i am newbie and i am just learning how to write programs in c for PIC 16f877a
I have written a code for rotating a stepper motor forward and backward.
Its basically i want to move the panel from morning 6 to evening 6 that is i want the motor to rotate 180 degrees in the entire 12 hour period and then quickly return to back its original position that is rotate revese by 180 degrees quickly and wait till 6 next morning to start rotating again.
The problem i have noticed is that in PROTEUS simulation i have set the stepper motor to move at an angle of 90* but in the first cycle it moves 45* and then by 90* each so when it comes back to its original position it does boack by -45* I dunno why this is.
Also what is the minimum delay i can implement on a stepper motor??
And i want to implement a delay of about 12 hours what code should i use or can i use a code to turn it off for 12 hours??
Could you'll please help me.
Sorry for asking so many questions but i would really help me to understand better.
Thank You
Hi there, Thanks for helping me..
I am now planning to expand my project cause i really have gotten into the mood of doing it.
I am planning to interface another motor to the pic but using the portD.
I want to know if it is possible to run both programs simultaneously cause i want to set different delay periods for the for both the motors but i need them to run simultaneously.
E.g I want a loop that turns the first motor to turn evey 2 minutes and simulataneously anothe loop to turn the 2nd motor after every 2 hours in the same process as the above program that is both forward and reverse directions.
Any suggestions or help..
Thanks once again..
what is step angle of steeper motor which is you used i think it may be of 0.9 degree so your getting exactly half rotation. try by using giving double pulses to stepper.
Thanks for your reply.
Sorry for the delay. Was having exams.
I decided to rotate the motor after i rotate the first motor backward as i have time.
I am finding interrupt hard to understand.
I expanded the code.
Just see what is the problem.
I am using isis stimulation and have written the program where after a count of 2 it rotates the motor by 1 step.
but after it rotates by one step the loop should start again at the firtst motor by counting from 0 till 2 but it doesn't stop at 2 and goes into a continous loop.
Please help me
I have put a video file along with it
Thanks again..
I fond the problem.. i had to remove that count=0 cause it was setting it to 0 when the if condition was not satisfied but still cant get it to work...
Thanks for your help..
I am trying to interface an lcd with the pic now..
I have stumbled on a problem..
The problem i find here is that if i write it as int am1 i get output as 1.0 (I want the output to show 1.8)
if i write it as double am1 i get an error saying operator not applicable to this operands
If i write it as long am1 it does not rotate properly i.e it turns 90 degrees and then 180* in the opposite direction (Considering Step Angle is 90*)
And can you tell me what does Lcd_Chr(1,10,48+am1); the 48+ part mean??
By the way i have shifted the code to mikroC as the lcd code was easily avaliable.
Thanks again for your time.
Is there any way where i can display it??
- - - Updated - - -
I got another problem also..
I have put 2 while loops if certain conditions are not satisfied..
Now after the while loops it should go to the infinite loop but after the first 2 for loops in the infinite loop it seems to start from the begining i.e. the while loop
Just see what is the problem..