Servo that will follow Jstick direction

i wish to add a servo that will follow the walk direction.
i used this code on ABB with Atom 28.

[code]servo _PulseMin con 600
servo_PulseMax con 2400

Code:
servo con P#

servo _Pulse var word

ZCoord var Sbyte

ZCoord = DualShock(3) - 128
if ZCoord > DeadZone then
ZCoord = ZCoord - DeadZone
elseif ZCoord < -DeadZone
ZCoord = ZCoord + DeadZone
else
ZCoord = 0
endif

   servo=  (((servo_PulseMax - servo_PulseMin) * ((ZCoord + 64 ) & $7F) |

’ / 127 + servo_PulseMax) min servo_PulseMin) max servo_PulseMax [/code]

e.g. using the right stick to control the hex as normal and having a (camera, or sensor) on the top. when direction is given to the hex, the servo will face that direction.
worked fine on atom28 but can this be put into Basic atom pro, ie Phoenix/black widow code as it is or will it need modifying?

There looks like two questions here.

  1. Can this same code work on the Atom Pro and I believe the answer is yes. You may need to verify variable sizes… The new powerpod files now can generate code for the Pro and it does appear to generate the Deck_pulse for both 180 and 360 degrees.

  2. The second half is can this be integrated into the phoenix code. I believe that it could, but Xan could probably answer this much better than I could…

Kurt

LOL, I already answered this in the PM but there is nothing wrong with sharing :wink:

Hi Innerbreed,

You’re free to add your part in my code. I didn’t check your code on functionality. Your planning to move a servo to the walking direction. What you can do is use the “walkingâ€

thanks xan and kurte.

i just thought i would check.
would have compiled the code myself, its just im not set up yet. wife nagging about the mess. i could only blame the child! LOL.

cheers.

OK my next question is…

i wish to add a time dalay to the servo so that when i move the stick 'say to the left, i want the servo to take longer to complete the rotation!

how do i add this using BApro?

[code]
IF (DualShock(2).bit1 = 0) THEN ;R2 Button test
TravelLengthX = -(Dualshock(5) - 128)
TravelLengthZ = (Dualshock(6) - 128)
ELSE
TravelLengthX = -(Dualshock(5) - 128)/2
TravelLengthZ = (Dualshock(6) - 128)/2
ENDIF

  TravelRotationY = -(Dualshock(3) - 128)/4
ENDIF

		 BodyPin=  (((Body_Max - Body_Min) * ((TravelLengthZ + 64 ) & $7F) |
	/ 127 + Body_Max) min Body_Min) max Body_Max [/code]

Hi Innerbreed,

Correct me if I’m wrong but I think you want to increase the time it takes to get the servos from A to B. The servos will travel at a lower speed.

The easiest ways to do this is by increasing the SSCTime. This changes the speed directly. Here is a snippet taken from the main loop. Check for the SSCTime. The NomGaitSpeed is separately defined for each gait. You can increase it there. The speed for body rotation and shift is defined 200 in the snippet shown down here.

[code] IF(HexOn)THEN
;Wait for previous commands to be completed while walking
IF(ABS(TravelLengthX)>TravelDeadZone | ABS(TravelLengthZ)>TravelDeadZone | ABS(TravelRotationY*2)>TravelDeadZone) THEN

  pause (PrevSSCTime - CycleTime -50) MIN 1 ;	Min 1 ensures that there alway is a value in the pause command
  
  IF(BalanceMode=0)THEN
  	SSCTime = NomGaitSpeed + (InputTimeDelay*2)
  ELSE
  	SSCTime = NomGaitSpeed + (InputTimeDelay*2) + 100
  ENDIF
  
ELSE
  SSCTime = 200 ;NomGaitSpeed
ENDIF
	
GOSUB ServoDriver

ELSE[/code]

You should play with those numbers to see what the effects are.

Let me know if there are any problems.

Xan

thanks for your reply Xan.

will this slow all the servos or just the one. i should have explained it better. say if you was running a "phoenix with a camera mounted on the body. i would want the gaits to remain the same "normal speed but the camera servo to travel at a lower speed.

EDIT:NomGaitSpeed is separately defined for each gait. Got it!

The solution I gave you slows down all the servos indeed. You can slow down a separate servo by using the “Sâ€

do you have an example?
would it look something like this

"#0P",DEC servo0pw,"T",DEC movetime,13]

when i was programming on an older IDE with atom28 id use the “T” + #
ie, T200#.

thinking it should look like this:

BodyPin= (((Body_Max - Body_Min) * ((TravelLengthZ + 64 ) & $7F) | / 127 + Body_Max) min Body_Min) max Body_Max WITH MOVETIME HERE?

BodyPin= (((Body_Max - Body_Min) * ((TravelLengthZ + 64 ) & $7F) | / 127 + Body_Max) min Body_Min) max Body_Max | serout SSC_OUTPUT,SSC_BAUT,BodyPin,"T200",13]?