Advertisement
ABCelectronica

PICAXE 28X2 + ULN2003 + Stepper

Dec 10th, 2012
2,305
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pic 16 3.40 KB | None | 0 0
  1. ;          PICAXE28X2 Shield Base
  2. ;-------------------------------------------
  3. ;      Disponible en ABCelectronica.net
  4. ;-------------------------------------------
  5. ;*******************************************
  6. ;Control de un motor stepper unipolar de 5V
  7. ;por medio del modulo driver ULN2803
  8. ;y microcontrolador PICAXE28X2 Shield Base
  9. ;Permitiendo colocar el eje a nuestra
  10. ;disposición y con la opcion de que de una
  11. ;vuelta completa
  12. ;*******************************************
  13.  
  14. ;-------------------------------------------
  15. ;declaración constantes y variables
  16. ;LED ENCENDIDO
  17. symbol led       = S.13
  18. symbol reloj     = b1
  19. ;valor correspondiente a una vuelta
  20. ;completa del eje del motor stepper
  21. symbol intervalo = w6
  22.  
  23. ;Pulsadores de set e inicio de programa
  24. ;pulsador config para colocar el eje
  25. ;en la posicion deseada
  26. symbol config    = pinS.6
  27. symbol ledconfig = S.7
  28. ;pulsador pulsini para iniciar el
  29. ;codigo de la programación
  30. symbol pulsini   = pinS.4
  31. symbol ledpulsini= S.5
  32.  
  33. ;SALIDA PARA EL DRIVER
  34. ;Bobina 1 - cable rosa
  35. ;Bobina 2 - cable naranja
  36. ;Bobina 3 - cable amarillo
  37. ;Bobina 4 - cable azul
  38. ;comun    - cable rojo
  39. symbol pinkb1   = S.A0
  40. symbol orangeb2 = S.A1
  41. symbol yellowb3 = S.A2
  42. symbol blueb4   = S.A3
  43.  
  44. ;fijando valores estandar
  45. ;intervalo 1mS
  46. reloj     = 1
  47. intervalo = 1
  48.  
  49. ;___________________________________________
  50.  
  51. ;PROGRAMACIÓN
  52. ;comprabando que el uC funciona Y
  53. ;"espera" a que un pulsador sea presionado
  54. preinicio:
  55.  toggle led
  56.  pause 500
  57.  toggle led
  58.  pause 500
  59.  low ledpulsini, ledconfig
  60. condiciones:
  61.  high led               ;led de funcionamiento ON
  62.  low ledpulsini, ledconfig  ;led configuracion y principal OFF
  63.  if config = 1 and pulsini=1 then goto preinicio
  64.  if config = 0 and pulsini=1 then goto configuracion
  65.  if config = 1 and pulsini=0 then goto principal
  66. goto preinicio
  67.  
  68. ;Rutina para elejir la posicion del eje
  69. configuracion:
  70.  low ledpulsini, ledconfig
  71. if config = 0 then          ;comprueba que el pulsador
  72.  do                     ;este presionado
  73.   high ledconfig
  74.   ;Movimiento del stepper
  75.   ;Paso 1
  76.   low orangeb2, blueb4
  77.   pause reloj
  78.   high pinkb1, yellowb3
  79.   pause reloj
  80.   ;Paso 2
  81.   low orangeb2,yellowb3
  82.   pause reloj
  83.   high pinkb1, blueb4
  84.   pause reloj
  85.   ;Paso 3
  86.   low pinkb1, yellowb3
  87.   pause reloj
  88.   high orangeb2, blueb4
  89.   pause reloj
  90.   ;Paso 4
  91.   low pinkb1, blueb4
  92.   pause reloj
  93.   high orangeb2, yellowb3
  94.   pause reloj
  95.   if config = 1 then goto condiciones ;si el pulsador deja de ser
  96.                           ;presionado el motor para
  97.  ;condicion para dar vuelta completa
  98.   inc intervalo
  99.  loop while intervalo<510 ;255 media vuelta
  100.  goto configuracion
  101. else
  102.  goto condiciones
  103. endif
  104. goto configuracion
  105.  
  106. principal:
  107. intervalo = 1
  108. low ledpulsini
  109. high ledpulsini
  110. if pulsini = 0 then
  111.  do
  112.   ;Movimiento del stepper
  113.   ;Paso 1
  114.   low orangeb2, blueb4
  115.   pause reloj
  116.   high pinkb1, yellowb3
  117.   pause reloj
  118.   ;Paso 2
  119.   low orangeb2,yellowb3
  120.   pause reloj
  121.   high pinkb1, blueb4
  122.   pause reloj
  123.   ;Paso 3
  124.   low pinkb1, yellowb3
  125.   pause reloj
  126.   high orangeb2, blueb4
  127.   pause reloj
  128.   ;Paso 4
  129.   low pinkb1, blueb4
  130.   pause reloj
  131.   high orangeb2, yellowb3
  132.   pause reloj
  133.   if config = 0 then goto condiciones ;si el pulsador config es
  134.                           ;presionado el motor pasa
  135.                           ;a la rutina de configuracion
  136.  ;condicion para dar vuelta completa
  137.   inc intervalo
  138.  loop while intervalo<510 ;255 media vuelta
  139.  goto principal
  140. else
  141.  goto condiciones
  142. endif
  143. goto principal
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement