Well I integrated the stuff I mentioned above into a powerpod PS2 program. However instead of using the square button, I used R3 (push the right joystick in). It still does the horn (We will rock you), but then it will start walking foreword until you press the button again. I had to configure the program for my hardware (PS2 on pins P0-3 using internal pull-up resistor) and P11 to talk to the SSC-32 (did have to change my ssc-32 back to slow speed (38400) but worked like a champ. Would not be hard to add in additional stuff like looking at sensor and change directons/speed, etc…
Nope, you can leave yours on P12-P15. Mine are on P0-3 as I have my XBee on the hardware serial port P14-P15. Also the SSC-32 you can leave in your normal spot. All of the pin number changes were done under an #ifdef, which I do not have defined in the verison I uploaded.
thank kurte~
so i will just copy and paste your code inside my atom pro 28 and without changing anything right?
you really help me a lot~
really thank very much~
just to help you deathsnake, here is some info on expanding the code for more range and direction if/when you come to it.
The XSpeed variable has a range of 120 (forward) to -120 (backwards).
The YSpeed variable has a range of 120 (right) to -120 (left). Rotation is named Steering. It’s not really steering because if you try to turn while both XSpeed and YSpeed are 0, the robot will rotate in place.
The range is 20 (right) to -20 (left) for steering and the speed of rotation is proportional to the value.
The body height is set by the Height variable and also has a range of -25 to 25.*
just some question innerbreed~
actually i not really understand about xspeed~
just let say i put xspeed = 120 and xspeed = 50
both also walking front but different speed right?
120 has a faster speed then 50 right?
At this point I think you should have plenty of information to start experimenting. There have been several posts from myself and others showing which variables, control walking and their ranges. If you look at the PS2 code, especially the part that I put in an if when you are not in Automode, which includes:
YSpeed = DualShock(3) - 128 ; Right Stick Horizontal
XSpeed = DualShock(4) - 128 ; Right Stick Vertical
Steering = DualShock(5) - 128 ; Left Stick Horizontal
...
Height = LastHeight + (((DualShock(6) - 128) / 5) - LastHeight) / StepFlag; Left Stick Vertical
You see that XSpeed, YSpeed, Steering and Height variables are all set depending on the position of the two sticks on the PS2. The DualShock array is an array of bytes which imply that it has a range from 0 to 255. When the stick is in the center the values are typically around 127 or 128 depending on the stick. There is some code in place to handle the slop. In this program that code looks like:
for Index = 3 to 6
if DualShock(Index) > (128 + DeadZone) then
DualShock(Index) = DualShock(Index) - DeadZone/2
elseif DualShock(Index) < (128 - DeadZone)
DualShock(Index) = DualShock(Index) + DeadZone/2
else
DualShock(Index) = 128
endif
next
When you move a joystick to one edge the value will be near 0, when you move it to the other edge it will be near 255. So when you read the code and see something like:
XSpeed = DualShock(4) - 128 ; Right Stick Vertical
Then you know that when the stick is in the center XSpeed 128-128 = 0
When it is at one edge it will be: 0-128 = -128 and when it is at the other edge it will be: 255-128= 127.
So given the code above that shows how the different variables are set by the joystick values and your ability to run the robot with the PS2, you should now be able to reasonably deduce what your robot should do when you set these values. And I have already provided you a version of the program that you can easily try it out, to confirm this.
So it is now up to you. Remember programming is not a spectator sport!
thank kurte~
i will slowly test it out
the program that you provided i have tried on my robot and it works!
but your robot legs pin is different as mine and you are using leg-C and mine is leg-B.
but i will change it back base on my original code.
i have try on my ping))) using this code:
wdist var word
main:
low p4
pulsout p4, 5
input p4
pulsin p4, 0, toolong, 40000, wdist
wdist = wdist / 148 ;convert for inches
serout s_out, i9600, "Distance: ", sdec wdist, 13, 10] ;display result in terminal
goto main
toolong: ; if the program gets here the sensor is not functioning, or wired wrong
serout s_out, i9600, "Timeout, sensor is not working", 13]
goto main
success also and if no object in front of ping))) then terminal 1 is showing distance 125
So my next plan is make my robot automatic move forward, meet object (let say distance <=50), then move to left or right, then continue forward and then i will stop the robot.
I will try to read your automatic forward code and try to make my own code.
And also i hope you can help me out~
thank.
PROBLEM SOLVED!
now i can made my robot walk forward when no object is in front and it will stop right there if a object is in front!
but anyway
please help me solve this
look at my code XSpeed = -50
it only will walk forward when Xsped = -50
if set to Xspeed = 50 it will walk backward.
just hope to ask, why this will happen?
Because I though when xspeed is positive and it should be walking front?
===================1st part====================
;code for ping)))
low p4
pulsout p4, 5
input p4
pulsin p4, 0, toolong, 40000, wdist
wdist = wdist / 148 ;convert for inches
if wdist > 50 then ;when distance >50 move forward, <50 turn right
aaa = 0 ;turning right automatic is off
Automode = 1 ;moving forward automatic is on
else
Automode = 0 ;moving forward automatic is off
aaa = 1 ;turning right automatic is on
endif
toolong: ; if the program gets here the sensor is not functioning, or wired wrong
============2nd part======================================
;moving forward automatic code
if Automode then
YSpeed = 0
XSpeed = -50 ; moving forward
Steering = 0 ;
StepFlag = 3 ; not sure try changing...
Height = 0
else
YSpeed = DualShock(3) - 128 ; Right Stick Horizontal
XSpeed = DualShock(4) - 128 ; Right Stick Vertical
Steering = DualShock(5) - 128 ; Left Stick Horizontal
StepFlag = (GaitSpeedTmp - 2) max 3
if HeightAdjust or LockLegs then
Height = LastHeight + (((DualShock(6) - 128) / 5) - LastHeight) / StepFlag; Left Stick Vertical
endif
Height = (Height Max HeightLimit) min - HeightLimit
endif
=====================3rd part===============================
;code turning right
if aaa then
YSpeed = 50 ;turning right
XSpeed = 0
Steering = 0 ;
StepFlag = 3 ; not sure try changing...
Height = 0
endif
about the code on top
there are 3 part, first part is ping))) code, second part is forward code and 3rd part is move to right code.
At first is code for ping))), when distance >50, automode = 1 and aaa = 0, robot will move forward. When there is an object and distance <50,automoce = 0 and aaa=1, robot will move right.
My question is…
for my program, robot move forward, then meet object, then it will keep walking to right until i stop the robot.
Anyone have any idea to make this?
robot move forward, meet object, then move to right but still keep detect the object until distance >50(no more object in front), then robot move forward again. I try to figure this for whole day but i just can’t get the idea
1 question
my robot still not walking straight.
It will slightly move to right site a bit.
offset and alignment (from powerpod) of my robot is quite ok already.
but still not walking straight.
So should i adjust the angle of the servo?
But i have no idea about the programming code of the servo in my programming part.
Can help?
THank~
main:
low p4
pulsout p4, 5
input p4
pulsin p4, 0, toolong, 40000, wdist
wdist = wdist / 148 ;convert for inches
serout s_out, i9600, "Distance: ", sdec wdist, 13, 10] ;display result in terminal
goto main
toolong: ; if the program gets here the sensor is not functioning, or wired wrong
serout s_out, i9600, “Timeout, sensor is not working”, 13]
goto main[/code]
The code on top will show me sensor distance in terminal 1 after i click connect.
I need all of the result from initial i start to click connect and until i stop the program.
How can i transfer my output data to Excel or notepad?
Because the initial result in terminal 1 will gone if my sensor data run too long, right?
I am not sure if you are asking for the obvious answer of you select the text, do a right mouse click and select copy, then go to either notepad or excel and do a paste command?
If the terminal program does not have enough hold enough lines you have options, try different terminal programs such as hyper term. If that does not work, you can easily write a VB app that can do it.
i can’t do copy and paste because terminal has not enough space to record my result.
i have no idea how to make a VB app to do this.
Can you help me on it or do you still have others way to help me how to record my sensor output into EXcel?