MACRO Macro Pad (C3 Maestro)

User avatar
raoulduke-esq

05 Mar 2021, 04:12

So I picked up one of those C3 Maestro 911 Operator keyboards from eBay and have taken to calling it the MACRO Macro Pad because it's freakin' HUGE. F&F switches, thick plastic top, metal bottom, double-shot caps... It's quite the looker.
The board itself complete with Tetris layout
The board itself complete with Tetris layout
IMG_0420.JPG (2.8 MiB) Viewed 5234 times
The problem is, I have no idea how to go about making firmware for a converter. I'm not exactly a noob- I've made converters for a bunch of other boards thanks to TMK and QMK, made some hand-wired boards, etc. but I'm also not super proficient in the underlying theory so I'm stumped on an atypical board like this.

I've researched and found the original manual which gives some clues as to the pinout and protocol.
C3 Guide.pdf
The manual.
(1.22 MiB) Downloaded 106 times
It's some kind of serial protocol, but only with a TX from the keyboard, which connected to an "Enhanced Audio Enclosure" which interfaced with a computer rather than to a computer directly. Its job seemed to be switching between audio sources and radio channels, so it appears it would be some kind of unique protocol. There's no clock and no RX.

As for the cable, red is VCC, white is data, green is ground, and black is shield. In order, these are pins 1, 2, 4, and 6 on the DB9.
Screenshot of the pinout.
Screenshot of the pinout.
Good pinout.png (133.07 KiB) Viewed 5234 times
Male DB9 pinout
Male DB9 pinout
IMG_0419.JPG (2.3 MiB) Viewed 5234 times
Male DB9 reverse
Male DB9 reverse
IMG_0418.JPG (2.77 MiB) Viewed 5234 times


Some photos included of the PCB and controller. It would appear the keyboard uses 10 rows and 16 columns and the controller parses this into serial and sends over the cable.
PCB with controller in place
PCB with controller in place
IMG_0410 copy.jpg (3.05 MiB) Viewed 5234 times
PCB with controller removed
PCB with controller removed
IMG_0409.JPG (2.97 MiB) Viewed 5234 times
Controller
Controller
IMG_0408 copy.jpg (3.64 MiB) Viewed 5234 times
I've tried a simple Pro Micro with several of the TMK serial converter builds just in case they might work, but no joy. However, when powered the piezo works when keys are pressed and delivers a delightful clicking sound.

Any suggestions for how to get the MACRO Macro Pad working? Is there anything in the photos that might suggest a starting point for firmware? Should I rip out the controller, get a Teensy++, and try to implement a matrix directly from the PCB pins even though it's capacitive? I don't expect to be spoon fed and am happy to read things- I just don't know where to begin. I'm also happy to add anything that would be useful about this board to the wiki!

Thanks in advance!

MMcM

05 Mar 2021, 07:57

Are you comfortable writing an Arduino sketch for your Pro Micro? It's still possible that it really is just plain-old TTY-level RS-232 serial. Connect the data line to RX. In setup, open Serial1 at some baud rate (1200 is a good first guess). In the loop, check available and print any character that comes in to console Serial.

If that doesn't seem to get anywhere, just loop doing digitalRead on the one pin and printing whenever it changes. These protocols were slow enough that you might be able to guess what's going on, even without a logic analyzer or oscilloscope. Like, how many times does the bit flip for which characters?

User avatar
raoulduke-esq

05 Mar 2021, 18:25

MMcM wrote:
05 Mar 2021, 07:57
Are you comfortable writing an Arduino sketch for your Pro Micro? It's still possible that it really is just plain-old TTY-level RS-232 serial. Connect the data line to RX. In setup, open Serial1 at some baud rate (1200 is a good first guess). In the loop, check available and print any character that comes in to console Serial.

