Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NeXT non-ADB keyboard timing #704

Closed
spenczar opened this issue Sep 11, 2021 · 4 comments
Closed

NeXT non-ADB keyboard timing #704

spenczar opened this issue Sep 11, 2021 · 4 comments
Labels

Comments

@spenczar
Copy link

I recently acquired a NeXT non-ADB keyboard, and have been exploring it pretty thoroughly with an oscilloscope and logic analyzer. Like you (https://github.com/tmk/tmk_keyboard/blob/master/tmk_core/protocol/next_kbd.c#L153-L162), I noticed that the timing of the keyboard's signal is not quite 50 microseconds, or even 51 microseconds.

It turns out that the timing is actually 52.75 microseconds per pulse, corresponding to a frequency of 18,957 hertz. That's because the keyboard uses a Ceralock CSB455 oscillator:

image

This oscillator has a frequency of 455 kHz, and drives the keyboard's signal, updating the pulse every 24 clock cycles. 455 kHz / 24 is 18.957 kHz - resulting in the 52.75 microsecond pulses.

I have no reason to believe your code is behaving too badly, but at the least you might want to fix comments and the header settings, for example here:

#define NEXT_KBD_TIMING 50

and here:

/* The keyboard sends signal with 50us pulse width on OUT line
* while it seems to miss the 50us pulse on In line.
* next_kbd_set_leds() often fails to sync LED status with 50us
* but it works well with 51us(+1us) on TMK converter(ATMeaga32u2) at least.
* TODO: test on Teensy and Pro Micro configuration
*/

@tmk
Copy link
Owner

tmk commented Sep 12, 2021

Thanks for the headsup.
I'll look into the timing when I setup NeXT keyboard and converter next time.

@tmk tmk added the TODO label Sep 12, 2021
@spenczar
Copy link
Author

FWIW, I wrote more about this here, including logic analyzer and oscilloscope images of the timing: https://journal.spencerwnelson.com/entries/nextkb.html

tmk added a commit that referenced this issue Apr 16, 2022
@tmk
Copy link
Owner

tmk commented Apr 17, 2022

Thank you for your detailed writeup.

I also confirmed the bit width(52.75us) with my NeXT Keyboard using Logic Analyzer.

The converter can read signal at way better timing now.

Before Fix(signal read timing at 9b99f8f)
8GB83tI

After Fix(signal read timing at dcebfb4)
pL7NeW3

In this capture the converter reads 'IN' at either edge of 'Read'.

MEMO: https://github.com/tmk/tmk_keyboard/wiki/NeXT#next-keyboard-protocol

@tmk tmk closed this as completed Apr 17, 2022
@tmk tmk added NOTE and removed TODO labels Apr 17, 2022
@tmk
Copy link
Owner

tmk commented Oct 12, 2024

Reimplemented NeXT converter interpreting the protocol as UART 9-bit data, not a long bit sequence.

https://github.com/tmk/tmk_keyboard/wiki/NeXT#next-keyboard-protocol

https://github.com/tmk/tmk_keyboard/tree/master/converter/next_usb_ng

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants