My DIY Dance Dance Revolution Hardpad

IMGP0429Something like ten years or so ago, I built my own hardpad for use on Dance Dance Revolution and Stepmania.  Most of the pads that are easily bought are “soft pads”.  These vary in quality, I have a couple of pads that are pretty light weight and plastic I used ages ago.  These pads tend to get damaged pretty easily, especially when wearing shoes, and slide all over the place when playing.  When i used mine in college I actually taped it to the underside of the rug in the dorm and taped out the grid of squares on the surface, so I could play using my shoes.  I’m sure the people living below me loooove that.  Probably as much as I loved the people above me who played dice constantly.   Some more pricey are made of a thicker though still pliable rubbery material.  These mats slide around less due to the grippy nature of the material, but they can get worn out and damaged by the rough beating of shoes.

The ideal pad is a hard pad.  These can run hundreds of dollars on-line.  They also tend to be large and bulky and heavy.  Shortly after i had finished in college I decided to employ me newly acquired Engineering design skills to build my own Hard Pad.  The electronics part was easy.  I went to the local used game store and asked for the cheapest used PS2 controller they had in stock.  The guy behind the counter actually asked if I was planning to build a DDR pad with it, which was funny since I was.

The pad itself was a bit trickier.  I’d studied several design ideas on-line that others has built.  I wanted something that was less bulky than most of the pads I’d seen.  I also wanted to keep costs down somewhat, which meant using a little material as I could and not having to invest in a bunch of expensive triggers to wire into everything.  The trigger is the key component of course, since it registers the steps when playing.  The dead squares are all just plywood covered in sheet metal.

The sheet metal is also what I ended up using to build the triggers for the step squares.  When you press a key on a video game controller, all that happens is that an electrically conductive pad is flattened and shorts the connection between two copper pads on a PCB board.  When the electrical short is made,  current can flow which causes some chip somewhere to register the button press.  For my step pads, I simply enlarged this process by attaching plates of sheet metal tot he base and to the bottom of each step pad.  To give the pads some cushion and bounce, I placed strips of weather stripping bought at the hardware store between the base and the pad.  Stepping on the pad creates more than enough weight to overpower the weather stripping causing the two sheet metal pads to connect and trigger, stepping off allows the weather stripping to flex back up pushing the pad back to a neutral, unconnected position. I took some CAT 5 cable and soldered it to the sheet metal contacts and the appropriate parts inside the PS2 controller to replicate the button press action inside the controller.

Everything else was cutting wood, attaching corner brackets and attaching sheet metal.   Here are some old photos of the process.

The general construction was sound, but it had a few issues that I never really got around to fixing until more recently.

In the original design, I soldered the connections for the step pads tot he controller’s D-pad.  Mostly because the solder points were larger and easier to solder to.  This had some unintended side effects that made the game unplayable at any higher difficulty level.  By design, the controller never expects opposite D-Pad buttons to be depressed at the same time.  That is, it doesn’t expect the player to press left and right at once, the D-Pad generally controls movement in most games, why would you need to press opposite ways at once.  Dance Dance Revolution has “jumps” in more difficult stages, these are sequences where two arrows have to be matched at the same time, as in “jumped on”.  Since the D-pad doesn’t register left+right or up+down, these jumps would never register and were always considered a miss.  Kind of game play breaking in the case of DDR.

I also wanted to add a box to the set up, to replicate the buttons on the front of a real DDR machine used to select songs and options.  Not something important, but it would add to the effect, and if I ever got really ambitious, I could build a whole cabinet someday.

The other major issue, when I built the original design, I didn’t really do any real management of the wires between the controller and the pad.  They kind of strung around on the sides, they were all too long, and the controller itself was permanently attached to the pad, making moving and storing tricky.  I wanted to make the controller bits, detachable.

