Help for 2012 Science Olympiad Competition!

Hey, I need help with the new program.

It works a lot better than the old program now!!! But, there are two things i need to be different.
First, the Home postion interferes with the circuit boards, the shoulder moves so far down. Where can I change the distance variables for that? It almost broke the SSC-32! :open_mouth:
Also, the wrist rotate always goes back to its farthest postion to the left once promped to move out of the home postion. It’ll rotate all the way clockwise to the right, but once I release the button during that process, the wrist goes back to the far left. Can i stop that from happening in the program? It makes it difficult to hold the wrist at the angle i want it to be. :confused:

Which program are you using?

BAsic micro studio
Also another note:
The gripper and HD rotate contols are switched, left side for the wrist and right side for the gripper but they should be the other way around.

Actually what I was trying to ask was are you using the program that you can download as part of the tutorial or from your later comment, I believe that you are probably using the PS2ARM1.bas.

Awhile ago I was playing with the Arm code while is was attached to rover and I had problems as well with it going to the init location hanging up on things… So I experimented with a two step Arm Init which if the arm was below would first move it up a safe position and then back to the init position. This helped on the rover version. I hacked it into the Ps2arm1.bas version for my configuration AL5D.

The actual init location goes to the position defined in:

InitWristPosX con 55 ;Init position X InitWristPosY con 120 ;Init position Y

The code I hacked in is condition on another position being defined…

InitWristPosXP con 55; 55 ;Init position X - Pre - may do init in two steps to keep arm from hanging up InitWristPosYP con 300 ;Init position Y

Again I only defined in in the AL5D version I uploaded here. But could try in any configuration.

Kurt
ps2arm1.bas (34.8 KB)

Please provide more information. Where do you see these controls being switched? An assembly guide, the instructions for controlling the arm, and left and right side of what exactly? :open_mouth:

A couple of things.

  1. Found an another issue with ps2arm1.bas. It appears like when you release the L1 button, the gripper returns back to a center location, which I don’t think is correct. I updated that code to use the same variable that L2 code used to update the gripper… Appears to work fine for me now…

  2. When you say that L1/L2 is switched with R1/R2 in usage. I think instead that maybe your servos are reversed. That is the gripper should be controlled by Pin 4 on SSC-32 and the Rotate is controlled by Pin 5. Maybe you have these two reversed.

Here is the updated program.

Kurt
ps2arm1.bas (34.8 KB)

Yes, you are correct Kurte, i am using the new ps2arm1.bas program. I will give your rover program update a test tomorrow! But did those changes you showed above affect the wrist rotate only? And did you reconfigure the arms start postition so at least the shoulder isnt so far back or no?

And I’m talking about on the ps2 remote; R1 and R2, which should be controlling the Wrist Rotate, are in fact controlling the Gripper opening and closing, and vice versa with the L1 and L2 buttons. I will check to make sure the pins arent switched up in the mess of zip-tied servo wires and extensions.

Thanks for your help!!!

Is there any way to make those changes for the version that has backhoe-mode as well? For that version the home position is fine when you hit the cross button, but when you first turn it on it goes straight down into the ground!

As I mentioned in a previous response, I put a hacked up 2 step init, which may help. If not you can try experimenting by modifying the two init’s that correspond to your arm

InitWristPosX    con 55   ;Init position X
InitWristPosY    con 120 ;Init position Y

