Universal Model M Controller

User avatar
phosphorglow

04 Mar 2015, 17:53

Okie doke. Well, in the mean time, here's what we've got:

View of USB-B connector and reset button. The reset button will have a smaller actuator and be more recessed than this. I'll have a slot in the "cover" to poke it with a paper clip.
2015-03-04 11.02.58.jpg
2015-03-04 11.02.58.jpg (38.63 KiB) Viewed 5523 times
View from the inside looking out. Notice the voltage regulator pads.
Also note the row of through holes on the upper left, that's the USB header tap, which comes in handy for your own cable/panel and for the next picture...
2015-03-04 11.03.54.jpg
2015-03-04 11.03.54.jpg (86.58 KiB) Viewed 5523 times
Take form of... MICRO USB!
(Well, visualize it. I don't have one on hand yet.)
2015-03-04 11.05.05.jpg
2015-03-04 11.05.05.jpg (76.5 KiB) Viewed 5523 times
I'll be updating the pads to accommodate through hole mounting legs, once I find the perfect connector. I keep going back to the Hirose ZX62D-B-5PA8.

Here's where things get a little fun. Ignore the highlighted holes. They don't exist. The rest do.

So, the idea is, USB input riding the rails to the controller. Unless you're using a Lipo for bluetooth, in which case you cut the traces. Then you have the USB input cabled to the Lipo, and then coming back in on the left side, which then goes back to the controller.

On the bottom of that board will be a SMT pushbutton (found one that sits in at 1.7mm) for bluetooth pairing. The previous reset button will be replaced with the same size button in the spot that the USB-B connector took up on the controller.

And lastly, for now, this.
2015-03-04 11.05.25.jpg
2015-03-04 11.05.25.jpg (88.65 KiB) Viewed 5523 times
The EE's can stop cringing at my previous use of 90 degree traces. Got those taken care of. :P
Mounting holes for 122 key M's, as well as a square cut out for the M's with the smaller controller. So far it happily fits everything I've tried it on, one way or another.

These pictures are maybe an hour or two old? There have been small revisions since then, but even those are bound to be tweaked, so you get the idea.

Oh yeah... Ideas! Throw some at me! Suggestions, tweaks, insight, or something you want implemented.

User avatar
Muirium
µ

04 Mar 2015, 17:59

Ooh, very nice! Want.

andrewjoy

04 Mar 2015, 18:00

I am so looking forward to this . With my franken silver label on the way ( is it AT, XT is it terminal NOBODY KNOWS! ) i am thinking i will be in the market for a replacement controller .

User avatar
Halvar

04 Mar 2015, 18:50

Yes! Looking forward to this.
phosphorglow wrote: Halvar - what needs to actually happen to switch between direct connection via usb and Bluetooth?
I'm using this double-pole switch but there are probably better alternatives without LED:

http://www.conrad.de/ce/de/product/1836 ... stend-1-St

The switch is functionally used to both switch between Bluetooth and USB and turn the battery power on or off.

Switch on: run on battery in bluetooth mode. If USB is connected it only loads the battery.
Switch off: run on USB if it's connected. Also loads the battery if needed. If USB is not connected this is a more or less hard power-off, the controller gets no power.

One pole is in parallel to the switch on the Lipo Rider and switches the battery power supply on or off. The other pole of the switch is connected to an AVR pin so the AVR chip knows if it should be running on Bluetooth or USB. This second pole might be unneeded though, you could directly get the voltage on the switched side over a high ohm resistor.

If you're fine with running the keyboard on battery all the time, even when running on USB, the switch could be fully omitted and you could switch between Bluetooth and USB with a keyboard macro.

Unfortunately there's no connectors on the Lipo Rider for a parallel switch so I had to improvise badly. I'll have a look if there's a better alternative.

My hardware looks really lame in comparison to this of course!

User avatar
XMIT
[ XMIT ]

04 Mar 2015, 21:52

I'll be watching this thread carefully. I do need a new controller board anyway. :-)

User avatar
phosphorglow

06 Mar 2015, 12:20

Thanks for clarifying, Halvar! I think I got this pretty well rigged up for that scenario now.

Found a perfectly fitting slide switch to fit where the USB-B goes. 5mm tall, with a 5mm actuator that will sit just above the case and be just accessible enough. Just high enough to keep that little board from being too high and interfering with the USB cable. So far, looks like perfect clearance. That connector area looks like it has plenty of space until you start trying to cram stuff in there! :P

Also leaving extra through holes to stuff an LED or two on the mini board.

Anyhoo - pretend like you're connecting the bluetooth hardware, and let me know if anything seems weird or could be done differently.
controller3.jpeg
controller3.jpeg (153.36 KiB) Viewed 5455 times
Open for suggestions/modifications before I send this off to be made on Tuesday or Wednesday.

Before then I'll be tweaking some traces to pretty them up, extending the breadboard area to the right a little more, possibly adding traces to the correct pin locations for the EZ Key module (maybe? It looks like it will fit with clearance to spare, at least on a full sized M), and probably adding some pad connectors on the bottom that connect to the ribbon connectors in case something goes horribly wrong with this layout. Then a Teensy can get slapped in the breadboard area and save the day. Don't think that will be an issue since my prototype worked until I put it in a coma that I haven't woken it up from yet, but it's a nice reassurance when you're getting 50 boards...

Also, going for an ENIG finish for shelf life and solderability with leaded/lead free. I really like the idea of a green color PCB for the sake of tradition, but red looks awesome... So I don't know yet?
Last edited by phosphorglow on 06 Mar 2015, 12:43, edited 1 time in total.

User avatar
Muirium
µ

06 Mar 2015, 12:36

Beautiful. The power switch is smartly implemented. It suits being tucked away back there quite nicely, as you don't need to touch it if you don't want to. Leave that to the OCD brigade like me!

Bluetooth does also require a pairing trigger of some sort, though. I'm thinking a keyboard shortcut would be the nice, subtle approach. Though others have certainly found their own way…

Image
https://learn.adafruit.com/convert-your ... d/overview

Pairing mode does benefit from some kind of indicator as well. That blue button there lights up, so serves both purposes. Wonder what we should use? I'd really rather not drill anything through the case! Perhaps a wee light round back with the switch? Or an LED module attached to the barrel frame, so you can see the light glowing around the base of the Escape key?

User avatar
phosphorglow

06 Mar 2015, 12:47

Thanks!

Is a key shortcut actually possible? That would be interesting! As of right now there's a pushbutton on the mini board. The plunger will be long enough to be pressed without interfering with the USB cable. I'll fiddle around with placing an LED on there. Avoiding any drilling is a major goal of this venture! :)