I’ve since solved all of these problems with some improvements, all somewhat related.  First problem was the triggers not working for jumps.  This was simple but tedious.  I needed to reqire the buttons from the D-Pad to the face buttons (Triangle, Circle, Square, X).  These work just fine when pressed together, lots of games have combinations where you have to press several buttons at once.

Please Parton my Shoddy Soldering

During this process, I also pitched the controller shaped housing and stuffed everything in a generic electrical project box.  I soldered the 4 shoulder buttons to 4 buttons attached to the box lid, to be used to interfacing with the menus.  Problem 2 solved, everything is in a nice box.

IMGP0430

The last bit was to make the controller easily detachable.  There are 4 pads, each with 2 wires, for a total of 8 wires going from the controller to the pad itself.  I was already using CAT-5 cable for the wire, it had 8 wires in it, so I attached an CAT5 end on the controller piece and a CAT5 receptacle to the dance pad.  Now the two were easily separable and securely attachable.

The ultimate test of course, does it all work?

stepmaniaresults

I’ve run several sets of tracks using the new set up and it certainly does work.  My DDR skill needs a lot of improvement to get back up where it was at my peak, but the pad itself works just fine.  Which is sort of the point, because it really is a fun way to get a pretty good workout in a short period of time.

 

 

Saving a Slice of Raspberry Pi

Raspberry_Pi_LogoSo of all the things on the network, the DNS and DHCP server are pretty important.  Especially because my experience has been the router the ISP provided is kind of mediocre at doing the DHCP job.  So when the Raspberry Pi I’ve tasked with doing the work started flaking out I was a little worried.

After some investigation, it seems the SD card had lost a sector, or whatever the equivalent thing is to a sector on flash memory.  These things do have a bit of a limited life and this particular one was a small 4GB card that was a little older.  Four gigabytes isn’t even above the recommended size for the Pi, but I knew I wasn’t planning on putting a lot on it.  Problems arose when it started dying though.  There actually isn’t much using the PiHole, some of the things my wife does with coupons and such I suspect might get blocked and I don’t want the headache of dealing with trying to manually whitelist things and complaints that this and that isn’t working.  The DHCP is another issue.  When the DHCP server disappears, it seems anything using it simply can’t connect to the internet.  I have a lot of static assignments but there’s quite a few assigned by the server.

I may have to look into setting up a secondary backup server, maybe on one of the CHIPs even.

I started out simply re-imaged Raspbian onto a fresh card and setting things up again following the tutorial I had posted.  Everything went pretty smoothly except that I was now out my old config file and would have to go through the hassle of recreating all of the changes I’d made adding and removing devices.

So I went with a new strategy, why not just clone the old card to a new one.  Unfortunately, Win32 Disk Imager, the recommended tool for imaging these SD cards, couldn’t read the whole card, it got hung up and failed partway in.  So I turned to my laptop and Linux hoping for something more robust, which I found in ‘dd’.  It probably stands for “Disk Duplicator”, but don’t quote me on that.

I started running dd to make an image of the old card to put onto a new card, unfortunately, it also failed, like Win32DiskImager.

Back to Square One…

After some searching, I found this post suggesting something called ddrescue.  Most of it wasn’t anything I needed aside from the following.

sudo apt-get install gddrescue
sudo ddrescue -v /dev/sdb /dev/sdc

A few things of note.  My laptop, like many, has a build in SD slot, I added a second using my USB card reader.  I opened the disk manager to get the path to each card, /dev/sdb and/dev/sdc.

This command also hit an error at the same point as both Win32DiskImager and the “dd” command, but it pushed on through, recovering everything else.  At this point it’s a matter of hoping that one bad spot wasn’t int he middle of an important file.

Internet of Things, Internet of Stuff

I wanted to take some time to touch on my every changing collection of Internet of Things style devices.  Honestly, it’s kind of iffy what constitutes an “IOT” device, but for the most part I’m sticking with “cheap” and “non traditional computing devices”.

The chief player among these are of course…

