Skip to content

Commit fe0c34f

Browse files
committed
Version 2.6.0
* Update to pyserial 2.7.0. Closes #17. * Add support for multiple motor resolutions. Closes #18.
1 parent 36d3925 commit fe0c34f

File tree

3 files changed

+77
-58
lines changed

3 files changed

+77
-58
lines changed

inkscape_driver/eggbot.inx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
33
<_name>EggBot Control</_name>
4-
<id>command.evilmadscientist.eggbot.rev250</id>
4+
<id>command.evilmadscientist.eggbot.rev260b3</id>
55
<dependency type="extension">org.inkscape.output.svg.inkscape</dependency>
66
<dependency type="executable" location="extensions">eggbot.py</dependency>
77
<dependency type="executable" location="extensions">inkex.py</dependency>
@@ -65,15 +65,15 @@ Note: Pressing 'Apply' will apply settings, but not plot.
6565

6666
<page name='options' _gui-text='Options'>
6767
<param name="revPenMotor" type="boolean"
68-
_gui-text=" Reverse motion of Motor 1 (pen):">true</param>
68+
_gui-text=" Reverse motion of Motor 1 (pen)">true</param>
6969
<param name="revEggMotor" type="boolean"
70-
_gui-text=" Reverse motion of Motor 2 (egg):">true</param>
70+
_gui-text=" Reverse motion of Motor 2 (egg)">true</param>
7171
<param name="wraparound" type="boolean"
72-
_gui-text=" Egg (x) axis wraps around:">true</param>
72+
_gui-text=" Egg (x) axis wraps around">true</param>
7373
<param name="startCentered" type="boolean"
74-
_gui-text=" Start with pen centered:">true</param>
74+
_gui-text=" Start with pen centered">true</param>
7575
<param name="returnToHome" type="boolean"
76-
_gui-text=" Return home when done:">true</param>
76+
_gui-text=" Return home when done">true</param>
7777
<param name="engraving" type="boolean"
7878
_gui-text=" Enable engraver, if attached">false</param>
7979
<param name="smoothness" type="float"
@@ -134,7 +134,7 @@ if you need to quit inkscape and resume later,
134134
be sure to save the document first.
135135
</_param>
136136
<param name="cancelOnly" type="boolean"
137-
_gui-text="Cancel and return home only:">false</param>
137+
_gui-text="Cancel and return home only">false</param>
138138
</page>
139139

140140
<page name="layers" _gui-text="Layers">
@@ -156,7 +156,7 @@ selected number, which can be up to 100.
156156
<_param name="instructions_general" type="description"
157157
xml:space="preserve">
158158
EggBot Control Inkscape extension
159-
Release 2.5.0, dated 2015-01-30
159+
Release 2.6.0, dated 2015-08-31
160160

161161
*EBB Firmware 1.96 or newer required for certain
162162
functions.

inkscape_driver/eggbot.py

Lines changed: 31 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
# Part of the Eggbot driver for Inkscape
33
# http://code.google.com/p/eggbotcode/
44
#
5-
# Version 2.5.0, dated 2015-01-30
5+
# Version 2.6.0, dated 2015-08-31
6+
# REQUIRES: Pyserial version 2.7.0
67
#
78
# This program is free software; you can redistribute it and/or modify
89
# it under the terms of the GNU General Public License as published by
@@ -32,12 +33,13 @@
3233
import sys
3334
import time
3435
import eggbot_scan
36+
import eggbot_conf
3537

3638
F_DEFAULT_SPEED = 1
3739
N_PEN_DOWN_DELAY = 400 # delay (ms) for the pen to go down before the next move
3840
N_PEN_UP_DELAY = 400 # delay (ms) for the pen to up down before the next move
39-
N_PAGE_HEIGHT = 800 # Default page height (each unit equiv. to one step)
40-
N_PAGE_WIDTH = 3200 # Default page width (each unit equiv. to one step)
41+
# N_PAGE_HEIGHT = 800 # Default page height (each unit equiv. to one step) - MOVED TO eggbot_conf.py
42+
# N_PAGE_WIDTH = 3200 # Default page width (each unit equiv. to one step) - MOVED TO eggbot_conf.py
4143

4244
N_PEN_UP_POS = 50 # Default pen-up position
4345
N_PEN_DOWN_POS = 40 # Default pen-down position
@@ -64,15 +66,6 @@
6466
DRY_RUN_OUTPUT_FILE = os.path.join( HOME, 'dry_run.txt' )
6567
MISC_OUTPUT_FILE = os.path.join( HOME, 'misc.txt' )
6668