User avatar
phosphorglow

06 Mar 2015, 12:58

But since you brought up the topic, here's how I'm doing LEDs nowadays:

Image

Surface mount LEDs and custom cut mylar holders. Fun stuff!

User avatar
Muirium
µ

06 Mar 2015, 13:09

Slick. I want a few of those! What's their power draw like? One to indicate USB powered battery charging, as well as a blinker for Bluetooth pairing would be just the ticket.

Actually, if we can get layer locks in the controller, I'd want more indicators besides! But LEDs suck juice hard, so these indicators would be about brief flashes rather than solid steady lights.

As for the key combo Bluetooth pairing trigger idea: I don't see a reason why not. We're running the controller, and if the EZkey doesn't take a signal to trigger pairing, we could always hack up something of our own. That's why I like replacing the original controller so much! Not only do you get a lot of immediate power saving, but you can implement new features right from the driving seat. Even stuff like password locks.

The big feature I'd like to see is smart polling. That's the key to saving power: slowing down the matrix scan cycle when the board's idle for a few seconds. Progressively slower rates can lead all the way to full sleep, automatically, if desired.

User avatar
Halvar

06 Mar 2015, 13:14

@phosphorglow: wow, that LED solution is neat!

Re pairing, the EZKey has an input pin that triggers pairing when drawn to 3V, so yes, the controller can do it.

