Yeah, the switches moved around a little between the 11/45 and 11/70.
But as far as the rotary switch goes, it's a completely different
concept/design on the DEC machines compared to the PiDP-11. The DEC
machines use a rotary selector. Essentially you have 9 pins on it. One
is the common pin, and then you have 8 select positions. One of them
will short to the common pin, and the other 7 are floating. And turning
the knob just moves the grounding to another pin. So it's an absolute
selector, and it has one pin per position.
The rotary selector for the PiDP-11 is done in a different way, which
just tells you which direction you are moving in, and you can tell how
much, but it don't tell you in which direction the selector actually is
pointing.
And it's encoded with just two bits/pins, and a common. You can
illustrate is as ON and OFF on each pin, in relation to the common pin.
And doing them as 0 and 1, you'll have one sequence going clockwise, and
another sequence going counterclockwise.
Basically, either:
00 -> 01 -> 11 -> 10 -> 00
or
00 -> 10 -> 11 -> 01 -> 00
And this is plain gray code. And while debouncing is always nice (and
it's really simple to do debouncing in software), if you don't have
debouncing with gray code, it don't really cause any issues in the
overall picture. It will just make the movement to appear to be going
back and forth at transition points. Possibly annoying, but not causing
anything to start acting in "reverse".
Could people try this patch, and see if it makes life any better?
=============
*** gpio.c.old 2020-11-22 01:30:22.898411675 +0100
--- gpio.c 2020-11-22 01:53:58.114274430 +0100
***************
*** 320,325 ****
--- 320,327 ----
code[0] = (switchscan & 0x300) >> 8;
code[1] = (switchscan & 0xC00) >> 10;
+
+ #if 0
switchscan = switchscan & 0xff; // set the 4 bits to zero
//printf("code 0 = %d, code 1 = %d\n", code[0], code[1]);
***************
*** 363,368 ****
--- 365,381 ----
// if (knobValue[1]<0)
// knobValue[1] = 3;
+ #else
+ for (i=0; i<2; ++i) {
+ if (lastCode[i] != code[i]) {
+ if ((code[i] == 0) && (lastCode[i] == 1))
++knobValue[i];
+ if ((code[i] == 1) && (lastCode[i] == 0))
--knobValue[i];
+ lastCode[i] = code[i];
+ }
+ }
+ #endif
+
+
knobValue[0] = knobValue[0] & 7;
knobValue[1] = knobValue[1] & 3;
=============
It works on my machine, but my sources might be a little out of date.
But a context diff usually gets through pretty ok. It also won't delete
any changes to the lines others have talked about before, but just makes
them inactive. If you want to revert back to your current code, just
change the #if 0 to an #if 1 in the code after you have applied the patch.
I'm attaching it as a file as well, so people don't have to try and cut
and paste... :-)
And in case people don't know how to apply context diff patches:
save the content between the "======" lines into a file. Let's call it
gpio.patch
Move that file into /opt/pidp11/src/11_pidp_server/pidp11
run: patch < gpio.patch
Hopefully, you should see:
raspberrypi:11_pidp_server/pidp11# patch < gpio.patch
patching file gpio.c
raspberrypi:11_pidp_server/pidp11#
Then rebuild as usual, in /opt/pidp11/src, run makeserver.sh
Reboot/restart/whatever, and see if it still works the same. If the
encoders really are of two different kinds, then this code cannot help
at all, but I just figured I could at least make the code a little
cleaner, and easier to follow (well, at least I think it is... :-) ).
I should also point out that this patch does not include any debouncing,
and I didn't spot any elsewhere in the code either. But at least on my
front panel, there are no visible issues with bouncing anyhow, so at the
moment I don't even bother.
Johnny
On 2020-11-21 16:57, Geert Rolf wrote:
> I do know the frontpanels of 11/45, /50, /55 differ from the 11/70 *),
> but I'm sure the rotary switches work zig-zag on the 45 etc.
>
> *) I had to search for the DEP switch the first time.
> On Thursday, November 19, 2020 at 12:35:44 AM UTC+1
garrya...@gmail.com
> wrote:
>
> Quite possibly not relevant to this specific discussion but . . .
>
> There are lots of rotary encoders that don’t use Gray Codes. Many
> use 2 signals in quadrature. The signals can be decoded by sampling
> two GPIO pins or using a dedicated decoder chip. They often have an
> index signal that could be used to determine the shaft’s absolute
> position but maintaining knowledge of that position across power
> cycles would be difficult.
>
> Regards,
>
> Garry Lockyer
> C:
+1.250.689.0686 <tel:(250)%20689-0686>
> <
https://groups.google.com/d/msgid/pidp-11/69f7f21e-0f67-08d6-bb37-a2e2c89c4e30%40softjar.se>.
>
> >>
> >> --
> >> Johnny Billquist || "I'm on a bus
> >> || on a psychedelic trip
> >> email:
b...@softjar.se || Reading murder books
> >> pdp is alive! || tryin' to stay hip" - B. Idol
> >
> > --
> > You received this message because you are subscribed to the
> Google Groups "[PiDP-11]" group.
> > To unsubscribe from this group and stop receiving emails from it,
> send an email to
pidp-11+u...@googlegroups.com.
> > To view this discussion on the web visit
>
https://groups.google.com/d/msgid/pidp-11/C96B8E12-A76B-4CCC-BCDC-298614036992%40sytse.net
> <
https://groups.google.com/d/msgid/pidp-11/C96B8E12-A76B-4CCC-BCDC-298614036992%40sytse.net>.
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "[PiDP-11]" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to
pidp-11+u...@googlegroups.com
> <mailto:
pidp-11+u...@googlegroups.com>.
> To view this discussion on the web visit
>
https://groups.google.com/d/msgid/pidp-11/2f6bc5e5-b664-407a-b083-adfc1aed3c53n%40googlegroups.com
> <
https://groups.google.com/d/msgid/pidp-11/2f6bc5e5-b664-407a-b083-adfc1aed3c53n%40googlegroups.com?utm_medium=email&utm_source=footer>.