We’ve previously discussed the mechanical and electrical hardware used in the XY plotter, however, we haven’t yet covered the programming of the device. This article provides an overview of some of the key functions used within the plotter. The source files are provided in a zip format at the end of this post. There are three main areas that I will briefly discuss; software macros, interrupts and simulation commands.
Since the XY plotter is a complicated device it requires the use of multiple macros, which for those of you unfamiliar with Flowcode, will be akin to that of a function in other programming languages. Macros are useful for two purposes; first they can simplify the main program by separating the body of the flowchart into smaller, easier to manage sections. Secondly, they allow us to repeat large sections of code if required. For example, if we desire to flash an LED 100 times we would place it in a loop which we characterise to turn an LED on and off, 100 times. A macro works in the same way, and can even be called multiple times within a program.
Another key feature used within the XY plotter was that of interrupts. Within this application, hardware interrupts are used to halt the XY plotter if limit switches were operated. This may occur if coordinates were used which were outside the maximum drawing area of the plotter. If the motor did not stop it could continue to drive the x or y axis into the supporting pillars and damage either the machine or the motors themselves.
The final aspect to mention is the use of simulation commands, one of the unique features of Flowcode 6. The code for the XY plotter reads in the coordinates provided by the user and moves the X and Y axes based on the calculated number of rotational steps of the stepper motors to achieve the required distance. Simulation commands are used here to calculate the XYZ location of the 3D model of the pen in the plotter, and draw a small circle. Doing this for each step provides the ability to draw a line, much like the principle of dot-matrix printer.
I have only briefly described the software functionality here, since the code has been provided for you to look at.
Source files can be downloaded HERE, or within the help files of Flowcode 6.
As always, comments welcome.
17,421 total views, 4 views today