Ok, better late than never I hope, I finally looked at the Feb 1
gearchanger, and here's some feedback:
The old gearchange in 2.4 has two gears: 1 and 2. When in gear 1,
output = input. When in gear 2, the output = input / scale2. In the
new gearchanger, output = input / scale-M. So the meaning of the scale
is consistent with the old version, and that's nice. :-)
The code is written in a way that's hard for me to read. This may be a
personal taste thing, but statements like these:
if (gear_number != -1) gear = gear_number;
else for (gear = personality-1 ; gear > 0 && !sel(gear) ; gear--) {}
and:
speed_target = speed_filtered / scale(gear) * ((speed_in < 0)?
-1 : 1);}
Seem more dense than clear. "Optimize for folk reading the code."
The unusual handling of personality would benefit from a comment in the
code.
It was hard for me to figure out from the manpage how it's supposed to
work. The documentation could be clearer I think. Some examples:
How is output computed from input and scale? Is it "output = input
* scale" or is it "output = input / scale"? Sure, I can test it, or
read the source code, but it'd be nice if the manpage just told me.
The speed-out command does not necessarily go to a DAC or PWM, as
the docs suggest. The only gearchange user I know of (the tormach
config) runs the output of the gearchanger into a velocity mode stepgen
(the spindle driver is controlled by the frequency of the signal).
Other things too, those are just some examples. A bit of time
invested early in docs can often save you lots of time later explaining
on the lists how it works.
I've added the beginnings of a testcase for the gearchanger, which shows
it working. So that's good.
Well that's all i have.
--
Sebastian Kuzminsky
>From 82350051fa9f02dbb9c4f68027974aba35aaa860 Mon Sep 17 00:00:00 2001
From: Sebastian Kuzminsky <[email protected]>
Date: Fri, 1 Apr 2011 16:04:15 -0600
Subject: [PATCH] gearchange: add a test
---
tests/gearchange/expected | 86 ++++++++++++++++++++++++++++
tests/gearchange/gearchange-input-patterns | 85 +++++++++++++++++++++++++++
tests/gearchange/runsampler | 3 +
tests/gearchange/runstreamer | 2 +
tests/gearchange/test.hal | 61 ++++++++++++++++++++
5 files changed, 237 insertions(+), 0 deletions(-)
create mode 100644 tests/gearchange/expected
create mode 100644 tests/gearchange/gearchange-input-patterns
create mode 100644 tests/gearchange/runsampler
create mode 100644 tests/gearchange/runstreamer
create mode 100644 tests/gearchange/test.hal
diff --git a/tests/gearchange/expected b/tests/gearchange/expected
new file mode 100644
index 0000000..8c92e2f
--- /dev/null
+++ b/tests/gearchange/expected
@@ -0,0 +1,86 @@
+# gear-number, speed-in, dir-in, speed-out, dir-out, min-lim, max-lim
+0 0.000000 0 0.000000 0 0 0
+0 12.000000 0 0.000000 0 0 0
+0 123.000000 0 0.000000 0 0 0
+0 1234.000000 0 0.000000 0 0 0
+0 12345.000000 0 0.000000 0 0 0
+0 -12.000000 0 0.000000 0 0 0
+0 -123.000000 0 0.000000 0 0 0
+0 -1234.000000 0 0.000000 0 0 0
+0 -12345.000000 0 0.000000 0 0 0
+0 12.000000 1 0.000000 1 0 0
+0 123.000000 1 0.000000 1 0 0
+0 1234.000000 1 0.000000 1 0 0
+0 12345.000000 1 0.000000 1 0 0
+0 -12.000000 1 0.000000 1 0 0
+0 -123.000000 1 0.000000 1 0 0
+0 -1234.000000 1 0.000000 1 0 0
+0 -12345.000000 1 0.000000 1 0 0
+1 0.000000 0 0.000000 0 0 0
+1 12.000000 0 100.000000 0 1 0
+1 123.000000 0 246.000000 0 0 0
+1 1234.000000 0 2468.000000 0 0 0
+1 12345.000000 0 5000.000000 0 0 1
+1 -12.000000 0 -100.000000 0 1 0
+1 -123.000000 0 -246.000000 0 0 0
+1 -1234.000000 0 -2468.000000 0 0 0
+1 -12345.000000 0 -5000.000000 0 0 1
+1 12.000000 1 100.000000 1 1 0
+1 123.000000 1 246.000000 1 0 0
+1 1234.000000 1 2468.000000 1 0 0
+1 12345.000000 1 5000.000000 1 0 1
+1 -12.000000 1 -100.000000 1 1 0
+1 -123.000000 1 -246.000000 1 0 0
+1 -1234.000000 1 -2468.000000 1 0 0
+1 -12345.000000 1 -5000.000000 1 0 1
+2 0.000000 0 0.000000 0 0 0
+2 12.000000 0 100.000000 0 1 0
+2 123.000000 0 123.000000 0 0 0
+2 1234.000000 0 1234.000000 0 0 0
+2 12345.000000 0 5000.000000 0 0 1
+2 -12.000000 0 -100.000000 0 1 0
+2 -123.000000 0 -123.000000 0 0 0
+2 -1234.000000 0 -1234.000000 0 0 0
+2 -12345.000000 0 -5000.000000 0 0 1
+2 12.000000 1 100.000000 1 1 0
+2 123.000000 1 123.000000 1 0 0
+2 1234.000000 1 1234.000000 1 0 0
+2 12345.000000 1 5000.000000 1 0 1
+2 -12.000000 1 -100.000000 1 1 0
+2 -123.000000 1 -123.000000 1 0 0
+2 -1234.000000 1 -1234.000000 1 0 0
+2 -12345.000000 1 -5000.000000 1 0 1
+3 0.000000 0 0.000000 0 0 0
+3 12.000000 0 100.000000 0 1 0
+3 123.000000 0 100.000000 0 1 0
+3 1234.000000 0 617.000000 0 0 0
+3 12345.000000 0 5000.000000 0 0 1
+3 -12.000000 0 -100.000000 0 1 0
+3 -123.000000 0 -100.000000 0 1 0
+3 -1234.000000 0 -617.000000 0 0 0
+3 -12345.000000 0 -5000.000000 0 0 1
+3 12.000000 1 100.000000 1 1 0
+3 123.000000 1 100.000000 1 1 0
+3 1234.000000 1 617.000000 1 0 0
+3 12345.000000 1 5000.000000 1 0 1
+3 -12.000000 1 -100.000000 1 1 0
+3 -123.000000 1 -100.000000 1 1 0
+3 -1234.000000 1 -617.000000 1 0 0
+3 -12345.000000 1 -5000.000000 1 0 1
+4 0.000000 0 -0.000000 1 0 0
+4 12.000000 0 -134.000000 1 1 0
+4 123.000000 0 -246.000000 1 0 0
+4 1234.000000 0 -2468.000000 1 0 0
+4 12345.000000 0 -6666.000000 1 0 1
+4 -12.000000 0 134.000000 1 1 0
+4 -123.000000 0 246.000000 1 0 0
+4 -1234.000000 0 2468.000000 1 0 0
+4 -12345.000000 0 6666.000000 1 0 1
+4 12.000000 1 -134.000000 0 1 0
+4 123.000000 1 -246.000000 0 0 0
+4 1234.000000 1 -2468.000000 0 0 0
+4 12345.000000 1 -6666.000000 0 0 1
+4 -12.000000 1 134.000000 0 1 0
+4 -123.000000 1 246.000000 0 0 0
+4 -1234.000000 1 2468.000000 0 0 0
+4 -12345.000000 1 6666.000000 0 0 1
diff --git a/tests/gearchange/gearchange-input-patterns b/tests/gearchange/gearchange-input-patterns
new file mode 100644
index 0000000..ee121b2
--- /dev/null
+++ b/tests/gearchange/gearchange-input-patterns
@@ -0,0 +1,85 @@
+0 0 0
+0 12 0
+0 123 0
+0 1234 0
+0 12345 0
+0 -12 0
+0 -123 0
+0 -1234 0
+0 -12345 0
+0 12 1
+0 123 1
+0 1234 1
+0 12345 1
+0 -12 1
+0 -123 1
+0 -1234 1
+0 -12345 1
+1 0 0
+1 12 0
+1 123 0
+1 1234 0
+1 12345 0
+1 -12 0
+1 -123 0
+1 -1234 0
+1 -12345 0
+1 12 1
+1 123 1
+1 1234 1
+1 12345 1
+1 -12 1
+1 -123 1
+1 -1234 1
+1 -12345 1
+2 0 0
+2 12 0
+2 123 0
+2 1234 0
+2 12345 0
+2 -12 0
+2 -123 0
+2 -1234 0
+2 -12345 0
+2 12 1
+2 123 1
+2 1234 1
+2 12345 1
+2 -12 1
+2 -123 1
+2 -1234 1
+2 -12345 1
+3 0 0
+3 12 0
+3 123 0
+3 1234 0
+3 12345 0
+3 -12 0
+3 -123 0
+3 -1234 0
+3 -12345 0
+3 12 1
+3 123 1
+3 1234 1
+3 12345 1
+3 -12 1
+3 -123 1
+3 -1234 1
+3 -12345 1
+4 0 0
+4 12 0
+4 123 0
+4 1234 0
+4 12345 0
+4 -12 0
+4 -123 0
+4 -1234 0
+4 -12345 0
+4 12 1
+4 123 1
+4 1234 1
+4 12345 1
+4 -12 1
+4 -123 1
+4 -1234 1
+4 -12345 1
diff --git a/tests/gearchange/runsampler b/tests/gearchange/runsampler
new file mode 100644
index 0000000..b066bd3
--- /dev/null
+++ b/tests/gearchange/runsampler
@@ -0,0 +1,3 @@
+#!/bin/bash
+echo "# gear-number, speed-in, dir-in, speed-out, dir-out, min-lim, max-lim"
+halsampler -n $(wc -l gearchange-input-patterns | cut -d ' ' -f 1) | tr ' ' '\t'
diff --git a/tests/gearchange/runstreamer b/tests/gearchange/runstreamer
new file mode 100644
index 0000000..700d68c
--- /dev/null
+++ b/tests/gearchange/runstreamer
@@ -0,0 +1,2 @@
+#!/bin/bash
+halstreamer gearchange-input-patterns
diff --git a/tests/gearchange/test.hal b/tests/gearchange/test.hal
new file mode 100644
index 0000000..53310ad
--- /dev/null
+++ b/tests/gearchange/test.hal
@@ -0,0 +1,61 @@
+setexact_for_test_suite_only
+
+loadrt threads name1=fast period1=100000
+
+loadrt streamer cfg=sfb depth=350
+loadrt sampler cfg=sfbfbbb depth=350
+
+# num_gears=5 in this case means "neutral and four gears"
+loadrt gearchange num_gears=5
+
+addf streamer.0 fast
+addf gearchange.0 fast
+addf sampler.0 fast
+
+net gear-number streamer.0.pin.0 => sampler.0.pin.0 gearchange.0.gear-number
+net speed-in streamer.0.pin.1 => sampler.0.pin.1 gearchange.0.speed-in
+net dir-in streamer.0.pin.2 => sampler.0.pin.2 gearchange.0.dir-in
+
+net speed-out gearchange.0.speed-out => sampler.0.pin.3
+net dir-out gearchange.0.dir-out => sampler.0.pin.4
+net min-limit gearchange.0.min-lim => sampler.0.pin.5
+net max-limit gearchange.0.max-lim => sampler.0.pin.6
+
+
+#
+# configure the gear changer
+#
+
+# gear 0 is neutral
+setp gearchange.0.scale-0 0
+
+# gear 1 is extra-low gear
+setp gearchange.0.min-1 50
+setp gearchange.0.max-1 2500
+setp gearchange.0.scale-1 0.5
+
+# gear 2 is low gear
+setp gearchange.0.min-2 100
+setp gearchange.0.max-2 5000
+setp gearchange.0.scale-2 1.0
+
+# gear 3 is high gear
+setp gearchange.0.min-3 200
+setp gearchange.0.max-3 10000
+setp gearchange.0.scale-3 2.0
+
+# gear 4 is reverse...
+setp gearchange.0.min-4 67
+setp gearchange.0.max-4 3333
+setp gearchange.0.scale-4 -0.5
+
+
+# present it with a pattern of input, one per thread invocation
+loadusr -w /bin/bash runstreamer
+
+# let the gearchanger run
+start
+
+# and sample its behavior for all the input patterns we specified
+loadusr -w /bin/bash runsampler
+
--
1.7.0.4
------------------------------------------------------------------------------
Create and publish websites with WebMatrix
Use the most popular FREE web apps or write code yourself;
WebMatrix provides all the features you need to develop and
publish your website. http://p.sf.net/sfu/ms-webmatrix-sf
_______________________________________________
Emc-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/emc-developers