67-
## if platform == 'darwin':
68-
## ''' There's no good value for OS X '''
69-
## STR_DEFAULT_COM_PORT = '/dev/cu.usbmodem1a21'
70-
## elif platform == 'sunos':
71-
## ''' Untested: YMMV '''
72-
## STR_DEFAULT_COM_PORT = '/dev/term/0'
73-
## else:
74-
## ''' Works fine on Ubuntu; YMMV '''
75-
## STR_DEFAULT_COM_PORT = '/dev/ttyACM0'
7669

7770
def parseLengthWithUnits( str ):
7871
'''
@@ -139,10 +132,6 @@ def __init__( self ):
139132
action="store", type="float",
140133
dest="smoothness", default=.2,
141134
help="Smoothness of curves" )
142-
## self.OptionParser.add_option( "--comPort",
143-
## action="store", type="string",
144-
## dest="comport", default=STR_DEFAULT_COM_PORT,
145-
## help="USB COM port to connect eggbot.")
146135
self.OptionParser.add_option( "--startCentered",
147136
action="store", type="inkbool",
148137
dest="startCentered", default=True,
@@ -252,22 +241,23 @@ def __init__( self ):
252241
nDeltaX = 0
253242
nDeltaY = 0
254243

255-
self.svgWidth = float( N_PAGE_WIDTH )
256-
self.svgHeight = float( N_PAGE_HEIGHT )
244+
self.svgWidth = float( eggbot_conf.N_PAGE_WIDTH )
245+
self.svgHeight = float( eggbot_conf.N_PAGE_HEIGHT )
257246
self.svgTransform = [[1.0, 0.0, 0.0], [0.0, 1.0, 0.0]]
258247

259248
# So that we only generate a warning once for each
260249
# unsupported SVG element, we use a dictionary to track
261250
# which elements have received a warning
262251
self.warnings = {}
263252

264-
# Hack for mismatched EBB/motors,
265-
# which have half resolution
266-
try:
267-
import motor1600
268-
self.step_scaling_factor = 2
269-
except ImportError:
270-
self.step_scaling_factor = 1
253+
# "Normal" value: self.step_scaling_factor = 2, for 3200 steps/revolution.
254+
255+
self.step_scaling_factor = eggbot_conf.STEP_SCALE
256+
257+
self.wrapSteps = 6400 / self.step_scaling_factor
258+
self.halfWrapSteps = self.wrapSteps / 2
259+
260+
271261

272262
def effect( self ):
273263
'''Main entry point: check to see which tab is selected, and act accordingly.'''
@@ -318,15 +308,6 @@ def effect( self ):
318308
self.EggbotOpenSerial()
319309
self.manualCommand()
320310

321-
## elif self.options.tab == '"timing"':
322-
## self.EggbotOpenSerial()
323-
## if self.serialPort is not None:
324-
## self.ServoSetupWrapper()
325-
##
326-
## elif self.options.tab == '"options"':
327-
## self.EggbotOpenSerial()
328-
## if self.serialPort is not None:
329-
##
330311
self.svgDataRead = False
331312
self.UpdateSVGEggbotData( self.svg )
332313
self.EggbotCloseSerial()
@@ -1047,8 +1028,8 @@ def getDocProps( self ):
10471028
Use a default value in case the property is not present or is
10481029
expressed in units of percentages.
10491030
'''
1050-
self.svgHeight = self.getLength( 'height', N_PAGE_HEIGHT )
1051-
self.svgWidth = self.getLength( 'width', N_PAGE_WIDTH )
1031+
self.svgHeight = self.getLength( 'height', eggbot_conf.N_PAGE_HEIGHT )
1032+
self.svgWidth = self.getLength( 'width', eggbot_conf.N_PAGE_WIDTH )
10521033
if ( self.svgHeight == None ) or ( self.svgWidth == None ):
10531034
return False
10541035
else:
@@ -1093,16 +1074,16 @@ def plotPath( self, path, matTransform ):
10931074

10941075
nIndex += 1
10951076

1096-
self.fX = float( csp[1][0] ) / self.step_scaling_factor
1097-
self.fY = float( csp[1][1] ) / self.step_scaling_factor
1077+
self.fX = 2 * float( csp[1][0] ) / self.step_scaling_factor
1078+
self.fY = 2 * float( csp[1][1] ) / self.step_scaling_factor
10981079

