The overall motion of the robot can be broken down into four different actions; rolling about the pipe's central axis, moving linearly along the power screw, rotating the marker mount and pivoting the turret to leave a mark on the page. The rolling and linear motion were controlled by stepper motors and drivers while the two turret movements were controlled by servos. The two forms of actuation had to be handled in different ways but coordinated in order to ensure that the marking took place as expected.
Both the power screw and the roller were actuated using bipolar stepper motors. Steppers were chosen to allow for high precision movements with minimal need for feedback control from encoders or other sensors. The motors themselves are actuated by a well timed series of oscillations between HIGH and LOW in the two coils in order to produce the desired movement. Although these rising and falling signals can be generated on the RIO, the motors require a larger current and voltage than what the RIO can provide. As a result, stepper drivers were used as an interface for the RIO to control the motors. The drivers allowed for an external, 12 V source to be used as the power supply for the motors and, depending on how the drivers were wired, could execute full or micro-steps.
Since the motors needed to exert a considerable amount of torque and the torque per microstep decreases as the number of microsteps is increased, the drivers were wired to only execute full steps. In other words, the smallest radial step possible, given the specifications of the motors used, was 1.8 degrees. This step angle, combined with the mechanical advantage of the power screw, resulted in approximately 2000 steps for one inch of linear movement. In regards to the roller, the large diameter of PVC pipe used meant that the smallest resolution possible in the rolling direction was ~0.1 in. This comparatively large resolution posed no problem since a smaller movement would have resulted in overlapping points in the painting.
Controlling the drivers from the RIO was quite straightforward; the motors direction was dictated by a HIGH or LOW to the "DIR" pin and every rising edge on the "STEP" pin would result in a step. These signals were interpreted by the drivers themselves, which then relayed the appropriate pulses to the coils. At first, the pulses from the RIO were sent as quickly as possible; however, the motors had difficulty keeping up due to the torque required to get moving. In order to compensate for this, delays were added between pulses. The delays for the rolling stepper came out to be much longer than the delays for the power screw (~10 times longer).
The servos used for the turret actuation were 180 degree hobby servos. These servos were powered from the 5V output on the MakerBoard provided in the kit and controlled using PWM signals. The on-board electronics convert the signals into a specific position and use a potentiometer and control loop to keep the servo at the specified angle. As a result of this control, the servos are well suited for high torque, limited range motions.
This was ideal for the turret application since both toque and precision were required, but there was no need for rotations greater than 180 degrees. When the software reached a new point in the reduced image array, it first switched to the correct color position. Each color was assigned an angle that corresponded to its location on the turret. These angles were converted to corresponding PWM signals sent out by the RIO and the turret would turn to the needed color position. Actuating the servo at the base of the turret was much simpler; only an UP and DOWN position were needed. If a color was detected in the array, the turret would swing towards the roller; however, if the color found corresponded to the background, the turret would stay in the UP position.
Much like the stepper motors, the coordination of the servos required proper timing and delays. Since the program runs much faster than the servos can move, delays of nearly 0.75 seconds were needed between servo movements to ensure that the system had settled before moving forward.
Since the stepper motors have no feedback to indicate their absolute position, it is impossible for the program to ensure that the the roller or linear screw are in the expected location. Through testing, it became apparent that, within the usable range of the power screw, the stepper did not miss many steps. If a few steps were missed, their effect was generally negligible since individual steps contribute very little to the linear movement. However, it was found that the rolling stepper often missed steps - especially when changing directions - due to increased torque. This often resulted in a noticeable drifting of the points drawn relative to the starting location.
In order to resolve this problem, an optical interrupt was added to act as a homing system. The optical interrupt is composed of an emitter and a detector set up across from each other. By blocking or opening the path between the two parts, the apparent resistance of the detector varies. By putting it in series with another resistor and creating a voltage divider, the interrupt could essentially be used as a switch. The homing sequence consisted of taking single steps backwards on the roller until the interrupt detected that its path had been obstructed by a small protrusion on the PVC pipe. At that point, the normal actuation would resume with certainty that the first point would appear at the right height. To ensure that the homing system continued to work correctly, the paper was attached to the pipe in the same location relative to the protrusion such that the turret would start at the very top of the page.