SDS KeyPadz  

 

  During the past year or so, I've been doing a lot of performing and even though the shows went smoothly, I've heard some complaints that there's too much of a "gap" between some songs.
If I'm performing without any accompaniment, then I can almost flow from one song to another, but if a song needs the MIDI sequencing from the computer, then I find I'm squinting at a screen (especially if it's outside with sun shining brightly on the screen) and trying to maneuver the touch-pad style mouse arrow to the next file.

 As they say, necessity is the mother of invention, and something needed to be done about this. I have researched using a keypad to trigger macros but couldn't find a reliable way to have a numeric entry from a standard USB number pad. It would converse with "hotkeys" in my sequencer program and do all sorts of weird things depending on which window was "on top".

 After some searching around, I thought I had found a macro program to fit the bill, only to discover it was almost $300, and with the limited "it can do this and that" info on the site, I wasn't about to fork over that kind of cash if they had no demo to test. So after some more searching a few days later I found the FREE program "AutoHotKey".  It is script based, and can do virtually
anything at all with the press of a keyboard key.

  Now all I need to do is find a keypad. I researched gamer keypads because they are robust and usually have some form of mounting hardware. They are programmable, but as I soon discovered,
not programmable enough. So I said to myself " OK! I'll build one dammit! "

  I want to be able to:

- type in a 3 digit song code (from my songbook or memory) and have it open the MIDI sequencer program if not already open,
  (FL Studio in my case) then load the song, ready to go.

- Have clearly defined Play/Pause & Stop Buttons

- Have a pedal switch that controls Play/Pause

- Be able to set the next song from the key pad and arm the pedal switch to load it when pedal pressed.

- See / feel the keys in the dark, so a large old telephone keypad will do. ( Thanks June for all the old phones! )

  I thought to myself, " why stop here? ". It's a big secret right now, but sometime in 2013 I will be performing a show with
projected video, special lighting effects, and live music to go with it, as a type of "musical" stage production.
I really need an interface that will recognize trigger codes embedded in (DVD) video, and load the appropriate song / software
setups / etc., so I can perform fluidly without any breaks in the productions flow. This takes care of having to have a sound
guy, a video guy, and a 'puter guy!

 I started studying up on PS/2 keyboard/mouse protocols when I found a game controller at the used/economy store in town. It's USB, but no "real" joystick, just arrows. The reason I bought it
was lots of round buttons ( which I like because one only need drill a hole to put one in a panel. ) Including it's "fire" buttons, there's 8 buttons plus 4 axis buttons.
 Why use a game controller? Because, even with an advanced HotKey program, keyboard keys can be a real pain in the butt if outside of the intended application. Every contingency must be
considered. Some programs "steal" the hotkeys, which isn't a problem with output from AutoHotkeys, but the input keys trigger other things, and windows dislikes being cooperative.
With a game controller, none of that is an issue!...well unless one likes playing games on one screen while composing music on the other lol!


So there it is, I plan to use a USB game controller board with a telephone keypad and built-in SVGA video code interface. Am I crazy? Ha ha!

  This is how everything will connect once the project is done. The game controller is actually inside the SDS KeyPadz unit, but I showed it for clarity.

    The Video Codes:

 I am lucky enough to have a BenQ MS510 projector which has an SVGA output that sends exactly what
video is input from the PC. To be able to project video, but also use other programs, a dual output video card is required. The SVGA from the projector goes back to the SDS KeyPadz for coded video decoding.



The Video code as shown above is comprised of all 3 colors, Red, Blue & Green. The Red is
Data, the Blue is the clock, and the green causes a Latch to grab the data.

  The video "code" is just 2 8-bit bytes, followed by a CRC or checksum byte. This means there will need to be 24 clock pulses, and an end pulse (green) to latch them into a microcontroller.

 Because of the way different media players and Codecs handle colors, I was unable to just overlap each color, i.e. blue/violet = blue and red, so I had to make the clock and data pulse
sequentially. Normally, in any 2-line serial communication, the data is set up on the data line, then the clock comes along and writes it in, but because I must stick to primary colors,
the data must be somehow held long enough for the clock pulse to clock it in.

  Using a simple delay capacitor between two 7414 invertors is an easy fix! (Diagram, left)
Because the PIC microcontrollers I love to use aren't anywhere near fast enough to deal with video signals, ( are any? ) I had to use some power hungry 74"LS"299 shift registers to get the data on to the board. The reason I put "LS" in quotes is 60mA/chip! Power pigs!


 But they are very fast, and I happen to have a few laying around...
So the video data is shifted into the '299's and the PIC chip reads each one via their OE pins, and an 8 bit bus on Port C.

  If you plan on building this as well, don't worry, I'll do up some better schematics when I have some time. So, before moving on the the simple keypad section, in a nutshell here's how the video signal and code looks /works...

  The bars near the bottom are pretty close to what the video image actually looks like.

  You may have noticed there are two bars? After playing around with the code and adding a CRC, which is the last 8 bits of  the sum of the first 2 bytes, I thought it's be secure enough.
By secure I mean that it won't be tripped by ordinary video graphics and images etc.. It's a one in 65536 chance.
I was wrong. Even though the code can't be zero, and it must be valid twice within 160mS, (i.e. 2 horizontal video scans) and the code, 0-65535, must be less than or equal to 999,
right away the title of one of my music videos tripped a code!
 Hence, the compliment code was born. This code must be sent at least 2 video frames (30fps) before the data code. It is a compliment (1=0,0=1) of the actual data byte, but the CRC
is true for the first two bytes. So, in the above example, code #901, you may notice the red bars are vacant on the opposite line, but only in the first 16 bits. (the last bit is the same)

  It's rock solid and hasn't monkeyed up yet.....well that way. Now there's a problem with getting the proper data. I noticed that video converted (to WMV in this case) and played back
wasn't always causing the code to trigger. So after looking at the signals coming into the shift registers, I noticed sometimes there was and extra clock pulse. The codec must've brightened
the video just slightly so the latch (green) pulse was causing a spike enough to raise the blue level. A brighter green does have blue in it. After messing around with filtering for a while,
I came up with an idea! The old adage "If you can't beat'em, join'em" rings true: Just combine the last clock pulse with the Latch pulse. This makes an awfully bright sky blue, but
totally annihilated the problem.

  After doing some "demo" videos, which start up FL Studio, and start playing a song part way through, then stopping it again, I have found those code bars at the bottom aren't even
noticeable, unless you are really looking for them. If it's right after a quick fade it's not there at all. Unfortunately, because of the 2 code structure, nothing else can be on the screen
while the code is active, except maybe a really dim image. But it's only 2 frames with a space in the middle.

 

  The Key Pad Circuit:

  As I mentioned above, I've decided to use a telephone keypad. Mostly because I'm very familiar with it, whereas the type on the right of a computer keyboard is alien to me. I can use a telephone in the dark, which I have done lots in dingy back hallways of bars and at night in dark payphones with burned out lights etc. When on the stage, sometimes the actual performance is all you want to think about, so anything the adds to the simplicity is a bonus.

  These keypads are all standard 3x4 layout, so the PIC 16F74 only needs to pull up each row
(Port D,0-3) while checking the column inputs (Port D,4-6) Port D,7 adds another column,and is used for the extra 2 buttons for Play & Stop.

  The foot pedal can't be scanned this way as the long wire would create too much capacitance and may trigger a Play/Pause at the wrong time, so better safe than sorry. Before each keypad scan, Port D,7 is checked for a high level. If it is high before the scan has started then foot pedal has been pressed.

The outputs on port A & B are driving a 4066 quad analogue switch to "press" the game controllers buttons. I could have used transistors with this controller, but if it ever fails, who knows what might be next, so once again, for the little extra board real estate it's worth it. Each pair from the 4066 is isolated away from ground/Vdd which is a good thing as some of the keys were positive & others neg.

The board to the right is mostly accurate, except the added 75 ohm resistors to ground at SVGA inputs B, G, & R. ...and a 100k pot to ground from the base of each Q to control the bias/gain levels.
Again I'll post a more detailed image with the jumpers etc. I used photo-etching to do this board, and it was the best I've ever done ( out of 60 - 70 photo-etched boards ) Must be our new laser printer I guess. The original image is >3000 pixels.

  On this game controller is a 4 way thing that looks like a POV hat, but it's not a POV, it's actually an X-Y axis that is simulated to act like a POV but control an X-Y! That'd suck for most racing/flying/shooting games I've ever seen, which is probably why it was at the economy store for $2 lol! If you are going to build this thing, a proper joystick would be best, then just hook the
Y axis <10 to Port B,6's 4066, & Y axis >60 to Port B,7's 4066. ( X-axis < 10 is on Port E,2's 4066 switch)

Because the game controller only had 8 buttons, I decided to only involve the numbers 1-8. This may have been a silly thing to do, but it's done so no going back hehe. The 2 remaining # keys close FL Studio (#0) and toggle between FL Studio and DJ Mixxx (#9) like <ALT> <TAB> does, except just between those 2. You could change the AutoHotKey script to anything though.

 

  Video Coder:

  "Where do those fancy coded video bars come from?" you may ask...


 Well I just had to show this thing off, and it's a flash program I wrote just for that.  The way it works is: you type in the code number, 0-888 (but can do up to 65535) then press [GO] twice and voila!


I then set the flash player to full screen, making sure "show all" is ticked first, then use a screen capture program to grab it. That image is then used in my video arranging software so it flahes the top bar for 1 frame, goes blank on the second, then flashes the bottom bar for 1 frame. They can be anywhere on the screen, but never at the same time. I've shrunk then down quite small as well.

So have a go with this flash to see the bars. Press any key to do again!

 

 

 Here's a photo of the case...I tore apart an old TV rotor controller I built back in the 90's, broke my heart but this better!

The USB power seems to handle it fine, and it's a little ugly, but it'll be tough and durable. Now I just need to figure out how to mount it on the music keyboards. The wiring is all over the place, but between the old telephone keypad and the play/stop
buttons I tore out of a different telephone, it couldn't be helped. The game controller was flat enough to install under my board,
so the wires are really short. The yellow blob is the foot pedal socket. I'm using my old Rock-Band drum pedal for now.

 Using the unit is pretty simple, just type in a 3 digit code and press the # for enter. If you hit * instead, then it waits for a
pedal press before sending the code. This is useful for quick load after a song, but don't want lights/keyboards to change yet.
 To Make MIDI sequencer play, press white/green button. To pause press again, to stop, press white/red button. The normal
operation of the pedal is Play/Pause. Two bright Leds will show any number key has been pressed as LED 1, LED2, Both.
These white LED's are bright enough to light the key pad. If a wrong # key was entered, just wait 4 seconds and it'll reset!

VIDEO


 Here's a youtube video of it really working! Feb.10th,2013

  Well, that's about it! I hope you could understand a least some of this, and to anyone that wants to build this thing, it'll be a lot clearer with proper schematics.
It's all that I'd hoped for, and I'm having so much fun with it. I've already added codes for most of my songs, but also added some to open up Sony Acid and add a recording track and start recording the 2 main channels off the mixer. Perfect for jamming so I don't have to stop and monkey with the PC for 2 minutes. I have some other ideas too. PC's should come with this!
  If you don't want to build stuff like this, but still like macros the make life in 'puter world so much easier and save tons of time, check out AutoHotKey, it's free & easy to use!

 I hope you enjoyed the article! Cheers!

                            Sandrine Sims *

 

 

Disclaimer: This is not an instructional page to build or manufacture the above project, nor are there any guarantees of accuracy herein.
This page is an "of interest" discussion, and the project is intended for my own personal use.
If you have any questions, or wish to pursue this project, you may contact me (Sandra) at fresh(at)freshnelly.com