Git Product home page Git Product logo

xy-plotter's Introduction

XY-Plotter

The plotter waits on its serial interface for commands.

Currently implemented commands are

  • s : manual mode. Pass in a path definition to make the plotter move.

  • E : enable the motors

  • D : disable the motors

  • C : continuous mode: see below

  • H : Go home - sets the plotter to its defined home point

  • u : pen up, raises the pen so that it does not draw

  • d : pen down, lowers the pen so that it draws

  • r<val>: set resolution to val steps per mm. Default is 160steps per mm

  • Q : emergency stop in manual mode

  • v<val> : set servo at passed int _val_ue

  • V : toggle verbose mode (default off)

  • R : toggle dry run (default off)

  • i : enable end switches

  • I : disable interrupts

  • z<c><val>: send z-Axis command c with value val. See zAxis.ino for more info

  • a<r>[,<start>,<end>] : arc (circle) with radius r. If start and end are given, an arc is created.

  • A<r>[,<start>,<end>] : arch like 'a', but current point is mid-point and not on the arc/circle

Path definition

Path commands are relative movements from the current position of the print head. The format follows:

    PIPE::= '|'
    SPACE ::= ' '
    XCHAR ::= 'X'
    YCHAR ::= 'Y'
    MINUS ::= '-'
    COMMA ::= ','
    NUM ::= ['0'-'9']
    PEN_UP ::= 'U'
    PEN_DOWN ::= 'D'

    radius ::= NUM+
    start :: NUM+
    end :: NUM+
    arc ::= ('A' | 'a') radius (COMMA start COMMA end)?
    item ::= (XCHAR | YCHAR) MINUS? NUM+
    move ::= item (SPACE item)
    segment ::= move | arc | PEN_UP | PEN_DOWN
    path ::= segment ( PIPE segment)*

where 'n' is a numeric digit.

Examples:

  • X30 - move 30 units on the X-axis

  • Y-2 - move -2 units on the Y-axis

  • X10 Y5 - move 10 units on the X-axis and also 5 units on the y-axis

  • X2 Y2|X-2 - first move 2 units on the X-axis and 2 on the y-axis. Then move -2 units on the X-axis

The units depend on the setting of the plotter. In my case 1 unit = 1mm.

Continuous mode

With the 's' command, the plotter expects one path definition, does the work and waits for a new command.

With continuous mode, the plotter only expects path segments after continuous mode was enabled. It processes the segments and then reads the next path from serial input. If it encounters -END it will stop and exit continuous mode.

Example to display the start of a Hilbert curve
C
X4 Y0|X0 Y4|X-4 Y0|X0 Y4|X0 Y4|X4 Y0|X0 Y-4
X4 Y0|X0 Y4|X4 Y0|X0 Y-4|X0 Y-4|X-4 Y0|X0 Y-4
-END

Plotter responses

The plotter responds with vaious kind of data. If it waits for more input it will reply with a text starting with OK. Debug output starts with D. If the plotter encounters an error it will repyl with ERR.

xy-plotter's People

Contributors

pilhuhn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

xy-plotter's Issues

Arc's in continuous mode

The arc commands work correctly on their own but when I try to use them in continuous mode they fail. I have tried both upper and lower case "aA". These are the commands I am sending.
Example2: 24mm square box with 2mm radius corners

C
D
X0 Y20|A2,0,90|X-20 Y0|A2,90,180|X0 Y-20|A2,180,270|X20 Y0|A2,270, 360
-END**

Please see attached video showing what happens.

IMG_1498.mp4

Scaling

Hi,
Can you please add in:

  1. a scaling function for both X axis and one for Y axis.
  2. breakout steps_per_mm for both X axis and Y axis.

These will help with mechanical variances. Thanks.

Change int's to floats

Please change the command functions arc, X, Y, stepsPerMM from int's to floats or better yet double floats. I believe this would fix other issues posted.

Arc's smaller than 1mm

Two things:

  1. I can not see to create an arc smaller than 1mm for example a0.254 to create a 0.5mm diameter circle.
  2. Also I can not create any odd numbered diameters for example: a1.5 to create a 3mm diameter circle.

Limit Switch Interrupts not working

Hi,

I am able to get the motors doing the right things with your commands. When I hit "H" to home X & Y axis's the optical switches are not seen or recognized and no interrupt is ever being created.

I created a separate small routine to test these same limit switch pins and optical switches using attachedInterrupt they all work fine they see the optical switches and create an interrupt.

I am not sure what I am missing in your code but for some reason it will not generate an interrupt to stop the motor when a limit switch is seen. Any guidance would be greatly appreciated.

Please add new functions

