Can you use a Raspberry Pi as a Teensy alternative?

User avatar
Lalaland124

04 Mar 2021, 19:50

I am trying to connect my Ampex 210 Plus board with a RJ10 connector to my modern computer. I just realised that I had an old raspberry pi model b+ laying around and wondered if I could use it as a development board to solder the RJ 10 connector on, like MMcM did in his post. (viewtopic.php?f=7&t=24440)

Is this possible, maybe even so that I could use the firmware he developed :D?

Thanks!

User avatar
Bjerrk

04 Mar 2021, 19:53

Would love to know this as well, since I have one laying around too.

Findecanor

04 Mar 2021, 20:04

I would just get a 5€ Pro Micro. It has the same microcontroller as the Teensy 2.0 and you could use the same firmware without modification. Just know that the D0 pin is pin 3 on the Pro Micro.

Then use the Pi B+ for RetroPi or something that could use more horsepower... ;)

User avatar
Muirium
µ

04 Mar 2021, 21:46

People suggest this—guys I just had a idea: you could like totally use a Pi!—quite often. Sure, you could. You just need to write the converter software for it yourself!

The firmwares already in the community that I know about run on 8 bit ATMega chips, as used in Teensy and Arduino pro micro. Obviously, Pi can run circles around that, but it kinda like needs the code ‘n stuff.

Here’s a Pi being used as a keyboard *controller* with links to code:

https://www.instructables.com/Cherry-Pi ... -Keyboard/

But you’re talking about a converter. Which means processing the original keyboard’s output signal, a different task indeed to driving a matrix.

Findecanor

04 Mar 2021, 23:25

Also: The ErgoBlue keyboard is a wireless ErgoDox-clone which uses a receiver running on a Raspberry Pi Zero W. It has custom firmware written in Go, available here.

andresteare

05 Mar 2021, 22:05

You can get a Pro Micro for 5usd on aliexpress

User avatar
inmbolmie

05 Mar 2021, 22:51

That will be the most overkill hardware ever for a converter. And it will be the only keyboard in the world to take 2 minutes to boot. And you even won't be able to connect it easily to anything over USB as the PI is a USB host and not a USB device.

Also my experience with the Pi is that as it is running a multitasking operating system is not suitable at all for any real time task for which it doesn't have dedicated hardware. Too many software layers between your application and the real hardware. That said, for sure it is possible to make it tinkering with the GPIO ports, but it won't be fun, productive or useable at all.

MMcM

06 Mar 2021, 00:32

Pi Zero and Pi 4 have USB OTG, but older ones can indeed only be a host.

There is even a three key macropad using a Pi Zero.

Overkill is all relative. The Teensy 2.0 has a UART and an ADC that we aren't using. Is that a waste? What about even more powerful SOCs like a Cortex-M4, which are becoming common, especially for BLE.

A more fundamental problem, unfortunately, is that the GPIOs on the Pi are 3.3V and the ones in most vintage keyboards, including this one, are 5V, as they are in the Teensy 2.0. So you'd need a level shifter. There are some nice hats that do that on Tindie. But they cost more than a Teensy and the whole things starts getting pretty complex.

User avatar
Bjerrk

06 Mar 2021, 00:41

inmbolmie wrote:
05 Mar 2021, 22:51
That will be the most overkill hardware ever for a converter. And it will be the only keyboard in the world to take 2 minutes to boot.
...
Also my experience with the Pi is that as it is running a multitasking operating system is not suitable at all for any real time task for which it doesn't have dedicated hardware.
Ah, but surely the idea would be to not run a multitasking operating system on it?

User avatar
inmbolmie

06 Mar 2021, 01:05

Running it without an OS? You mean bare-metal programming the Pi then... That would be VERY hard and makes even less sense, the micros have nice development environments to do that, with a Pi you will really have a bad day just to get a working "Hello World" .

Well, everything is possible, it is only that I feel that the required effort isn't worth (in my opinion) in this case, unless you absolutely want to do it for any reason. Just already having the Pi for me is not a good reason, as you are probably trading weeks of effort versus the cost of a $5 pro-micro or a Teensy 2.0.
Bjerrk wrote:
06 Mar 2021, 00:41
inmbolmie wrote:
05 Mar 2021, 22:51
That will be the most overkill hardware ever for a converter. And it will be the only keyboard in the world to take 2 minutes to boot.
...
Also my experience with the Pi is that as it is running a multitasking operating system is not suitable at all for any real time task for which it doesn't have dedicated hardware.
Ah, but surely the idea would be to not run a multitasking operating system on it?

Hak Foo

06 Mar 2021, 04:07

What's interesting is that the Teensy/Pro Micro is becoming a strange "local maximum."

The home-brew ecosystem has revolved around Atmel chips for a long time, but they're expensive for the performance. I'm also a bit worried about long-term availability-- the PJRC site has "we have supplies til about 2022" warnings with a distinct implication that the Teensy 2.0 range will be sunset after that.

I can see the 5v support needs for *converter* style builds, but when you're making a "scan the matrix yourself" controller, there's relatively little reason not to buy a cheaper, more performant ARM board if it runs the firmware you want.

I wonder if there will eventually be some sort of adapters that will make, say, the super-cheap "Black Pill" or "Raspberry Pi Pico" boards 5v friendly. Something like those adapter kits they made so you could run a 3.3-volt 486 in a motherboard that only offered 5v.

User avatar
Muirium
µ

06 Mar 2021, 09:16

Hak Foo wrote:
06 Mar 2021, 04:07
What's interesting is that the Teensy/Pro Micro is becoming a strange "local maximum."
Well, a common hardware platform. I'm no coder, really, but I suppose our problem is the lack of portability in our controller and *especially* converter software. It was built for these 8 bit chips specifically, and the hardware interface features you describe.

That's how we wind up with weird combinations like Hasu's Bluetooth upgrade board for the HHKB (which I adore!) running their software on a whole separate 8 bit chip from the significantly more advanced Bluetooth stuff on the same community designed PCB!

If someone wants to embrace the future and refactor TMK/QMK, Soarer's or whatever else for Arm processors, they'd have our thanks, as this low end ATmel stuff is going to die out sooner or later. (PJRC keeps extending those Teensy 2 phase-out horizons. I remember when it was all meant to be dead, years ago by now.)

But! I suspect there's a ton more work required than mere tweaking and recompiling. These modern Arm doodads may be too specific for our long-term low-value drop-in desires. That's where Teensy 2 / Pro Micro really wins: it's the same wee board, every time. Flash and run! Whether it's 2021 or 2011… No promises though for 2031 or 2041.

User avatar
NeK

06 Mar 2021, 09:45

Has anyone done any input lag tests on the Soarer's firmware and Pro Micro/Teensy? I hate to find out that there is like 10+ ms delay. I hope for 10ns instead.

Findecanor

06 Mar 2021, 12:40

Hak Foo wrote:
06 Mar 2021, 04:07
The home-brew ecosystem has revolved around Atmel chips for a long time, but they're expensive for the performance.
A 16 MHz AVR is faster than the CPUs in my first four computers, at least on 8-bit integer maths.
You shouldn't need a faster µC unless you run something like analogue sensing or a faster USB connection.

The thing that makes the Atmel chips expensive is the electric robustness: being 5V-capable, being able to drive other components on output pins, and not requiring additional ESD protection. Those properties and that it is well-documented and easy to program has made it popular for teaching and tinkering. The drawback is that these chips need to be physically bigger, and a lower yield per silicon waver is what gives the higher price.

They do have a relatively high power consumption though. Not ideal for hooking up a tablet or smartphone, and wireless keyboards using AVR and a separate BLE module have especially shitty battery life.
NeK wrote:
06 Mar 2021, 09:45
Has anyone done any input lag tests on the Soarer's firmware and Pro Micro/Teensy? I hate to find out that there is like 10+ ms delay. I hope for 10ns instead.
I'd think it is limited more by the PS/2 protocol than anything else. Over PS/2, it takes 1 to 4 ms to send a single key press in the theoretical best case, depending on which key it is. Two simultaneous key presses takes more, and I'd wager that many vintage keyboards are also limited internally making them even slower.