The Raspberry Pi

I’m up to 5 Raspberry Pis, a B+, two B2s, one B3, and one Pi Zero.  I have already discuss these quite a bit so they don’t need a ton of additional discussion.  The B+ still operates my DNS/DHCP server, one B2 still runs my IRC stuff, one B2 still runs a Minecraft server.  I actually have not yet come up with a good use for the B3 and Zero yet.  I’ve started messing with Windows 10 IOT on the B3 a bit and there is a Retro Gaming GameBoy project using the Pi Zero floating around on Reddit I may have a go at.

Arduino

If Raspberry Pi is the king of IOT, then Arduino is definitely the Queen. I’ve kind of dropped out of doing Arduino projects a bit and dismantled most of the ones I had built.  Other than adding a WiFi enabled board to my set (by mistake, I thought I was ordering a Shield not a board), not much has changed on my Arduino library.

i did try to build a little digital hourglass project I found online but it’s not going super great.  Stay Tuned for More

Next Thing’s CHIP

CHIP is still one of the most annoying and impossible to search for terms online.  I’m up to three CHIPs now, I’ve received my second Kickstarter CHIP and my VGA DIP.  I’ve still been having some bad luck getting my CHIPs to do much of anything.  I tried to build an Amazon Alexa with no luck in the end after a ton of troubleshooting.  I’ve been trying to get Synergy combined and running on one to let it work with my multi monitor set up.

Now that the Kickstarter campaign is more or less finished and the CHIP is reaching a wider audience I’m hoping it starts to get more support online.

Remix Mini

Another kickstarter product, the Remix Mini is a small computer that runs Android as a desktop.  It works pretty well, I mostly used it last year while traveling for work in the Hotel Room.  I have not touched it since, for one simple, stupid reason.  The HDMI output doesn’t support any of my HDMI to DVI cables.  I can’t plug it into a regular monitor, so I just have… not used it.  I could plug it into a TV but it’s effectively a simple desktop machine and doesn’t work as well for a “lean back” experience.  Maybe if I had a wireless KB and Mouse it would work better.

It’s a shame to because I was really looking forward to this one and it runs a lot of my apps surprisingly well.

ChromeCast

I picked up a Chromecast last year on Black Friday. I used it a bit but in the end, it’s ended up in a drawer.  It’s just too much of a hassle and it caused too many problems.  First off, the hassle.  My crappy old Nexus 7 is partially to blame here but in general the lack of any built in interface is just a flat out pain.  Having to dig out my tablet to use it is a pain.

Worse yet, it was causing problems with the Wireless in the house.  I disabled guest mode which eliminated the problem (eliminating the interference) but it’s still kind of lame that it was an issue to start with.

Kindle Fire Stick

A more recent addition to the network, I added a Kindle Fire Stick.  This is effectively the same as the Chromecast, without the hassle and bull shit of needing a separate device to use it.  It’s not completely without it’s issues but it works pretty well.  The main problem I’ve had is that it loses signal, a lot.  It doesn’t work as all directly hooked to my HDMI switch and at this point it’s cabled out and laying out on the floor behind everything to get it away from any interference.

It runs Amazon videos, which I don’t really use, it runs Netflix, which is used a lot.  It also works well with the fact that I buy my MP3s primarily through Amazon.  Another nice bonus, I use Amazon Cloud to backup all of my Photos, so they are all available through the Fire Stick now to view on the TV.

SteamBox

 Another newer addition is the SteamBox.  Specifically, the cheap streaming box.  It works pretty nicely.  I haven’t had a chance to really put it through the loops yet but my first tests worked well.  I’ll probably do a more in depth write up at some point on it.

NextThing CHIP and Raspberry Pi Zero

Raspberry Pi Zero and Next Thing's CHIPI’ve already briefly discussed my NextThing CHIP computers before. A few weeks ago I was purchasing a Raspberry Pi 3 and found that the store had Pi Zeros in stock as well, so I tossed one on because, hey, $5, and they are apparently hard to find.

