I have never programmed a PIC and I need help in controlling 3 motors (they can be any combination of Stepper or Servo motors). After I make my project description maybe members can suggest which I use where.
I have a robot arm basically, which has a camera on its "palm". So basically the arm senses the colour (through a MATLAB code which generate the RGB values). After sensing the colour, the arm has to pick and drop it at the appropriate box. There is a Red box, Blue box, Green box, and "Other" box. The color communication is done by communicating with the computer through RS-232, and MAX-232
The robot arm consists of 3 motors, motor 1 at the base for the rotational motion to face before a particular box. Motor 2 for the ascending and descending of the arm, Motor 3 for gripping and dropping. So for a given color, only the action of motor 1 will vary, 2 and 3 remain the same because they only are for picking and dropping.
I still haven't decided whether to use these as servos or steppers, or in what combination. A diagramatic representation might help (I've tried giving a 3D effect):

So first I need a suggestion on the motors for now I am thinking Motor 1 - Servo, Motor 2, 3 - Stepper. Then I need help with the program from scratch as I have never worked with PIC!
******************
But this is the general program "blocks"/structure I have thought (motor 1 = M1, motor 2 = M2, motor 3 = M3):
---------------------------------
1. Initialize registers
2. All motors in original position (M1 - facing pick up box, M2 - ascended, M3 - "drop"/"open palm" position).
3. Descend_action (M2) (now with the palm open, the camera faces the single-color object closely)
4. Enable hex read of RGB codes through RS-232
5. Receive hex data
6. Disable hex read of RGB codes through RS-232
7. Grip_action (M3)
8. Ascend_action (M1)
9. IF (red condition)
move M1 to face red box
ELSE
{
IF (blue condition)
move M1 to face blue box
ELSE
{
IF (green condition)
move M1 to face green box
ELSE
move M1 to face "other" box
}
}
}
10. WHILE (M1=red condition||M1=blue condition||M1=green condition||M1=other condition)
Descend_action (M2)
WHILE (M2=descend_action && (M1= condition 10.))
Drop_action (M3)
WHILE (M3=drop_action && (M1=condition 10.))
Ascend_action (M2)
WHILE (M3=drop_action && M2=ascend_action)
move M1 to face pick up box
11. GOTO 2.
-----------------------------------
I think the logic is right, but I would like to know if there is any possible mistake. After that I guess I could try the actual code of the PIC.
thanks.
Good Answers:
"Almost" Good Answers: