
 
  Pi_bi_step
 =  Control a bi-polar stepping motor wit the Raspberry Pi
   Jochen Lueg
 (0  http://roevalley.com (bottom of the page)
 2  Limavady, January 2013
 <  Version 1.0
 F
 P   error
 Z
 init
 d 
 n& "RMEnsure GPIO 0.00 RMLoad GPIO"
 x@ "RMensure GPIO 0.40 ERROR  Please install the GPIO module"
  setupGPIO
 
 
  
   " Motor controls"
  
 #  " Left       . . . . . .  Z"
 #  " Right      . . . . . .  C"
 #  " Stop       . . . . . .  X"
  
 #  " Full step  . . . . . .  F"
 #  " Half step  . . . . . .  H"
  
 #  " Fastest    . . . . . .  1"
  " to"
#  " Slowest    . . . . . .  9"
 
"(  " Press 'Q' to leave the program"
,
6 
@   Key$=(0) :   (0)=-1
J/    Key$="c"  Key$="C" Direction$="Right"
T.    Key$="z"  Key$="Z" Direction$="Left"
^2    Key$="q"  Key$="Q" Direction$="Finished"
h.    Key$="x"  Key$="X" Direction$="Stop"
r)    Key$="h"  Key$="H" Mode$="Half"
|)    Key$="f"  Key$="F" Mode$="Full"
,    Key$="1" T%=150*S%   :Speed$="Fast"
.    Key$="2" T%=200*S%   :Speed$="Fast-1"
.    Key$="3" T%=300*S%   :Speed$="Fast-2"
.    Key$="4" T%=625*S%   :Speed$="Fast-3"
,    Key$="5" T%=1250*S%  :Speed$="Half"
.    Key$="6" T%=2500*S%  :Speed$="Slow+3"
.    Key$="7" T%=5000*S%  :Speed$="Slow+2"
.    Key$="8" T%=10000*S% :Speed$="Slow+1"
,    Key$="9" T%=20000*S% :Speed$="Slow"
=    Direction$="Right"  Mode$="Full"  full_step_right
=    Direction$="Right"  Mode$="Half"  half_step_right
<    Direction$="Left"  Mode$="Full"   full_step_left
<    Direction$="Left"  Mode$="Half"   half_step_left
R    Direction$="Stop" 1,19)"Motor stopped                                 "
6    Direction$="Stop" all_off: Direction$="Wait"
d    Direction$ <> "Wait" 1,19);Mode$;" step. Turning ";Direction$;" with speed ";Speed$;"   "
&  Direction$="Finished"
0 close
: Ș
D
N all_off
X  J%=1  4
b%   ș"GPIO_WriteData",Port%(J%),0
l 
v 


 full_step_right
  J%=4  1 -1
%   ș"GPIO_WriteData",Port%(J%),1
5   ș"GPIO_WriteData",Port%(J%-1),0:  I%=1 T%:
 
 


 full_step_left
  J%=1  4
%   ș"GPIO_WriteData",Port%(J%),1
5   ș"GPIO_WriteData",Port%(J%-1),0:  I%=1 T%:
 
  
*
4
> half_step_right
H  J%=4  1 -1
R%   ș"GPIO_WriteData",Port%(J%),1
\5   ș"GPIO_WriteData",Port%(J%-1),0:  I%=1 T%:
f5   ș"GPIO_WriteData",Port%(J%+1),1:  I%=1 T%:
p 
 


 half_step_left
  J%=1  4
%   ș"GPIO_WriteData",Port%(J%),1
5   ș"GPIO_WriteData",Port%(J%-1),0:  I%=1 T%:
5   ș"GPIO_WriteData",Port%(J%+1),1:  I%=1 T%:
 
 


 init
	 W%=0
$ Direction$="Stop"
. S%=200
8 T%=S%*150
B Speed$="Fast"
L Mode$="Full"
t 
~

 error
  $;" at line ";  :
  J%=1  4
%   ș"GPIO_WriteData",Port%(J%),0
 
 
 


 setupGPIO
+  Port%(5) : Port%()=15,24,23,18,15,24
  ș"GPIO_EnableI2C",0

  ș"GPIO_ExpAsGPIO",2
  J%=1  4
%   ș"GPIO_WriteMode",Port%(J%),1
( 
< 
F
