Teensy 4 MIDI controller experiment

551 views
Skip to first unread message

K7MDL

unread,
Oct 14, 2021, 3:43:43 AM10/14/21
to Hermes-Lite
I have been interested in making a MIDI control pod (vs buying one) co-located next to a HDMI touchscreen as a 2nd monitor for a PC/tablet and even for a PiHPSDR "cheap" version which has few controls compared to the PCB version buildups (I built one of each). This could also serve as a CW keyer.  There are a couple projects along this line out there,, not all public/published yet.  I have never programmed or used MIDI before so it was a bit of a mystery to me.

One twist is I use several i2c connected encoders with push switches and RGB shaft/knob lighting.  I also have a i2c joypad version with a ring of RGB LEDS around the edge and push switch in the middle to try out.

Tomorrow a milled Hammond extruded box arrives from Front Panel Express to house the PiHPSDR Controller2_V2 PCB assembly.  My cheap "V1" style controller is complete with 3W audio amp, external speaker and mic connections, mic PTT working as well.  I used a 12V audio amp with analog volume control and works great, reacts faster.

While in wait mode I decided to take a wack at programing a Teensy4 to be a MIDI controller.  I started with a simple test program by N2ADR for aN aRDUINO midi CW keyer interface. Wanting to have real hardware to use for testing and save wiring time, I had a Teensy SDR sitting here with 2 i2c encoders wired up.  So I inserted the appropriate MIDI output commands lines into my SDR encoder handling code.  That was easy, what took several hours was learning the various commands, mostly how the SDR apps use the 0xB0 command and discovering the different range of MIDI support in Quisk, ThestisHL2 nd PiHPSDR, mostly by looking at the source code for each.  I then adding the 0xB0 command function for the i2c encoders.

I got Quisk working using all my available encoders+switches.  I found the Band Up and Band Down commands are not working right, or at all, and if I used a switch for PTT it crashed.  I have not looked into that yet.   

With Thetis HL2, making too many changes at times caused the program to freeze, forcing me to kill the app but leaving a copy running that I could kill via task manager.  One sequence to cause a freeze is to configure one or more buttons, hit Save, then hit Apply in settings page instead of OK.  On program restart you cannot run MIDI diagnostics, reports not enough memory.  Sometimes have to reboot the PC though rerunning ThetisHL2 and quitting a few times sometimes works around it. If you edit a control the reported value is -2147483648. It does feature a very broad range of assignable commands. 

In Quisk I spent the most time trying to get VFO tune via Knob to work.  I ended up using the (jog) wheel assignment instead.  For that I send the encoder count (+ or - count since last read and cleared) followed by value=64.  That is working well on a otherwise standard encoder. I have yet to get VFO tuning to work in Thetis.

Next steps are to copy the relevant bits to a standalone program and enable the CW keyer interface part.  I am also looking into the ability to use that same Teensy 4.X as a USB Audio sound card using a I2S DAC. 

I am thinking that might be useful to mix the sidetone sound on the host computer sound system and add digital audio out on my Teensy SDR to provide digital audio to a Host PC to run programs like WSJT-X and FLDIGI instead of using an analog cable connection.  This might work on PiHPSDR as well since the Teensy can support multiple USB serial and Audio connections in theory.

My Teensy SDR modified code is on GitHub as usual, most of the work is in SDR_I2C_Encoder.cpp in the KeithSDR/SDR_RA8875 project area. I will post any standalone work up there as well.

Mike, K7MDL, EL87

Steve Haynal

unread,
Oct 16, 2021, 2:22:55 PM10/16/21
to Hermes-Lite
Hi Mike,

Thanks for the update. It all sounds very interesting. A key feature (which some people miss) of the Teensy keyer I am working on is that it is also USB sound device. Users select this new device as the audio output device in the SDR software. This allows the CW tone to be mixed with received audio with low latency right at the keyer. It sounds as if you might be able to do the same.

73,

Steve
kf7o

K7MDL

