Looking for Picaxe/L293D half step truth table

JayAuckland

New Member
Trying to half-step a bipolar stepper motor (which I'm driving just fine using full-stepping) I've searched and searched the net and the forum and can't find a truth table to apply to four outputs of a Picaxe feeding the four inputs of a L293D which in turn feeds the motor. I've found one or two truth tables but they seem to apply to the motor connections rather than the L293D inputs and produce shabby jerky results. My humidity-addled brain is also fried from trying to think it through and make up my own table. Can anyone hold my hand for a moment?😟😟😟😟😟😟
 

PieM

Senior Member
Hi,
Sorry but in french !

Rich (BB code):
'===================================================
'Commande moteur PAP bipolaire 
'18M2 sur CHI035 Driver L293D
' connections moteur : sur A et B du L293D 
'===================================================
#picaxe 18M2
setfreq M32
'===================================================

symbol MOT = outpinsB   'MOT correspond au portB du 18M2
symbol period = W1      'temps entre pas en 1/100 de ms
symbol nbpas = W2       'Nombre de pas    
dirsB= %11110000        'affectation B.4 à B.7 en sortie vers le L293

'mémorisation de la sequence de commande pour le moteur en demi pas
eeprom 0,(%1010,%1000,%1001, %0001,%0101,%0100,%0110,%0010)

'prg principal ==============================
princ: 

do
      'mise hors tension du moteur .
      Mot = Mot & $0f | %00000000 
      pause 3000
      
      'actionne x demi-pas dans un sens avec une vitesse donnée
      period = 50 : nbpas = 200
      for w10 = 1 to nbpas
      inc b0
      gosub PAS
      next
      
      'actionne x demi-pas dans l'autre sens avec une autre vitesse
      period = 20 : nbpas = 200
      for w10 = 1 to nbpas 
      dec b0
      gosub PAS
      next
      
      pause 500
      
      'actionne x pas dans un sens avec une vitesse donnée
      period = 50  :nbpas = 200: b0 = 0 'va lire une séquence (paire) sur deux (mode 2 enroulements alimentés)
      for w10 = 1 to nbpas  
      b0 = b0+2
      gosub PAS
      next
      
      'actionne x pas dans l'autre sens avec une autre vitesse
      period = 28 :nbpas = 200: b0 = 1'va lire une séquence (impaire) sur deux (mode 1 enroulement alimenté)
      for w10 = 1 to nbpas  
      b0 = b0-2
      gosub PAS
      next
      
loop


PAS: ' Commande en demi pas ******************

      b0 = b0 & %00000111 'la valeur de b0 est limitée à 3 bits, soit 0 à 7 
      read b0, b1       ' va lire la séquence 0 à 7 dans l'eeprom.
      b1 = b1*16        'decale de de 4 bit pour être au niveau de b.4 à b.7
      Mot = Mot & $0f | b1    'envoi de cette séquence au moteur en masquant  les b.0 à b.3 
      pause period            'pause en ms
return
 

AllyCat

Senior Member
Hi,

Strictly, half-stepping needs the drive current to be reduced for the half-steps (when both coils are driven at the same time) which isn't (easily) possible with a L293D. Here is a quote from the first reference I found :

"The half-step driving method is relatively more complicated than the full-step driving method. At the same time, both phases may need to be energized, and the energizing current should be √2/2 of the single-phase energizing current. Of course, it is also possible to directly pass a current equal to the single-phase current. As a result, the torque during the rotation of the motor is not constant, but it has the advantage of simplifying the driving circuit or software writing. "

However, if the inductance of the coils is sufficiently high (and/or the drive pulses sufficiently short), then you may be able to control the current by using different pulse widths.

Personally, I like to consider the drive sequences of ALL stepper modes in terms of 8 phases or "timeslots" (or an even greater number for microstepping). The eight timeslots might all have the same period, or the odd-numbered and even-numbered slots might be arranged to have different periods. This allows the current drain (and hence torque) of the motor to be controlled to suit the application (and the motor itself). In an "extreme" case, either the odd or even slots can be set to zero, to give a "normal" 4-phase sequence.

Another complication is that there are two ways to switch "OFF" each coil, or 3 if you include "tri-stating" the pin(s), i.e. disconnecting or floating a drive pin to the coil (not possible with the L293D). Either both ends of the coil can be driven HIGH, or Both LOW (therefore no current can flow) so there is more than one "pattern" of drive sequences that can produce the desired effect. Thus, for a pair of pins driving a coil, there are four possibilities:
"00" = No current , "01" = "Forwards" current , "10" = "Backwards" current and "11" = No current. But here I will show the current flowing in the coils (A and B) as +A , -A , +B , -B and 0 if no current flows.

There are four basic drive sequences but it's possible to "morph" between some by reducing either the odd or even timeslots to zero. Moving from left towards right, the total load current increases (perhaps to "dangerous" levels) and hopefully also the torque. The third sequence column is the nearest to "Half-stepping" and setting the Even-numbered timeslots to perhaps 70% of the Odd-numbered slot-period might be rather smoother. But much depends on the physical characteristics of the stepper motor.
Code:
Timeslot      Low current ............................High current
    0               0          -B         +A -B         +A -B
    1              +A          +A         +A  0         +A -B
    2               0          +A         +A +B         +A +B
    3              +B          +B         0  +B         +A +B
    4               0          +B         -A +B         -A +B
    5              -A          -A         -A  0         -A +B
    6               0          -A         -A -B         -A -B
    7              -B          -B         0  -B         -A -B
    8               0          -B         +A -B         +A -B
Personally, I normally drive stepper motors with a simple sequence of HIGH pin , PAUSE period1 , LOW pin , PAUSE period2 , etc. commands, or even TOGGLE pin , etc.. because it's much easier to "see" what's happening, but if you really need a "drive sequence" then we can probably create one for you. ;)

Cheers, Alan.
 
Last edited:
Top