Frusta

Check-in [7c129b9525]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:added exercise resonance tests
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:7c129b9525b047739aa127ebf11d6d046b697eeb
User & Date: rmelton 2013-10-23 16:29:04
Context
2013-10-23
19:11
changed gcode precision to be .00 (hundredths) check-in: 28fd787106 user: rmelton tags: trunk
16:29
added exercise resonance tests check-in: 7c129b9525 user: rmelton tags: trunk
04:23
First working version of gcode exercise code generator check-in: 04002210f3 user: rmelton tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to lib/machine/machine_0.1.tcl.

15
16
17
18
19
20
21


22
23
24
25


26
27
28
29
30
31
32
..
67
68
69
70
71
72
73


74
75
76
77
78
79
80

81
82
83
84
85
86
87


88
89
90
91
92
93
94
...
116
117
118
119
120
121
122






123
124
125
126
127
128
129
...
130
131
132
133
134
135
136

137
138
139

140
141
142

143
144
145

146

147
148








149
150
151
152
153
154
155
...
271
272
273
274
275
276
277






































278
279
280
281
282
283
284
  set v(bedY1) [Settings::Get buildHeight]
  set v(loops) 20
  set v(autoHome)        1
  set v(doOpositeSides)  1
  set v(doOpositeCircle) 1
  set v(doSideStitch)    1
  set v(doSpiral)        1


  set v(segsOpositeSide)    5
  set v(segsOpositeCircle) 10
  set v(segsStitchSides)   20
  set v(segsSpiral)        20



  proc ExerciseFrame {} {
    variable w
    catch {destroy $w}
    toplevel $w
    wm title $w "Printer Exercise Frame"

................................................................................
      label $w.loop.loopL -text "loop test \#times = "
      spinbox $w.loop.loops -from 0 -to 100 -textvariable [namespace current]::v(loops) -width 6 -justify right
      checkbutton $w.loop.homming        -text "X/Y/Z homming"   -variable [namespace current]::v(autoHome)
      checkbutton $w.loop.opositeCorners -text "oposite sides"   -variable [namespace current]::v(doOpositeSides)
      checkbutton $w.loop.opositeCircle  -text "oposite circle"  -variable [namespace current]::v(doOpositeCircle)
      checkbutton $w.loop.stitchSides    -text "stitch sides"    -variable [namespace current]::v(doSideStitch)
      checkbutton $w.loop.doSpiral       -text "spiral"          -variable [namespace current]::v(doSpiral)



      label $w.loop.n -text "\# segments"
      spinbox $w.loop.segsOpositeSide   -from 0 -to 100 -textvariable [namespace current]::v(segsOpositeSide)   -width 6 -justify right
      spinbox $w.loop.segsOpositeCircle -from 0 -to 100 -textvariable [namespace current]::v(segsOpositeCircle) -width 6 -justify right
      spinbox $w.loop.segsStitchSides   -from 0 -to 100 -textvariable [namespace current]::v(segsStitchSides)   -width 6 -justify right
      spinbox $w.loop.segsSpiral        -from 0 -to 100 -textvariable [namespace current]::v(segsSpiral)        -width 6 -justify right
      


      grid $w.loop.loopL $w.loop.loops
      grid x             $w.loop.homming        $w.loop.n                 -sticky w
      grid x             $w.loop.opositeCorners $w.loop.segsOpositeSide   -sticky w
      grid x             $w.loop.opositeCircle  $w.loop.segsOpositeCircle -sticky w
      grid x             $w.loop.stitchSides    $w.loop.segsStitchSides   -sticky w
      grid x             $w.loop.doSpiral       $w.loop.segsSpiral        -sticky w


    }

    label $w.stlFileLabel -text "Output STL File:"
    entry $w.stlFileName

    canvas $w.view -width [expr {[Settings::Get buildWidth]}] -height  [expr {[Settings::Get buildDepth]}]
    button $w.preview -text "Preview" -command [namespace code Preview]
