@

@

Software Design


 

Interface


Because our device uses a great deal of math in determining its current and next plot position with its unique plotting method, the control software has a significant role in its operation. Our interface software is essentially a state machine that handles transitions from one mode to another, as well as the internal states within each operation mode - The user can choose which mode to go into by looking at the available options displayed on the LCD and press the keypad to make the selection. The state machine shares the same time counter with a variable timeframe.  We adopted some of the structural aspects of the state machine used in the Vertical Plotter project from Spring 2001 in the initial development, but over time, the code gradually developed to a very separate form as we extended its capabilities. The software interface offers 4 different plotting modes to the user: Freedraw, Plot Coordinates, Plot Text, and Plot Programmed objects, all utilizing the universal plotting function plotLine(), which handles motor movements to draw the desired lines and/or objects.

@

@


@

Fig. 6 - Control program State Machine

 

PlotLine()


The center piece of this device, the plotLine() function is responsible for making the necessary calculations and controlling the stepper motors appropriately in order to plot the lines as commanded by the user.  It takes in two values, dx and dy, which is obtained by other mode functions from the user, and determines the amount of winding or unwinding for each motor to plot the correct distance and angle. 

 

The software has a series of condition checks to make sure that the plotter can travel to the destination point safely, which is necessary to maintain its accuracy.  One problem is that there is no default position in the stepper motors, meaning that they can step in either direction indefinitely.  This can be a serious problem because as the motor unwinds the string to move the plotter and reaches a point where the string is fully extended, it does not realize that the motor has returned to its initial point, and continues to step in that direction – i.e. changing the unwinding motion to a winding motion.  To prevent this, we keep track of motor steps taken in both directions, and take that into account when determining whether the plot request that the user entered can be made or not.

 

Once the plotting is accomplished, it then updates the coordinate values, x and y, and the string length values, a and b, to their most recent values, and depending on the mode it will either go back to the parent mode that called plotline() or retrieve a new coordinate set and plot the next line.

 

Associated functions are as following.

 

The details of each plotting mode and associated programs are listed below.

 

Freedraw


As its name implies, this mode allows the user to have direct control of the pen apparatus. It draws lines of desirable length in the allowed 8 directions (up, down, left, right and diagonal directions 45 degrees in between) corresponding to the directional keys on the keypad. The line increment is predetermined (default at 0.3cm) and the number of times it travels at that increment is determined by the length of time that the user holds the key of the corresponding direction. Each time the plotter reaches the increment, it updates the x and y-position of the plotter, and if it still detects the button press, it recalculates the da and db which it has to travel and repeats the process. If the user releases the button before it reaches the increment, additional adjustment schemes have been made so that it reverse-calculates the dx and dy traveled by using the number of steps it has taken from the starting point and adjusts the x and y-positions to its most recent values.

 

Associated functions:

Exit from this mode is done by pressing the e* e key, which takes the user back to the main menu. 

 

Plot Coordinates


We implemented a coordinate system loosely based on polar coordinates, where the line plot is expressed by two values: plotDist, which is the length of the line, and plotAngle, the angle of the line in respect to the y-axis in the clockwise direction. After entering this mode it first prompts for the length of the line to be drawn and its angle of direction. It then checks whether if it can plot to the entered position, and if not it would indicate gOut of boundsh and will prompt for a new distance and angle – otherwise it will continue with executing the plotting function. After finishing the plots returns to length entry state for the next line to be plotted. The diagram below shows how the entered values relate to the coordinates on the plotter system.

@

fig. 7 - device coordinate set values

 

Again, exit from this mode is done by pressing the e* e key when prompted for the values, but not when it starts plotting, which it takes the user back to the main menu. 

 

Associated functions:

 

Plot Text


 This mode being and extended feature of the plot coordinates function, allows printing of a single line text string entered by the user at its last placed pen location.  Each character roughly at a size of 1cm x 1cm, the plotter will start writing the character from its lower left corner, and ends at the lower right corner. It is also designed to allocate a 1mm space after the character automatically to allow the continuous printing of multiple characters. User can enter the characters using the keypad, where each key is responsible for the printed segment of characters on it.  The user can hold on to the key to scroll through the list of character it handles, and release once it reaches the desired character. The user repeats this process until he or she completes the target string, then the press of eCf key will initiate the writing process. Once completed the software will return to the string entry prompt for the next string to be plotted. Printable characters are numerals 0-9, upper case alphabets A-Z, period(e.f), hyphen (e-e), and space (e e).

 

Associated functions:

@

Plot Programmed-objects


As another extended mode of the plot coordinates function, this mode will plot preprogrammed simple objects selected by the user onto the sheet.  We implemented 3 objects for this mode: a square, equilateral triangle, and a simple house graphic, and by using methods similar to those mentioned in Plot Text mode, it retrieves a series of coordinate sets for that specific object and plot lines one by one until the object is completed.  For the square and the equilateral triangle, the user can scale it to a larger size by entering the scale factor that is applied on to a base length of 1cm. The house is drawn with a series of fixed-length lines, roughly occupying 2.5cm x 2.5cm space.

 

Associated functions:

Other functions


Other independent functions that were necessary in the operation: