Source Code on GitHub
Autonomous Crane | Hexapod Walker
System Architecture | Software Design | Electrical Design | Mechanical Design
The OpenCM is powered by the two 3.7V batteries (connected in series to create 7.4V). The OpenCM is connected to the XL-320 servos by 3-wire cables. The first two wires connect the servos to the Vin (7.4V) and Ground used by the OpenCM, while the 3rd wire is used for serial communication with the servos. The OpenCM communicates with the servos using the Dynamixel protocol v2 - a one-wire, half-duplex, multi-drop UART protocol that allows multiple servos to be daisy-chained from the same port on the microcontroller.
The NC (normally closed) and NO (normally open) connectors on the contact switch are conected to the 5V and Ground pins, respectively, of the OpenCM, while the switch's input pin (State) is connected to pin P15 of the OpenCM to sense whether the switch is pressed (State is low) or not (State is high). Additionally, the ultrasonic sensor's 5V and Ground pins are connected to the same pins on the OpenCM for power, while the trigger pin is connected to pin P8 and the echo pin is conected to pin P9 on the OpenCM. The OpenCM pulses the sensor's trigger pin high to start a reading, and in response the echo pin is held high for as long as it takes the ultrasonic ping to return to the sensor - which is linearly proportionaly to the distance the ping travelled to the nearest object.