View previous topic :: View next topic |
Author |
Message |
atmega64
Joined: 23 Feb 2005 Posts: 298 Location: ITALY
|
Posted: Thu Jun 23, 2011 11:04 am Post subject: Stepping motor and SPI interface |
|
|
Hi,
I have drivers for stepper motor with integrated l9935.
I connected my microprocessor through the SPI interface to the driver of the motor, and I sent the sequence as following the directions on page 14 of datasheet http://pdf1.alldatasheet.com/datasheet-pdf/view/22673/STMICROELECTRONICS/L9935.html, but nothing, the motor will not run!
The SDO and SDI pins L9935 are respectively connected to DOUT and DIN is OK?
I used the following code where the error? wrong sequence?
Please help me thanks.
Code: |
'TEST
$regfile = "m32def.dat"
$crystal = 4000000
$hwstack = 40
$swstack = 16
$framesize = 32
Config Spi = Soft , Din = Pinb.0 , Dout = Portb.1 , Ss = None , Clock = Portb.2
Dim A(18) As Byte
Waitms 50
Spiinit
A(1) = &B11111111
A(2) = &B11011011
A(3) = &B11010011
A(4) = &B11010010
A(5) = &B11011010
A(6) = &B11011011
A(7) = &B11010011
A(8) = &B11010010
Spiout A(1) , 8
End
|
|
|
Back to top |
|
|
Evert :-)
Joined: 18 Feb 2005 Posts: 2156
|
|
Back to top |
|
|
atmega64
Joined: 23 Feb 2005 Posts: 298 Location: ITALY
|
Posted: Thu Jun 23, 2011 2:58 pm Post subject: |
|
|
CSM pin is grounded, but I tried also to connect to the micro, but nothing.
The code is complete?
It seems that the micro and l9935 are not communicating ... |
|
Back to top |
|
|
atmega64
Joined: 23 Feb 2005 Posts: 298 Location: ITALY
|
Posted: Thu Jun 23, 2011 3:07 pm Post subject: |
|
|
This is the circuit diagram that I followed:
|
|
Back to top |
|
|
mattcro
Joined: 03 Oct 2007 Posts: 327 Location: Scotland
|
Posted: Thu Jun 23, 2011 9:03 pm Post subject: |
|
|
Read the Bascom help for CONFIG SPI and SPIOUT. You must define and control a CS pin yourself if you use SS=NONE in CONFIG SPI.
The CS pin on the driver MUST be driven from a pin on the AVR - easiest to use the SS pin and specify this pin in CONFIG SPI.
It also looks like you SDI and SDO are the wrong way around. SDO is an output on the L9935 driver, so that should connect to DIN on the AVR, and vice versa.
You must also add some delay between sending each byte to the driver so that the step rate is suitable for the motor. Try something like WAITMS 50 between sending each byte in the step sequence. _________________ If all else fails, read the manual. Even better: read the manual before something fails. If you can't find it in the manual, search the forum.
BascomAVR 2.0.8.5 |
|
Back to top |
|
|
|