Busca quizá L6506 y te dará alguna idea mejor, pero lo único que diferencia al L6506 es que el L297 contiene dentro un L6506, pero añade la lógica de secuencias para mover las bobinas de los motores. De todas formas, yo con el ATMEL90S8515, que se encuentra por ahí en todos los mercadillos a un precio muy barato (se usaba antes en las tarjetas piratas del canal satélite) realicé un programa en basic para mover las bobinas de un motor más complejo con cinco bobinas bipolares tipo "Berger-Lahr" y el programa BASCOM para AVR.
Un ejemplo:
'======================================================================================================================
'PROGRAMA PARA AVR-BASCOM Y 90S8515 CON EL QUE SE PILOTA UN MOTOR DE CINCO FASES BERGER-LAHR.
'90S8515 a 8 Mhz.
'Sevilla,14 dejunio de 2007.
'BASADO EN TRABAJOS DE OLLI SILVÉN DE LA UNIVERSIDAD DE OULU (1993) Y EN HISSI, CON LA AYUDA DE GOETZ AUTOMATION (GERMANY).
'y también en un programa en JAL (para PIC) aunque para motor de 5 fases en estrella.
'Se dif en set ledpulso, en lugar un impulso y de cambiar sentido de giro de motores CCW en lugar de CW
'======================================================================================================================
'PATILLAJE DEL MICRO:
'Puerto A (salidas)= PA0W1, PA1W1, PA2W2, PA3W2, PA4W3, PA5W3, PA6W4, PA7W4.
'Puerto B (salidas)= PB0W5, PB1W5, PB2ENABLE1L298, PB3ENABLE2L298, PB4ANLEDW5, PB5CATLEDW5, PB6INDEX o home, PB7 (LEDENABLE).
'Puerto C (salidas)= PC0ANLEDW1, PC1CATLEDW1, PC2ANLEDW2, PC3CATLEDW2, PC4ANLEDW3, PC5CATLEDW3, PC6ANLEDW4, PC7CATLEDW4.
'Puerto D (entradas D0-D4 y salidas D5-D7)= PD0ENABLE(entr), PD1PULSO(entr), PD2SENTIDO(entr), PD3MODO(entr), PD4RESET "Reseteado"(entr),
'PD5LEDPULSO(SALIDA INVERSA), PD6LEDSENTIDO(SALINVERSA), PD7LEDMODO(SALINVERSA).
'Los led testigos de pulso, sentido y modo están en lógica inversa y se encienden cuando las patillas de salida del micro valen "0".
'En la versión del 28 de enero de 2007 se trata de adecuar en compatibilidad al L297.
'Esta versión del 15 de febrero intenta recopilar todo pero adecuándolo a un mejor trabajo.
'Deriva de la versión del 12-feb versión 1.2 y 1.3 (esta última no sé en qué se diferencia de la 1.2).
'Reseteado -> Se pone en paso 1
'Home (sal) es en colector abiero y se colocaría en alto (a dif 16v1.2feb2007).
'En este ejemplo de 14 de junio se desactivan enables 1 y 2 de los 298.
'======================================================================================================================
'Definiciones:
'Enable= Activado cuando la señal es alta (igual que en L297).
'Si es baja,las bobinas de los motores se desactivarán "flywehel",evitando consumos innecesarios.
'Sentido= 1 es CW y 0 CCW (igual que en L297)
'Pulso= Por aquí se recibirán los pulsos desde el 8255 (0 súbida,1 bajada, es decir que el clock es activo en bajo).
'Modo= 0 paso entero 1 semipaso (igual que en L297)
'el algoritmo sería el siguiente:
'declarar variables y constantes
'pind.0=enable; pind.1=Pulso; pind.2=Sentido; pind.3=Modo
'inicialización mediante este proceso se toman: port A,B y C como salidas y algunos pines del D como entradas.
'los puertos A, B y C se ponen a 0. Configurar el puerto D como entradas y salidas.
'el pind.0 será el enable, el pind.1 el pulso y el pind.2 será el de sentido.
'poner todas las bobinas a cero (ya mencionado).
'si enable es bajo (pind.0), las bobinas se ponen a cero.
'si enable alto, mirar si hay pulso pind.1=0.
'si pind.1=1(ya que se activa en este flanco) mirar si pind.2= 1 o 0 y cargarlo en una variable (variable sentido) y pind.2 (variable modo) si es 1 o 0.
'Salidas: puerto A para motor (1 byte), puerto B >bits 0 y 1 para motor; 2 y 3 para activación del L298 y los cuatro restantes para las luces de motor (concretamente bobina E o W5) y otros.
'El puerto C para luces del motor (bobinados A,B,C y D); y por último el puerto D para entradas (enable, pulso, sentido,modo ...).
'y los tres restantes bits para las luces de estado de estas patillas> hay que definir DDRD.
'Desactivación motor: primero puerto B y luego el A, para que así se anule antes el que activa al L298).
'=====================================================================================================================
'Declaración de sinónimos:
Const Cw = 1
Const Ccw = 0
Const Semipaso = 1
Const Entero = 0
Const high=1
Const low=0
Enablechip Alias Pind.0
Pulso Alias Pind.1
Sentido Alias Pind.2
Modo Alias Pind.3
Reseteado Alias Pind.4
Ledpulso Alias Portd.5
Ledsentido Alias Portd.6
Ledmodo Alias Portd.7
Enable_1_298 Alias Portb.2
Enable_2_298 Alias Portb.3
Anledw5 Alias Portb.4
Catledw5 Alias Portb.5
Index Alias Portb.6
Ledenable Alias Portb.7
'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Inicio:
'Declaración de funciones
Dim Paso As Byte
Dim State_prev as bit
'Configuración de pines
Config Porta = Output
Config Portb = Output
Config Portc = Output
Config Portd = &B11100000
'YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
arranque: 'Poner a 0 todos las entradas de los puertos
Porta=0
Portb=&B00000000
Portc=0
LedPulso=1
LedSentido=1
Ledmodo = 1
State_prev=high
'ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
Primerpaso: 'primer paso
Do
if Enablechip=0 Then
Portb=&B10000000
Porta = 0 : Portc = Porta:Ledpulso=1:Ledsentido=1:Ledmodo=1
else
reset ledenable
If Pulso=0 and State_prev=high then
State_prev=low
end if
if Pulso=1 and State_prev=low then
Porta = &B10011001:Portb = &B01001100 : Portc = Porta : Anledw5 = Portb.0 : Catledw5 = Portb.1
reset Ledpulso
Ledmodo=not modo
Ledsentido=not sentido
Paso=1
State_prev=high:set ledpulso:exit do
end if 'viene del if Pulso=1 and State_prev=low then
end if 'viene del else
Loop
'WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW
Main:
Do
if Enablechip=0 Then
Portb=&B10000000
Porta = 0 : Portc = Porta:Ledpulso=1:Ledsentido=1:Ledmodo=1
else
reset ledenable
' ¿Reseteado?
If Reseteado=0 then
exit do
End if 'reseteado
'enablechip a 1
If Pulso=0 and State_prev=high then
State_prev=low
end if
if Pulso=1 and State_prev=low then
reset Ledpulso
If Sentido = CCW Then 'horario
If Modo = entero Then 'entero
Select Case Paso
Case 20 : Paso = 2
Case 19 : Paso = 1
Case Else : Paso = Paso + 2
End Select
Else ' Semipaso
If Paso = 20 Then
Paso = 1
Else
Paso = Paso + 1
End If
End If
Else
If Modo = entero Then 'entero
Select Case Paso
Case 1 : Paso = 19
Case 2 : Paso = 20
Case Else : Paso = Paso - 2
End Select
Else ' Semipaso
If Paso = 1 Then
Paso = 20
Else
Paso = Paso - 1
End If
End If
End If
Select Case Paso
Case 1 : Portb = Portb and &B11110011
Porta = &B10011001:Portb = &B01001100 : Portc = Porta : Anledw5 = Portb.0 : Catledw5 = Portb.1
Case 2 : Portb = Portb and &B11110011
Porta = &B10011001:Portb = &B00001101 : Portc = Porta : Anledw5 = Portb.0 : Catledw5 = Portb.1
Case 3 : Portb = Portb and &B11110011
Porta = &B10011000:Portb = &B00001101 : Portc = Porta : Anledw5 = Portb.0 : Catledw5 = Portb.1
Case 4 : Portb = Portb and &B11110011
Porta = &B10011010:Portb = &B00001101 : Portc = Porta : Anledw5 = Portb.0 : Catledw5 = Portb.1
Case 5 : Portb = Portb and &B11110011
Porta = &B10010010:Portb = &B00001101 : Portc = Porta : Anledw5 = Portb.0 : Catledw5 = Portb.1
Case 6 : Portb = Portb and &B11110011
Porta = &B10010110:Portb = &B00001101 : Portc = Porta : Anledw5 = Portb.0 : Catledw5 = Portb.1
Case 7 : Portb = Portb and &B11110011
Porta = &B10000110:Portb = &B00001101 : Portc = Porta : Anledw5 = Portb.0 : Catledw5 = Portb.1
Case 8 : Portb = Portb and &B11110011
Porta = &B10100110:Portb = &B00001101 : Portc = Porta : Anledw5 = Portb.0 : Catledw5 = Portb.1
Case 9 : Portb = Portb and &B11110011
Porta = &B00100110:Portb = &B00001101 : Portc = Porta : Anledw5 = Portb.0 : Catledw5 = Portb.1
Case 10 : Portb = Portb and &B11110011
Porta = &B01100110:Portb = &B00001101 : Portc = Porta : Anledw5 = Portb.0 : Catledw5 = Portb.1
Case 11 : Portb = Portb and &B11110011
Porta = &B01100110:Portb = &B00001100 : Portc = Porta : Anledw5 = Portb.0 : Catledw5 = Portb.1
Case 12 : Portb = Portb and &B11110011
Porta = &B01100110:Portb = &B00001110 : Portc = Porta : Anledw5 = Portb.0 : Catledw5 = Portb.1
Case 13 : Portb = Portb and &B11110011
Porta = &B01100100:Portb = &B00001110 : Portc = Porta : Anledw5 = Portb.0 : Catledw5 = Portb.1
Case 14 : Portb = Portb and &B11110011
Porta = &B01100101:Portb = &B00001110 : Portc = Porta : Anledw5 = Portb.0 : Catledw5 = Portb.1
Case 15 : Portb = Portb and &B11110011
Porta = &B01100001:Portb = &B00001110 : Portc = Porta : Anledw5 = Portb.0 : Catledw5 = Portb.1
Case 16 : Portb = Portb and &B11110011
Porta = &B01101001:Portb = &B00001110 : Portc = Porta : Anledw5 = Portb.0 : Catledw5 = Portb.1
Case 17 :Portb = Portb and &B11110011
Porta = &B01001001:Portb = &B00001110 : Portc = Porta : Anledw5 = Portb.0 : Catledw5 = Portb.1
Case 18 : Portb = Portb and &B11110011
Porta = &B01011001:Portb = &B00001110 : Portc = Porta : Anledw5 = Portb.0 : Catledw5 = Portb.1
Case 19 : Portb = Portb and &B11110011
Porta = &B00011001:Portb = &B00001110 : Portc = Porta : Anledw5 = Portb.0 : Catledw5 = Portb.1
Case 20 : Portb = Portb and &B11110011
Porta = &B10011001:Portb = &B00001110 : Portc = Porta : Anledw5 = Portb.0 : Catledw5 = Portb.1
End Select
' Leds
ledmodo = not modo
ledsentido = not sentido
set Ledpulso
State_prev = high
End if 'pulso=1 y estado previo=low
end if'enablechip
Loop
goto primerpaso
end
'SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
'Bobina W5 W4W3W2W1
'Paso B2,1 76543210
' 1 00 10011001 (paso 0)
' 2 01 10011001
' 3 01 10011000
' 4 01 10011010
' 5 01 10010010
' 6 01 10010110
' 7 01 10000110
' 8 01 10100110
' 9 01 00100110
'10 01 01100110
'11 00 01100110
'12 10 01100110
'13 10 01100100
'14 10 01100101
'15 10 01100001
'16 10 01101001
'17 10 01001001
'18 10 01011001
'19 10 00011001
'20 10 10011001