................................................................................
    if {$v(doSideStitch)} {
      drawPathInCanvas $w.view [stitchSidesXY      $v(x0) $v(y0) $v(x1) $v(y1) $v(segsStitchSides)]  25 {-fill white}
    }
    if {$v(doSpiral)} {
      drawPathInCanvas $w.view [spiralOutXY         $v(x0) $v(y0) $v(x1) $v(y1) $v(segsSpiral)]        1 {-fill purple -arrow none}
      drawPathInCanvas $w.view [spiralInXY          $v(x0) $v(y0) $v(x1) $v(y1) $v(segsSpiral)]        1 {-fill pink -arrow none}
    }






  }

  proc BuildExercise {} {
    variable v
    gcode::write::Open
    gcode::write::Init
    gcode::write::Display "Motor Exercise"
................................................................................
    for {set i 0} {$i < $v(loops)} {incr i} {
      gcode::write::Display "Motor Exercise $i/$v(loops)"
      if {$v(autoHome)} {
        gcode::write::Home
      }
      gcode::write::Path -move [list $v(x0) $v(y0) $v(z0)]
      if {$v(doOpositeSides)} {

        gcode::write::Path -move [squareCrissCrossXY $v(x0) $v(y0) $v(x1) $v(y1) $v(segsOpositeSide)]
      }
      if {$v(doOpositeCircle)} {

        gcode::write::Path -move [roundCrissCrossXY  $v(x0) $v(y0) $v(x1) $v(y1) $v(segsOpositeCircle)]
      }
      if {$v(doSideStitch)} {

        gcode::write::Path -move [stitchSidesXY      $v(x0) $v(y0) $v(x1) $v(y1) $v(segsStitchSides)]
      }
      if {$v(doSpiral)} {

        gcode::write::Path -move [spiralOutXY         $v(x0) $v(y0) $v(x1) $v(y1) $v(segsSpiral)]

        gcode::write::Path -move [spiralInXY          $v(x0) $v(y0) $v(x1) $v(y1) $v(segsSpiral)]
      }








    }
    gcode::write::Close
  }

  proc drawPathInCanvas {c path {delay 0} {pathArgs {}}} {
    set pathPt [lassign $path P0]
    lassign $P0 x0 y0
................................................................................
      for {set deg 0} {$deg < 360} {incr deg 5} {
        set r [expr {1.0*$R/$N*$j+((1.0*$R/$N)*(1-($deg/360.0)))}]
        set i [expr {$deg/360.0*2*$Pi}]
        set x [expr {cos($i)*$r+$Xc}]
        set y [expr {sin($i)*$r+$Yc}]
        lappend path [list $x $y]
      }






































    }
    return $path
  }


}








>
>




>
>







 







>
>






|
>







>
>







 







>
>
>
>
>
>







 







>



>



>



>

>


