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


Reply With Quote

Bookmarks