Kronos Robotics and Electronics
Site Map
 
Home Zeus Projects App Notes Downloads Dios Athena Forums
 

DAN106

Interfacing the Dios to the SN754410

for bi-polar motor control

  By Michael Simpson

 

I recently put together a small CNC mill for building plastic enclosures and decided to experiment with interfacing the stepper motors to a couple of different micro controllers.  For my experiments I decided to use a bipolar cause of the raw power that they have.  The controller requirements are a bit more complex but after bit of testing it looked like the SN754410 Motor controller that I was familiar with could easily handle the bi-polar requirements.

I had just recently done a paper on interfacing the SN754410 to DC motors and really liked this device.  It can run 1 amp continually (per coil)  and 2 amps peak.  However the chips can be stacked for more current.  They also have thermal shutdown and built in clamping diodes so unless you hook them up incorrectly they are kind of hard to blow.

The stepper motors that I will be using need 2A at 7.5 volts.  See Figure 1.  I am currently using 2 controllers soldered together with a heat sink as shown in figure 2.

Figure 2

 

The Stepper motor I am using has 4 wires which make it very easy to Identify the coils.  Just use a voltmeter to determine which leads are connected to which coils.  Use schematic 1 to wire the motor controller to your microcontroller.  I used a simple bread board for my connections

 

Figure 3

The hookup is really strait forward.  The Motor power should be a separate power source than the one you are using to power the microcontroller.   It should have enough voltage and power to supply the Stepper motors.  Don't over drive them. 

The minimum voltage the motor controller can use is 4.5 volts.  Anything less and it starts to act funny.   

If the motor controllers start shutting down a small muffin fan can me used to help dissipate some of the heat.  With this method I was able to run a single SN754410 controller continually for hours with just 1 motor controller and no heat sink.

Schematic 1

The following is the truth table for getting the stepper motor to step.  The two separate channels of the motor controller will energize the coils in both forward or reverse directions to move the motor.

Enable M1A M1B M2A M2B  
0 - - - - All off no lock
1 1 0 1 0 Step 1
1 0 0 1 0 Step 2
1 0 1 0 1 Step 3
1 1 0 0 1 Step 4
P4 P0 P1 P3 P4 Dios Connections
1,9 2 7 15 10 SN754410 Connections

One of the problems with stepper motors is knowing where you are when you stop stepping.  You cant always start stepping at step 1 above or the motor will get out of sink.  For instance if you move t 2 phase motor ahead 3 steps you must start on the third step to keep it synchronized.

We will keep track of the position with the software with the phz variable.  The following program sets up a couple subroutines that will allow you to step your motor forward or backwards a number of steps at a particular speed.

Proagram (download it here)

'Demonstrates the use of a stepper motor and SN754410 motor controller
func main()

initstepper(100,10)

'The main routine
mainloop:

'The following commands will move the motor in various directions.
'with a 200 step motor it will always pause in the same location.
stepper(1,50)
stepper(0,100)
stepper(1,200)
stepper(0,150)

goto mainloop
endfunc



'--------------------------------------------------------
'Sets up variables for stepper function
'
'--------------------------------------------------------
func initstepper(tdirdelay,tspeed)

'Demonstrates the use of a stepper motor and SN754410 motor controller
gconst M1A 0
gconst M1B 1
gconst M2A 2
gconst M2B 3
gconst ME 4
output M1A
output M1B
output M2A
output M2B
output ME

'This turns on the motor controller
high ME

'This is a dealy used when the motor reverses. It keeps the motor from loosing steps
'at high speed when reversing direction because of inertia. Set it to 1 id you are
'using the motor to drive a bot
global dirdelay as integer
dirdelay = tdirdelay

'Phase is used by the program to keep track of where it is
global phz as integer
phz=0

'Step speed. The higher the number the slower the movement.
global speed as integer
speed = tspeed

endfunc

'------------------------------------------------------
'move stepper motor a number of steps
'dir: 0=bwd 1=fwd
'ct: number of steps
'-----------------------------------------------------
func stepper(dir,ct)

if dir = 1 then
while ct <> 0
'Step the motor forward
gosub phasefwd
wend
pause dirdelay
exit 0
else
while ct <> 0
'Step the motor backward
gosub phasebkwd
wend
pause dirdelay
exit 0
endif


'The phase commands cycle through phase steps forward or backwards
phasefwd:
phz = phz + 1
if phz <= 4 then goto phasefwdcont
phz=1
phasefwdcont:
gosub dobranch
ct = ct -1
return

phasebkwd:
phz = phz - 1
if phz > 1000 then goto itsless
if phz >=1 and phz < 255 then goto phasebkwdcont
itsless:
phz = 4
phasebkwdcont:
gosub dobranch
ct = ct -1
return


'The following routines do the actual stepping
dobranch:
pause speed
branch phz,dostep0,dostep1,dostep2,dostep3,dostep4
return


dostep0:
return


dostep1:
high M1A '-v
low M1B

low M2A '+v
high M2B
return

dostep2:
low M1A '+v
high M1B

low M2A '+v
high M2B
return

dostep3:
low M1A '+v
high M1B

high M2A '-v
low M2B
return

dostep4:
high M1A '-v
low M1B

high M2A '-v
low M2B
return


endfunc
 

A final note.  If the motor does not move in the correct direction you can just reverse one of the coils and the motor will reverse.

Parts

 

Easy RS232 Driver  

DiosPro 28 Pin Chip

Dios 32 Pin Carrier (Carrier #1)

SN754410 Motor Controller

16 Pin Dip Heat Sink

Easy Motor PCB

6 Cell Battery Holder

9v Battery Clip

7805

 

 

 

 

Copyright © 2001 - 2007 Kronos Robotics