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

DAN101

Interfacing the Dios to the SN754410

for DC Motor Control

  By Michael Simpson

I was in the process of building a robot and was wiring up the relays when I decided to do something different.  I did a bit of research and found that there were all kinds of solid state options available to me.  One of the most popular options was to use a L293.  I searched and searched and could not find any of these.  Finally I found a L293DNE from Texas Instruments at one of my dealers.  I ordered one.  While it was on the way I pulled down the data sheet from the web to get a head start.  I soon found that not all L293 chips are created equal.  Here are just a few of my findings.

  • L293D from SGS-THOMSON is rated at 600ma and includes internal clamp diodes to prevent induction transients..

  • L293B from SGS-THOMSON is rated at 1A but does not include the clamp diodes.  You will have to include them yourself to prevent the transients.

  • L293 from Texas Instruments is rated at 1A but does not include the diodes.

  • L293D from Texas Instruments is rated at 600ma and includes the diodes

  • SN754410 from Texas Instruments is rated at 1A and does have the clamping diodes.

When my L293 from TI arrived I started to experiment but promptly ordered a few of the SN754410 chips.  I liked the SN754410 so well I decided to carry them on my site.

Lets take a look at the SN754410 features first.

  • 4 Drivers or 2 bipolar channels

  • 1A per channel

  • Supports 4.5-36v

  • Build in clamping diodes

  • Logic and input supplies may be separate if you wish.

  • Thermal shutdown

  • Input hysteretic improves noise immunity

  • Sink/Source interlocks prevents simultaneous conduction

  • No output glitch during power up or power down

You can set up the SN754410 like a relay and just set the ports of your microcontroller and move on to other things while the SN754410 does its job.  You can also use PWM on the Enable pin of each motor to vary the speed.

Schematic 1 (click picture to enlarge)

Note that the Scematic shows a Dios 32 Pin Module.  This is basically a Dios 28 Pin chip and a Carrier #1.

 

In the configuration shown in Schematic 1 you can use the same power supply to power the motors and Dios.   The catch is the the battery source must not exceed 5.5 volts or so.    With many other microprocessors they may have problems with this configuration because of the drop out voltage.   Since the Dios will run with a voltage all the way down to 2.2 volts the voltage drop when the motors are engaged are not a problem. 

Just tie the Vcc2 lead to Vcc and connect a second Vss lead from the driver chip to the negative side of the battery.  The 39 ohm resistor will keep any ground loops from getting out of hand.  For single power sources this configuration works quit well.

Now a word about the connections between the motor controller and the Dios.  I recommend placing a 10K resistor between the Dios and each motor controller connection.  These keep any connection or motor problems from blowing your Dios  Since I have been doing this on my motor controllers I have yet to blow a microcontroller.

Please check out my motor controller interfacing application note.

Each motor must have noise suppression capacitors.  If you fail to do this again you could blow the controller or Athena.  Check out my motor noise application note.

 

The concept behind the motor drivers is quite simple.  There are 4 drivers built into the chip.  Each driver can be set to source or sink based on its input pin.  You could drive 4 motors with just on or off and no direction control, but by connecting the two leads of the motor to the two output leads we can control which lead gets sourced or sunk.

For instance, by setting the M1 input A High the M1 output A goes to +Motor Power.  If the M1 input B is Low then the M1 output B is at ground.  This will cause the motor to spin in one direction.

Setting the M1 input A Low causes the M1 output A to ground.  And with the M1 input B High the M1 output B goes to +Motor Power.  This will cause the motor to spin in the opposite direction.

If both the input pins are set the same then both the output pins will be set to ground or +Motor Power.  This in effect causes the motor to short causing dynamic breaking.

All this only works if the Motor Enable pin is high.  If it is low both output pins go into a tri-state condition.  We are going to take the enable pins and tie them to an signal generator.  The amount of time the signal is high will determine how much actual on time each motor gets.  If we do it fast enough – for example at 2400 times a second - there will be no herky-jerky motion and everything will run smoothly.

We now know it takes three leads to gain total control of each motor.  Lets look at the truth table to recap what kind of control we have on each motor.

Enable A B  
0 - - Coast
1 0 0 Dynamic Breaking
1 1 1 Dynamic Breaking
1 1 0 Motor Forward
1 0 1 Motor Reverse

Any time the A and B inputs are set the same dynamic breaking is enabled on the motor.

Lets do some simple things first.  

Lets take a bot base like the one shown above.  The Kronos Crawler has two motors that drive each track.  Each of these motors are connected to the controllers M1 and M2 connections.   If you find that the direction on one or both of your tracks/wheels don't move in the proper direction just reverse the motor leads. 

Program 1 download it here

func main()

initMC() 'Set up constants and init ports

again:
   MC_m1fwd()
   MC_m2rev()
   pause 3000
   MC_m1rev()
   MC_m2fwd()
   pause 3000
