rs232-sigmakoki 0.1.3 → 0.1.4
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.
- data/README +32 -31
- data/lib/rs232-sigmakoki.rb +24 -9
- data/rakefile.rb +15 -5
- data/test/test_rs232-sigmakoki.rb +6 -1
- metadata +13 -8
data/README
CHANGED
@@ -1,39 +1,40 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
1
|
+
|
2
|
+
|
3
|
+
RS232-SigmaKoki
|
4
|
+
|
5
|
+
Ruby interface to Windows Serial Port API
|
6
|
+
|
7
|
+
author hugo benichi
|
8
|
+
email hugo[dot]benichi[at]m4x[dot]org
|
9
|
+
copyright 2012,2013 hugo benichi
|
10
|
+
version 0.1.4
|
11
|
+
|
12
|
+
|
13
|
+
Installation:
|
14
|
+
|
15
|
+
run in the gem root directory:
|
16
|
+
$ rake gem_install
|
17
|
+
|
18
|
+
It will compile the gem library and produce a .gem package for ruby, and
|
19
|
+
automatically install it
|
20
|
+
|
21
|
+
Usage:
|
22
|
+
|
24
23
|
cf test/test_rs232-sigmakoki.rb
|
25
|
-
|
24
|
+
|
26
25
|
the list of commands is
|
27
|
-
|
28
|
-
home # brings back both
|
26
|
+
|
27
|
+
home # brings back both rotating plates to mechanical origin
|
29
28
|
stop # stop with deceleration
|
30
29
|
stop! # emergency stop
|
31
|
-
status # current
|
30
|
+
status # current plate driver status
|
32
31
|
rom # internal rom version
|
33
|
-
ready?
|
34
|
-
busy? # is the stage
|
32
|
+
ready? # is the stage ready to accept the next command
|
33
|
+
busy? # is the stage currently executing some command
|
35
34
|
jog '++'|'++'|'+-' # slowly moves both stages in + or - direction
|
36
|
-
move a,
|
37
|
-
move! a,
|
35
|
+
move a [,b] # move stage 1 of a steps, and stage 2 of b steps
|
36
|
+
move! a [,b] # same as move, but wait until the stages are ready
|
37
|
+
amove a [,b] # move stage 1 to position ax, and stage 2 to b
|
38
|
+
amove! a [,b] # same as amove, but wait until the stages are ready
|
38
39
|
position # return the position of both stages
|
39
40
|
position_of i # return the position of stage i (1,2)
|
data/lib/rs232-sigmakoki.rb
CHANGED
@@ -2,6 +2,7 @@ class SigmaKoki
|
|
2
2
|
|
3
3
|
require 'rs232'
|
4
4
|
|
5
|
+
# programatically define commands
|
5
6
|
[
|
6
7
|
[:home, 'H:W--'],
|
7
8
|
[:stop, 'L:W'],
|
@@ -9,44 +10,53 @@ class SigmaKoki
|
|
9
10
|
[:go, 'G'],
|
10
11
|
].each{ |meth,c| define_method(meth){ @comm.write c} }
|
11
12
|
|
13
|
+
# programatically define queries
|
12
14
|
[
|
13
15
|
[:status, 'Q:'],
|
14
16
|
[:rom, '?:V'],
|
15
17
|
[:busy, '!:'],
|
16
18
|
].each{ |meth,c| define_method(meth){ @comm.query c} }
|
17
19
|
|
18
|
-
|
20
|
+
# checks if the device is idle
|
19
21
|
def ready?
|
20
22
|
'R' == self.busy[0] #gsub(' ','').split(',')[-1]
|
21
23
|
end
|
22
24
|
|
25
|
+
# checks if the device is currently bury rotating
|
23
26
|
def busy?
|
24
27
|
'B' == self.busy[0] #gsub(' ','').split(',')[-1]
|
25
28
|
end
|
26
29
|
|
27
|
-
|
30
|
+
# blocking wait until the device is free to execute command again
|
31
|
+
def wait
|
28
32
|
sleep 0.2 while busy?
|
29
33
|
end
|
30
|
-
|
34
|
+
|
35
|
+
# initiates a continuous and slow rotation
|
31
36
|
def jog *args
|
32
37
|
@comm.write "J:W%s%s" % args[0..1]
|
33
38
|
go
|
34
39
|
end
|
35
40
|
|
36
|
-
|
41
|
+
# main command to rotate the plates (non-blocking)
|
42
|
+
# step1 and step2 are the number of angle units to move (relative move)
|
37
43
|
def move step1, step2 = 0
|
38
|
-
|
44
|
+
step1 = 0 if step1.nil?
|
39
45
|
s1, s2 = step1 > 0 ? "+" : "-", step2 > 0 ? "+" : "-"
|
40
46
|
command = "M:W%sP%i%sP%i" % [s1,step1.abs,s2,step2.abs]
|
41
47
|
@comm.write command
|
42
48
|
go
|
43
49
|
end
|
44
|
-
|
50
|
+
|
51
|
+
# main command to rotate the plates (blocking)
|
52
|
+
# step1 and step2 are the number of angle units to move (relative move)
|
45
53
|
def move! step1, step2 = 0
|
46
54
|
move step1, step2
|
47
55
|
wait
|
48
56
|
end
|
49
57
|
|
58
|
+
# main command to rotate the plates (non-blocking)
|
59
|
+
# step1 and step2 are the final angular position (absolute move)
|
50
60
|
def amove *step_args
|
51
61
|
move *self.position.map { |x|
|
52
62
|
y = step_args.shift
|
@@ -54,20 +64,25 @@ class SigmaKoki
|
|
54
64
|
}
|
55
65
|
end
|
56
66
|
|
67
|
+
# main command to rotate the plates (blocking)
|
68
|
+
# step1 and step2 are the final angular position (absolute move)
|
57
69
|
def amove! *step_args
|
58
70
|
amove *step_args
|
59
71
|
wait
|
60
72
|
end
|
61
|
-
|
73
|
+
|
74
|
+
# pulls back the rotating plates to mechanical origin (blocking)
|
62
75
|
def home!
|
63
76
|
home
|
64
77
|
wait
|
65
78
|
end
|
66
|
-
|
79
|
+
|
80
|
+
# gets current position of plates (length 2 array)
|
67
81
|
def position
|
68
82
|
self.status.gsub(' ','').split(',').map{|x| x.to_i}[0..1]
|
69
83
|
end
|
70
|
-
|
84
|
+
|
85
|
+
# gets current position of plate 1 or 2
|
71
86
|
def position_of chan
|
72
87
|
self.status.gsub(' ','').split(',')[chan-1].to_i
|
73
88
|
end
|
data/rakefile.rb
CHANGED
@@ -1,10 +1,20 @@
|
|
1
|
-
task :test_global do
|
2
|
-
|
1
|
+
task :test_global do # if testing after gem install
|
2
|
+
ruby "test/test_rs232-sigmakoki.rb"
|
3
|
+
end
|
4
|
+
|
5
|
+
task :test_local do # if testing from gem root dir
|
6
|
+
ruby "-Ilib test/test_rs232-sigmakoki.rb"
|
7
|
+
end
|
8
|
+
|
9
|
+
task :gem_build do
|
10
|
+
sh "gem build rs232-sigmakoki.gemspec"
|
11
|
+
end
|
3
12
|
|
4
|
-
task :gem_build do sh "gem build rs232-sigmakoki.gemspec" end
|
5
13
|
task :gem_install => :gem_build do
|
6
|
-
gemfile = Dir.new("./").entries.select{ |f|
|
14
|
+
gemfile = Dir.new("./").entries.select{ |f|
|
15
|
+
f =~ /rs232-sigmakoki-[\d]+\.[\d]+\.[\d]+.gem/ # auto-get find current vers
|
16
|
+
}.sort[-1]
|
7
17
|
sh "gem install --local %s" % gemfile
|
8
18
|
end
|
9
19
|
|
10
|
-
task :default => :test_local
|
20
|
+
task :default => :test_local
|
@@ -1,5 +1,10 @@
|
|
1
1
|
require 'rs232-sigmakoki'
|
2
2
|
|
3
|
+
# A simple test program to confirm the good communication with the
|
4
|
+
# plate rotator over serial port.
|
5
|
+
#
|
6
|
+
# By default the port name used is 'COM1'
|
7
|
+
|
3
8
|
plate = SigmaKoki.new 'COM1'
|
4
9
|
|
5
10
|
plate.home
|
@@ -24,4 +29,4 @@ plate.move! 20000
|
|
24
29
|
plate.home
|
25
30
|
|
26
31
|
|
27
|
-
puts "ok"
|
32
|
+
puts "ok"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rs232-sigmakoki
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-03-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rs232
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,15 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
25
|
-
|
26
|
-
|
27
|
-
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
description: Allows to script the control of SigmaKoki step motor controllers with
|
31
|
+
simple command without directly dealing with the serial port
|
32
|
+
email: hugo[dot]benichi[at]m4x[dot]org
|
28
33
|
executables: []
|
29
34
|
extensions: []
|
30
35
|
extra_rdoc_files: []
|
@@ -53,7 +58,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
53
58
|
version: '0'
|
54
59
|
requirements: []
|
55
60
|
rubyforge_project:
|
56
|
-
rubygems_version: 1.8.
|
61
|
+
rubygems_version: 1.8.23
|
57
62
|
signing_key:
|
58
63
|
specification_version: 3
|
59
64
|
summary: Ruby interface to SigmaKoki step motor controllers over the serial interface
|