Please add new functions:

  1. Ability to Set Origin 0:0 as a reference for example: using commands to move the pen to the corner of the page and set / store that as the 0:0 reference.

  2. Ability to apply Offset values for both X & Y where to start printing from the origin on the page.

  3. Break out the stepsPerMM ability to define one for the X axis and another for the Y axis.

Compile errors

Arduino: 1.8.13 (Mac OS X), Board: "SAME51N19A M4 (SAME51), Enabled, 120 MHz (standard), Small (-Os) (standard), 50 MHz (standard), Arduino, Off"

/Users/JimD/Documents/Arduino/xy-plotter/xy-plotter.ino: In function 'void setup()':
xy-plotter:122:3: error: 'servoMove' was not declared in this scope
122 | servoMove(SERVO_PIN, PEN_UP);
| ^~~~~~~~~
/Users/JimD/Documents/Arduino/xy-plotter/xy-plotter.ino: In function 'void panic()':
xy-plotter:140:3: error: 'Timer1' was not declared in this scope; did you mean '_timer1'?
140 | Timer1.stop();
| ^~~~~~
| _timer1
xy-plotter:141:3: error: 'println' was not declared in this scope; did you mean 'printf'?
141 | println("STOPPED");
| ^~~~~~~
| printf
/Users/JimD/Documents/Arduino/xy-plotter/xy-plotter.ino: In function 'void oneStep()':
xy-plotter:161:5: error: 'println' was not declared in this scope; did you mean 'printf'?
161 | println(F("D One step, hit a switch"));
| ^~~~~~~
| printf
xy-plotter:162:5: error: 'servoMove' was not declared in this scope
162 | servoMove(SERVO_PIN, PEN_UP);
| ^~~~~~~~~
xy-plotter:163:5: error: 'Timer1' was not declared in this scope; did you mean '_timer1'?
163 | Timer1.stop();
| ^~~~~~
| _timer1
xy-plotter:173:5: error: 'servoMove' was not declared in this scope
173 | servoMove(SERVO_PIN, PEN_UP);
| ^~~~~~~~~
xy-plotter:178:5: error: 'servoMove' was not declared in this scope
178 | servoMove(SERVO_PIN, PEN_DOWN);
| ^~~~~~~~~
xy-plotter:188:5: error: 'Timer1' was not declared in this scope; did you mean '_timer1'?
188 | Timer1.stop();
| ^~~~~~
| _timer1
xy-plotter:197:7: error: 'printWorkItem' was not declared in this scope
197 | printWorkItem(wItem);
| ^~~~~~~~~~~~~
xy-plotter:199:5: error: 'setDirection' was not declared in this scope
199 | setDirection(wItem);
| ^~~~~~~~~~~~
/Users/JimD/Documents/Arduino/xy-plotter/xy-plotter.ino: In function 'void interruptOnX1()':
xy-plotter:235:3: error: 'disableXInterrupts' was not declared in this scope
235 | disableXInterrupts();
| ^~~~~~~~~~~~~~~~~~
/Users/JimD/Documents/Arduino/xy-plotter/xy-plotter.ino: In function 'void interruptOnX2()':
xy-plotter:242:3: error: 'disableXInterrupts' was not declared in this scope
242 | disableXInterrupts();
| ^~~~~~~~~~~~~~~~~~
/Users/JimD/Documents/Arduino/xy-plotter/xy-plotter.ino: In function 'void interruptOnY1()':
xy-plotter:249:3: error: 'disableYInterrupts' was not declared in this scope
249 | disableYInterrupts();
| ^~~~~~~~~~~~~~~~~~
/Users/JimD/Documents/Arduino/xy-plotter/xy-plotter.ino: In function 'void interruptOnY2()':
xy-plotter:256:3: error: 'disableYInterrupts' was not declared in this scope
256 | disableYInterrupts();
| ^~~~~~~~~~~~~~~~~~
/Users/JimD/Documents/Arduino/xy-plotter/xy-plotter.ino: In function 'void startWork()':
xy-plotter:267:5: error: 'enableMotors' was not declared in this scope
267 | enableMotors();
| ^~~~~~~~~~~~
xy-plotter:268:5: error: 'enableEndSwitches' was not declared in this scope
268 | enableEndSwitches();
| ^~~~~~~~~~~~~~~~~
xy-plotter:277:5: error: 'Timer1' was not declared in this scope; did you mean '_timer1'?
277 | Timer1.initialize(100); // No motor movement, so we can speed up
| ^~~~~~
| _timer1
xy-plotter:279:5: error: 'Timer1' was not declared in this scope; did you mean '_timer1'?
279 | Timer1.initialize(200);
| ^~~~~~
| _timer1
xy-plotter:281:3: error: 'Timer1' was not declared in this scope; did you mean '_timer1'?
281 | Timer1.attachInterrupt(oneStep);
| ^~~~~~
| _timer1
/Users/JimD/Documents/Arduino/xy-plotter/xy-plotter.ino: In function 'void loop()':
xy-plotter:313:23: error: 'preParse' was not declared in this scope
313 | String path = preParse();
| ^~~~~~~~
xy-plotter:314:9: error: 'parsePath' was not declared in this scope
314 | parsePath(path);
| ^~~~~~~~~
xy-plotter:323:11: error: 'enableMotors' was not declared in this scope
323 | enableMotors();
| ^~~~~~~~~~~~
xy-plotter:326:11: error: 'disableMotors' was not declared in this scope
326 | disableMotors();
| ^~~~~~~~~~~~~
xy-plotter:333:27: error: 'preParse' was not declared in this scope
333 | String path = preParse();
| ^~~~~~~~
xy-plotter:334:13: error: 'parsePath' was not declared in this scope
334 | parsePath(path);
| ^~~~~~~~~
xy-plotter:355:13: error: 'println' was not declared in this scope; did you mean 'printf'?
355 | println("D Homing");
| ^~~~~~~
| printf
xy-plotter:358:13: error: 'parsePath' was not declared in this scope
358 | parsePath(path);
| ^~~~~~~~~
xy-plotter:365:13: error: 'servoMove' was not declared in this scope
365 | servoMove(SERVO_PIN, PEN_UP);
| ^~~~~~~~~
xy-plotter:373:13: error: 'servoMove' was not declared in this scope
373 | servoMove(SERVO_PIN, PEN_DOWN);
| ^~~~~~~~~
xy-plotter:381:13: error: 'servoMove' was not declared in this scope
381 | servoMove(SERVO_PIN, val);
| ^~~~~~~~~
xy-plotter:385:11: error: 'enableEndSwitches' was not declared in this scope
385 | enableEndSwitches();
| ^~~~~~~~~~~~~~~~~
xy-plotter:400:13: error: 'disableXInterrupts' was not declared in this scope
400 | disableXInterrupts();
| ^~~~~~~~~~~~~~~~~~
xy-plotter:401:13: error: 'disableYInterrupts' was not declared in this scope
401 | disableYInterrupts();
| ^~~~~~~~~~~~~~~~~~
xy-plotter:420:11: error: 'handleZ' was not declared in this scope
420 | handleZ(arg);
| ^~~~~~~
xy-plotter:426:11: error: 'handleArc' was not declared in this scope
426 | handleArc(c,command);
| ^~~~~~~~~
xy-plotter:442:5: error: 'println' was not declared in this scope; did you mean 'printf'?
442 | println("D .. done reached ..");
| ^~~~~~~
| printf
xy-plotter:466:11: error: 'parsePath' was not declared in this scope
466 | parsePath("Y-200");
| ^~~~~~~~~
xy-plotter:471:11: error: 'parsePath' was not declared in this scope
471 | parsePath("X-200");
| ^~~~~~~~~
xy-plotter:484:21: error: 'preParse' was not declared in this scope
484 | String path = preParse();
| ^~~~~~~~
xy-plotter:486:7: error: 'parsePath' was not declared in this scope
486 | parsePath(path);
| ^~~~~~~~~
xy-plotter:492:9: error: 'disableMotors' was not declared in this scope
492 | disableMotors();
| ^~~~~~~~~~~~~
/Users/JimD/Documents/Arduino/xy-plotter/xy-plotter.ino: In function 'void compensate_move(int)':
xy-plotter:514:3: error: 'println' was not declared in this scope; did you mean 'printf'?
514 | println(" Start crawling");
| ^~~~~~~
| printf
xy-plotter:531:5: error: 'enableYInterrupts' was not declared in this scope; did you mean 'noInterrupts'?
531 | enableYInterrupts(CHANGE);
| ^~~~~~~~~~~~~~~~~
| noInterrupts
xy-plotter:533:5: error: 'enableXInterrupts' was not declared in this scope; did you mean 'noInterrupts'?
533 | enableXInterrupts(CHANGE);
| ^~~~~~~~~~~~~~~~~
| noInterrupts
Multiple libraries were found for "Servo.h"
Used: /Users/JimD/Documents/Arduino/libraries/Servo
Not used: /Applications/Arduino 2.app/Contents/Java/libraries/Servo
Not used: /Users/JimD/Library/Arduino15/packages/adafruit/hardware/samd/1.6.6/libraries/Servo
exit status 1
'servoMove' was not declared in this scope

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.