These two little devices are pretty similar, but at the same time so different.

Both are small computers, not just microcontrollers like an Arduino, but little Linux machines. Both have GPIO pins, both can be used as a regular “desktop” if you wanted, both cost less than $10… Mostly…

Raspberry Pi ZeroThe cost is where things get tricky, especially for the Raspberry Pi Zero. Upfront, the Pi Zero is only $5, which looks great on paper, and it’s still pretty cheap. That five dollars gets you a small flat circuit board with a few low profile ports on it. Chances are you’ll need a power supply, if you want to be able to configure it at all you’ll also need a way to plug a standard USB hub for keyboard and mouse into a micro USB port. The display out is a mini HDMI port, which you’ll likely also need an adaptor for. The Pi Zero also doesn’t have any sort of case on it. All of this is stuff that you may or may not need, you might have on hand, or, if you’re programming many Zeros, you can reuse the adapters and parts on all of the Pi Zeros you want, once configured.

The point is, after picking up even some cheap accessories, you’re probably looking at closer to $15 for a Pi Zero. Still cheap, just not quite AS cheap.

Next Thing CHIPThe CHIP on the other hand, is $9. It has built in WiFi and Bluetooth, it comes with a little plastic case for the underside of the board, and it comes with an RCA adapter. The RCA isn’t ideal and an HDMI or VGA attachment are both coming (for $10-$15) but the RCA is usable for setting up WiFi easily for SSH or VNC access. It even has built in storage. For $9, you’re pretty much up and running right out of the box. The Pi Zero is actually kind of useless all on it’s lonesome.

That doesn’t necessarily mean the CHIP is better.

Both The Raspberry Pi Zero and Next Thing’s CHIP run an arm based version of Debian (by default, but this could be changed), thus both have a lot of common in terms of what sorts of software can be used. The CHIP however seriously lacks the Raspberry Pi’s strong community. I’ve not been able to find any decent resources for how to even use the GPIO pins, for example. I had hoped to use one of my CHIPs for a project in the garage but I’ve hit some roadblocks.

chipdesktopI’ve actually had lots of roadblocks with the CHIP. Initially they were unstable, requiring a firmware update. I’ve had many strange problems getting software packages to work properly, even when following tutorials put out by others. The closest I’ve come to finishing a project is making a homemade Alexa clone. Even after buying identical parts (Mic and Button really), after trying many fixes and even wiping the thing out and starting from scratch, I still get errors with the Audio about “Period too large”.

Everything being built in is really convenient though. I honestly haven’t come up with any ideas yet for what to do with my Pi Zero. It ends up with some goofy dongles all over it to make it functional and I have 4 full sized Raspberry Pis at my disposal for other projects. I’ve seen an interesting Game Boy emulator build using the Zero I will probably try but so far, it’s pretty much just been running quietly on my workspace counter.

Personally, I think that ultimately it comes down to there is a point where these things become too cheap or small to be useful, at least for my needs. The sorts of projects a smaller board like this may be useful for feel like they would be better suited for an Arduino. Most of the projects I use my Pis for amount to “Hardware VMs”. Single task servers that can easily be repurposed or swapped out (using SD cards).

 

Raspberry Pi Project 02 – Ad Blocking DNS and DHCP

Raspberry_Pi_LogoI’ve been at a bit of a loss for a while on what to do with my RaspberryPi B+.  I have a B+ and two RaspberryPi B 2s.  The B2s are so much more useful and powerful than the B+ that the poor B+ has kind of been tossed to the wayside.  I was using it as a server for ZNC, an IRC Bouncer.  When I set up my milti-monitor set up, I tried running X-Chat on the B+ with ZNC but the lag was too much.  I’m not sure if the load was from XChat or from ZNC or from Synergy, but the short of it is, the B+ wasn’t useful to my array of machines and needed a headless activity assigned to it.

