The code for this project was done entirely in Arduino, and consisted of processing the electrical output, robotic firmware, and interacting with user through an Arduino serial port.
In order to interface with both the electrical and mechanical subsystems, we need two continuous thought processes. Because of processing limitations, each subject was uploaded onto its own arduino. The first dealt with interfacing with the electrical subsystem and continuously interpreted and processed the beat signal. This “sense” arduino needed to be run first, to start printing values to the serial port that the second arduino would base its logic on. The second was characterized as a “think/act” arduino. The “thinking” takes in and processes the raw bpm information, and the “act” interfaces with the mechanical system. The two communicated over open serial ports, however information was only sent one way from the sense to the act arduino.
The sense arduino is responsible for interfacing with the electrical system, and converting the “beat” signal into information for the motors to use. The DC wave is read through an analog pin, and debounced to the eliminate the inconsistencies and faults inherent in the electrical detection.
In order to interface with both the electrical and mechanical subsystems, we need two continuous thought processes. Because of processing limitations, each subject was uploaded onto its own arduino. The first dealt with interfacing with the electrical subsystem and continuously interpreted and processed the beat signal. This “sense” arduino needed to be run first, to start printing values to the serial port that the second arduino would base its logic on. The second was characterized as a “think/act” arduino. The “thinking” takes in and processes the raw bpm information, and the “act” interfaces with the mechanical system. The two communicated over open serial ports, however information was only sent one way from the sense to the act arduino.
The sense arduino is responsible for interfacing with the electrical system, and converting the “beat” signal into information for the motors to use. The DC wave is read through an analog pin, and debounced to the eliminate the inconsistencies and faults inherent in the electrical detection.
A continuous reading loop is run to determine the times between the detection of beats in the signal. A function would then take this period and store it. The signal is sampled five times to account for inconsistencies, then sent onto the next stage of code, which converts period to bpm to allow for easier user comprehension. This information is then sent across the serial port to the second arduino.
The main loop of the act arduino contains an extensive user interface via serial. There is a large array of commands, defined at the bottom of the page. This user interface is set up to account for the phase shift between the original signal, and the beat that the robot plays. The user can press keys to temporarily increase or decrease the amount of time the robot waits between each time it plays. Having these keys allows the human controller to manually sync the robot up with the beat. The UI also has commands for starting and stopping the robot to allow for easier control over plugging and unplugging power cables.
The main loop of the act arduino contains an extensive user interface via serial. There is a large array of commands, defined at the bottom of the page. This user interface is set up to account for the phase shift between the original signal, and the beat that the robot plays. The user can press keys to temporarily increase or decrease the amount of time the robot waits between each time it plays. Having these keys allows the human controller to manually sync the robot up with the beat. The UI also has commands for starting and stopping the robot to allow for easier control over plugging and unplugging power cables.
The goal was to create a robotics drummer, not a drumming machine, meaning we wanted to emulate the physical motion and presence of a drummer. We wanted to have a wrist flick in the arm. To create this motion, the arm travels up first, pauses briefly, then hits down to carry momentum into the wrist, creating the flick. The rest is necessary to maintain a smooth pattern and prevent putting too much stress on the mechanical system and generate issues between the gears and belt. To control how long the arm was to raise, rest, or strike, we use timer loops instead of the in-built arduino delay so that this arduino is able to continuously read information from the first. The arm moves up and down at different speeds and for different lengths of time. When the arm moves down, it moves faster because of the physical weight of the arm. If pushed too fast, this can result in belt skip. However, we also want the downward stroke to be fast enough to generate a flick motion. The downward motion comes out to be slightly faster than the up-stroke to generate the flick, but is run for a much shorter amount of time to account for the mechanical slipping. The two times and speeds on the arm are manually tuned to prevent belt drift.
The foot was to travel up then down to press the kick drum foot pedal. Unlike the arm, the foot position is based off of a potentiometer rather than time. With the potentiometer, we were able to establish a very consistent range of movement.Due to the power of the motors, they would occasionally drift past one of the potentiometer bounds. To correct for this, we check if the foot is outside of the upper or lower bound every time it moves. If the status is such, the motors drive in the appropriate direction until the potentiometer is inside the desired bounds.
Both limbs use roughly the same method of calibration to play at the right speed. Each is actuated accordingly, then rests for some determined amount of time until it is time to play again. This time is determined as a function of the period of the electrical signal, and the time each takes to run. Just as the limb starts to move, the time is recorded. As soon as the limb finishes its movement, the time is recorded again. The difference between the two is subtracted from the period, and the limb rests for that amount of time.