Diagnostic Functions and Program

Discuss and share software for making your mePed navigate and move about in the real world
RockyMtnMark
Posts: 3
Joined: Sat Dec 30, 2017 4:23 pm

Diagnostic Functions and Program

Postby RockyMtnMark » Thu Jan 18, 2018 4:03 pm

I wrote and tested a couple of routines that may help others diagnose some types of post-assembly mePed issues. Two functions I've just incorporated into the distributed starter program for simple range testing of both the vertical (lift) servos, and horizontal (pivot) servos. The other is a stand-alone Arduino program that replaces the distributed mePed code, and allows the user to select each servo individually and test the full range of each, as installed on the mePed. Both are attached to this post.

I've uploaded both my updated mePed starter program (where I added the "test" routines to unused IR remote buttons 7 and 9), and my stand-alone test program (uses the Arduino SDK Serial Monitor for prompts and command entries) for use by anyone who wants to try them. The additional code is described below.

====== IR Remote Buttons 7 & 9 in mePed_IR_Starter_Program_X1.ino ======
--- CODE ---
mePed_IR_Starter_Program_X1.zip
Extension to standard mePed program - adds IR remote buttons 7 (squat / lift up) & 9 (rotate each leg).
(4.98 KiB) Downloaded 4529 times
--- OPERATION DESCRIPTION ---
In this modified "X1" version of the default mePed program, all I've done is add a couple of functions that are invoked by the currently unused IR remote buttons 7 & 9. To use these changes, you need to upload this program to the mePed from the Arduino IDE (development application *downloaded* from https://www.arduino.cc/en/Main/Software - see the posts "Programming the mePed" and "generating binaries" in this mePed Software forum).
  • Button 7, LIFT SERVO TEST - This button makes the mePed squat down evenly with all four legs, and blinks the L1 LED on the Arduino board slowly. After about three seconds, the mePed rises up fully on all four legs, and blinks the L1 LED more quickly for 3 seconds. It then settles down to the normal position. This tests the full down, then full up, positions of all four lift (vertical) servos of the mePed. You can check that all the lift servos are approximately fully down during the slow-blink phase, then that all the lift servos are approximately fully up during the fast-blink phase. Then all should be returned to the default (90 degree) position. If one or more servos do not match the expected position, or do not match the other servo positions, you may need to adjust the centering of one or more servos (or diagnose a failure).
  • Button 9, PIVOT SERVO TEST - This button makes the mePed lean to the right for balance, then lifts and rotates the front left leg to the left fully (approximately). While in this position, the L1 LED blinks once to indicate this is leg #1. After a few seconds, the leg is re-positioned fully right for a few seconds, blinking once again. The leg is then re-centered. This sequence is then repeated for the back left leg (#2), and the LED blinks twice for each full left/right position. The mePed then leans to the left for balance, and repeats the pivot tests (rotating each leg) for the back right leg (#3) blinking 3 times, then the front right leg (#4) blinking 4 times. By watching these leg pivot positions, you should be able to verify correct operation of all four pivot servos, and make any adjustment needed.
Note that these routines assume that at least the basics of the mePed is working to some degree (for balancing, etc.), since multiple servos are used for some positioning. If your mePed seems to have problems, you might try raising the body up off the table/ground to relieve weight from the servos - use a can, cup, or small box that does not interfere with mePed leg movements. Then see if these functions work better. If this does not help diagnose a problem, or for more controlled single-servo testing, you can try my stand-alone diagnostic program described below.

--- THE CODE ---
If you want to see what the code does, see the bottom of the program mePed_IR_Starter_Program_X1.ino (starting at line 714). I've added four functions:
  1. blink_led() - Used by the other functions to blink the L1 LED on the Arduino Nano board, as visual feedback for the current operation, so you can tell what SHOULD be happening.
  2. squat_lift() - Called when button 7 of the remote is pressed. Performs the sequence of positioning all lift servos to the lowest position, pauses, then lifts the mePed by setting all servos to the highest position, then re-centers all.
  3. pivot_arms() - Called when button 9 of the remote is pressed. Leans the mePed for balance as required, then sequences through all 4 arms to test the pivot left/right positioning.
  4. pivot_test() - A utility function called by the pivot_arms() function. Performs the pivot test function on a single specified mePed leg.
The two main functions (squat_lift() and pivot_arms()) are called by the remote button processing switch statement, lines 212 and 222 respectively.


