Coding problems

5 views
Skip to first unread message

Malcolm

unread,
Oct 9, 2009, 3:46:28 PM10/9/09
to PIC32-Basic
Struggling with some code for driving stepper motor and its getting
worse rather than better.
Now getting error "LB buffer underflow " as well as wend being flagged
up.
A summary of the code :-
Setup ports,
function move
dim variables
input angle (angle to turn through)
deg# = 0
while deg# < angle
m1
wend
endf
function m1
f1
f2
f3 to f8 (eight half steps of motor)
endf

function f1
exitif deg# < angle
portb "bos" 12
portb "boc" 13
portb "boc" 14
portb "boc" 15
wait 10
deg# = deg#+0.9
endf
// this is repeated for the functions f1 -> f8

I have also tried using breakif but still get error though I think I
did not get the "lb buffer underflow".
The idea is to half step the motor until a preset angle is achieved
then stop cleanly.

Any ideas?

Malcolm Smith

peter247

unread,
Oct 10, 2009, 4:26:46 PM10/10/09
to PIC32-Basic
I like to use prints to see if the varible are what you think they
are.
It`s to build up your code function by function and test if it does
what you think it should.

Malcolm

unread,
Oct 11, 2009, 2:25:31 PM10/11/09
to PIC32-Basic
Peter,
That is the method I use. I cut all the extras from the code since I
was typing it.
All the variable give the expected results and the code drives the
stepper as expected.
The control has to drop out at the correct half step function or the
angle is wrong.
It is when this happens that the errors occur which prompts me to
believe my code
could be improved or I should not be using 'breakif' or 'exitif'
Maybe I should be throwing away some function return addresses.
I will go through the documentation again to see if I can find some
answers.

Malcolm

peter247

unread,
Oct 11, 2009, 3:33:30 PM10/11/09
to PIC32-Basic
What version of pic basic are you running ?.

If your code doesn`t use any of the updated functions I would go back
to pervious version which tells you where the error is in the code.

Malcolm

unread,
Oct 12, 2009, 6:54:37 PM10/12/09
to PIC32-Basic
Peter,
I have been running 1.460, but following your reply I have just
upgraded to 1.472.
However running my code I still get an error when leaving the
programme
at function move. The error I am getting is 'LB stack underflow [].
I feel this must be associated with jumping through the other function
upto f8.

Malcolm

Malcolm

unread,
Oct 19, 2009, 5:44:01 PM10/19/09
to PIC32-Basic


On Oct 12, 11:54 pm, Malcolm <tmsm...@freeuk.com> wrote:
> Peter,
> I have been running 1.460, but following your reply I have just
> upgraded to 1.472.
> However running my code I still get an error when leaving the
> programme
> at function move. The error I am getting is 'LB stack underflow [].
> I feel this must be associated with jumping through the other function
> upto f8.
>
> Malcolm
>
To all
Error problem sorted.
It was a bug in PIC32 which has now been fixed by Jim
See new release

Malcolm

peter247

unread,
Oct 20, 2009, 6:25:22 PM10/20/09
to PIC32-Basic
Missed the upgrade, so I’ve just installed it.

I see “Super vague mode” is still switched on for error reporting, so
far as I can see.
Eg if you add a Print installed of a print this is the error
generated:-

error: undefined variable or sub [Print]
error: text interpreter stack underflow []

Sum errors are now a pig to track down with only a

Error I got [1] and want [2] ???

But where !!! and what made it ?.
Reply all
Reply to author
Forward
0 new messages