Disclaimer: I am neither an EE major or electrician. What follows is based upon my understanding of the task which may or may not be correct. This applies to wiring “design”/implementation as well as how the software interfaces. By following my examples for wiring and by downloading and using the software you assume all responsibility.
Assembly of robotic arm purchased from Aliexpress. This arm consists of 6 servo motors featuring metal gears. The motors are: Tower Pro – MG996R. This kit provides more parts then are required. I suppose this is because the base is multifunctional and depending upon how you assemble it those additional parts might be employed.
Pictures may be double clicked for expanded view.
The following table will attempt to show/explain the wiring configuration for the above arm (6 servos) and the Adafruit motorHAT. Because of the attributes of the motors employed it was not possible to connect the motor’s servo cable to the 3 output pins on the HAT. These motors would overload the HATs capability so the motor’s signal pin was connected to the HAT’s signal pin and the motor’s +/- wires are connected to a common +/- busbar (in this case a beefed up Adafruit 1/2 siezed Perma Proto board. The wiring for a single motor would look like this:
For six servo motors the 6 V batter pack’s + lead would run to a + bus bar and then to each motor. There are some photos later of this wiring setup.
The video below is based upon the Adafruit 16-Channel PWM / Servo HAT for Raspberry Pi. I have written a short python app to interface to the HAT and control 6 servo motors between their min/max servo positions. For those of us new to servos I feel that this app will help understand how to control the servo in real time. This should help also with defining your servo’s “servoMin and servoMax” parameters. Just be sure to move slowly. If your are not careful you can push the servo beyond in min and max offsets and possibly strip your servo’s gears or cause other damage.
If your servos have a total swing of 180o then you can move the servo using degrees once you have determined servoMin/servoMax. You need to convert degrees to a value between servoMin and servoMax. Here is the formula
rawrange = servoMax – servoMin
pulseLength = (degrees / 180) * rawrange + servoMin
so if you want to move your servo to 30o:
servoMin = 150 (this would be 0o)
servoMax=450 (this would be 180)
rawrange = 450 –150
pulseLength = (30/180)*450 + 150 = 225 (moving your servo to this value would be 30o from the servoMin position
channel# will be the 3pin connector you have your servo connected to on the Adafruit HAT
issue the command: pwm.setPWM(channel#, 0, pulseLength)
Regarding the videos and software. I have removed the video for single servo control and replaced it with a newer video showing the control of all 6 motors and two leds. I have removed the software for single motor control and replaced it with the new software for all 6 motors and leds. You can use the 6 motor software to test a single motor. In fact I would recommend this until you figure out your servoMin/servoMax values and frequency setting. If I had to to this again I would have had the servos free standing (no arm) to check out their functionality.
Two downloads follow (they require the use of an Adafruit servoHat):
- the first will help you determine your servo motors minimum/maximum displacement. It sets the following values: servoMin and ServoMax to 100 and 600 and calculates the middle offset, ServoMiddle. With the gui you will be able to control the servo and determine the values of servoMin and servoMax for your servos.
- NOTE: Regarding the led control portion. You cannot plug a led or two directly into the servo. You must design your own small pcb with resister. ALSO: the program set channel 15 for the led control. Be sure to use this channel only for your leds. If you plug a servo into this channel then you will mostly likely overdrive your servo and damage it.
- the second will control a robotic arm with 6 servos and brighten/dim two leds. This second download set values for my setup. You will need to look at servoMin, servoMax. frequency, the initialization values, etc. and adjust as necessary for your setup.
The following table attempts to show current loading on the arm for:
- all servos as measured on the common + bus
- a single servo. I chose #2 because it has to support the entire arm and I wanted to know the current required for this effort. The other servos with the exception of #6 would have less work to do.
The following table shows voltages across the Servo5’s lines – Orange, Red, Brown at various slider settings
|Servo5 slider values||120||200||300||400||500||530||after “quit”|
|2 LEDS – slider values||0||200||300||1400||3100||4095||after “quit”|
Note: OR + OB = RB seems to be true. Some variations occur. Could be interpretation of meter or not waiting for meter to settle.
LED values are coming strictly from the ServoHAT, i.e., the signal pin (O) and 5V+ (R) pin at various slider settings.