====== Stand-Alone Servo Test Program mePed_TestServoRange.ino ======
--- CODE ---
mePed_TestServoRange.zip
Stand-alone test program to position mePed servos one at a time. Uses Arduino IDE Serial Monitor
(2.49 KiB) Downloaded 4409 times
--- OPERATION DESCRIPTION ---
If a problem cannot be determined by the original program or the additional tests above, it may be useful to test each individual servo on the mePed, without the additional load of moving multiple servos at the same time. Of course, this would also be useful to test each servo "out of the box" before assembly, to verify all servos work correctly before assembly, narrowing down mePed assembly issues.

This program allows you to position each servo to a specific degree angle, or fine-control the position using the Arduino servo library function "writeMicroseconds()" for even more control. It can also display the currently set position of each servo in degrees, as feedback after positioning. It uses the built-in "Serial Monitor" of the Arduino IDE for both entering user commands, and for display of instructions and result feedback. Thus, you need to upload this program to the mePed from the Arduino IDE (see the posts "Programming the mePed" and "generating binaries" in this mePed Software forum), and run it from the IDE's monitor. You must keep the USB cable connected between the PC and the mePed to send commands to and read feedback from the mePed.

Before using the program, place your mePed's body up on a support (like a can, small food storage container, cup, or small box) that allows full range of motion for each leg servo independently.

After uploading the program to the mePed, open the Monitor (Tools > Serial Monitor) from the Arduino IDE's menu. You should see the following menu:

Code: Select all

  mePed Servo Range Test

  Enter a number 10-180 to test angle in degrees.  Enter a number 650-2350 to specify Microseconds.
  Enter 's1' - 's8' to select a servo (1-8) for subsequent commands.  Servos control the following:
     s1 = Front Left Pivot Servo
     s2 = Front Left Lift Servo
     s3 = Back Left Pivot Servo
     s4 = Back Left Lift Servo
     s5 = Back Right Pivot Servo
     s6 = Back Right Lift Servo
     s7 = Front Right Pivot Servo
     s8 = Front Right Lift Servo
  Enter 'c' to center the current servo, or 'ca' to center all servos.
  Enter 'a' to display angles of each servo.  Enter 'h' to re-display this help.

  **CAUTION!**  Test range limits carefully to avoid servo damage!

  Currently selected servo is s1, angle=93
Servo s1 (front left pivot servo) is selected by default. Select any desired servo by entering "s" followed by the desired servo number (1-8) in the command line at the top of the monitor window, then press Enter (or click Send). Your servo selection will be remembered for future commands until you select a new servo. The new selection will be displayed at the bottom of the Monitor window.

To position the selected servo to a particular angle, enter just the angle number (10-180) in the command field. Angles smaller than 10 are not allowed, to help protect your servos as installed in the mePed (this is a limit I've chosen from my testing of mePed servo minimal mechanical positions).
**CAUTION!** Approach a minimum or maximum angle of ANY servo with conservative numbers, progressing from center (90 degrees) toward the angle limits, until you can verify the servo, as installed in the mePed, can mechanically move to that limit! For example, most vertical (lift) servo limit positions can NOT be reached with the mePed, due to mechanical limits (like link arm limits)! I have found that some lift servos reach their limit at only about 35 degrees (up) and 105 (down). Pivot (horizontal) servos may be limited by the servo body hitting the mePed frame. The program allows larger and smaller numbers so you can test full ranges of all servos, but note that there may be a large difference even between individual servos. BE CAREFULL and approach limits gradually. Servos will continue to attempt to reach the position requested, and could possibly be damaged if left "searching" (stalled) too long while being physically restrained.

You can also experiment with setting the servo angles using Microseconds instead of angles. Just enter a number between 650 and 2350 to set microsecond positions - the monitor will display the equivalent angle in degrees after setting the microsecond value, so you can see the equivalences. Again, BE CAREFUL WITH THE LIMIT VALUES - I've chosen the program's microsecond limits based on my experiments with my mePed, but individual servos may have very different limits, especially the lift servos!

--- THE CODE ---
Hopefully, the code is fairly simple and self-explanatory. There are comments throughout the code. Feel free to post questions on the Software forum if you need more explanation, and I'll try to answer them.

After testing/experimenting with this application, the original mePed application is available for re-loading from:
http://www.meped.io/sites/default/files ... gram_0.ino
Or, you can use the mePed_IR_Starter_Program_X1.ino program described above and attached to this thread. It is basically the same as the original starter program, but with the additional functionality of the test routines on buttons 7 & 9.

I hope some of this is useful to others!

Who is online

Users browsing this forum: No registered users and 7 guests