Building the Duinotech Pan and Tilt Bracket (Part 1)
As part of our mission to build Alexa M (a Raspberry Pi based robot with voice recognition), we have decided to include an ultrasonic sensor and/or camera. To that end we will include a pan/tilt bracket with a couple of servos.
While they are cheap, construction details are best described as scant (or perhaps missing). You do get a before and after shot, but the after shot only shows one servo.
It looks like Adafruit supply a similar unit, so here are the construction details from them.
Assembling the Base (Pan Unit)
Insert the servo into one side of the pan bracket.
Make sure that the servo shaft is at the opposite side from the pivot point for the tilt bracket.
Assemble the second side of the pan bracket to enclose the servo.
Attach the two halves of the pan bracket using two of the small screws.
Attach the 4-armed servo horn to the servo shaft using one of the short screws as shown.
Use one of the shorter screws to attach the base to the servo shaft. The longer mounting screws packed with some servos will damage the servo if screwed in too far.
Align the servo horn so that the longer arms are vertical when the servo is at the midpoint of its rotation - don't worry too much about this you will need to move it when you calibrate the servo.
Attach the base to the servo horn, using 4 of the smallest screws as shown. I had to trim the horn so it would fit in the base.
Before assembling the tilt bracket in the next post we will test our pan servo with the Raspberry Pi and create a servo library that we can reuse.
You will see in the comments below that some time in 2021, something changed with the Duinotech 3-axis magnetometer and the Honeywell HMC5883L Arduino libraries stopped working.
I recently purchased a new module and compared it to the original I bought in 2015. They are very different, in particular there is one less pin and the magnetometer IC and supporting components have changed.
I've done a full write up on the Reefwing Medium site. If you can't be bothered reading this, the new chip being used is the Memsic MMC5883MA. I list some compatible Arduino libraries in my article - so you should read it!
*******************************
At a recent mini maker faire, I purchased the duinotech 3 Axis Compass Magnetometer Module (Part Number: XC-4496) from the Jaycar Electronics stand. I thought this would be handy for calculating heading information for AVA the robot.
Unfortunately, the module comes with no instructions and just these very brief specifications:
Operating Voltage: 5VDC (or 3.3 VDC)
Resolution: 12 bits
Interface: I2C
Includes: 5V to 3.3V level shifter (so you can operate it from 5 VDC)
Dimensions: 20(L) x 16(W) x 5(H) mm
We know that the module communicates via I2C but without knowing the module address or the available instructions, this isn't much use. No problem, I'll head over to the Jaycar website and look up the technical specs. Bzzzzzzzt! If you click on the link above, you will see the only information provided is the specifications printed on the packaging. It appears that Jaycar are moving away from Freetronics for their Arduino compatible boards, shields and sensors to duinotech a Chinese manufacturer. I assume they are doing this based on cost, the Freetronics stuff is good quality and very well documented.
2. Honeywell HMC5883L 3-Axis Digital Compass IC
If you have good eye sight you will see HMC5883L printed on the PCB. A quick google will determine that this is a 3-Axis Digital Compass IC produced by Honeywell. The HMC5883L Data Sheet is very comprehensive and requires everything that you need to interface the chip to an Arduino via I2C. The duinotech module is apparently a break out board for the HMC5883L, similar to the one produced by SparkFun. It is in fact an improvement on the SparkFun version in that it can be driven from 5VDC and the interrupt line is also broken out.
3. HMC5883L Arduino Library
Armed with the data sheet you could work out how to get the module talking to an Arduino but as usual, a number of people have already done the hard work for you. I ended up using a library written by Korneliusz Jarzebski, a Polish chap. The HMC5883L Arduino Library is accompanied by a tutorial, which is in Polish but google translate does a pretty good job of converting this to English.
One thing that the library is missing is the keyword definition file which the Arduino IDE uses to colour highlight defined library names and methods. I have produced a keywords.txt file for the Jarzebski HMC5883L Library which you are free to download and use. It includes all of the public methods exposed by the HMC5883L class.
To use the library, create a folder called HMC5883L in the Arduino libraries folder. Within this copy the HMC5883L.h and HMC5883L.cpp files from the Jarzebski Github repository and the keywords.txt file. Also create a sub folder called examples and copy the HMC5883L_calibrate, HMC5883L_compass, and HMC5883L_simple files into it. You will need to restart the Arduino IDE to see the new library. The HMC5883L_simple sketch example shows how to use the library and test your module.
Here is a quick video which shows the HMC5883L mounted on my robot AVA. On the OLED screen you can see when the compass is connected and the observed heading when the text scrolls up.