>
>
>
>
>
>
>
>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
..
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
...
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
...
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
...
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
  set v(bedY1) [Settings::Get buildHeight]
  set v(loops) 20
  set v(autoHome)        1
  set v(doOpositeSides)  1
  set v(doOpositeCircle) 1
  set v(doSideStitch)    1
  set v(doSpiral)        1
  set v(doResonanceX)       1
  set v(doResonanceY)       1
  set v(segsOpositeSide)    5
  set v(segsOpositeCircle) 10
  set v(segsStitchSides)   20
  set v(segsSpiral)        20
  set v(segsResonanceX)     5
  set v(segsResonanceY)     5

  proc ExerciseFrame {} {
    variable w
    catch {destroy $w}
    toplevel $w
    wm title $w "Printer Exercise Frame"

................................................................................
      label $w.loop.loopL -text "loop test \#times = "
      spinbox $w.loop.loops -from 0 -to 100 -textvariable [namespace current]::v(loops) -width 6 -justify right
      checkbutton $w.loop.homming        -text "X/Y/Z homming"   -variable [namespace current]::v(autoHome)
      checkbutton $w.loop.opositeCorners -text "oposite sides"   -variable [namespace current]::v(doOpositeSides)
      checkbutton $w.loop.opositeCircle  -text "oposite circle"  -variable [namespace current]::v(doOpositeCircle)
      checkbutton $w.loop.stitchSides    -text "stitch sides"    -variable [namespace current]::v(doSideStitch)
      checkbutton $w.loop.doSpiral       -text "spiral"          -variable [namespace current]::v(doSpiral)
      checkbutton $w.loop.doResonanceX   -text "resonanceX"      -variable [namespace current]::v(doResonanceX)
      checkbutton $w.loop.doResonanceY   -text "resonanceY"      -variable [namespace current]::v(doResonanceY)

      label $w.loop.n -text "\# segments"
      spinbox $w.loop.segsOpositeSide   -from 0 -to 100 -textvariable [namespace current]::v(segsOpositeSide)   -width 6 -justify right
      spinbox $w.loop.segsOpositeCircle -from 0 -to 100 -textvariable [namespace current]::v(segsOpositeCircle) -width 6 -justify right
      spinbox $w.loop.segsStitchSides   -from 0 -to 100 -textvariable [namespace current]::v(segsStitchSides)   -width 6 -justify right
      spinbox $w.loop.segsSpiral        -from 0 -to 100 -textvariable [namespace current]::v(segsSpiral)        -width 6 -justify right
      spinbox $w.loop.segsResonanceX    -from 0 -to 100 -textvariable [namespace current]::v(segsResonanceX)    -width 6 -justify right
      spinbox $w.loop.segsResonanceY    -from 0 -to 100 -textvariable [namespace current]::v(segsResonanceY)    -width 6 -justify right

      grid $w.loop.loopL $w.loop.loops
      grid x             $w.loop.homming        $w.loop.n                 -sticky w
      grid x             $w.loop.opositeCorners $w.loop.segsOpositeSide   -sticky w
      grid x             $w.loop.opositeCircle  $w.loop.segsOpositeCircle -sticky w
      grid x             $w.loop.stitchSides    $w.loop.segsStitchSides   -sticky w
      grid x             $w.loop.doSpiral       $w.loop.segsSpiral        -sticky w
      grid x             $w.loop.doResonanceX   $w.loop.segsResonanceX    -sticky w
      grid x             $w.loop.doResonanceY   $w.loop.segsResonanceY    -sticky w
    }

    label $w.stlFileLabel -text "Output STL File:"
    entry $w.stlFileName

    canvas $w.view -width [expr {[Settings::Get buildWidth]}] -height  [expr {[Settings::Get buildDepth]}]
    button $w.preview -text "Preview" -command [namespace code Preview]
