I did it.
Code:
'****************************************************************
'* Name : UNTITLED.BAS *
'* Author : [Leonardo Bilalis] *
'* Notice : Copyright (c) 2013 *
'* : All Rights Reserved *
'* Date : 3/3/2013 *
'* Version : 1.0 *
'* Notes : Stepper Motor *
'* : *
'****************************************************************
@ DEVICE pic16F628A, intOSC_osc_noclkout, WDT_OFF, PWRT_OFF, BOD_OFF, MCLR_ON
define osc 4
Include "MODEDEFS.BAS"
StepM var WORD ; distance to move
delay var word ; time in ms between each step pulse
i var word
cmcon = 7
PORTB = 0
TRISB = %11110011
but var PORTB.1 ; ASIGN THE PIC16F88 PORTB.2 AS A PUSH BUTTON
Motor_Step VAR PORTB.2 ; ASIGN THE PIC16F88 PORTB.5 TO STEP PIN ON THE BIG EASY DRIVER
DIRECTION VAR PORTB.3 ; ASIGN THE PIC16F88 PORT.4 TO DIR PIN ON THE BIG EASY DRIVER
CW con 0 ;HERE WE GIVE A CONSTANT DIRECTION
CCW con 1 ;HERE WE GIVE A CONSTANT DIRECTION
BEGIN:
LOW MOTOR_STEP ; WE CAN START BY MAKING LOW THE PORTB.4
LOW DIRECTION ; WE CAN START BY MAKING LOW THE PORTB.5
pAUSE 100 ; THEN WE GIVE 1 SECOND DELAY
if but = 0 then ; WE HAVE CONNECTED A PUSH BUTTON AT PORTB.2
stepM = 3200 ; the number of the motor steps
DELAY = 1 ; 1us between each step
direction = CW ; THE DIRECTION IS COUNTERWISE
gosub Rotation
endif
goto begin
end
;THE FOLLOWING CODE SUPPOSE TO ROTATE THE SHAFT 1 STEP AT A TIME
ROTATION:
for i = 0 to (stepM - 1)
gosub StepIt
pauseUS delay
next
return
StepIt:
motor_step = 1 ;generate a 1us wide pulse on the step pin
pauseUS 1
motor_step = 0
RETURN
;thanks to Henrik at Melabs forum.
there are some problems though.
i cannot sent one step pulse. i think i need to understand completely what is doing exactly through the Big easy driver.
Bookmarks