USB keyboards don't send a key press at a time but instead send longer "report" packets containing the state of all keys. Why many of them have only up to 1000 Hz polling rate is that the USB device modules inside most microcontrollers (AVR or ARM-based) are limited to Full Speed USB, which has that as its maximum.
Another limiting deficiency is that most hardware are based on a model where reports are put in a queue, whereas the ideal model in my view would have been to be able to swap the report atomically and then check whether the previous report had been sent or not. This would add a delay of one polling-cycle unless the queue is empty. It does not matter much for keyboards, but does for mice that very well could have a new report every ms (or more frequently).
The firmware in the Zaunkoenig M1K mouse reads the optical sensor four times every ms, replacing the report packet each time (if necessary). The µC here is actually an AVR: ATmega32u2 - one of the few microcontrollers on which this can be done.

User avatar
ddrfraser1

06 Mar 2021, 13:39

Would be like pulling a plow with a Cessna

User avatar
Bjerrk

06 Mar 2021, 14:34

ddrfraser1 wrote:
06 Mar 2021, 13:39
Would be like pulling a plow with a Cessna
So, definitely cool and worthy of a Discovery Channel special?

User avatar
NeK

06 Mar 2021, 15:07

Findecanor wrote:
06 Mar 2021, 12:40
I'd think it is limited more by the PS/2 protocol than anything else. Over PS/2, it takes 1 to 4 ms to send a single key press in the theoretical best case, depending on which key it is. Two simultaneous key presses takes more, and I'd wager that many vintage keyboards are also limited internally making them even slower.
Agreed, the inherent latency of the ps/2 protocol and of each particular keyboard is what it is. Ideally the converter should not add any additional latency. This is what I am worried about.

I didn't know that PS/2 had any latency worth mentioning about. As a direct CPU interrupt, it should be almost intantaneous. Probably I am missing something.
USB keyboards don't send a key press at a time but instead send longer "report" packets containing the state of all keys. Why many of them have only up to 1000 Hz polling rate is that the USB device modules inside most microcontrollers (AVR or ARM-based) are limited to Full Speed USB, which has that as its maximum.
[snip]
I know that, however this means that it has up to 1ms latency maximum, which is "good enough" in order to minimize the asynchronicity with all the other components in the input - output chain of the system, to a degree down to a 1ms max that is hardly perceptible by humans. I.e. it minimizes stuttering in mouse movements and they are displayed and seen as smoother.
The best would be, of course, perfect synchronization across all the input-process-output-display stack. But that is probably practically impossible.

The 4 reads per ms approach that you mentioned minimizes the input delay to a maximum of a 0.25ms i.e. how recent is the latest read from the mouse. which minimizes the input lag by 0.75ms, which is good, however it does not have any effect on the asyncronicity issue above.

Tahoma

18 Mar 2021, 03:01

Be cognizant of the fact that the Pi is 3.3 volt tolerant, and putting 5 volts on any of its GPIOs risks having a smoked Pi.

This issue can be mitigated (level converters).

User avatar
Muirium
µ

18 Mar 2021, 08:53

That’s an interesting use of the word “tolerant” there! I’d say it’s 5 volt intolerant myself. But I’m no engineer, maybe down is up to them after all.

Tahoma

18 Mar 2021, 17:30

I'd say you're phrasing is correct and more common.

Hak Foo

20 Mar 2021, 06:07

Findecanor wrote:
06 Mar 2021, 12:40
A 16 MHz AVR is faster than the CPUs in my first four computers, at least on 8-bit integer maths.
You shouldn't need a faster µC unless you run something like analogue sensing or a faster USB connection.
Honestly, I think the bigger aspect is the price more than the performance. It doesn't have to be faster, but cheaper is always appealing.

This is especially true if your design puts you a bit above the size threshold of the classic Teensy/Pro Micro. The Teensy can *barely* do a 104-key board (I think BlindAssassin111's AT101W PCB used one) but if you want anything bigger, or need extra pins for LEDs and encoders, you're gonna run out. Then your next stop is a $25 Teensy. The $5 ARM alternatives have a few extra I/Os, and they're laid out so you aren't trying to access pin holes in the middle of the PCB.

Findecanor

20 Mar 2021, 16:18

I've seen Blue Pill and Black Pill microcontroller boards being used for a bunch of DIY keyboards quite recently (which is why I added them to the wiki ;) ). Those have 32 and 30 GPIO pins respectively.

The new Raspberry Pi Pico has been in the news quite a bit, but I don't think it has useful firmware yet, and it has only 26 GPIO pins, only one more than the Teensy 2.0.

Post Reply

Return to “Keyboards”