Sure, I could let it continue to run ZNC, but dedicating two Pis to IRC seems like overkill, so I moved ZNC to the B2 that I run Xchat on and freed the B+ for whatever I wanted.

Pi-Hole for DNS

I started out by setting up Pi-Hole.  It has a fancy name and is simple to install, but at the core, Pi-Hole is just a DNS server that filters sites based on some predefined public lists.  Specifically, it filters ads.  There is a whole debate to be made on the pluses and minuses of ad filtering, but it is what it is and I’m not getting into that debate here.  Pi-Hole has a white list anyway, for “good ads”.  Mostly, it’s a way to filter on mobile, where it’s not easy to install an ad blocker.

Installing Pi-Hole is as simple as entering the following into the command line over SSH or even on the RaspberryPi itself:

sudo curl -L install.pi-hole.net | bash

Though you will also need to set up the Pi with a static IP and then later point your computer’s DNS records to the IP of the Pi.

On a bit of a side note, DNS is Domain Name Server.  The easy analogy is that it is a phone book to the Internet.  Servers where websites live all have IP addresses assigned in various ways, but in order to keep things simple for humans, these servers get friendly names, like Microsoft.com or Facebook.com.  The DNS is where your computer looks up “Facebook.com” to find out what IP address it’s located at.  In this case, ads come from specific servers and providers, often not related to the core domain.  So Website.com may serve ads from advertiser.org.  With Pi-Hole, your computer looks up both domains when you connect to Website.com, but the RaspberryPi Pi-Hole simply replies “I don’t know where Advertiser.org is located”.  You computer then fetches what it can from Website.com, but displays nothing from Advertiser.org.

ISC-DHCP for DHCP

Sort of tangentially related, I recently changed ISPs.  I went from a 3Mbps DSL to 50Mbps Cable modem.  I keep my home network crazy organized since there are a ton of devices on it.  For every person in my house there are something like 4 devices, and this doesn’t count game consoles, media devices, or my own little IOT devices.  On the old modem, I set up MAC assignments on the router so that wireless devices like my phone, where I can’t assign a static IP, get assigned a specific IP.  I went through and set all of this up on the new modem, but none of the assignments seem to have taken.  I’m not entirely sure why, I have theories, but I’ve instead decided to use this as an excuse to re-purpose my B+ and to learn more about managing a DHCP server.

So what is DHCP.  DHCP stands for Dynamic Host control Protocol.  I mentioned earlier that DNS was the way to connect the firstly domain name to an unfriendly IP address.  DHCP assigns those IP addresses.  Some static devices like routers or desktop computers that never go anywhere can pick and self assign an IP but things like phone that move between networks need to be given a temporary IP address as they come and go.  DHCP handles this.  Every device on a network has a unique IP address, though small networks like the one in your home, all tend to share IP ranges since to the outside world they appear to be one node/thing/device.  DHCP can be used to give out reserved “static like” IPs to these roaming devices though based on the device’s MAC Address.  A MAC Address is a device unique identifier.  For example, when the DHCP server or router sees a specific MAC, it can say “I know you, you get IP 192.168.1.50”.  When a strange device shows up, it will simply say “Here, this time you are 192.168.1.103, which is the next free IP in my pool of IPs”.

The set up for DHCP is a bit more involved than for Pi-Hole.  There is a detailed guide below but I’ll run through the cliff notes version.  There is a lot more that can be done but I’m not going to get super detailed here.  This is essentially for a simple home network with one subnet.  The first steps are to set up and configure the server, it will likely error out in the middle, just keep going with it.

sudo apt-get install isc-dhcp-server

sudo nano /etc/dhcp/dhcpd.conf

This is where it gets a little trickier.  You will need to edit the options in the config file.

option domain-name “your_domain”
option domain-name-servers

Your Domain can be more or less anything really, it’s often just “Workgroup” by default in Windows.  It should be all one word though.  Domain Name Servers are specific however.  If you are using Pi-Hole, set the IP of the Pi running Pi-Hole into this list.  You can add additional DNS servers with a comma between each one, some suggestions, 8.8.8.8, and 8.8.4.4 are Google’s DNS servers.  OpenDNS uses 208.67.222.222 and 208.67.20.220.  It’s a good idea to have more than one in case there are issues.

The only other thing you NEED to set is the ip information and range found under

subnet 10.0.0.0 netmask 255.255.255.0
{ range  10.0.0.1 10.0.0.200;
option routers 10.0.0.254;
}

You will need to replace the IP information in this block.  the subnet should be the first three octets of your network followed by a .0.  The most common ones in a home network are 192.168.1.0, 192.168.0.0, and 10.110.1.0.  The range is the range of IPs to give out.  If you are going to use static IPs, i would recommend setting this range beyond your static IP ranges.  For example, I have a spreadsheet blocking off reservations through 192.168.1.100, I added some extra for my router to serve as a backup DHCP server and set the range on the RaspberryPi as 192.168.1.175 192.168.1.250.  This means, when a device connects, it will be assigned an IP starting at the next available at .175.

The final option is routers, chances are really good that you have only one, and chances are the IP ends in .1 or .254.  This will assign the router IP so that devices know how to get out to the Internet.

If you want to ensure your Pi DHCP server is assigning IPs over anything else on the network (ie your router) you will need to find the line that reads “If this DHCP is the official DHCP server…” and uncomment the line “authoritative”.

Finally at the bottom, there are blocks to assign static IPs using a format like:

host MACHINENAME
{
hardware ethernet MACADDRESS;
fixed-address FIXED_IP_YOU_WANT_TO_ASSIGN;
}

An easy way, if you are running Windows, to find out MAC addresses of devices is to run Netscan.  This will give you a list of everything connected to your home network.  There are a few ways to decipher which IP/MAC is which.  Some will have the MAC printed on them, often near the network port.  In the case of phones or tablets, it’s simplest to simply disable the WiFi or turn them of and rescan to see which disappears.  Some may show up with names you may recognize.  You can also sometimes search for the first 3 sets of numbers (IE 45:3b:a3) which is manufacturer specific to decipher that “That’s a Sony device, the only Sony thing I own is the Blu Ray player”.

Setting reserve assignments is entirely optional.  The main purpose is to better organize your home network.  If you only have a half dozen devices, it really probably isn’t necessary at all.

Once you are done editing, CTRL+O (for Output) to save the file, and CTRL+X to close it. If you get an error that you can’t write the file then you forgot to do a”sudo” and you will need to do it all over again.

Wrap Up

Things are not quite finished yet.  You will need to start the DHCP server, since it error-ed out earlier.  You can do this using the following commands:

service isc-dhcpd-server stop
service isc-dhcpd-server start

HOWEVER, I still got an error when I did this.  A little searching and I found a similar issue and fix which I used.

sudo pico /etc/default/ifplugd

Then change this:

INTERFACES=”auto”
HOTPLUG_INTERFACES=”all”
ARGS=”-q -f -u0 -d10 -w -I”
SUSPEND_ACTION=”stop”

To match this:

INTERFACES=”eth0″
HOTPLUG_INTERFACES=”eth0″
ARGS=”-q -f -u0 -d10 -w -I”
SUSPEND_ACTION=”stop”

then reboot and after the reboot start the server with:

sudo reboot

service isc-dhcpd-server start

Everything should be working now.  You can run Netscan later and see if IPs are being assigned into the range you chose.  This may not happen immediately since IPs have a lease time and devices may hold on to the old IP for a bit.

Reference:

Pi-Hole

Configuring the Raspberry Pi as a DHCP Server under Raspbian Wheezy

How To : Use The Raspberry Pi As A Wireless Access Point/Router Part 3…B!