If that doesn't seem to get anywhere, just loop doing digitalRead on the one pin and printing whenever it changes. These protocols were slow enough that you might be able to guess what's going on, even without a logic analyzer or oscilloscope. Like, how many times does the bit flip for which characters?
I've never done so but I dabble in other languages so this at least gives me a place to start. Thanks for that!

User avatar
raoulduke-esq

05 Mar 2021, 23:44

MMcM wrote:
05 Mar 2021, 07:57
It's still possible that it really is just plain-old TTY-level RS-232 serial.
MMcM's idea yielded some great results. I found a couple of sketches having to do with reading serial from the Pro Micro's serial ports and loaded them up.

This sketch below was used to generate the "Number" section of the image below. Each key, with the exception of Alt, yields 4 numbers: two when pressed and two when released.

Code: Select all

int incomingByte = 0; // for incoming serial data

void setup() {
  // put your setup code here, to run once:
     // open the serial port:
   Serial1.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
  if (Serial1.available() > 0) {
    // read the incoming byte:
    incomingByte = Serial1.read();
    // say what you got:
    Serial.print("I received: ");
    Serial.println(incomingByte, DEC);
  }
}
This sketch below was used to generate the "Keyboard" section of the image below and causes the Pro Micro to translate the serial input into keyboard output and type it wherever the cursor currently is. Each key, with the exception of Alt, yields one or two characters. Some yield a "boop" in that they cause my Mac to go boop.

Code: Select all

#include "Keyboard.h"

void setup() {
  // put your setup code here, to run once:
     // open the serial port:
   Serial1.begin(9600);
   // initialize control over the keyboard:
   Keyboard.begin();
}

void loop() {
  // put your main code here, to run repeatedly:
   if (Serial1.available() > 0) {
      // read incoming serial data:
      char inChar = Serial1.read();
      // Type the next ASCII value from what you received:
      Keyboard.write(inChar);
   }
}
What it do.png
What it do.png (1.14 MiB) Viewed 5122 times
It's clear that the keyboard is sending two ASCII values when pressed and two when released. For example, ESC when pressed generates 31 59, which an ASCII table says is "Unit Separator" and "Semicolon", then 108 and 0 when released, which is "Small l" and "Null". When the keyboard sketch is running, ESC yields ; upon press and l on release. Some of the keys end with 1 "Start of Header" instead of 0 when released.

So now that we know that we know the keyboard is sending ASCII, what's the next step to get from here toward a functioning QMK converter? I'm open to suggestions, links, similar projects I might be able to bastardize, etc.

micmil

06 Mar 2021, 01:03

Alright, you convinced me. Not that I need another project, but I have one on the way. :D I'm looking over all of the documentation and I can say without a doubt that I do not, for one second, miss anything about the DOS days. I see "IRQ" and go into anaphylactic shock.

Found a cool operations guide for the system: http://www.repeater-builder.com/ge/lbi- ... 892r1a.pdf Not that it's really of any help.

User avatar
raoulduke-esq

06 Mar 2021, 01:26

micmil wrote:
06 Mar 2021, 01:03
Alright, you convinced me. Not that I need another project, but I have one on the way. :D I'm looking over all of the documentation and I can say without a doubt that I do not, for one second, miss anything about the DOS days. I see "IRQ" and go into anaphylactic shock.

Found a cool operations guide for the system: http://www.repeater-builder.com/ge/lbi- ... 892r1a.pdf Not that it's really of any help.
Nice! Can’t have enough projects. Hopefully we can get the MACRO Macro Pad working. Imagine using this bad boy to supplement a Planck or HHKB! That guide you found is great- appreciating and understanding how the tools were originally used is one of the most fascinating parts of this hobby to me. Spent a lot of time going through 3270 manuals not too long ago.

MMcM

06 Mar 2021, 01:36

Did you try any other baud rates than 9600? In particular, something slower?

Are the codes stable / reliable? That is, does pressing the same key always give the same codes?

