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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
03/09/04 19:59
Read: times


 
#66354 - RE: stepper motor control
Responding to: ???'s previous message
Build the step motor control into a piece of state machine code that gets called periodically on a regular basis. Once each call can create one step of the phase sequence for the stepper motor. This will use a global variable or two to keep track of the current state of the sequencer machine. Next totally discard the idea of making the time betewwn steps be generated by for(;;) timing loops. That approach is poor and would leave you no time in the mainline code to support formatting the current step count and direction information for transmission out the UART port. Instead read up on and implement a timer that is setup to auto re-load on a periodic basis. The time interval of the re-load should correspond to the stepping rate interval of the stepper motor. Have this timer generate an interrupt at each re-load event. Supply a timer interrupt service routine that then directly calls that subroutine I told you to make as a state machine. This will take care of running the motor. Change the reload value of the timer on the fly to ramp the speed up and down!! You may even add in a small bit of code that uses a flag variable that the main line code turns on and off to enable and disable stepping. When disabled the ISR calling of the state machine subroutine can be skipped thus leaving the motor position unchanged.

You can look at this link to gather some ideas on how a timer interrupt is implemented and how a state machine subroutine could be coded. (Note that the code sample at the link is slightly different from what I am recommending above in that the timer ISR does not call the state machine directly). You will want the ISR to call directly so that you minimize the timing variation from step call to step call.

Link to State Machine & Timer Article


Michael Karas




List of 41 messages in thread
TopicAuthorDate
stepper motor control            01/01/70 00:00      
   RE: stepper motor control            01/01/70 00:00      
   RE: stepper motor control            01/01/70 00:00      
      RE: stepper motor control            01/01/70 00:00      
         RE: stepper motor control            01/01/70 00:00      
            erik: stepper motor control            01/01/70 00:00      
         RE: stepper motor control            01/01/70 00:00      
            RE: stepper motor control            01/01/70 00:00      
               RE: stepper motor control            01/01/70 00:00      
                  RE: stepper motor control            01/01/70 00:00      
                     RE: stepper motor control            01/01/70 00:00      
                     RE: stepper motor control            01/01/70 00:00      
                        RE: stepper motor control            01/01/70 00:00      
                           RE: stepper motor control            01/01/70 00:00      
                              RE: stepper motor control            01/01/70 00:00      
                                 RE: stepper motor control            01/01/70 00:00      
                                    RE: stepper motor control            01/01/70 00:00      
                                       RE: stepper motor control            01/01/70 00:00      
                                       RE: stepper motor control            01/01/70 00:00      
                                       RE: stepper motor control            01/01/70 00:00      
                                          RE: stepper motor control            01/01/70 00:00      
                                 RE: stepper motor control            01/01/70 00:00      
                                    RE: stepper motor control            01/01/70 00:00      
                                       RE: stepper motor control            01/01/70 00:00      
                                          RE: stepper motor control            01/01/70 00:00      
                                       RE: stepper motor control            01/01/70 00:00      
                                          RE: stepper motor control            01/01/70 00:00      
                                          RE: stepper motor control            01/01/70 00:00      
                                             RE: stepper motor control            01/01/70 00:00      
                                                RE: stepper motor control            01/01/70 00:00      
                                                   RE: stepper motor control            01/01/70 00:00      
                                                      RE: stepper motor control            01/01/70 00:00      
                                                         RE: stepper motor control            01/01/70 00:00      
                                                            RE: stepper motor control            01/01/70 00:00      
                  A Doubt            01/01/70 00:00      
                     RE: A Doubt            01/01/70 00:00      
               RE: stepper motor control            01/01/70 00:00      
   RE: stepper motor control            01/01/70 00:00      
      Crystal accuracy- Patrick            01/01/70 00:00      
         RE: Crystal accuracy- Patrick            01/01/70 00:00      
            RE: Crystal accuracy- Patrick            01/01/70 00:00      

Back to Subject List