How to write a printer driver

Hey all, I realize this may be steering away from arduino territory, but I'm coming up short on appropriate places to articulate my question.

As a programming/embedded learning project, I've invented a completely original "solar printer" that focuses direct sunlight onto a moving platform in order to burn an image onto a piece of wood. Using mainly 3d printer parts, the unit is functional and currently prints basic designs with manually-programmed gcode coordinates (sent via Grbl Controller) and two stepper motors that move the platform.

The next project phase is writing a suitable software to run it. My goals are flexible in that I'm willing to adjust them if the learning curve is too steep, but these are the tangible project goals I'd like to aim for:

-controlled by Raspberry Pi (because I'm powering the entire project from a 12v solar/battery source)

-prints vector lines or dot matrix patterns from file located on Raspberry Pi (for simplicity)

-accommodates real-time sensor inputs & adjusts output signals (for adapting to varying solar intensity)

-controls an iris over the lens to regulate burning intensity (optional)

So keeping in mind that I'm doing this to learn, What's the closest existing framework for something like this? In other words, what upper-level directions could I take to get from image-file to wood-print using a raspberry pi as the brains?

If we just consider printing text then you could create a series of GCode commands for each letter and have a PC program (I include the RPI in the concept of PC) to read a text file and output the necessary GCode groups for the various letters.

Printing a simple dot matrix image (a BMP file) would not be a great deal more complex. You would need to establish the scale of the image and then the PC program could scan across the lines of the image creating GCode that moves the burning point in sync and either turns the heat on or off depending on whether the pixel is black or white.

After the PC has generated the GCode file it would just be a matter of sending it to the solar printer.

...R

LOL ... first moment I thought you were talking about things like these Markus Kayser - Solar Sinter Project - YouTube :slight_smile:

Whagt's your resolution / dot-size?

A GDI printer only needs to burn lines of pixels, everything else is done by the Windows GDI.

I'd collect solar light in a battery and use a laser for burning the dots or lines. This removes blinds and a lot of mirrors and lenses with associated positioning motors.

To answer the question you posed as title to you posting.

You begin with writing everything as functions. Begin with the smallest possible thing your device can do. For a stepper motor, one step. Another function to change direction. For any other device, the minimal that it can do.

Then you begin to write functions that will call the lowest level function one or more time to get it to do a higher level move, like a movement for some linear length of a line. Or write a function that calls the lowest levels to draw a circle or other geometric design. Always use functions!!!

Paul

zwieblum:
LOL ... first moment I thought you were talking about things like these Markus Kayser - Solar Sinter Project - YouTube :slight_smile:

Whagt's your resolution / dot-size?

That is WAY cooler, LOL. 3d printing sand with sun?! brilliant!

My dot size is pretty big, like a 5mm burn width using my big old cheap magnifying lens from amazon. You can see it's pretty big. But given the dot size, a better optic may give me better resolution while letting me scale down lens size (and height?) for a smaller overall profile.

DrDiettrich:
A GDI printer only needs to burn lines of pixels, everything else is done by the Windows GDI.

I'd collect solar light in a battery and use a laser for burning the dots or lines. This removes blinds and a lot of mirrors and lenses with associated positioning motors.

That is very practical advice. Since the primary goal of this is skill acquisition, it makes it more fun to have an eccentric and novel design.

Paul_KD7HB:
To answer the question you posed as title to you posting.

You begin with writing everything as functions. Begin with the smallest possible thing your device can do. For a stepper motor, one step. Another function to change direction. For any other device, the minimal that it can do.

Then you begin to write functions that will call the lowest level function one or more time to get it to do a higher level move, like a movement for some linear length of a line. Or write a function that calls the lowest levels to draw a circle or other geometric design. Always use functions!!!

Paul

This is actually immensely helpful and gives me a lot to think about! Hmm, so you could do it with arduino because then letters are just functions that call other basic shapes to certain relative positions... Interesting.

Once you get into how to do the minimal functions, you will want to have the functions return a status byte telling the caller if the function did what was asked or if it failed. And eventually, you will want to do error recovery when something fails, not just report the failure and die.

Paul

@ driver: It's not worth building a gereric driver. Bette use something that emits g-code and stay with grbl. There are plugins for inkscape that do stull like this (I've modified one from evilmadscientists eggbot for my needs).

What I suggested in Reply #1 would also use functions - one for each letter, for example.

If you already have a GCode interpreter then you should build on that. The GRBL GCode interpreter is the logical equivalent of the low-level functions mentioned by @Paul_KD7HB

…R