There are a few things in there that suggest the timing isn't quite right. First, there are several keys whose key up code is 252 0, even though things are otherwise generally unique. Second, there are adjacent keys that have 31 followed by changes by factors of two. 16, 32, 64 or 15, 30, 60. Of course that's not impossible but shifting can occur if the start / stop bits aren't detected right.

I think it's worth a few minutes making sure we have the codes understood as best we can. Then it won't be as big a deal translating them into key presses using something like QMK.

micmil

06 Mar 2021, 01:52

The EDACS system this is part of has both 9600 baud and 150 baud communications within it.

http://www.repeater-builder.com/ge/lbi- ... 38587b.pdf

This specifically mentions the C3 as one of the supported consoles

And THEN there's this file:
http://www.repeater-builder.com/ge/lbi- ... 38662b.pdf
Which says on page 10 the console control data link is 9600 baud or 19200 baud.

So, there are some starting points if nothing else.

User avatar
raoulduke-esq

06 Mar 2021, 02:02

Happy to spend a few minutes getting it right!

I tried a few different baud rates, mainly with the ESC key- here's what they did:

1200: all keys 0 down 0 up unless pushing multiple keys at a time which might yield a 56 or 128
2400: single digit, inconsistent up and down codes e.g. 1 1 or 0 3 or 0 2 depending on how fast the key is pressed
4800: double digit, inconsistent up and down codes e.g. 21 down 29 up or 23 29 depending on how fast the key is pressed
9600: consistent regardless of speed; e.g. 31 59 down 108 0 up
19200: consistent 254 224 158 0 down 224 158 0 up

Rayndalf

06 Mar 2021, 04:35

Really glad some savvier users bought these as well.

The hardest part is going to be making macros for all the keys.

MMcM

06 Mar 2021, 06:24

Okay, yeah, it looks like 9600 is right. The complexity must make sense in the original context.

Pressing ALT doesn't do anything right away. But if you keep it pressed, does it affect what other keys send?

Have a look at some of the converters in QMK that use serial_recv and implement a state machine based on the characters.

Something like this:
  • If 31 is received, go to another state to wait for key down code.
  • that code should be unique so set the corresponding bit in the matrix and set state back to default
  • if first character is something other than 31, remember it and set another state to wait for second key up code
  • when that arrives, combine the two and look that up in some in-flash table to map to matrix codes that you want to now mark as up; clear that bit and set state back to normal
The mapping for 252 0 isn't unique. It could be key up for KP-3, P5, F1, MODL 12, or MODL 5 TX. So I guess you need to special case that to clear them all. Most others seem to be unique, so just need a mapping table.

micmil

06 Mar 2021, 15:46

MMcM wrote:
06 Mar 2021, 06:24
Okay, yeah, it looks like 9600 is right. The complexity must make sense in the original context.
Having spent a fair amount of time going through these docs the complexity definitely makes sense. Realtime switching between hundreds of audio and data sources with two-way communication. Basically, being the focal point for controlling this: https://wiki.radioreference.com/index.php/EDACS

It's excruciatingly boring stuff, to be honest. And yes, I'm sure there's some radio nerd looking at this discussion and thinking the keyboard is the least interesting thing going on in the system. :lol:

User avatar
raoulduke-esq

06 Mar 2021, 17:40

Curiouser and curiouser...
What it do with Alt.png
What it do with Alt.png (1.5 MiB) Viewed 4933 times
Added codes for each key when holding Alt. The start code is 15 for all keys and the down code is the same as it is without Alt for all keys. Stop code 0 or 1 stayed the same for many keys, but some saw it change to 2 or 3. In some places Alt seems almost like a halving or doubling operation, except when it doesn't. I'm wondering if either the folks who built this just did it willy-nilly or if we're missing something that would make more sense.

First, there's MODL12 and F1, which have identical codes for default and Alt operation. Then there's the fact that the start code for Alt keys is 15, which is not quite half of 31. The Alt up code is a double of the default up code like on ESC (108, 216) and ICALL SEL (52, 104) except when it isn't, like on F2 (244, 232) or F6 (212, 168). Numpad 9 has default stop code 0 and Alt stop code 2.

