Motor Mount, Wheel Kit and HB25 from Parallax
Hallo everyone.
·
I have bought the hardware from Parallax to control my robot I look on the example that was published on their website.
·
Look below.
·
' {$STAMP BS2}
' {$PBASIC 2.5}
'
' Position_Controller_Test_Interface.bs2
' Parallax Inc.· 2008.07.18· Version 1.1
' This code is a simple test 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.
'
'--- 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 ---
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 3000
SEROUT CommPin, BaudValue, [noparse][[/noparse]SREV + RightWheel]· 'Reverses the sensor on the right
SEROUT CommPin, BaudValue, [noparse][[/noparse]CLRP]·············· 'Clears any prior position info
·
'Go forward 100 positions
Wheel = AllWheels
Distance = 750
GOSUB GoDistance
PAUSE 20
Wheel = AllWheels
Distance = -750
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, [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
·
This is working fine but now I will to increase the max speed, and that I can control the left and the right wheel for turning can anybody help my or is there a expanded example.
I downloaded the manual from the site but its explain not how to control the separately.··
·
I have bought the hardware from Parallax to control my robot I look on the example that was published on their website.
·
Look below.
·
' {$STAMP BS2}
' {$PBASIC 2.5}
'
' Position_Controller_Test_Interface.bs2
' Parallax Inc.· 2008.07.18· Version 1.1
' This code is a simple test 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.
'
'--- 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 ---
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 3000
SEROUT CommPin, BaudValue, [noparse][[/noparse]SREV + RightWheel]· 'Reverses the sensor on the right
SEROUT CommPin, BaudValue, [noparse][[/noparse]CLRP]·············· 'Clears any prior position info
·
'Go forward 100 positions
Wheel = AllWheels
Distance = 750
GOSUB GoDistance
PAUSE 20
Wheel = AllWheels
Distance = -750
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, [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
·
This is working fine but now I will to increase the max speed, and that I can control the left and the right wheel for turning can anybody help my or is there a expanded example.
I downloaded the manual from the site but its explain not how to control the separately.··
Comments
The example code can be modified to control the wheels separately. You control which wheel is being affected by the contents of the Wheel variable. It must be either LeftWheel, RightWheel or AllWheels. The interesting part is this one from the original:
All that is necessary to move the wheels individually is to set the Wheel variable to either the Left or Right as you desire. For example, to move the left wheel this would become:
For setting the maximum speed you can do a similar thing to what the subroutine GoDistance is doing, but change the command to be SMAX and create a new variable to hold the maximum speed you desire. First, add a new WORD variable like this:
Then create a new subroutine to send the commands to control the maximum speed, very similar to GoDistance:
Now call your new routine something like this:
Hope this helps.
Greg
Post Edited (Greg Norton) : 12/2/2008 6:52:11 AM GMT
Can anybody help my how to controlling the two wheels separately.
I will for example that the right wheel go’s 200 pulses and the left 300 at the same time,
And that they stops at the same time.
·
In the example you can only one wheel controlling, can anybody explain how to controlling two wheels at a different speed.
You must issue two separate commands to the wheels to do this.· They will not stop at the same time assuming you have set the same maximum speed for both wheels.
Greg
Greg
separately. thanks...
Greg
If I program this, then go's left wheel 300 pulses and stops, and then go's the Right wheel 200 pulses and stops.
this is not what I will.
is it possible to program the 2 wheels together an the same time so that left wheel moves 300 pulses and the right wheel 200
and stops both at the same time.
I think you are mistaken. Once the first command is sent the left wheel should start moving. Your program will then return and the right wheel will start moving very soon after that. It will be as close to to the same time as you can get. What part of the program makes it wait until the left wheel has finished moving? The GoDistance subroutine has no such code to wait until the wheel is finished moving.
Did you try it out?
Greg
This is what I have trait, but it will not work the wheels are on controlled backwards end will not stop.
' {$STAMP BS2}
' {$PBASIC 2.5}
'
' Position_Controller_Test_Interface.bs2
' Parallax Inc. 2008.07.18 Version 1.1
' This code is a simple test 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.
'
'--- 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 ---
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
MaxSpeed VAR Word
SpeedRamp VAR Word
MaxSpeed = 1000
SpeedRamp = 3
'--- Initialization ---
PAUSE 3000
SEROUT CommPin, BaudValue, [noparse][[/noparse]SREV + RightWheel] 'Reverses the sensor on the right
SEROUT CommPin, BaudValue, [noparse][[/noparse]CLRP] 'Clears any prior position info
'Go forward 100 positions
GOSUB SetMaxSpeed
GOSUB SetSpeedRamp
Wheel = RightWheel
Distance = 300
GOSUB GoDistance
Wheel = LeftWheel
Distance = 200
GOSUB GoDistance
Wheel = RightWheel
Distance = -300
GOSUB GoDistance
Wheel = LeftWheel
Distance = -200
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, [noparse][[/noparse]TRVL + Wheel]
SEROUT CommPin, BaudValue, [noparse][[/noparse]Distance.HIGHBYTE, Distance.LOWBYTE]
RETURN
SetMaxSpeed:
SEROUT CommPin, BaudValue, [noparse][[/noparse]SMAX + Wheel]
SEROUT CommPin, BaudValue, [noparse][[/noparse]MaxSpeed.HIGHBYTE, MaxSpeed.LOWBYTE]
RETURN
SetSpeedRamp:
SEROUT CommPin, BaudValue, [noparse][[/noparse]SSRR + Wheel]
SEROUT CommPin, BaudValue, [noparse][[/noparse]SpeedRamp.HIGHBYTE, SpeedRamp.LOWBYTE]
RETURN
DisplayPosition:
SEROUT CommPin, BaudValue, [noparse][[/noparse]QPOS + Wheel]
SERIN CommPin, BaudValue, [noparse][[/noparse]RxData.HIGHBYTE, RxData.LOWBYTE]
DEBUG SDEC RxData
RETURN
Can you explain what do I wrong, gif my a example please.
Try this you may need to change the for next loop to get the proper timming right but this will stop the program
I = VAR Word ' Used as a counter
'Continually check the position of each wheel until for-next loop completes
FOR I = 1 to 500
Wheel = LeftWheel
DEBUG "L= "
GOSUB DisplayPosition
Wheel = RightWheel
DEBUG " R= "
GOSUB DisplayPosition
DEBUG CR
next I
END
Hope this is what you were asking for.
Jax
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
If a robot has a screw then it must be romoved and hacked into..
I did not understand your last post. Are you saying the wheels keep turning forever or they don't turn at all?
If they don't turn at all, note that the travel distances are cumulative. This means when you give commands to travel +200 and then -200, the sum is 0. If the commands are sent fast enought it may appear that the wheel does not move at all. Add some delay between the commands to go positive distances and negative distances like about 10 seconds to be sure. Make it look like this:
This will allow the wheel time to finish its forward motion and then start moving backware. What GWJax is saying is also true, once your program enters CheckLoop it will never exit. Try to just get the movement part down first.
Greg
Jax
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
If a robot has a screw then it must be romoved and hacked into..
I tray this again but the problem is that if I use this in my program:
Wheel = RightWheel
Distance = 300
GOSUB GoDistance
Wheel = LeftWheel
Distance = 200
GOSUB GoDistance
PAUSE 10000
Wheel = RightWheel
Distance = -300
GOSUB GoDistance
Wheel = LeftWheel
Distance = -200
GOSUB GoDistance
It will begin turning the right and left wheel at the same time, and the left wheel is turn about 6 sec turn from forwards to backwards, and after about 8 sec turn the right wheel .
the left wheel stops, and after 2 sec the right wheel.
The “pause 10000” will only wait for 10 sec in between from forwards to backwards.
I think that if the time have a proportion of 6 to 8 sec that the speed have the same proportion.
So that the wheels stops at the same time but this is a lot of programming.