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


Reply With Quote

Bookmarks