Scratching my head...

headphone_jack

06 Mar 2021, 17:42

I recently bought a lot of 6 of these off of eBay. Sigh... guess now I have to convert all of them. Damn you for giving me yet another opportunity to assign shitposts to keys.

User avatar
raoulduke-esq

06 Mar 2021, 17:51

headphone_jack wrote:
06 Mar 2021, 17:42
I recently bought a lot of 6 of these off of eBay. Sigh... guess now I have to convert all of them. Damn you for giving me yet another opportunity to assign shitposts to keys.
Nice! I'm definitely viewing this board as something to help automate the more boring parts of my job. Some of my macros might include things like:

"Haven't heard back so I'm following up to see if you received my previous email in this thread."

"Yes, this is on my list for today, just like it is on the 1st and 15th of every month."

"Please find attached this week's submission of xxxxx"

"It's the last day of the pay period, so remember to submit your timesheets at the end of the day."

micmil

06 Mar 2021, 19:41

In the manual there's only a couple of combinations it specifically mentions ALT working with. ALT-PVT switches to an encrypted transmit mode. The other is ALT-MODULE SELECT.

micmil

13 Mar 2021, 03:29

Mine arrived yesterday. I figured it wouldn't be trash but I was not expecting it to be as substantial as it is.

I hadn't realized that the larger keys actually use multiple switches... do we know if both switches send signal, or if one's just an empty?

MMcM

04 Apr 2021, 06:16

Okay. I believe I know what is going on here.

It is indeed 9600 baud and there are indeed two codes for each key press / release. But it is reverse polarity from what the microcontroller expects, that is, idle low rather than idle high.
C3-Maestro-ESC.png
C3-Maestro-ESC.png (15.45 KiB) Viewed 4471 times
Normal key down is C1 and normal key up is C0. ALT is E1 and E0.

This makes the codes look rather more uniform.

Code: Select all

+---+   +---+---+---+---+---+---+---+---+---+---+
|12 |   |00 |01 |02 |03 |04 |05 |06 |07 |08 |09 |
+---+   +---+---+---+---+---+---+---+---+---+---+
+---+---+---+---+---+               +---+---+---+   +---+---+---+---+---+---+   +---+---+---+
|13 |8E |45 |19 |14 |               |10 |11 |0F |   |0C |0E |1E |1F |20 |0B |   |24 |25 |26 |
+-------------------+               +-------|   |   +-------------------|   |   +-----------+
|ALT|8F |90 |2E |28 |               |21 |22 |   |   |33 |91 |92 |93 |94 |   |   |36     |37 |
+---+---+---+---+---+               +---+---+---+   +---+---+---+---+---+---+   +-------+---+
+-------+---+---+---+---+---+---+---+---+   +---+---+---+       +---+---+---+   +---+---+---+
|48     |42 |43 |47 |4A |2A |46 |95 |49 |   |16 |5A |5B |       |17 |2C |1B |   |3E |3F |40 |
+-------+---+---+---+---+---+---+---+---+   +---+---+---+       +---+---+---+   +-----------+
+---+---+---+---+---+---+---+   +---+---+---+---+---+---+---+                   |50 |51 |52 |
|53 |54 |55 |56 |57 |58 |59 |   |5C |5D |5E |5F |60 |61 |62 |   +---+---+---+   +-----------+
+---------------------------+   +---------------------------+   |96 |3C |3D |   |63 |64 |65 |
|7C |7D |7E |7F |80 |81 |82 |   |84 |85 |86 |87 |88 |89 |8A |   +-----------+   +-----------+
+---+---+---+---+---+---+---+   +---+---+---+---+---+---+---+   |3B |97 |4D |   |79 |7A |7B |
                        +-----------+                           +-----------+   +-----------+
                        |83         |                           |98 |4E |4F |   |8B |8C     |
                        +-----------+                           +---+---+---+   +---+-------+