There's also an output pin for the bluetooth LED. Annoyingly, this LED slowly blinks all the time when the keyboard is connected so it definitely can't be too bright:

Image.

User avatar
Muirium
µ

06 Mar 2015, 13:31

Ingeniously bad! I'd definitely recommend against connecting anything to that. On all grounds: power, irritation, common sense…

The way Apple's Bluetooth keyboards use their single LED is about right. You never see it unless you just turned on the board (it glows solidly for a few seconds) or the board is in pairing mode (it blinks in a sharp pattern faster than any in the table, where it's off most of the time but still highly conspicuous) or when a host wakes it up (solid glow for a second or so). When you're actually using the keyboard, you never see it. Ideal!

Of course it helps that Apple can read the battery level from the host and display low power warnings on screen instead. We might need something to handle that. (My suggestion: a key combo which triggers a varying number of flashes from an indicator. Or maybe a flash of three LEDs in a row. Depends what we can measure.) Or just not bother and recommend attaching to USB whenever in doubt!

User avatar
phosphorglow

06 Mar 2015, 13:40

Heeee! This gets more exciting every day! Neat!

Depending on the LED color and what resistor is paired up, I think it was in the 5-10ma range. I'll have to hook one up to my ammeter again to double check. I'll probably be modifying the mounting of the LED to face up but I'll need to create a small "wall" to block visibility at certain angles. At that point they should be able to run a bit dimmer and draw less current. It's on my fiddle list. :P

I'm glad the 1286 has so many extra pins - I'd love some layer lock LEDs in addition to the regular lock keys. Which hasu's firmware supports if I recall correctly. I wonder if he has the smart polling integrated? That would be super exciting.

Oooh, yeah... those blinkies are a bit much. Definitely be tucking that one nice and dim into the connector area. :P
I'm thinking a tiny little SMT in front of the reset button paired to like a 1.5-2k resistor. Plenty of room right there I think.

User avatar
phosphorglow

06 Mar 2015, 13:45

Looks like the Lipo rider has a built in charge indicator, but that's beginning to open up a new can of worms for putting extra LEDs on the mini board. Unless creative placement will allow utilizing the speaker grill..?

User avatar
Muirium
µ

06 Mar 2015, 13:51

There's two good places for LEDs, and you're already thinking of them:
  • Tucked around back in the SSL opening, next to the USB port and switch.
  • Mounted to barrels, where they are visibly associated with certain keys.
The options for the latter are obviously very large! Layer lock lamps could be along the number row or function row. Escape could be the pairing light and trigger (with an appropriate combo). Battery indicators could be along some other sequence of keys, like the three above the nav sixpack.

Depends how cheaply you can implement something like that LED holder of yours! For occasional, flashing lights I think it's magnificent! And when on USB power, they're obviously good for general lighting duties too. As a Shift+Shift=Caps Lock user myself, my SSKs could use a lock light! Ditto for embedded numpad mode.

User avatar
phosphorglow

06 Mar 2015, 14:06

Ohhhhh yeeeeeahhh! Hadn't thought of using the barrel LEDs for the charge status, good call! I wonder if pulling the switch on the Lipo to ground via a key combo in firmware would work? Of course, that will require some fun tinkering attaching small wires to the Lipo.

As for implementing the holders, I can basically whip up whatever design/layout I can create and cut it out on my electric die cutter. ^_^

User avatar
Muirium
µ

06 Mar 2015, 14:26

How many "bars" of battery power are reported by the battery controller?

I'd got for momentary lights (blinks on request) over static (on for hours at a time) LEDs in any case when running off battery power.

Interestingly, the Apple keyboard I mentioned has a standard Caps Lock light (in the same location as on the MacBook lines) which glows green regardless of battery! I guess Apple took the approach of WHO CARES ABOUT THOSE GUYS. Caps Lock is more of a warning than a way of life…
phosphorglow wrote: As for implementing the holders, I can basically whip up whatever design/layout I can create and cut it out on my electric die cutter. ^_^
Sweet. With the kind of interest I expect a Bluetooth SSK kit to generate, and several lights per board, I think it'll see a lot of work!

