rotor 0.1.9 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 50f2b68c317d9cb0d9b000f8d082c1372c3cab25
4
- data.tar.gz: ba40643e271f161807e12782e30c0ecd8b0edc63
3
+ metadata.gz: 113473297a421939fb5df7f1e6297aab7f7db0ab
4
+ data.tar.gz: daa003e3aa36d83c96410389d3ef85ec4ec54df1
5
5
  SHA512:
6
- metadata.gz: 18bf94a2ebec5eb2c47ad03756f8b59fe4e773b9b8009da8d6fc8733f167e441f37d6fac60c4bc110e9009b2114a2c8eefce5573d294dd56ff80c470cdfc65e4
7
- data.tar.gz: 11d6bf222f6ee4d8ea3b989d347f900dbf8937c1078e8d495f75702e9dd8d6a1346be45e80469881f1ca69af371ce94c5873d1f9f75c4d6f7ee5bc07e3abe39e
6
+ metadata.gz: 98e16965a096bcdbe70c40e0147b791ae9b8193c1d0a9772f591448ce55dd75c5cbf94c5a4f500a1dd717553033e18ce2f85451aa364bb074a8112f8a2c948f6
7
+ data.tar.gz: 33a57e1c215bede215b05e6817021357c176c309b7240c3dc00512f7f2d700bd08bccb0af7486054c86eefba1b320face637b2d68ac0074fc7d6dd20d2f0cab4
@@ -1,6 +1,16 @@
1
1
  Rotor (Ruby Motor)
2
2
  ==================
3
3
 
4
+ Version 0.2.0
5
+ -------------
6
+
7
+ My only experience with GCode is stuff that I have generated. However, upon experimenting with
8
+ various other types of GCode and generators, I have found that the repetition of G0 and G1 is not
9
+ always necessary. This version takes into account the previous command if no new one is provided for
10
+ G movements.
11
+
12
+ I've also added back in the movement delays that were causing some problems before.
13
+
4
14
  Version 0.1.9
5
15
  -------------
6
16
 
@@ -21,16 +21,17 @@ module Rotor
21
21
  line_num = 0
22
22
 
23
23
  @file.each_line do |line|
24
+ line[0..2] = @previous_command if line[0..2] == " "
24
25
  parsed_line = parse_line(line)
25
26
 
26
27
  line_num += 1
27
28
  if parsed_line[:g]
28
29
  #Move to this origin point.
29
30
  if parsed_line[:g] == 0
30
- puts "Move Stepper::#{parsed_line}"
31
+ puts "Move Stepper (#{line_num})::#{parsed_line}"
31
32
  move_stepper(parsed_line,@fast_move)
32
33
  elsif parsed_line[:g] == 1
33
- puts "Move Stepper::#{parsed_line}"
34
+ puts "Move Stepper (#{line_num})::#{parsed_line}"
34
35
  move_stepper(parsed_line,speed)
35
36
  elsif parsed_line[:g] == 2 || parsed_line[:g] == 3
36
37
  # Get my ARC on
@@ -85,14 +86,14 @@ module Rotor
85
86
  arc_line[:x] = radius * Math.cos(current_degrees) + x_origin
86
87
  arc_line[:y] = radius * Math.sin(current_degrees) + y_origin
87
88
  arc_line[:z] = nil
88
- puts "Move Arc Stepper (#{line_num})::#{arc_line}::#{start_angle},#{end_angle}"
89
+ # puts "Move Arc Stepper (#{line_num})::#{arc_line}::#{start_angle},#{end_angle}"
89
90
  move_stepper(arc_line,speed)
90
91
  end unless ignore
91
92
 
92
93
  else
93
- # puts "GLINE - Something else"
94
- puts "DEBUG::GLINE - Something else::#{parsed_line}"
94
+ # puts "DEBUG::GLINE - Something else::#{parsed_line}"
95
95
  end
96
+ @previous_command = line[0..2]
96
97
  elsif parsed_line[:m]
97
98
  if line[0..2] == "M03"
98
99
  puts "Lowering marker"
@@ -101,13 +102,11 @@ module Rotor
101
102
  puts "Lifting marker"
102
103
  @servo.rotate(:up) if @servo
103
104
  else
104
- # puts "MLINE - Something else"
105
- puts "DEBUG::MLINE - Something else::#{parsed_line}"
105
+ # puts "DEBUG::MLINE - Something else::#{parsed_line}"
106
106
  end
107
107
  else
108
- # puts "Something else"
109
- puts "DEBUG::????? - Something else::#{parsed_line}"
110
- end
108
+ # puts "DEBUG::????? - Something else::#{parsed_line}"
109
+ end
111
110
  end