What this means in terms of writing a converter is that you either need to add an inverter or switch to a microcontroller that supports inverted serial. The Teensy 3.2 is the only one that both does this and tolerates 5V TTL levels. In Teensyduino, do

Code: Select all

  Serial1.begin(9600, SERIAL_8N1_RXINV_TXINV);

micmil

04 Apr 2021, 06:32

That kind of makes sense. Since this thing was designed to plug into an audio routing system that might create a lower noise floor. Absolutely never would have thought of that.

Just another check in the "I need an oscilloscope" box. Great work!

User avatar
raoulduke-esq

04 Apr 2021, 06:49

Damn that’s a major breakthrough!!!!! Nice!

Got a couple Teensy 3.2 on the way to me now.

User avatar
raoulduke-esq

18 Apr 2021, 21:41

So I got a 3.2 and I got it able to receive and replicate what MMcM got in terms of output above and felt really excited for a moment until I realized I have no earthly idea how to turn that information into QMK firmware. Perhaps I overestimated my ability to just figure it out by looking at other keyboards' firmware.

If anyone knows of any guides that explain how to develop your matrix.c and your board.h based on knowledge of what the up/down codes for normal and alt mode and keycodes sent by each key are I'd greatly appreciate it. Even an existing firmware with enough comments in it for a nooooooooob to understand would be GREAT!

User avatar
raoulduke-esq

25 Apr 2021, 02:22

Greetings Comrades! SO close yet so far! Need some smart eyes on this.

Found a great firmware guide from our own Matt3o and reviewed MMcM's repo for a long time and finally got a rough framework together for what I think the firmware might need to be. It's not at a point where I can compile yet due to errors having to do with obsolete config files. Documentation on how to implement QMK with Chibios is even more sparse than for how to develop firmware for a random Serial board.

I'm working on this HERE and I'm really hoping some smart firmware folks can take a look and make some suggestions. There are some brilliant minds on here; please help get this thing over the hump!

MMcM

25 Apr 2021, 20:58

raoulduke-esq wrote:
25 Apr 2021, 02:22
I'm working on this HERE and I'm really hoping some smart firmware folks can take a look and make some suggestions. There are some brilliant minds on here; please help get this thing over the hump!
I don't see a matrix.c file or equivalent that does the actual serial I/O. Is it missing from the checkin?

User avatar
raoulduke-esq

25 Apr 2021, 21:01

MMcM wrote:
25 Apr 2021, 20:58
I don't see a matrix.c file or equivalent that does the actual serial I/O. Is it missing from the checkin?
No- I honestly just don't know what to do with that.

I was hoping that what's in c3_maestro.h would actually work and so it would just need to be a serial receiver basically, but then I don't know how to implement ALT with that or to do any of it within the scope of chibios. I'm in way over my head.

MMcM

25 Apr 2021, 21:28

raoulduke-esq wrote:
25 Apr 2021, 21:01
I was hoping that what's in c3_maestro.h would actually work and so it would just need to be a serial receiver basically, but then I don't know how to implement ALT with that or to do any of it within the scope of chibios. I'm in way over my head.
Yeah, it sucks that there isn't a single QMK serial abstraction that actually works for AVR and chibios. But the basic idea is the same using the serial HAL: do sdStart to open the serial point in matrix_init and do sdGetTimeout with TIME_IMMEDIATE for a non-blocking read in matrix_scan.

There is no serial output to worry about. All serial input is two bytes, with four possible prefix bytes. You could have a state machine, but it's so simple that just remembering the prefix byte (with some special value like 0 or FF meaning don't have yet) between invocations is probably simpler. When you get the second byte, shift and mask it into a row and column. Turn on or off the column's bit in the row based on whether it's a key press or key release prefix. If it's one of the ALT prefixes, also update the bit chosen for the ALT key.

Post Reply

Return to “Workshop”