Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Stepping motor and SPI interface

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Archive
View previous topic :: View next topic  
Author Message
atmega64

Bascom Member



Joined: 23 Feb 2005
Posts: 269
Location: ITALY

italy.gif
PostPosted: Thu Jun 23, 2011 11:04 am    Post subject: Stepping motor and SPI interface Reply with quote

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
View user's profile Visit poster's website
Evert :-)

Bascom Expert



Joined: 18 Feb 2005
Posts: 2114

netherlands.gif
PostPosted: Thu Jun 23, 2011 12:45 pm    Post subject: Reply with quote

And where did you connected CSN to? It should be controlled by SS.
_________________
www.evertdekker.com Bascom code vault
Back to top
View user's profile Visit poster's website
atmega64

Bascom Member



Joined: 23 Feb 2005
Posts: 269
Location: ITALY

italy.gif
PostPosted: Thu Jun 23, 2011 2:58 pm    Post subject: Reply with quote

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
View user's profile Visit poster's website
atmega64

Bascom Member



Joined: 23 Feb 2005
Posts: 269
Location: ITALY

italy.gif
PostPosted: Thu Jun 23, 2011 3:07 pm    Post subject: Reply with quote

This is the circuit diagram that I followed:

Back to top
View user's profile Visit poster's website
mattcro

Bascom Member



Joined: 03 Oct 2007
Posts: 324
Location: Scotland

uk.gif
PostPosted: Thu Jun 23, 2011 9:03 pm    Post subject: Reply with quote

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.2
Back to top
View user's profile
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Archive All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum