Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
11/15/04 09:44
Read: times


 
#81156 - RE: Servo control
Responding to: ???'s previous message

or is there a better way


Yes. There is. And normally called Interrupts. Read more about it in the Tutorials.

The other three posts till now give you some more tips for following.

And when you think about creating a delay like the way you coded, think a little bit more:

- You have to do something once every 1 ms.
- So it goes like this :
1msDelayloop - SomeJob_1 - 1msDelayLoop - SomeJob_2 - 1msDelayLoop - SomeJob_3 .......

The pitfalls are :

A. When the 1msDelayLoop is running, the MCU cannot react to any external event till it times out. It kind of is frozen in the loop.

B. Your 1msDelayLoop is no longer guranteed to be 1 millisecond. It DEPENDS on the SomeJob_1, SomeJob_2 etc. SomeJob_2 will be executed after (1msDelayLoop + SomeJob_1 ) and so on.

C. It is possible that SomeJob_1 is only about 10 microsecond long and thus may not mean much when compared to 1ms which is 1000 microsecond. BUT if the delay is handled by Interrupt dispatch, then you have almost ALL of the 1000 microseconds to do SomeJob_1 and still be ready for SomeJob_2 EXACTLY 1ms later!

Maybe elementary stuff, but just thought will talk about it, since you said you are fresh to MCUs.

Good Luck

Raghu


List of 5 messages in thread
TopicAuthorDate
Servo control            01/01/70 00:00      
   RE: Servo control            01/01/70 00:00      
   RE: Servo control            01/01/70 00:00      
   RE: Servo control            01/01/70 00:00      
   RE: Servo control            01/01/70 00:00      

Back to Subject List