As for backhoe-mode, yes it is doable, you can easily look at the program I uploaded here with it. It has the code all under ifdef (#ifdef enable_catmode). Should not be very difficult to add the similar code to the ps2arm1.bas program but for now I will probably get back to working on my own projects. Good Luck!

Kurt

Thank you so much Kurt everything is working great. We switched the wires and all the controls are correct. Now how can we change the home position of the arm? The shoulder goes way too far back and it could damage the electronics.

Read Previous post. If I were you, I would probably try changing the X value…

Kurt

Oh, sorry. Must’ve missed it.

So I tryed to change the x value under AL5D IntiWristPosX, but nothing happened that changed the shoulder… any other suggestion???

Works for me:
First off you need to make sure to update the values you are updating coorespond to the ARM you have defined…

In My case: AL5D con 1

Then I used the two step stuff I mentioned. For mine I tried:

#ELSEIFDEF AL5D HumerusLength con 147 ;Length of the Humerus [mm] UlnaLength con 187 ;Length of the Ulna [mm] InitWristPosX con 90;55 ;Init position X InitWristPosY con 150 ;Init position Y InitGripperAngle1 con -550;Init Angle gripper #if 1 InitWristPosXP con 90; 55 ;Init position X - Pre - may do init in two steps to keep arm from hanging up InitWristPosYP con 300 ;Init position Y #endif #ENDIF

Kurt

GOT IT! Thanks so much for the help. :laughing:

Okay, I have a couple new changes I need; can someone point to me where i can change the limit of the elbow servo, I need it to be able to go further down to get objects that are close to the arm.
Also Im not quite sure but can a magnet, rare earth magnet to be more specific, damage a servo if it makes contact with it? I had the idea of using one to help pick up metal objects better.

Is this section in the upper portion of the program named [MIN/MAX ANGLES] the part I am looking for?

[code];[MIN/MAX ANGLES] Degrees * 10
Base_MIN con -900 ;Mechanical limits of the Base
Base_MAX con 900

Shoulder_MIN con -780 ;Mechanical limits of the Shoulder
Shoulder_MAX con 900

Elbow_MIN con -710 ;Mechanical limits of the Elbow
Elbow_MAX con 450

Wrist_MIN con -900 ;Mechanical limits of the Wrist
Wrist_MAX con 900

Gripper_MIN con -720 ;Mechanical limits of the Gripper
Gripper_MAX con 680

WristRotate_MIN con -760 ;Mechanical limits of the WristRotate
WristRotate_MAX con 830[/code]
I tried changing these constants, but didnt see a difference in arm movement.

And Im also looking to speed up the servos too…is this possible in the program?

[code]IF ABS(Dualshock(5) - 128) > DeadZone THEN ;Left Stick L/R
IF IKSolutionWarning THEN ;Allow only movement to the base
WristPosX = WristPosX -((Dualshock(5) - 128)/18) MIN 0 ;X Position
ELSE
WristPosX = WristPosX -(Dualshock(5) - 128)/18 ;X Position
ENDIF
ENDIF

IF ABS(Dualshock(6) - 128) > DeadZone THEN ;Left Stick U/D
    IF IKSolutionWarning THEN
      IF WristPosY > BaseLength THEN ;Allow only downward movement
        WristPosY = WristPosY -((Dualshock(6) - 128)/18) MIN 0	        
      ELSE ;Allow only upward movement
        WristPosY = WristPosY -((Dualshock(6) - 128)/18) MAX 0      
      ENDIF
    ELSE
      WristPosY = WristPosY -(Dualshock(6) - 128)/18 ;Y Position
    ENDIF
ENDIF

IF ABS(Dualshock(3) - 128) > DeadZone THEN ;Right Stick L/R
    BaseAngle1 = BaseAngle1 -(Dualshock(3) - 128)/4 ;Base Rotation
ENDIF
  [/code]

I tried changing the 128/18 variables to a lower number like 10 instead of 18, but i dont notice a big difference. Also, the arm now has gotten to the point where the shoulder servo will not go as far forward as it used to, meaning like instead of it moving about 180 degrees from almost flat over the electronics to a forward postion away from them, it stops at about 120 degrees in the air. I didnt change the Mechanical limit of it posted above^^ and it was hot when this was occuring…problem?? :neutral_face:

**note AL5D arm, BB2, BAP 28, and SSC-32 all connected up to par.

I would rather play with some other stuff, but did take a little while to play some more with the code, to take care of a few things I did not like. Things like why it took so long after hitting the start button, until it did something. Also some of the timings. Likewise the wrist angle would hang when you got to the end as the underlying value would keep incrementing or decrementing, but the variables that were set from these were limited… So some of the changes that are different in this code from the one is part of the tutorial include:

  1. I have an optional 2 step arm init that moves the arm up slightly before going to the actual start/stop position. I needed this at times when the arm stretched out, it would hang up…
  2. I changed the start position for AL5D to be farther out… Sort of arbitrary but wanted it out a ways…
  3. Have a little more control of speed. I made 4 byte tables:

abWXSpeedDivisor bytetable 18, 12, 8, 4 ; Wrist Pos X Speed divisor (Left joy stick Left/right) abWYSpeedDivisor bytetable 18, 12, 8, 4 ; Wrist pos Y (Left Joy stick up/down abBSpeedDivisor bytetable 8, 4, 3, 2 ; Base rotate speed (Right Joystick Left/Right) abGSpeedDivisor bytetable 4, 3, 2, 1 ; Gripper Angle speed (Right Joystick Up/Down)
These tables are what different divisors that are used speed up or slow down movements that are controlled by the PS2 joysticks. I up using the D Button Up and Down buttons on the joystick to control which speed to use… If these values don’t work for you have fun and experiment. You can also add more tables and maybe use it to control how fast the gripper closes…

  1. On the Wrist angle (right joystick up and down), I added a hack in that keeps the value calculated from the joystick to a reasonable value… So that if you hit the limit and still holding joystick up or down, when you finally go the other direction, the servo will actually move…

Currently the code is configured for AL5D with SSC-32.

Kurt
ps2arm1.bas (35.7 KB)

Thanks for the programing help. Can you give me an example of how I would add a table to make the gripper close faster? Im not quite sure where it should be or what to write in the program.

abGOSpeedDivisor bytetable 18, 12, 8, 4 ; Gripper Opening/Closing Speed (L1/L2)

Ive been trying different numbers for the gripper, but no such luck. its labeled GO for Gripper Open, and I’m not sure how the program would know what servo i want it to control.

Sorry don’t have time to do everything. What have you tried? But some simple hints.

As you know the gripper close is controlled by the L1 and L2 buttons of the PS2. So have you done a search for example L1? If so you will quickly see the lines:

IF (DualShock(2).bit2 = 0) AND (GripperPressure>GripperHoldPressure) THEN ;L1 Button test TargetGripper1 = (TargetGripper1-40) min Gripper_MIN ;Gripper Close ENDIF
So it appears like it is modifying a variable by subtracting 40 from it. What happens if you use 60 instead?

To make it table driven maybe define your table like:

abGOModifier     bytetable 20, 40, 60, 80         ; Gripper Opening/Closing Speed (L1/L2) 

Then change:

TargetGripper1 = (TargetGripper1-abGOModifier(ArmSpeedSelect)) min Gripper_MIN ;Gripper Close
Again did this on fly not sure if 100%. Need to do similar for L2. Maybe different table for R1/R2…

Kurt

Thanks man, i do apreciate this^^^ Im still a noob at programing.