rotor 0.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7e809240d00248a17b4f0968d9ef774a433bd618
4
+ data.tar.gz: 6c23efe5fd4047c8ac3f4f3ad36a688b9c6c6dd9
5
+ SHA512:
6
+ metadata.gz: 17b772dedf3a7b7afcbd89cef0054ab3218fa09fb007439b98208b710f917ab9f7db6f6091e10ea634404481805da828321ca9d6bd11fb88fcbc1bcbb5506d8d
7
+ data.tar.gz: 42d6859e214b3309e0abd1e500f7b6eaac9fe90e2b3e1ae45cf2ae7f811515f700025f4e840e15efcba2aa7bcbd6724300843da31ce9cd22fbe39946c0d703c1
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rotor.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 kobaltz
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,81 @@
1
+ # Rotor (Ruby Motor)
2
+
3
+ Tested on RaspberryPi Model B+ but should work for any Raspberry Pi.
4
+
5
+ This Ruby gem allows you to control different kinds of stepper motors. You
6
+ can use this gem to run both Bipolar and Unipolar motors with either L293D
7
+ or ULN2800 Integrated Controllers.
8
+
9
+ ## Installation
10
+
11
+ Make sure that you have WiringPi installed first
12
+
13
+ gem install wiringpi
14
+
15
+ Install Rotor
16
+
17
+ gem install rotor
18
+
19
+ # Usage
20
+
21
+ The goal of this gem is to make controlling your robotics easier than
22
+ other solutions.
23
+
24
+ stepper_x = Rotor::Stepper.new(4,17,23,24,18)
25
+ stepper_y = Rotor::Stepper.new(25,12,16,21,18)
26
+
27
+ loop do
28
+ puts "Enter steps forward::"
29
+ text = gets.chomp
30
+
31
+ threads = []
32
+ threads << Thread.new { stepper_x.forward(5,text.to_i) }
33
+ threads << Thread.new { stepper_y.forward(5,text.to_i) }
34
+ threads.each { |thr| thr.join }
35
+
36
+ puts "Enter steps backward::"
37
+ text = gets.chomp
38
+
39
+ stepper_x.backwards(5,text.to_i)
40
+ stepper_y.backwards(5,text.to_i)
41
+ end
42
+
43
+ # Asynchronous Movement
44
+
45
+ By default, if you run the first motor and then the second motor commands,
46
+ the first command will execute first and the second one will execute afterwards.
47
+ This may not always be the desired result as your plot/laser/mill may get ruined
48
+ by having nonsynchronous movements.
49
+
50
+ Since Ruby by default will not asynchronously execute commands, you can combine
51
+ the X/Y/Z movements into their own threads.
52
+
53
+ threads = []
54
+ threads << Thread.new { stepper_x.forward(5,text.to_i) }
55
+ threads << Thread.new { stepper_y.forward(5,text.to_i) }
56
+ threads.each { |thr| thr.join }
57
+
58
+ # License
59
+
60
+ Copyright (c) 2015 kobaltz
61
+
62
+ MIT License
63
+
64
+ Permission is hereby granted, free of charge, to any person obtaining
65
+ a copy of this software and associated documentation files (the
66
+ "Software"), to deal in the Software without restriction, including
67
+ without limitation the rights to use, copy, modify, merge, publish,
68
+ distribute, sublicense, and/or sell copies of the Software, and to
69
+ permit persons to whom the Software is furnished to do so, subject to
70
+ the following conditions:
71
+
72
+ The above copyright notice and this permission notice shall be
73
+ included in all copies or substantial portions of the Software.
74
+
75
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
76
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
77
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
78
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
79
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
80
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
81
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,53 @@
1
+ module Rotor
2
+ class Stepper
3
+ def initialize(coil_A_1_pin, coil_A_2_pin, coil_B_1_pin, coil_B_2_pin, enable_pin)
4
+ @io = WiringPi::GPIO.new(WPI_MODE_GPIO)
5
+ @coil_A_1_pin = coil_A_1_pin
6
+ @coil_A_2_pin = coil_A_2_pin
7
+ @coil_B_1_pin = coil_B_1_pin
8
+ @coil_B_2_pin = coil_B_2_pin
9
+ @enable_pin = enable_pin
10
+ [coil_A_1_pin, coil_A_2_pin, coil_B_1_pin, coil_B_2_pin, enable_pin].each do |pin|
11
+ `echo #{pin} > /sys/class/gpio/unexport`
12
+ @io.mode(pin,OUTPUT)
13
+ @io.write(pin,LOW)
14
+ end
15
+ @io.write(enable_pin,HIGH)
16
+ end
17
+
18
+ def forward(delay=5,steps=100)
19
+ delay_time = delay/1000.0
20
+ (0..steps).each do |i|
21
+ set_step(1, 0, 1, 0)
22
+ sleep delay_time
23
+ set_step(0, 1, 1, 0)
24
+ sleep delay_time
25
+ set_step(0, 1, 0, 1)
26
+ sleep delay_time
27
+ set_step(1, 0, 0, 1)
28
+ sleep delay_time
29
+ end
30
+ end
31
+
32
+ def backwards(delay=5,steps=100)
33
+ delay_time = delay/1000.0
34
+ (0..steps).each do |i|
35
+ set_step(1, 0, 0, 1)
36
+ sleep delay_time
37
+ set_step(0, 1, 0, 1)
38
+ sleep delay_time
39
+ set_step(0, 1, 1, 0)
40
+ sleep delay_time
41
+ set_step(1, 0, 1, 0)
42
+ sleep delay_time
43
+ end
44
+ end
45
+
46
+ def set_step(w1, w2, w3, w4)
47
+ @io.write(@coil_A_1_pin, w1)
48
+ @io.write(@coil_A_2_pin, w2)
49
+ @io.write(@coil_B_1_pin, w3)
50
+ @io.write(@coil_B_2_pin, w4)
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,3 @@
1
+ module Rotor
2
+ VERSION = "0.0.1"
3
+ end
data/lib/rotor.rb ADDED
@@ -0,0 +1,5 @@
1
+ require "rotor/version"
2
+ require 'rotor/motor'
3
+ module Rotor
4
+ # Your code goes here...
5
+ end
data/rotor.gemspec ADDED
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'rotor/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "rotor"
8
+ spec.version = Rotor::VERSION
9
+ spec.authors = ["kobaltz"]
10
+ spec.email = ["dave@k-innovations.net"]
11
+ spec.summary = %q{Ruby Gem for controlling Bipolar and Unipolar motors}
12
+ spec.description = %q{Ruby Gem for controlling Bipolar and Unipolar motors}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.7"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_dependency "wiringpi"
24
+ end
metadata ADDED
@@ -0,0 +1,95 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rotor
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - kobaltz
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-01-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: wiringpi
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Ruby Gem for controlling Bipolar and Unipolar motors
56
+ email:
57
+ - dave@k-innovations.net
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - Gemfile
64
+ - LICENSE.txt
65
+ - README.md
66
+ - Rakefile
67
+ - lib/rotor.rb
68
+ - lib/rotor/motor.rb
69
+ - lib/rotor/version.rb
70
+ - rotor.gemspec
71
+ homepage: ''
72
+ licenses:
73
+ - MIT
74
+ metadata: {}
75
+ post_install_message:
76
+ rdoc_options: []
77
+ require_paths:
78
+ - lib
79
+ required_ruby_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ required_rubygems_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ requirements: []
90
+ rubyforge_project:
91
+ rubygems_version: 2.4.5
92
+ signing_key:
93
+ specification_version: 4
94
+ summary: Ruby Gem for controlling Bipolar and Unipolar motors
95
+ test_files: []