................................................................................
    if {$v(doSideStitch)} {
      drawPathInCanvas $w.view [stitchSidesXY      $v(x0) $v(y0) $v(x1) $v(y1) $v(segsStitchSides)]  25 {-fill white}
    }
    if {$v(doSpiral)} {
      drawPathInCanvas $w.view [spiralOutXY         $v(x0) $v(y0) $v(x1) $v(y1) $v(segsSpiral)]        1 {-fill purple -arrow none}
      drawPathInCanvas $w.view [spiralInXY          $v(x0) $v(y0) $v(x1) $v(y1) $v(segsSpiral)]        1 {-fill pink -arrow none}
    }
    if {$v(doResonanceX)} {
      drawPathInCanvas $w.view [resonanceX          $v(x0) $v(y0) $v(x1) $v(y1) $v(segsResonanceX)] 1 {-fill orange}
    }
    if {$v(doResonanceY)} {
      drawPathInCanvas $w.view [resonanceY          $v(x0) $v(y0) $v(x1) $v(y1) $v(segsResonanceY)] 1 {-fill cyan}
    }
  }

  proc BuildExercise {} {
    variable v
    gcode::write::Open
    gcode::write::Init
    gcode::write::Display "Motor Exercise"
................................................................................
    for {set i 0} {$i < $v(loops)} {incr i} {
      gcode::write::Display "Motor Exercise $i/$v(loops)"
      if {$v(autoHome)} {
        gcode::write::Home
      }
      gcode::write::Path -move [list $v(x0) $v(y0) $v(z0)]
      if {$v(doOpositeSides)} {
        gcode::write::Display "squareCross $i/$v(loops)"
        gcode::write::Path -move [squareCrissCrossXY $v(x0) $v(y0) $v(x1) $v(y1) $v(segsOpositeSide)]
      }
      if {$v(doOpositeCircle)} {
        gcode::write::Display "circleCross $i/$v(loops)"
        gcode::write::Path -move [roundCrissCrossXY  $v(x0) $v(y0) $v(x1) $v(y1) $v(segsOpositeCircle)]
      }
      if {$v(doSideStitch)} {
        gcode::write::Display "sideStitch $i/$v(loops)"
        gcode::write::Path -move [stitchSidesXY      $v(x0) $v(y0) $v(x1) $v(y1) $v(segsStitchSides)]
      }
      if {$v(doSpiral)} {
        gcode::write::Display "spiralOut $i/$v(loops)"
        gcode::write::Path -move [spiralOutXY         $v(x0) $v(y0) $v(x1) $v(y1) $v(segsSpiral)]
        gcode::write::Display "spiralIn $i/$v(loops)"
        gcode::write::Path -move [spiralInXY          $v(x0) $v(y0) $v(x1) $v(y1) $v(segsSpiral)]
      }
      if {$v(doResonanceX)} {
        gcode::write::Display "resonanceX $i/$v(loops)"
        gcode::write::Path -move [resonanceX          $v(x0) $v(y0) $v(x1) $v(y1) $v(segsResonanceX)]
      }
      if {$v(doResonanceY)} {
        gcode::write::Display "resonanceY $i/$v(loops)"
        gcode::write::Path -move [resonanceY          $v(x0) $v(y0) $v(x1) $v(y1) $v(segsResonanceY)]
      }
    }
    gcode::write::Close
  }

  proc drawPathInCanvas {c path {delay 0} {pathArgs {}}} {
    set pathPt [lassign $path P0]
    lassign $P0 x0 y0
................................................................................
      for {set deg 0} {$deg < 360} {incr deg 5} {
        set r [expr {1.0*$R/$N*$j+((1.0*$R/$N)*(1-($deg/360.0)))}]
        set i [expr {$deg/360.0*2*$Pi}]
        set x [expr {cos($i)*$r+$Xc}]
        set y [expr {sin($i)*$r+$Yc}]
        lappend path [list $x $y]
      }
    }
    return $path
  }

  proc resonanceX {X0 Y0 X1 Y1 N} {
    #test for x-axis resonance, at y,z corners drive X oscillations
    set path {}
    set Xc [expr {($X0+$X1)/2}]
    set Yc [expr {($Y0+$Y1)/2}]
    variable v
    set Z0 $v(z0)
    set Z1 $v(z1)
    set Zc [expr {($Z0+$Z1)/2}]
    foreach z [list $Z0 $Zc $Z1] {
      for {set x $X0} {$x < $Xc} {incr x 1} {
        for {set i 0} {$i < $N} {incr i} {
          lappend path [list $x $Yc $z] [list $Xc $Yc $z]
        }
      }
    }
    return $path
  }

  proc resonanceY {X0 Y0 X1 Y1 N} {
    #test for x-axis resonance, at y,z corners drive X oscillations
    set path {}
    set Xc [expr {($X0+$X1)/2}]
    set Yc [expr {($Y0+$Y1)/2}]
    variable v
    set Z0 $v(z0)
    set Z1 $v(z1)
    set Zc [expr {($Z0+$Z1)/2}]
    foreach z [list $Z0 $Zc $Z1] {
      for {set y $Y0} {$y < $Yc} {incr y 1} {
        for {set i 0} {$i < $N} {incr i} {
          lappend path [list $Xc $y $z] [list $Xc $Yc $z]
        }
      }
    }
    return $path
  }


}