User avatar
Halvar

06 Mar 2015, 15:10

Muirium wrote: How many "bars" of battery power are reported by the battery controller?

I'd got for momentary lights (blinks on request) over static (on for hours at a time) LEDs in any case when running off battery power.
I'm sensing battery voltage with one of the ADC input ports of the microcontroller, and my plan was to just use a LED to light up or blink when battery is low. There's still a lot to do in my software ... :roll:

I'm using the "standard" LiPo Rider, not the LiPo Rider Pro, so mine doesn't have any charge status LEDs.

User avatar
Muirium
µ

06 Mar 2015, 15:49

So just a binary FULL / LOW then? Or can we do better without extra hardware?

Low warning is good. Hell of a lot better than sudden power loss. Each extra shade of grey improves matters asymptotically.

User avatar
Halvar

06 Mar 2015, 16:02

If you have a good idea ...

There could even be a macro that lets the keyboard type current battery percentage ...

User avatar
Muirium
µ

06 Mar 2015, 16:20

Good is for others to decide. But here's one I like: flash LEDs along the function row (F1-4 or even F1-12 if you have that accuracy) when the user hits a certain combo. And crucially: do it whether connected to a host or not!

Robotic typing of strings is interesting but limited. (Just the sort of thing to shock the unexpecting!) I want one in honour of Jack Torrance of course.

User avatar
Halvar

06 Mar 2015, 18:00

Ok, we'll see how many MC pins we will have left for stuff like this further down the road... ;)

User avatar
hasu

07 Mar 2015, 02:02

It looks nice!

I skimmed the board image and found some to think about. I'm not 100% sure about these, just hope it helps.

- J4 and J11 connectors are provided 5V from USB. This won't be safe when MCU runs at 3.3V. I think they also should be supplied MCU VCC voltage(3.3V).
- For Bluetooth option 'external power input' pin is needed to feed with battery? If you use EZkey it has regulated 3.3V output(100mA).
- VCC line(U6 regulator input) will be connected to USB 5V directly when it acts as a normal USB only controller or it'll be connected to 'external power input' when Bluetooth. You will need solder jumper for this.

EDIT: Added diagram.
uniM.pdf
(23.28 KiB) Downloaded 183 times
phosphorglow wrote: Anyhoo - pretend like you're connecting the bluetooth hardware, and let me know if anything seems weird or could be done differently.
The attachment controller3.jpeg is no longer available
Open for suggestions/modifications before I send this off to be made on Tuesday or Wednesday.

User avatar
phosphorglow

09 Mar 2015, 18:52

Ok I think I see what you mean, but I'm still a little confused.

The Lipo rider regulates the voltage back up to 5V, so essentially we're still running off of "USB" voltage even on battery power.

So, that power input will be heading to the voltage regulator AND to UVCC (which is an internal voltage regulator on the 1286). From the voltage regulator, it's brought down to 3.3V and connecting to VCC, AVCC, and UCAP.

So, regardless of whether the controller will be connected to external USB or internal power, it should still be configured to run at 3.3V/8MHz in this application.

Am I overlooking something or do I understand this correctly?

Configuring for 3.3V/8MHz will lower the power consumption which is the goal for battery operation, and we still get the same 5V for LEDs.
Last edited by phosphorglow on 09 Mar 2015, 19:00, edited 2 times in total.

User avatar
phosphorglow

09 Mar 2015, 18:56

Here's this from the datasheet.
controller4.jpeg
controller4.jpeg (18 KiB) Viewed 5270 times
Teensy schematic connects 3.3V to UCAP as well, but I think that's basically just for direct 3V battery power. According to the datasheet, I suppose I don't need to do the same thing, right?

User avatar
Halvar

09 Mar 2015, 23:41

Sorry, I had a lot going on in RL over the last wtwo weeks. I hope I can take a better look on it tomorrow.

