[Tutor] Pen plotter data format

Cameron Simpson cs at cskk.id.au
Fri Mar 31 21:54:51 EDT 2023


On 01Apr2023 11:21, Phil <phillor9 at gmail.com> wrote:
>Briefly, my laptop reads a gcode file and extracts the x any y 
>coordinates into two lists (one x and one y). The pen-up and pen_down 
>commands are not currently saved. The laptop then sends the x and y 
>coordinates to the micro-controller one at a time until the lists are 
>empty. The controller expects and waits for three bytes of x values and 
>then three bytes of y values in that order.

Why in threes?

Is this approach deficient because there's no delimiters, so if you're 
out of sync you misinterpret x as y etc?

>I'm thinking that a better approach might to send an x byte, for 
>example, like this "x, 123"

I'd be inclined to drop the comma.

>and have the micro-controller separate the value.

It's running software of your own, in Python, receiving the data?

>Currently, the micro-controller only accepts data and moves the motors 
>and doesn't perform any processing.
>
>Something like this might be better:
>
>if cmd starts with 'x';
>    strip off the coord value
>    run the motor to that coord
>
>if cmd starts with 'y':
>    etc
>
>if cmd starts with 'z':
>    lift or lower pen

Sounds ok.

>I'm still not sure how the laptop should handle the 'z' (pen-up) 
>commands because they don't fit neatly into the same x and y pair 
>pattern.

I happened to look at HPGL recently for a job application and IIRC it 
has pen-up motions (to x,y) and pen-down motions (to x,y). (And pick a 
pen colour, etc etc etc.)

>Maybe the laptop should just parse the gcode file one line at a time 
>and then send the complete line to the micro-controller for processing 
>until the end of the file is reached? That would mean that all sent 
>bytes would have to be the same length but I could add padding as I'm 
>currently doing.

I think you need to describe what's going on with the micro-controller a 
bit more. Is there a reason you can just progressively read the G-Code 
and stream instructions to the micro-controller as parsed? Do you need 
to wait for the micro-controller to physically perform the motions?

>I don't know what format pen plotters normally receive their data in 
>and I'm hoping that someone may know. An Internet search hasn't helped 
>so far.

Once upon a time a lot of HP plotters used HPGL. I wrote a (very) basic 
parser for the above mentioned job application. The language spec reads 
to me like something written after the printers were in the wild, as a 
formalisation of the protocol which people had implemented as they went; 
a bit ad hoc and weird.

No docs for your plotter? Or have you complete control?

Cheers,
Cameron Simpson <cs at cskk.id.au>


More information about the Tutor mailing list