unread,
Oct 25, 2021, 10:34:46 PM10/25/21
to Hermes-Lite
I have never used KiCAD before so today I created a PCB layout 5" x 2.5" for the Teensy keyer files Steve posted up.  I put all 4 pots and the headphone hack on the front, along wit the MEMS mic, and the rest along the back edge.  I added a vertical Coin cell battery holder for the Teensy RTC backup.

Now to decide on a board house.  I have for 20 years used PCBExpress so going this route is new experience for me.   I used Steve's files for a big jumpstart and added the placement and routing work.  I did not spend the time getting fancy with analog or digital grounds, ground planes or anything, just tried to group things like FB and caps near connectors best I could.  

I usually use Teensy 4.1 boards but have a unused collection of Teensy 4.0 here that I decide it was time to some. After considering using proto board to extract the underside pins, or using a large breakout board I had, I decided to just to a PCB.   

I have some test MIDI code working using i2C encoders with RGB led knobs that I will slip into the keyer code and expand this into a full control pod with knobs and switches for PC (or RPi) SDR app control.

I have my PiHPSDR Controller2 V2 99.5% finished, mounted in the Hammond extruded box and have previously built a V1 "cheap version" .  I am tracking down some SDR app to HL2 UDP disconnect issues with the PC and the V2 controller apps. the V1 controller does not show this issue, and all are  on the same HL2 and network Gig switch, one at a time, swapping power and enet cables. Very hard to troubleshoot!


20211017_173247.jpg20211021_223029.jpg20211022_194554.jpg

20211022_203839.jpg
20211023_011552.jpg
Above is the V1, V2 in center, my 4.3" Teensy SDR far left,  K3 +  P3 below right.  A wireless mini keyboard is shared amongst the controllers.  Both controllers have 3W stereo amps with internal stereo speakers, external speaker jack/switch, and microphone with Mic PTT.  The PCB mezzanine board slides out with s single screw.  The V2 also used a SSD removed from a old laptop and has a USB 4 port hub inside for USB audio dongle  and external USB connection.  

The Hammond case is $40 saving well over $100 at FPE compared to using their Schaeffer extruded box. This box is 1" longer and more than an inch taller., and 66mm deep which was handy.  I also milled out speaker and fan grills on the sliding back plate.   Used cheap robotics enclosed speakers on the V1 inside the SmartiCase Pi Pro case, and Dayton 1.25" speakers on the V2 back plate, mounted on 1/8" standoffs.  Sound from both is very decent, loud, and totally usable.  I wired speaker audio on the 8 pin mic connectors to use a speaker mick or easy connection to an external digital mode CPU if desired.  The V2 case also sports a HDMI connection to use a bigger screen on TH RPI when I want to run WSJT-XX and logging programs.

I chose to only engrave a few controls knowing that  I will reassign them periodically so will use white rub on letters for those controls.

Some parts like the DC DC converter and the FET switch arrived well after I built V2 PCB.  Trying to solder those down was problematic with al the other little parts around it so I chose another path to heat sink it.   I bent the chips vertical then soldered a tinned terminal ring, bent 90degrees and used lots of solder for thermal mass.
20211021_214743.jpg

The PC and both these controllers are using the Teensy keyer with MIDI commands and running 24/7 (only one HL2 so one at a time)..

   - Mike
K7MDL

K7MDL

unread,
Oct 25, 2021, 10:36:41 PM10/25/21
to Hermes-Lite
The PCB image got dropped that was to lead off the story.  Here is is for your visual entertainment and dart throwing contests.
KF7O Teensy  Keyer PCB image.jpg

K7MDL

unread,
Oct 25, 2021, 10:41:35 PM10/25/21
to Hermes-Lite
A follow up question for Steve, Did you have particular part numbers in mind for the jacks and pots to fit those footprints in KiCAD or were those generic library parts?  The PCB is not ready to send off yet until I verify those part fitments.  The pots line up well with a number of one off analog pots in my junk box , can also panel mount and wore them.  I do not have enough so will be ordering pots and jacks.  The jack footprints do not match anything I have here.  I have not looked online yet, just my local stock.