User avatar
hasu

10 Mar 2015, 01:34

I didn't know Lipo rider output is 5V. I think it works as you said but my concern is sitll there. When MCU core runs 3.3V it is not safe to handle higher 5V with IO pins. Pratically it may be no problem.
- J4 and J11 connectors are provided 5V from USB. This won't be safe when MCU runs at 3.3V. I think they also should be supplied MCU VCC voltage(3.3V).

Another concern is,
VBUS is used for USB plug-in detection and it is not good idea to connect to battery, it should be connected to real USB 5V line. This is not indispensable but will be needed to support switching between Bluetooth and USB.

User avatar
phosphorglow

11 Mar 2015, 03:15

No problem Havlar! Hope all is well! It'll probably be another couple of days anyhoo. Lots of other things keep popping up.

I see what you mean hasu. For some reason the idea that the IO pins pulling 5V to ground for the LEDs when set for 3.3V wouldn't be a big issue, but I agree - it doesn't sound safe at all. It might work, but who knows for how long.

So, I'm thinking the simplest solution would be to just cut the 5V trace that runs the remainder of the circuit and power it from the voltage regulator? It's rated for 500ma. How does that sound?
hasu wrote: Another concern is,
VBUS is used for USB plug-in detection and it is not good idea to connect to battery, it should be connected to real USB 5V line. This is not indispensable but will be needed to support switching between Bluetooth and USB.
This I'm curious about since Halvar seems to have been able to do this:
Halvar wrote: One pole is in parallel to the switch on the Lipo Rider and switches the battery power supply on or off. The other pole of the switch is connected to an AVR pin so the AVR chip knows if it should be running on Bluetooth or USB. This second pole might be unneeded though, you could directly get the voltage on the switched side over a high ohm resistor.
I'm guessing he's using one of the ADC pins?

User avatar
hasu

12 Mar 2015, 03:43

phosphorglow wrote: No problem Havlar! Hope all is well! It'll probably be another couple of days anyhoo. Lots of other things keep popping up.

I see what you mean hasu. For some reason the idea that the IO pins pulling 5V to ground for the LEDs when set for 3.3V wouldn't be a big issue, but I agree - it doesn't sound safe at all. It might work, but who knows for how long.

So, I'm thinking the simplest solution would be to just cut the 5V trace that runs the remainder of the circuit and power it from the voltage regulator? It's rated for 500ma. How does that sound?
Sounds good. Probably 3.3V is even enough to turn on old LEDs.

hasu wrote: Another concern is,
VBUS is used for USB plug-in detection and it is not good idea to connect to battery, it should be connected to real USB 5V line. This is not indispensable but will be needed to support switching between Bluetooth and USB.
This I'm curious about since Halvar seems to have been able to do this:
Halvar wrote: One pole is in parallel to the switch on the Lipo Rider and switches the battery power supply on or off. The other pole of the switch is connected to an AVR pin so the AVR chip knows if it should be running on Bluetooth or USB. This second pole might be unneeded though, you could directly get the voltage on the switched side over a high ohm resistor.
I'm guessing he's using one of the ADC pins?
As Halvar said, Bluetooth module can be controlled with the physical switch state IO pin.
VBUS is for doing funcy things in firmware, you can use Bluetooth without VBUS connection I described.

EDIT:
Technically VBUS is needed to USB interrupt VBUSTI which is useful for USB stack to manage power/connection cycle. But without that I think you can do, in fact ATMega32U2 has no VBUS pin.

User avatar
Halvar

12 Mar 2015, 09:54

VBUS and UVCC are connected to the Lipo Rider's 5v USB output pin. I can't detect if USB is connected to the PC from these, because they're always on +5V whenever the controller is on. It wouldn't make sense to use this for detection of a connected PC anyway, because you could always also connect a USB charger or a PC in some power saving mode to the USB port. You could also want to use the keyboard for your tablet via BT while it's connected to the PC by USB for charging. That's why I went with the switch instead of some kind of autodetect.

Post Reply

Return to “Workshop”