PDA

View Full Version : some question of position controller



playrobot
03-20-2009, 06:33 PM
I have bought your Motor Mount and Wheel Kit (#27971) with Position Controller (#29319),and i have some simple question...

I wish to allow my car·stop and·turn continuous·but it cant..The following are the·source code·at your station

'--- User Constants & Variables ---
AllWheels··· CON····· 0
RightWheel·· CON····· 1············· 'ID of the right side Position Controller
LeftWheel··· CON····· 2············· 'ID of the left side Position Controller
CommPin····· CON····· 12············ '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, [SREV + RightWheel]· 'Reverses the sensor on the right
SEROUT CommPin, BaudValue, [CLRP]·············· 'Clears any prior position info
'Go forward 350 positions
Wheel = AllWheels
Distance = 350
GOSUB GoDistance
'Continually check the position of each wheel
CheckLoop:
· Wheel = LeftWheel
· DEBUG "L= "
· GOSUB DisplayPosition
· Wheel = RightWheel
· DEBUG "· R= "
· GOSUB DisplayPosition
· DEBUG CR
· GOTO· CheckLoop
· END
'--- Subroutines ---
GoDistance:
· SEROUT CommPin, BaudValue, [TRVL + Wheel]
· SEROUT CommPin, BaudValue, [Distance.HIGHBYTE, Distance.LOWBYTE]
RETURN
DisplayPosition:
· SEROUT CommPin, BaudValue, [QPOS + Wheel]
· SERIN· CommPin, BaudValue, [RxData.HIGHBYTE, RxData.LOWBYTE]
· DEBUG SDEC RxData
RETURN

i·mark "SEROUT CommPin, BaudValue, [SREV + RightWheel]··and hoped that the car turn but result isn't i want...May I ask what have I done wrong?

And..can·you give me some example program·, such as·QSPD·and CHFA , tell me how to· use·these two·commands ,thank you your help!!!

by the way, i live in taiwan, If there expression·is not clear, please forgive me

TreeLab
03-20-2009, 08:08 PM
This belongs in the Basic Stamp forum.

Cheers!
Paul Rowntree