Mike

Mike Lewis

unread,
Oct 25, 2021, 11:14:49 PM10/25/21
to Mike Lewis, Hermes-Lite

Exported a Step file from KiCAD and imported it into FreeCAD to generate this 3D.  The 3 tall posts will be a vertical coin cell holder.   This is facing front with the 4 pots and headphone jack on the far left.  Teensy USB and the jacks on the back intended to set flush with a box back panel.    The PCB size was not chosen for any special box, I made it as small as I figured I could  reasonably squeeze everything in.  The front pots are easy to separate and panel mount and wire if the chosen box is too deep.  First time I have run this program.   I have created a number of small PCBs over the year but the last time I did it professionally was on the late 80s with a 286 and EGA screen with a $15K P-Cad dongle attached, an big improvement of the hand taped layouts.  Times have changed since then, cost have dropped to Free.

 

 

 

Mike

K7MDL  EL87sm & CN88sf

 

Steve Haynal

unread,
Oct 26, 2021, 1:15:28 AM10/26/21
to Hermes-Lite
Hi Mike,

Nice to see you have placed and routed a board in KiCad! KiCad is quite the tool, especially for being open source. 

The jacks are the same as used on the HL2 board. This is so makerfabs only has to source one part. See the HL2 BOM for an exact part number. You have to manually add a cutout on the circuit board for the front of each of those jacks as there is a plastic there that protrudes below the level of the PCB. See the HL2 layout.

The pots are a standard pinout and pin spacing. I think I bought several different brands in my last Digi-Key order. They are available from AliExpress too.
for example P160KN-0QC15B50K or any matching pinout.
1528-2164-ND are nice knobs on Digi-Key.

As I floorplan and layout a PCB, I often adjust the schematic to avoid wire crossings, pick other components to reduce footprint size, etc. For example, I reduced the size of the two test points. There have been several changes like this and I have updated github. 

The wm8960 datasheet gives some PCB guidelines for the speaker outputs to reduce EMI. Components must be placed close to those pins. R33 is to terminate the clock and should be close to the wm8960.

I respecified a 2x5 connector so that the pinout matches the JTAG on the HL2. The HL2 JTAG can be used for fast communication, up to 30Mbs. 

Sorry about this but I didn't know you were laying out a board! I just wanted you to be aware of new differences. Your board should still work although there may be minor differences in the pinout connections to the Teensy 4.0 which will have to be updated when building the firmware.

The 10cmx5cm size follows the 5cm increments for price increases that most PCB houses outside of the USA observe. Check out www.pcbshopper.com for places to have boards fabbed.

I don't know if we can use Teensy in the name. I remember seeing something about that somewhere but can't find it again on the prjc.com site.

KiCad has a 3D renderer builtin. Here is my board with components more or less placed. Next step is routing!

73,

Steve
kf7o

TeensyKeyerShield.png

Mike Lewis

unread,
Oct 26, 2021, 1:23:57 AM10/26/21
to Steve Haynal, Hermes-Lite

No worries on updates.  I just started this to learn KiCAD and maybe save wiring time on a proto board build, my usual approach, I will be following your build I the long run, or short tun if you end up routing sooner than later.  These Teensy 4s are sitting on my desk, calling me, begging for something to do…. 

 

I will check out the parts sources you mentioned and start parts acquisition.  Thanks for getting this started in your spare time.  I am retired, I do this all day 😊.

 

Mike

K7MDL  EL87sm & CN88sf

 

From: herme...@googlegroups.com <herme...@googlegroups.com> On Behalf Of Steve Haynal
Sent: Tuesday, October 26, 2021 01:15
To: Hermes-Lite <herme...@googlegroups.com>
Subject: Re: Teensy 4 MIDI controller experiment

 

Hi Mike,

 

Nice to see you have placed and routed a board in KiCad! KiCad is quite the tool, especially for being open source. 

 