goto again
endfunc

'-------------------------------------------------------
'You must call this function before calling
' The others. You can also change the pinout.
func initMC()
'Set up some contestants
   gconst Enable1 13
   gconst Enable2 4
   gconst M1InputA 0
   gconst M1InputB 1
   gconst M2InputA 2
   gconst M2InputB 3

'Set port direction
   output Enable1,M1InputA,M1InputB
   output Enable2,M2InputA,M2InputB
endfunc
 

'--------------------------------------------------------
'Motor1 forward
func MC_m1fwd()
   high M1InputA
   low M1InputB
   high Enable1
endfunc
 

'--------------------------------------------------------
'Motor1 Reverse
func MC_m1rev()
   low M1InputA
   high M1InputB
   high Enable1
endfunc
 

'--------------------------------------------------------
'Motor2 forward
func MC_m2fwd()
   high M2InputA
   low M2InputB
   high Enable2
endfunc
 

'--------------------------------------------------------
'Motor2 Reverse
func MC_m2rev()
   low M2InputA
   high M2InputB
   high Enable2
endfunc
 

'--------------------------------------------------------
'Motor2 stop
func MC_m1stop()
   low Enable1
endfunc
 

'--------------------------------------------------------
'Motor2 Stop
func MC_m2stop()
   low Enable2
endfunc


 

As you can see the SN754410 works pretty much like a relay in this mode.  By changing the state of the three leads on each motor we can control the overall behavior of the Bot.

 

Now lets get a bit more fancy.  Lets control the speed of motors.  We are going to use the PWM generators to control the speed.  Each PWM channel is connected the enable leads of the motor controller.

 

Program 2 download it here

func main()

  initMC()

again:
   MC_setspeed(255) 'Full speed
   MC_m1fwd()
   MC_m2rev()
   pause 3000
   MC_m1rev()
   MC_m2fwd()
   pause 3000

   MC_setspeed(245) 'Slow it down a bit
   MC_m1fwd()
   MC_m2rev()
   pause 3000
   MC_m1rev()
   MC_m2fwd()
   pause 3000

goto again
endfunc

 

'------------------------------------------------------------------
'You must call this function before calling
' The others. You can also change the pinout.
func initMC()
   'Set up some contstants
   gconst Enable1 13 'Must be this port with PWM
   gconst Enable2 4 'Must be this port wih PWM
   gconst M1InputA 0
   gconst M1InputB 1
   gconst M2InputA 2
   gconst M2InputB 3

'Set port direction
   output Enable1,M1InputA,M1InputB
   output Enable2,M2InputA,M2InputB
   MC_m1stop()
   MC_m2stop()
 

   'Init the hardware PWM
   initPWM(2)
   PWMcourse(0)
   PWMperiod(255)
   MC_setspeed(255)
endfunc
 

'------------------------------------------------------------------
'Motor1 forward
func MC_m1fwd()
    high M1InputA
    low M1InputB
endfunc
 

'------------------------------------------------------------------
'Motor1 Reverse
func MC_m1rev()
    low M1InputA
    high M1InputB
endfunc
 

'-----------------------------------------------------------------
'Motor2 forward
func MC_m2fwd()
    high M2InputA
    low M2InputB
endfunc
 

'-----------------------------------------------------------------
'Motor2 Reverse
func MC_m2rev()
    low M2InputA
    high M2InputB
endfunc
 

'-----------------------------------------------------------------
'Motor1 stop
func MC_m1stop()
    low M1InputA
    low M1InputB
endfunc
 

'-----------------------------------------------------------------
'Motor2 Stop
func MC_m2stop()
    low M2InputA
    low M2InputB
endfunc
 

'-----------------------------------------------------------------
func MC_setspeed(value)
    value.bit(8)=1
    value.bit(9)=1
    PWM1duty(value) 'Motor 1 speed
    PWM2duty(value) 'Motor 2 speed
endfunc
 


include \lib\DiosHWPWM.lib

 

The function MC_setspeed is used to set the duty cycle of signal of each PWM signal.   A value of 255 will give you a 99.9% duty cycle which will be the fastest.   A value of 245 will slow it down just a bit.   A value you 200 will most likely stall the bot.

Now let me talk a bit about the SN754410 a bit more.  I said earlier that the chip can handle 1Amp per channel.   In order to get the full 1Amp you will need to add a dip heat sink.  

Now say you want to handle a bigger motor. 

  How bout this you can stack the SN754410 chips.  Just solder one on top of the other or connect them all to a circuit board and run all the leads in parallel.

One final note.  The SN754410 can also be used to control stepper motors and solenoids.  I will be creating more papers on these topics in the future.

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

9 Pin Cable

 

 

 

Copyright © 2001 - 2007 Kronos Robotics