rotor 0.0.8 → 0.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: efdfa8dfa157a160fd34ee4cba2172ad9c61a0fd
4
- data.tar.gz: be2e7ac6ae1eff646744f446ea2e68b9b6086057
3
+ metadata.gz: aa2fcf001b7e6b6b5e85665dddef2e60e7e2c3f5
4
+ data.tar.gz: 2bacd1a6fe7eb1f2059cc33475353edfae4a7021
5
5
  SHA512:
6
- metadata.gz: 211018402c1a451afd286a73d82d0643e6703fde6c377e26c666454370333d2f3c2446c4f70b71ddfa4f5560991102daa1594f9547502a2ced40e8dd5a2bd4c9
7
- data.tar.gz: f31608d7e2eba65c05131e2e50afe5147b72edb3eecd43c6eb45b1a2c704f94327a2aa5af6003154b580aa7a7e771efda86f1b953434b7f216d92efc2f38ed2e
6
+ metadata.gz: 7724f36d2c54faa710930479ffffc837c6891ebe83410f10b467972adb9df55e66720efde485f67a6ebc8e8293773ec66382eaa4bd6bbd038ab1f6b8a103aa20
7
+ data.tar.gz: 8e61f974397d41c4a611107641ade1303200c20701415dd2267f18720aa11d2677a235a8aa4a66c17876d7693d169cd0025e00fb29c927b98df4e9c63bfb8ffa
data/.DS_Store CHANGED
Binary file
data/lib/.DS_Store ADDED
Binary file
Binary file
@@ -0,0 +1,29 @@
1
+ module Rotor
2
+ class Gcode
3
+ def initialize(stepper_x=nil,stepper_y=nil)
4
+ @stepper_x = stepper_x
5
+ @stepper_y = stepper_y
6
+ end
7
+
8
+ def open(file)
9
+ @file = File.open(file)
10
+ end
11
+
12
+ def simulate
13
+ @file.each_line do |line|
14
+ case line[0]
15
+ when "G"
16
+ puts "GLINE"
17
+ when "M"
18
+ puts "MLINE"
19
+ else
20
+ puts "something else"
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+
27
+ gcode = Rotor::Gcode.new
28
+ gcode.open('sample.nc')
29
+ gcode.simulate
data/lib/rotor/motor.rb CHANGED
@@ -63,16 +63,11 @@ module Rotor
63
63
  `echo #{homing_switch} > /sys/class/gpio/unexport`
64
64
  @io.mode(homing_switch,INPUT)
65
65
  @move = true
66
-
67
66
  while @move == true
68
- backwards(10,5) if direction == :backwards && @io.read(homing_switch) == homing_normally
69
- forward(10,5) if direction == :forward && @io.read(homing_switch) == homing_normally
67
+ backwards(2,1) if direction == :backwards #&& @io.read(homing_switch) == homing_normally
68
+ forward(2,1) if direction == :forward #&& @io.read(homing_switch) == homing_normally
69
+ @move = false unless @io.read(homing_switch) == homing_normally
70
70
  end
71
-
72
- #after :pin => homing_switch, :goes => homing_normally_open do
73
- # @move = false
74
- #end
75
-
76
71
  end
77
72
 
78
73
  end