The jacks are the same as used on the HL2 board. This is so makerfabs only has to source one part. See the HL2 BOM for an exact part number. You have to manually add a cutout on the circuit board for the front of each of those jacks as there is a plastic there that protrudes below the level of the PCB. See the HL2 layout.

 

The pots are a standard pinout and pin spacing. I think I bought several different brands in my last Digi-Key order. They are available from AliExpress too.

for example P160KN-0QC15B50K or any matching pinout.

1528-2164-ND are nice knobs on Digi-Key.

 

As I floorplan and layout a PCB, I often adjust the schematic to avoid wire crossings, pick other components to reduce footprint size, etc. For example, I reduced the size of the two test points. There have been several changes like this and I have updated github. 

 

The wm8960 datasheet gives some PCB guidelines for the speaker outputs to reduce EMI. Components must be placed close to those pins. R33 is to terminate the clock and should be close to the wm8960.

 

I respecified a 2x5 connector so that the pinout matches the JTAG on the HL2. The HL2 JTAG can be used for fast communication, up to 30Mbs. 

 

Sorry about this but I didn't know you were laying out a board! I just wanted you to be aware of new differences. Your board should still work although there may be minor differences in the pinout connections to the Teensy 4.0 which will have to be updated when building the firmware.

 

The 10cmx5cm size follows the 5cm increments for price increases that most PCB houses outside of the USA observe. Check out www.pcbshopper.com for places to have boards fabbed.

 

I don't know if we can use Teensy in the name. I remember seeing something about that somewhere but can't find it again on the prjc.com site.

 

KiCad has a 3D renderer builtin. Here is my board with components more or less placed. Next step is routing!

 

73,

 

Steve

kf7o

 

 

 

 

 

 

On Monday, October 25, 2021 at 8:14:49 PM UTC-7 K7MDL wrote:

Exported a Step file from KiCAD and imported it into FreeCAD to generate this 3D.  The 3 tall posts will be a vertical coin cell holder.   This is facing front with the 4 pots and headphone jack on the far left.  Teensy USB and the jacks on the back intended to set flush with a box back panel.    The PCB size was not chosen for any special box, I made it as small as I figured I could  reasonably squeeze everything in.  The front pots are easy to separate and panel mount and wire if the chosen box is too deep.  First time I have run this program.   I have created a number of small PCBs over the year but the last time I did it professionally was on the late 80s with a 286 and EGA screen with a $15K P-Cad dongle attached, an big improvement of the hand taped layouts.  Times have changed since then, cost have dropped to Free.

 

 

 

Mike

K7MDL  EL87sm & CN88sf

 

--
You received this message because you are subscribed to the Google Groups "Hermes-Lite" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hermes-lite...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/hermes-lite/053e68e1-3745-425d-babd-fab66e821e2cn%40googlegroups.com.

Matthew

unread,
Oct 26, 2021, 1:41:24 AM10/26/21
to Hermes-Lite
Hi Mike,

Kicad is quite a powerful tool and I'm sure you will enjoy getting to grips with it.

I'm not sure if you have used an auto router to layout your board? A quick look at your board shows some right angle tracks and stub tracks. I have used a couple of autorouters (including some paid for ones) and I have always given up and routed the board myself.

I would recommended getting familiar with the design rule checker, it can save you time and money by picking up mistakes before you get the boards made.

73 Matthew M5EVT.

Mike Lewis

unread,
Oct 26, 2021, 1:47:19 AM10/26/21
to Matthew, Hermes-Lite

I did this one all by hand.  That is why there  are differences, for a quick proto, I was not applying all the best practices.  I did use the DRC and fixed some traces that were too close.  I thought I got rid of any stubs.  I toggle the various layers to spot them by eye.  I used only the defaults.  25 years ago I used to lay out high speed data acquisition boards, this is certainly not that level 😊.   But this was done in hours, not weeks.

 

Mike

K7MDL  EL87sm & CN88sf

 

Reply all
Reply to author
Forward
0 new messages