Andres Rodriguez
New Member
The code shown below is a modification of the sample shown in Manual #3. It runs fine for a full turn forward and a full turn back. But then I get the following message and don't know how to correct it.
"Stack error - more nested gosubs than the stack allows!"
"Stack error - more nested gosubs than the stack allows!"
Code:
; Filename: Stepper motor
; Date:
; File Version:
; Written by:
; Function:
'Run a Bipolar Stepper motor.
'96 steps for 360 Deg
'continuous forward and reverse motion
; Last Revision:Oct 6, 2008
; Target PICAXE: 28A
; *******************************
'Directives
#picaxe 28A
#com 4
'======================================
Main:
for W5 = 0 to 95 'start a for...next loop to left
gosub lstep 'call LEFT step sub-procedure00
next W5 'next loop
for W6 = 0 to 95 'start a for...next loop to right
gosub rstep 'call RIGHT step sub-procedure
next W6 'next loop
lstep:
let b1 = b1 + 1 'add 1 to variable b1
goto step1 'goto the lookup table
rstep:
let b1 = b1 - 1 'subtract 1 from variable b1
goto step1
step1:
let b1 = b1 & %00000011 'mask lower two bits of b1
lookup b1,(%10100000,%10010000,%01010000,%01100000),b2 'lookup code into b2
B2=B2/16
let pins = b2 'output b2 onto control lines
If W6=96 then goto Main
Return