10991080
# store home
11001081
if self.ptFirst is None:
11011082

11021083
# if we should start at center, then the first line segment should draw from there
11031084
if self.options.startCentered:
1104-
self.fPrevX = self.svgWidth / ( 2 * self.step_scaling_factor )
1105-
self.fPrevY = self.svgHeight / ( 2 * self.step_scaling_factor )
1085+
self.fPrevX = self.svgWidth / ( self.step_scaling_factor )
1086+
self.fPrevY = self.svgHeight / ( self.step_scaling_factor )
11061087

11071088
self.ptFirst = ( self.fPrevX, self.fPrevY )
11081089
else:
@@ -1223,14 +1204,14 @@ def plotLineAndTime( self ):
12231204

12241205
if self.bPenIsUp:
12251206
self.fSpeed = self.options.penUpSpeed
1226-
1207+
12271208
if ( self.options.wraparound ):
1228-
if ( nDeltaX > 1600 / self.step_scaling_factor ):
1229-
while ( nDeltaX > 1600 / self.step_scaling_factor ):
1230-
nDeltaX -= 3200 / self.step_scaling_factor
1231-
elif ( nDeltaX < -1600 / self.step_scaling_factor ):
1232-
while ( nDeltaX < -1600 / self.step_scaling_factor ):
1233-
nDeltaX += 3200 / self.step_scaling_factor
1209+
if ( nDeltaX > self.halfWrapSteps ):
1210+
while ( nDeltaX > self.halfWrapSteps ):
1211+
nDeltaX -= self.wrapSteps
1212+
elif ( nDeltaX < -1 * self.halfWrapSteps ):
1213+
while ( nDeltaX < -1 * self.halfWrapSteps ):
1214+
nDeltaX += self.wrapSteps
12341215

12351216
else:
12361217
self.fSpeed = self.options.penDownSpeed
@@ -1348,9 +1329,9 @@ def getSerialPort( self ):
13481329
# Before searching, first check to see if the last known
13491330
# serial port is still good.
13501331

1351-
serialPort = self.testSerialPort( self.svgSerialPort )
1352-
if serialPort:
1353-
return serialPort
1332+
# serialPort = self.testSerialPort( self.svgSerialPort )
1333+
# if serialPort:
1334+
# return serialPort
13541335

13551336
# Try any devices which seem to have EBB boards attached
13561337
for strComPort in eggbot_scan.findEiBotBoards():

inkscape_driver/eggbot_conf.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# eggbot-conf.py
2+
# Part of the EggBot driver for Inkscape
3+
# Version 2.6.0, dated August 31, 2015.
4+
#
5+
# https://github.com/evil-mad/EggBot/
6+
#
7+
# "Change numbers here, not there." :)
8+
9+
10+
11+
# Page size values typically do not need to be changed. They primarily affect viewpoint and centering.
12+
13+
N_PAGE_HEIGHT = 800 # Default Inkscape page height (each unit equiv. to one pixel/step)
14+
N_PAGE_WIDTH = 3200 # Default Inkscape page width (each unit equiv. to one pixel/step)
15+
16+
17+
'''
18+
Motor resolution: The "standard" setup for brand-name EggBot machines (at least through 2015) has been 3200 steps per revolution.
19+
20+
Early (clear-chassis) models had 400 step/rev motors with 8X microstepping drivers, and more recent versions ("white-chassis" EggBot 2.0, Deluxe EggBot, Ostrich EggBot, and EggBot Pro) have all used 200 step/rev motors with 16X microstepping drivers (EBB 2.0).
21+
22+
The STEP SCALING FACTOR below can be used to work with motor-driver combinations that give a different overall number of steps per revolution-- for example 1600 (200 step/rev motors with 8X drivers) or 6400 (400 step/rev motors with 16X drivers) for "corner cases" and unofficial builds.
23+
24+
25+
For 1600 steps/rev, use:
26+
STEP_SCALE = 4
27+
28+
For NORMAL USE, with overall 3200 steps/rev, use the default value:
29+
STEP_SCALE = 2
30+
31+
For 6400 steps/rev, use:
32+
STEP_SCALE = 1
33+
34+
Other _integer_ scaling values can be used as well, with similar scaling.
35+
36+
'''
37+
38+
STEP_SCALE = 2

0 commit comments

Comments
 (0)