112
111
  end
113
112
 
@@ -115,12 +114,15 @@ module Rotor
115
114
 
116
115
  def move_stepper(parsed_line,delay)
117
116
  threads = []
117
+ comp_delay_calc = []
118
+
118
119
  @x_move = nil
119
120
  if parsed_line[:x]
120
121
  @x_move = parsed_line[:x]
121
122
  @x_move ||= 0
122
123
  @x_move *= @scale
123
124
  @x_movement = (@x_move - @x).abs
125
+ comp_delay_calc << @x_movement
124
126
  end
125
127
 
126
128
  @y_move = nil
@@ -129,6 +131,7 @@ module Rotor
129
131
  @y_move ||= 0
130
132
  @y_move *= @scale
131
133
  @y_movement = (@y_move - @y).abs
134
+ comp_delay_calc << @y_movement
132
135
  end
133
136
 
134
137
  @z_move = nil
@@ -137,10 +140,12 @@ module Rotor
137
140
  @z_move ||= 0
138
141
  @z_move *= @scale
139
142
  @z_movement = (@z_move - @z).abs
143
+ comp_delay_calc << @z_movement
140
144
  end
141
145
 
142
-
143
146
  if parsed_line[:x]
147
+ x_delay = comp_delay_calc.max * delay / @x_movement
148
+ x_delay = delay if x_delay == 0.0
144
149
  if @x_move.to_f < @x #move to the right
145
150
  if @stepper_x # && @stepper_x.at_safe_area?
146
151
  threads << Thread.new { @stepper_x.forward(delay, @x_movement) }
@@ -152,36 +157,40 @@ module Rotor
152
157
  end unless @x_movement == 0
153
158
  @x = @x_move
154
159
  end
160
+ @x_move ||= @x
155
161
 
156
162
  if parsed_line[:y]
163
+ y_delay = comp_delay_calc.max * delay / @y_movement
164
+ y_delay = delay if y_delay == 0.0
157
165
  if @y_move.to_f < @y #move to the right
158
166
  if @stepper_y # && @stepper_y.at_safe_area?
159
- threads << Thread.new { @stepper_y.forward(delay, @y_movement) }
167
+ threads << Thread.new { @stepper_y.forward(y_delay, @y_movement) }
160
168
  end
161
169
  elsif @y_move.to_f > @y #move to the left
162
170
  if @stepper_y # && @stepper_y.at_safe_area?
163
- threads << Thread.new { @stepper_y.backwards(delay, @y_movement) }
171
+ threads << Thread.new { @stepper_y.backwards(y_delay, @y_movement) }
164
172
  end
165
173
  end unless @y_movement == 0
166
174
  @y = @y_move
167
175
  end
176
+ @y_move ||= @y
168
177
 
169
178
  if parsed_line[:z]
179
+ z_delay = comp_delay_calc.max * delay / @z_movement
180
+ z_delay = delay if z_delay == 0.0
170
181
  if @z_move.to_f > @z #move to the right
171
182
  if @stepper_z # && @stepper_z.at_safe_area?
172
- threads << Thread.new { @stepper_z.forward(delay, @z_movement) }
183
+ threads << Thread.new { @stepper_z.forward(z_delay, @z_movement) }
173
184
  end
174
185
  elsif @z_move.to_f < @z #move to the left
175
186
  if @stepper_z # && @stepper_z.at_safe_area?
176
- threads << Thread.new { @stepper_z.backwards(delay, @z_movement) }
187
+ threads << Thread.new { @stepper_z.backwards(z_delay, @z_movement) }
177
188
  end
178
189
  end unless @z_movement == 0
179
190
  @z = @z_move
180
- end
181
- puts "Moving to G#{parsed_line[:g]} #{@x_move}(#{@x_movement}), #{@y_move}(#{@y_movement}), #{@z_move}(#{@z_movement})"
182
- sleep (delay * 500) if @x_move == 0.0 && @y_move == 0.0 && @z_move > 0.0
191
+ end
192
+ @z_move ||= @z
183
193
  threads.each { |thr| thr.join }
184
- sleep (delay * 500) if @x_move == 0.0 && @y_move == 0.0 && @z_move > 0.0
185
194
  File.open("output.txt", 'a') { |file| file.write("#{@x_move},#{@y_move},#{@z_move},#{@x_movement},#{@y_movement},#{@z_movement}\n") } if File.exists?("output.txt")
186
195
  end
187
196
 
@@ -1,3 +1,3 @@
1
1
  module Rotor
2
- VERSION = "0.1.9"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rotor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - kobaltz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-06 00:00:00.000000000 Z
11
+ date: 2015-02-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler