Subject:
|
RE: RotateMotorEx hangs
|
Newsgroups:
|
lugnet.robotics.nxt
|
Date:
|
Sun, 5 Aug 2007 12:00:47 GMT
|
Viewed:
|
21888 times
|
| |
| |
"... Maybe I could check that the power level is not equal to zero as
well..."
Good idea. Will be included in the coming release?
--Elizabeth
-----Original Message-----
From: news-gateway@lugnet.com [mailto:news-gateway@lugnet.com] On Behalf Of
John Hansen
Sent: Friday, August 03, 2007 3:26 PM
To: lugnet.robotics.nxt@lugnet.com
Subject: Re: RotateMotorEx hangs
In lugnet.robotics.nxt, Elizabeth Mabrey wrote:
> This is actually the topic about interrupting RotateMotor(). I resend with a
> more appropriate topic.
> --E
When you call RotateMotorXXX here is the code that is executed:
subroutine __RotateMotor0
brtst EQ, __rotate_Done0, __rotate_angle0
sign __rotate_thePower0, __rotate_angle0
abs __rotate_theAngle0, __rotate_angle0
mul __rotate_thePower0, __rotate_thePower0, __rotate_power0
set __rotate_theUF0,
UF_UPDATE_TACHO_LIMIT+UF_UPDATE_SPEED+UF_UPDATE_MODE+UF_UPDATE_PID_VALUES
brtst EQ, __rotate_NoSync0, __rotate_sync0
set __rotate_theOM0, OUT_MODE_MOTORON+OUT_MODE_BRAKE+OUT_MODE_REGULATED
set __rotate_theRM0, OUT_REGMODE_SYNC
mov __rotate_theTurnPct0, __rotate_turnpct0
brtst EQ, __rotate_Start0, __rotate_theTurnPct0
add __rotate_theUF0, __rotate_theUF0, UF_UPDATE_RESET_BLOCK_COUNT
jmp __rotate_Start0
__rotate_NoSync0:
set __rotate_theOM0, OUT_MODE_MOTORON+OUT_MODE_BRAKE
set __rotate_theRM0, OUT_REGMODE_IDLE
set __rotate_theTurnPct0, 0
__rotate_Start0:
set __rotate_theRS0, OUT_RUNSTATE_RUNNING
setout __rotate_ports0, OutputMode, __rotate_theOM0, RegMode,
__rotate_theRM0,
TachoLimit, __rotate_theAngle0, RunState, __rotate_theRS0, RegPValue,
__rotate_theRVP0, RegIValue, __rotate_theRVI0, RegDValue, __rotate_theRVD0,
Power, __rotate_thePower0, TurnRatio, __rotate_turnpct0, UpdateFlags,
__rotate_theUF0
// Waits till angle reached
index __rotate_firstPort0, __rotate_ports0, NA
__rotate_Running0:
getout __rotate_rs0, __rotate_firstPort0, RunState
brcmp EQ, __rotate_Running0, __rotate_rs0, OUT_RUNSTATE_RUNNING
brtst EQ, __rotate_Reset0, __rotate_stop0
// Regulates for speed = 0
set __rotate_theOM0, OUT_MODE_MOTORON+OUT_MODE_BRAKE+OUT_MODE_REGULATED
set __rotate_theRM0, OUT_REGMODE_SPEED
set __rotate_theUF0, UF_UPDATE_SPEED+UF_UPDATE_MODE
setout __rotate_ports0, OutputMode, __rotate_theOM0, RegMode,
__rotate_theRM0,
RunState, __rotate_theRS0, Power, 0, UpdateFlags, __rotate_theUF0
// Verifies that motor doesn't rotate for 50ms, else loops
getout __rotate_RotCount0, __rotate_firstPort0, RotationCount
__rotate_Stabilize0:
mov __rotate_OldRotCount0, __rotate_RotCount0
// wait loop
gettick __rotate_now0
add __rotate_then0, __rotate_now0, 50
__rotate_Waiting0:
gettick __rotate_now0
brcmp LTEQ, __rotate_Waiting0, __rotate_now0, __rotate_then0
// check rotation
getout __rotate_RotCount0, __rotate_firstPort0, RotationCount
brcmp NEQ, __rotate_Stabilize0, __rotate_OldRotCount0, __rotate_RotCount0
setout __rotate_ports0, RunState, OUT_RUNSTATE_IDLE, OutputMode,
OUT_MODE_COAST, UpdateFlags, UF_UPDATE_MODE
__rotate_Reset0:
// maybe reset the block rotation count
brtst EQ, __rotate_Done0, __rotate_theTurnPct0
setout __rotate_ports0, UpdateFlags, UF_UPDATE_RESET_BLOCK_COUNT
__rotate_Done0:
return
ends
As you can see there are some loops in here. The first loop repeats while
RunState is OUT_RUNSTATE_RUNNING. Unfortunately, Off (which brakes the
motors)
specifically sets the RunState to OUT_RUNSTATE_RUNNING with a power level of
zero (i.e., to stop and brake the motors). In order to interrupt the loop
in
RotateMotor you will need to stop the motors without braking by using Coast
instead of Off.
You can brake after you coast if you want but for at least a little while
the
motors need to not be in the running runstate otherwise this loop will not
exit.
Perhaps it would be good to introduce some other mechanism for breaking out
of
this loop other than checking the RunState value. Maybe I could check that
the
power level is not equal to zero as well.
John Hansen
|
|
Message has 1 Reply:
Message is in Reply To:
| | Re: RotateMotorEx hangs
|
| (...) When you call RotateMotorXXX here is the code that is executed: subroutine __RotateMotor0 brtst EQ, __rotate_Done0, __rotate_angle0 sign __rotate_thePower0, __rotate_angle0 abs __rotate_theAngle0, __rotate_angle0 mul __rotate_thePower0, (...) (17 years ago, 3-Aug-07, to lugnet.robotics.nxt)
|
8 Messages in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
This Message and its Replies on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
Active threads in NXT programmable brick
|
|
|
|