The purpose of the PC software is to translate a vector graphic into a list of steps for painting the imported image. These steps detail the current length of each belt, the speed of each motor, and the status of the actuator. These instructions are sent to the PIC, which follows the directions by controlling the motors and the solenoids, thereby drawing the picture. Converting an image into a list of instructions based on belt position requires several intermediate processes.
Our device specifies that the input image be in the form of a scalable vector graphic (SVG). SVG files are XML-formatted text representations of vector graphics. The first processing step, then, is to parse SVG’s XML to extract a list of paths. Within each path, SVG use single letter strings followed by zero or more coordinates to define how each segment of the path should be drawn. The instruction
['L', 5, 10], for example, directs the computer to draw a straight line from the current point to the Cartesian point (5, 10). More complicated instructions, however, rely on Bézier curves to describe how a curve should be drawn. In order to use this information, we must first translate the Bézier curve into a list of Cartesian points.
Once the SVG image is successfully parsed, we convert each of the Bézier path segments (curves) into a list of X-Y points. This process begins by determining the order of each Bezier curve (the number of points required to describe the curve). We then convert each curve into a list of discrete Cartesian points using the parametric definition for the order of the Bezier curve. The number of Cartesian points used in this conversion depends on the length of the curve. This is calculated using the formula for arc length of a parametric function. This software component also scales the image so that the largest Cartesian coordinate corresponds to the edge of our drawing area. In this way, we convert each Bezier curve into a list of Cartesian points which fit on the drawing area and closely resemble the imported image.
With our original image represented as a list of Cartesian points, we convert the X-Y points to a different coordinate system. In this system, each point is represented by its distance from the two motors, located just above the upper right and the upper left of the drawing frame. Converting between these coordinate systems involves basic geometry: each belt’s length forms the hypotenuse of a right triangle, with legs equal to the vertical and horizontal distances to each motor. This function also reads the single letter instructions from the SVG and translates them into either a 1 or 0, depending on whether or not the spray can should be actuated to prevent from spraying lines when moving between different paths.
The final software component determines the speed of each motor between points. By experimenting with different paint intensities, we decided that the spray-can should move no faster than four inches per second. Using this speed our software works backwards to determine how much time the spray-can has to move between points. Dividing the change in belt length of each motor by this time yields the speed of both motors. This information is packaged along with belt positions and actuation status to provide the PIC with a complete list of instructions for how to draw the imported image. We then send this path data to the microcontroller one instruction at a time over full-speed USB.