This is my first post to this forum. I am fairly experienced in electronics, but am in the process of learning C, Arduino coding, and how to use microcontrollers in general for various applications.
I have a toy-like 5 degree of freedom (DOF) robot arm that is currently controlled using the OEM hand-held switch box. It is a basic electromechanical robot arm to illustrate the fundamentals and it uses DC motors to drive the joint motions. The direction of motion is controlled by changing the polarity of the applied voltage. The manufacturer did offer an "interface board" and SW to be able to hook up the arm and control it using a computer program. However, this approach was fairly dated and their SW was not compatible with windows 8.1. I wanted to experiment and use an Arduino Uno Rev 3 and 5V DC relay PCBs to develop my own interface system.
Basically, the HW aspect was straightforward and is working fine. The Arduino SW also is working fine. I am playing around with 2 variations of the program: 1) One program that simultaneously moves up to 3 joints and 2) A sequential joint movement program where each joint only moves after the other has finished moving. One note about the simultaneous program is that I am using the "internal" batteries in the robot's base (only 3V each direction) and thus can not realistically move more than 3 joints at the same time without putting too much load on the source voltage.
Ok, now to my question! As it stands now, the program works well, but is not intuitive. Each joint has 2 relays associated with it: one for each direction of travel. There are 5 joints total in the robot arm. I am able to use the program easily since I know directly (from setting up the HW and then the SW) which relays correspond to which Arduino pins and of course which relays correspond to each joint. I'd like to make the program more intuitive where instead of "2,2,0,0,3,4" input string for example, the user would do something like "B,CCW,S,CW" where B is for B = base, CCW = is counter clockwise etc.
Please note that in the numerical only input string "2,2,3,4" for example, the 2nd value corresponds to the duration in seconds that the relay will be ON (and thus the joint moving). The robot arm is not very sophisticated in that it doesn't have encoders for position feedback. The simplest way (and the method which the OEM interface board uses) to interface this arm and make a program where the arm will move in a "hands-off fashion" was to use relays and program delays (to create time durations of joint movement". The numerical only input works really well currently and it was very easy to use examples to figure out how to parse a comma separated string.
I understand (I think) from looking at the examples how to parse a comma separated text string and pull from it the input values.
BUT, I am uncertain how to use those input values and then associate them in the SW with the correct relays (Arduino Pins)!
I have already tried seeking help with this but am unable to understand this thread: http://forum.arduino.cc/index.php/topic,94701.0.html
Basically, I need a 2D table where the joint and direction are input and then the SW associates one particular relay with those inputs. Please see the table below for a graphical example of what I tried to say above.
One possible solution that I dread and saw mentioned was to use a ton of if else-if statements.... I dread this since I want to be able to input any joint in any order and thus it seems like when the code parses the input string for the ith relay, it would have to check ALL of the conditions to see which joint it is, which direction etc. For example, I think I could minimize the # of if statements needed if I only entered in the input commands in a certain order: base first, shoulder next, etc. Doing so however, limits the intuitiveness of the program.
Thank you all for reading this! I hope this isn't too challenging!