Help with Pololu DRV8711 Stepper Motor Driver


+ Reply to Thread
Results 1 to 9 of 9
  1. #1
    Join Date
    Sep 2006
    Location
    Florida, USA
    Posts
    94

    Default Help with Pololu DRV8711 Stepper Motor Driver

    Hello - I am trying to write a simple program to run a stepper motor back and forth using the Pololu DRV8711 driver (Link: https://www.pololu.com/product/3730). In order to use the driver, you must first enable it and then you can use the DIR and Step Pins to run your stepper. With other drivers, all you needed to do was drive the ENABLE pin high and you were good to go. With the 8711 board, you have to enable it via SPI. This is done by sending 16-bit values to the registers on the board. Page 27 of the data sheet for this (Link: https://www.ti.com/lit/ds/symlink/drv8711.pdf) shows the registers and gives the default values. Technically, all I should have to do is to set bit 0 of the CTRL register to 1 and that should enable the motor, correct? I also want to limit the current to 1/2 of it's maximum value of 4A. This is done using the lower 8 bits of the TORQUE register. Here is my routine to do that:

    Code:
    '****************************************************************
    InitStepper1:
        'Set current to 1/2 max (2A) 
        '$1180 = %0001000110000000
        high M1SCS
        Shiftout m1SDAT, M1SCLK, 1, [$1180/16]
        low M1SCS
        
        pause 50
        'Enable Motor
        '$0C11 = %0000110000010001
        high M1SCS
        Shiftout m1SDAT, M1SCLK, 1, [$0C11/16]
        low M1SCS    
        
        return
        
    '****************************************************************
    I am leaving all of the other values at their default. After executing the InitStepper1 code, I go to stepping the motor by pulsing the STEP pin and nothing happens. My stepper spins freely and I get no indication from my power supply that there is any additional current draw. Is there something I am not doing or doing wrong? Thanks! Jeff

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,610


    Did you find this post helpful? Yes | No

    Default Re: Help with Pololu DRV8711 Stepper Motor Driver

    Looks like you're shifting out $1180 divided by 16, truncated to 8 bits, so $22. That's not what you want, is it?

    Be careful with / vs \ ;-)

  3. #3
    Join Date
    Sep 2006
    Location
    Florida, USA
    Posts
    94


    Did you find this post helpful? Yes | No

    Default Re: Help with Pololu DRV8711 Stepper Motor Driver

    THANKS! Good catch and yes, I feel stupid. I will give this a try and let you know if that was it! Jeff

  4. #4
    Join Date
    Sep 2006
    Location
    Florida, USA
    Posts
    94


    Did you find this post helpful? Yes | No

    Default Re: Help with Pololu DRV8711 Stepper Motor Driver

    Well, While that was a problem, it was not THE problem. Still no movement. I tried both mode 1 and mode 0 for the SHIFTOUT methods, also, to no avail.
    Here is a snip of the circuit board design for examination. It seems pretty straight forward, so I think my issue is with setting the registers. Any thoughts are appreciated.
    NOTES: There are 2 drivers on board. Green traces = 5V, Blue = Gnd, Red = 12V, Black = Signal. PIC = PIC16F877A. Thanks!
    Name:  Snip1.JPG
Views: 114
Size:  109.4 KB

  5. #5
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,610


    Did you find this post helpful? Yes | No

    Default Re: Help with Pololu DRV8711 Stepper Motor Driver

    Hmm...PortA...have you disabled the analog functions (ADCON1 and CMCON registers, I believe)?
    Have you verified (logic analyzer or scope) that the expected data does appears on the pins?

  6. #6
    Join Date
    Sep 2006
    Location
    Florida, USA
    Posts
    94


    Did you find this post helpful? Yes | No

    Default Re: Help with Pololu DRV8711 Stepper Motor Driver

    Yes, I did set ADCON1 and no, I have not used a scope on this yet. Here is the entire code. I am simply trying to initialize the driver and run a stepper back and forth with 2 LEDs that indicate which direction. I really feel that there is some initialization that I am not doing or not doing correctly. Other than setting the torque and enabling the driver, I am using all the other register defaults... Thanks!

    Code:
    '****************************************************************
        DEFINE OSC 20
    @ DEVICE HS_OSC
      
        TRISA = %00000000
        TRISB = %10111111
        TRISC = %01110000
        TRISD = %00000000
        TRISE = %00000000
    
        ADCON1 = 7          ' Set PortA Pins as I/O pins 
        
    '   M1 = Stepper1
        M1SCS       var PORTB.6
        M1SCLK      var PORTA.0
        M1SDAT      var PORTA.1
        M1DIR       Var PORTA.2
        M1STEP      var PORTA.3
        
        RedInd      var PORTD.0
        GrnInd      var PORTD.1
        
        Icnt        var word
        M1NumSteps  var word
        M1Delay     var word  'delay between steps - 250-12500 uS
    
    '    CTRL Register
    '    EnableON = %0000110000010001   '$0C11
    '    EnableOFF = %0000110000010000  '$0C10
        
    '    Torque Register
    '    Torque50 = %0001000110000000  'Set current at 50% (2A) $1180
    '    Torque100 = %0001000111111111  'Set current at 100% (4A) $11FF
        
    '****************************************************************
        low RedInd
        low GrnInd
        
        low M1SCS ' Set reset pin low
        low M1Sclk ' Set clock pin low
        low M1Step
        
    '****************************************************************
        pause 1000
        
        goto TestStepper1
    
    '****************************************************************
    '****************************************************************
    TestStepper1:
        gosub InitStepper1
        M1numsteps = 4000
        M1Delay = 5000 'uS between steps
    
    DoAgain1:
        high RedInd
        low GrnInd
        
        low M1DIR 'CW
        for icnt = 1 to M1numsteps
            high M1step
            pauseus 10
            low M1Step
            pauseus M1Delay
        next
    
        low RedInd
        low GrnInd
        pause 1000 
        low RedInd
        high GrnInd 
         
        high M1DIR 'CCW
        for icnt = 1 to M1numsteps
            high M1step
            pauseus 10
            low M1Step
            pauseus M1Delay
        next
        
        low RedInd
        low GrnInd
        pause 1000
        goto DoAgain1        
            
    '****************************************************************
    InitStepper1:
        'Set current to 1/2 max (2A)  
        '$1180 = %0001000110000000
        high M1SCS
        Shiftout m1SDAT, M1SCLK, 0, [$1180\16]
        low M1SCS
        
        pause 50
        'Enable Motor
        '$0C11 = %0000110000010001
        high M1SCS
        Shiftout m1SDAT, M1SCLK, 0, [$0C11\16]
        low M1SCS    
        
        return
        
    '****************************************************************
        End

  7. #7


    Did you find this post helpful? Yes | No

    Default Re: Help with Pololu DRV8711 Stepper Motor Driver

    looks like it wants MSB first..... mode 1 on shiftout ???

  8. #8
    Join Date
    Sep 2006
    Location
    Florida, USA
    Posts
    94


    Did you find this post helpful? Yes | No

    Default Re: Help with Pololu DRV8711 Stepper Motor Driver

    Amgen - Thanks for your input. Yes, I have tried both Mode 0 and 1 with no luck. I have also tried reversing the SCS pin (low, shiftout, high as opposed to high, shiftout, low) and nothing there either. I still think there is something in one of the registers that I am not setting correctly...

  9. #9
    Join Date
    Sep 2006
    Location
    Florida, USA
    Posts
    94


    Did you find this post helpful? Yes | No

    Default Re: Help with Pololu DRV8711 Stepper Motor Driver

    OK - Problem solved. I went to Pololu and got help from their tech folks and they helped me figure this out. In a nutshell, it had to do with how I was creating the CTRL and TORQUE registers and sending them out. If you want to see how that all played out, just go to this link: https://forum.pololu.com/t/using-a-d...c-pro/27792/13. Don't see any reason to re-hash it here. In any event, I am now able to set the registers and control my stepper nicely. Here is my updated code that should get you started. The Pololu PNs for these boards is 3730 and 3731. Enjoy!

    Code:
    '****************************************************************
    '*  Name    : Pololu Stepper-DRV8711.BAS                        *
    '*  Author  : Jeff Wheat                                        *
    '*  Date    : 05/21/2025                                        *
    '*  Version : 1.0                                               *
    '*  Notes   : PIC16F876A                                        *
    '*          : Uses Pololu 4&8A Driver Boards                    *
    '****************************************************************
    @ DEVICE HS_OSC
        DEFINE OSC 20
    
        ADCON1 = 7 ' Set PortA Pins as I/O pins    
           
        TRISA = 0
        TRISB = 0
        TRISC = %00001111
                  
        ' Define the LCD Hookup parameters
        ' data pins D4-D7 are hooked to pins B.0-B.3, respectively
        define LCD_DREG     PORTB   'Data Port = PORTB
        define LCD_DBIT     0       'Data starting bit = 0
        define LCD_RSREG    PORTB   'Register Select Port = PORTB
        define LCD_RSBIT    7       'RS bit = PortB.7
        define LCD_EREG     PORTB   'Enable Port = PORTB
        Define LCD_EBIT     4       'Enable Bit = PortB.4
        define LCD_BITS     4       'LCD Bus Size = 4
        define LCD_LINES    2       'Number of lines on LCD
           
        MenuBtn     var     PORTC.0
        UpBtn       var     PORTC.2
        DnBtn       var     PORTC.1
        EnterBtn    var     PORTC.3
    
        DirPin  	var     PORTA.3
        StepPin 	var     PORTA.5
        SDATO       var     PORTA.1  'connect to SDATI pin on driver board
        SDATI       var     PORTA.2  'connect to SDATO pin on driver board
        SCLK        var     PORTA.0
        SCS         var     PORTC.7
        
        Icnt        var     word
        StepDelay	var	    word
        StepMode    var     byte
        NumSteps    var     word
        DataOut     var     word
        DataIn      var     word
        
        Line1       con     $80
        Line2       con     $C0
        
        LSBFirst    con     0
        MSBFirst    con     1
        
     '****************************************************************    
        low steppin
        low DirPin
        low SCS
        
        pause 500 
        LCDOUT $FE, 1 ' Clear LCD screen 
        pause 20
        
        lcdout $FE, line1, " Pololu Stepper "
        lcdout $FE, line2, " Board - DRV8711"
    
        pause 2000
        LCDOUT $FE, 1
    
        gosub InitStepper
        pause 50
        
    '    Gosub ReadRegisters
    '    Stop
        
        Numsteps = 4000
        StepDelay = 500 'uS between steps
        
    '****************************************************************
    Start:
        lcdout $FE, line1, "Dir = CW "
        
        low DIRpin 'CW
        for icnt = 1 to numsteps
            high stepPin
            pauseus 10
            low StepPin
            pauseus StepDelay
        next
    
        pause 1000
        lcdout $FE, line1, "Dir = CCW" 
    
        high DIRpin 'CCW
        for icnt = 1 to numsteps
            high steppin
            pauseus 10
            low Steppin
            pauseus StepDelay
        next
        
        pause 1000
        goto Start        
            
    '****************************************************************
    ReadRegisters:
        'Read CTRL register 000
        DataIn = 0
        DataOut = %1000  
        high SCS    
        Shiftout SDATO, SCLK, MSBFirst, [DataOut\4]      
        Shiftin SDATI, SCLK, MSBFirst, [DataIn\12]      
        low SCS  
        
        lcdout $FE, line1, bin DataIn  'Display result in binary
        
        'read TORQUE register 001
        DataIn = 0
        DataOut = %1001  
        high SCS    
        Shiftout SDATO, SCLK, MSBFirst, [DataOut\4]      
        Shiftin SDATI, SCLK, MSBFirst, [DataIn\12]      
        low SCS 
        
        lcdout $FE, line2, bin DataIn
              
        Return    
            
    '****************************************************************
    '****************************************************************
    InitStepper:    
        'TORQUE Register - Set current to 1/2 max (2A for 36v4 and 4A for 36v8)
        '         BIT0              BIT15
        'DataOut = %0 001 0 000 11011111  
        DataOut = %0001000011011111      
        high SCS
        Shiftout SDATO, SCLK, MSBFirst, [DataOut\16]   
        low SCS
        
        'CTRL Register - Enable Motor
        'DataOut = %0 000 11 11 0 0010 0 0 1
        'DataOut = %0000111100000001  'full step
        DataOut = %0000111100001001   '1/2 step
        'DataOut = %0000111100010001  '1/4 step
        high SCS
        Shiftout SDATO, SCLK, MSBFirst, [DataOut\16]       
        low SCS 
              
        return
        
    '****************************************************************
        end

Similar Threads

  1. Stepper motor question:
    By MOUNTAIN747 in forum General
    Replies: 6
    Last Post: - 20th June 2021, 23:56
  2. Motor Stepper Example
    By Melanie in forum Code Examples
    Replies: 134
    Last Post: - 3rd January 2015, 17:58
  3. Possible? to use 'SOUND' to drive a Stepper Motor Driver Board
    By rayzrocket in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 30th October 2013, 15:28
  4. Pololu Dual Serial Motor Controller
    By larzazral in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 7th August 2011, 05:11
  5. Stepper Motor troubles
    By Fryin in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 21st March 2007, 01:56

Members who have read this thread : 13

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