This project demonstrates Direct Memory Mapping and Hybrid applications which leverage Arduino libraries on Windows 10 IoT Core for Raspberry Pi.
The key elements of this project are:
- Using camera to capture an image, with a live preview
- Using Xaml UI to display intermediate stages of the plot
- Dither the input image to generate a series of dots
- Use a travelling salesperson algorithm to connect the the dots using line segments
- Use the line segements to drive an H-Bot style carteisian plotter
- Drive steppers using the Arduino library AccelStepper written by Mike McCauley.
- Raspberry Pi 2
- MakeBlock Lab Kit (or equivelent parts)
- MakeBlock Long Rails
- 2x SparkFun Big Easy Driver
- (optional) Adafruit permaproto HAT for Raspberry Pi 2
- Video Camera which supports USB Video Class driver.
- 3d Printed Idle Wheel
- Windows 10 IoT Core, build 10556 or later
- Win2D for Windows 10
- AccelStepper
- Travelling Salesman Algorithm
The hardware for this plotter is configured as an H-Bot cartesian frame. An HBot uses a single long toothed belt and two stepper motors to drive the X and Y axes. The configuration has the benefit that both of the the stepper motors are mounted to the frame, which means the central carriage is very light and can move exceptionally fast. The downside of the HBot it is not balanced - if the Y axis is not extremely rigid, there can be racking. The simplicity of this design makes it a quick and easy build.
The two steppers work together to drive the X and Y axes, instead of each motor controlling a single axis. The formula for converting from axis steps to multi-motor steps are:
aStepper = xStep + yStep
bStepper = xStep - yStep
The application that drives this project is a hybrid application - it uses a C# and Xaml host, with a C++/CX Windows component which hosts the Arduino wiring code.
The Capture pipeline uses MediaCapture in the Windows.Media.Capture namespace. This component is associated with a live preview window in xaml. When the user selects capture, a picture is saved to storage then processing begins.
The image is then processed using a Floyd-Steinberg Two-dimensional error diffusion dithering algorithm. It is currently configured to reduce the number of points for speed purposes. This can be controled by adjusting kBWThreshold
in Dithering.cs
The points in the dither are connected using a Travelling Salesperson Algorithm - generating TSP Art. The agorithm is currently configured for expedient rendering, not an optimal solution. If you want to reconfigure this, instructs are available in TravellingSalesmanAlgorithm.cs
Once the TSP is generated, the Win2D canvas draws the TSP, with progress. The datastructure backing the rendering is used to generate the toolpath - and ultimately the stepper profiles using AccelStepper.
There are many things that can be done with this project:
- Convert the H-Bot to CoreXY which balances the load better
- Use a rigid plotter frame
- Laser Engraving
- Parallelize dithering and TSP generation