@@ -0,0 +1,75 @@
1
+ require 'wiringpi'
2
+
3
+ module Rotor
4
+ class Stepper
5
+ def initialize(coil_A_1_pin, coil_A_2_pin, coil_B_1_pin, coil_B_2_pin, enable_pin=nil, homing_switch, homing_normally)
6
+ @io = WiringPi::GPIO.new(WPI_MODE_GPIO)
7
+ @coil_A_1_pin = coil_A_1_pin
8
+ @coil_A_2_pin = coil_A_2_pin
9
+ @coil_B_1_pin = coil_B_1_pin
10
+ @coil_B_2_pin = coil_B_2_pin
11
+ @enable_pin = enable_pin
12
+
13
+ @homing_switch = homing_switch
14
+ @homing_normally = homing_normally
15
+ [@coil_A_1_pin, @coil_A_2_pin, @coil_B_1_pin, @coil_B_2_pin].each do |pin|
16
+ `echo #{pin} > /sys/class/gpio/unexport`
17
+ @io.mode(pin,OUTPUT)
18
+ @io.write(pin,LOW)
19
+ end
20
+
21
+ unless @enable_pin == nil
22
+ `echo #{@enable_pin} > /sys/class/gpio/unexport`
23
+ @io.mode(@enable_pin,OUTPUT)
24
+ @io.write(@enable_pin,LOW)
25
+ @io.write(@enable_pin,HIGH)
26
+ end
27
+ end
28
+
29
+ def forward(delay=5,steps=100)
30
+ delay_time = delay/1000.0
31
+ (0..steps).each do |i|
32
+ set_step(1, 0, 1, 0)
33
+ sleep delay_time
34
+ set_step(0, 1, 1, 0)
35
+ sleep delay_time
36
+ set_step(0, 1, 0, 1)
37
+ sleep delay_time
38
+ set_step(1, 0, 0, 1)
39
+ sleep delay_time
40
+ end
41
+ end
42
+
43
+ def backwards(delay=5,steps=100)
44
+ delay_time = delay/1000.0
45
+ (0..steps).each do |i|
46
+ set_step(1, 0, 0, 1)
47
+ sleep delay_time
48
+ set_step(0, 1, 0, 1)
49
+ sleep delay_time
50
+ set_step(0, 1, 1, 0)
51
+ sleep delay_time
52
+ set_step(1, 0, 1, 0)
53
+ sleep delay_time
54
+ end
55
+ end
56
+
57
+ def set_step(w1, w2, w3, w4)
58
+ @io.write(@coil_A_1_pin, w1)
59
+ @io.write(@coil_A_2_pin, w2)
60
+ @io.write(@coil_B_1_pin, w3)
61
+ @io.write(@coil_B_2_pin, w4)
62
+ end
63
+
64
+ def set_home(direction)
65
+ `echo #{@homing_switch} > /sys/class/gpio/unexport`
66
+ @io.mode(@homing_switch,INPUT)
67
+ @move = true
68
+ while @move == true
69
+ backwards(10,5) if direction == :backwards && @io.read(@homing_switch) == @homing_normally
70
+ forward(10,5) if direction == :forward && @io.read(@homing_switch) == @homing_normally
71
+ end
72
+ end
73
+
74
+ end
75
+ end
data/lib/rotor/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Rotor
2
- VERSION = "0.0.8"
2
+ VERSION = "0.0.9"
3
3
  end
data/lib/rotor.rb CHANGED
@@ -1,5 +1,4 @@
1
1
  require "rotor/version"
2
- require 'rotor/motor'
2
+ require 'rotor/stepper'
3
3
  module Rotor
4
- # Your code goes here...
5
4
  end
data/sample.nc ADDED
@@ -0,0 +1,24 @@
1
+
2
+ G90
3
+ G21
4
+ G0 X5.3854 Y15.7945
5
+
6
+ M03
7
+ G1 F100.000000
8
+ G1 X10.5888 Y15.7945
9
+ G1 X10.5888 Y14.8575
10
+ G1 X6.4988 Y14.8575
11
+ G1 X6.4988 Y12.4211
12
+ G1 X10.418 Y12.4211
13
+ G1 X10.418 Y11.484
14
+ G1 X6.4988 Y11.484
15
+ G1 X6.4988 Y8.5019
16
+ G1 X10.6881 Y8.5019
17
+ G1 X10.6881 Y7.5649
18
+ G1 X5.3854 Y7.5649
19
+ G1 X5.3854 Y15.7945
20
+ M05
21
+
22
+ G0 X0.000 Y0.000
23
+ M05
24
+ M02
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rotor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - kobaltz
@@ -65,10 +65,15 @@ files:
65
65
  - LICENSE.txt
66
66
  - README.md
67
67
  - Rakefile
68
+ - lib/.DS_Store
68
69
  - lib/rotor.rb
70
+ - lib/rotor/.DS_Store
71
+ - lib/rotor/gcode.rb
69
72
  - lib/rotor/motor.rb
73
+ - lib/rotor/stepper.rb
70
74
  - lib/rotor/version.rb
71
75
  - rotor.gemspec
76
+ - sample.nc
72
77
  homepage: https://github.com/kobaltz
73
78
  licenses:
74
79
  - MIT