Position Controller Demo.bs2 How do you stop the motor and still keep your da
With out your value going to (0000)
So far the only way to stop the motor is with this command how ever this the data to· 0000
SEROUT CommPin, BaudValue, [noparse][[/noparse]CLRP]·············· 'Clears any prior position info
What I want to do is stop the motor with a code command line·and still have the count that·was there before I stop the motor
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any·
·that you may have and all of your time finding them 
·
·
·
·
Sam
Post Edited (sam_sam_sam) : 4/4/2010 10:23:57 PM GMT
So far the only way to stop the motor is with this command how ever this the data to· 0000
SEROUT CommPin, BaudValue, [noparse][[/noparse]CLRP]·············· 'Clears any prior position info
What I want to do is stop the motor with a code command line·and still have the count that·was there before I stop the motor
'------------------------------------------------------------------------'
' Position Controller Demo.bs2 '
' '
' < Description > '
' This code is a simple demo interface for a two-wheel robot design. '
' It sends a command to travel forward 350 positions and continually '
' queries the current position of each wheel to display to the '
' debug (serial) terminal. Once the 350 positions are completed the '
' controller will loop forward and then backward. '
' '
' < Harware Configuration > '
' This sample uses an HB25 to control a 12 VDC motor '
' '
'------------------------------------------------------------------------'
' {$STAMP BS2}
' {$PBASIC 2.5}
'--- Command Value Constants ---
QPOS CON $08 'Query Position
QSPD CON $10 'Query Speed
CHFA CON $18 'Check for Arrival
TRVL CON $20 'Travel Number of Positions
CLRP CON $28 'Clear Position
SREV CON $30 'Set Orientation as Reversed
STXD CON $38 'Set TX Delay
SMAX CON $40 'Set Speed Maximum
SSRR CON $48 'Set Speed Ramp Rate
'--- User Constants & Variables ---
LeftWheel CON 1 'ID of the left side Position Controller
CommPin CON 7 'communication bus pin
BaudValue CON 32 'for 19.2kbps
Wheel VAR Byte 'Specifies which wheel to command for subroutines
Distance VAR Word 'Used to set the travel distance
RxData VAR Word 'Used to receive data
'--- Initialization ---
PAUSE 1000
SEROUT CommPin, BaudValue, [noparse][[/noparse]CLRP] 'Clears any prior position info
'Go forward 5000 positions
Forwards:
Wheel = LeftWheel
Distance = 5000
GOSUB GoDistance
GOTO Checkloopf
'Go backward 5000 positions
Backwards:
Wheel = LeftWheel
Distance = - 5000
GOSUB GoDistance
GOTO Checkloopb
'Continually check the position of each wheel
Checkloopf:
Wheel = LeftWheel
DEBUG "L= "
GOSUB DisplayPosition
DEBUG CR
IF RxData = 4999 THEN GOSUB Backwards ELSE GOTO Checkloopf
Checkloopb:
Wheel = LeftWheel
DEBUG "L= "
GOSUB DisplayPosition
DEBUG CR
IF RxData = 1 THEN GOSUB Forwards ELSE GOTO Checkloopb
'--- Subroutines ---
GoDistance:
SEROUT CommPin, BaudValue, [noparse][[/noparse]TRVL + Wheel]
SEROUT CommPin, BaudValue, [noparse][[/noparse]Distance.HIGHBYTE, Distance.LOWBYTE]
RETURN
DisplayPosition:
SEROUT CommPin, BaudValue, [noparse][[/noparse]QPOS + Wheel]
SERIN CommPin, BaudValue, [noparse][[/noparse]RxData.HIGHBYTE, RxData.LOWBYTE]
DEBUG SDEC RxData
RETURN
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any·
·that you may have and all of your time finding them 
·
·
·
·
Sam
Post Edited (sam_sam_sam) : 4/4/2010 10:23:57 PM GMT
