Driving two stepper motors at the same time


Closed Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2007
    Location
    South-West of Australia. A small town called Denmark. 'Where the forest meets the sea.'
    Posts
    136

    Default Driving two stepper motors at the same time

    I have a flatbed scanner/plotter with a stepper motor on each axis.
    The motors drivers take care of high power and phase switching so that I only have to provide:

    1. Direction CW or CCW.
    2. Step pulse - and after all the electrical and mechanical factors, the maximum frequency I will ever need is about 1000 Hz.

    I'm using a PIC18F8722 running at 40MHz and It's working OK - but only moving one motor at a time.

    How do I write the code to move both motors at the same time? I need to do this to make diagonal moves.

    I presume you work out the ratio of pulses - for example to move X100 and Y300 - you issue one X_Pulse followed by three Y_Pulses?

    Has anyone done this or got some better ideas?

    Regards Bill Legge

  2. #2
    Join Date
    Sep 2007
    Location
    USA, CA
    Posts
    271


    Did you find this post helpful? Yes | No

    Default

    The easiest way is with interrupts and two timers. Set up one timer to control x, and the other for y. You calculate the timer preset values based on the delay between pulses.

    With an 18F you can even do it with low and high priority interrupts... you just use the low priority on the axis that will be going the slowest. If you won't know, then pick any one for low priority, or use one high priority interrupt with a test to see which timer rolled over.

  3. #3
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,615


    Did you find this post helpful? Yes | No

    Default

    Hi,

    If it is for diagonal moves only ...

    same clock signal for both motor drivers and just invert or not rotation ...

    if direct drive ...

    just can be solved by twisting 1 st motor signals ...

    only logics with bits ...

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

Similar Threads

  1. 18f4431; driving a stepper IN HARDWARE mode
    By DDDvvv in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 21st January 2010, 16:49
  2. Replies: 1
    Last Post: - 1st May 2008, 05:07
  3. Driving Stepper Motor with PBL3717
    By crhomberg in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 8th November 2007, 20:59
  4. Driving a stepper motor bipolar
    By debutpic in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 18th June 2007, 17:34
  5. Serout2/serin2 Pbp Problem
    By SOMRU in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 11th December 2006, 19:55

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts