About Mikazo Tech Blog

My name is Mike, and this blog is my way of saving people time. If someone has a specific problem that I've encountered before, hopefully these posts will save them the extraneous Googling I had to go through to solve the same problem. Also, when I have something to say about technology today, I will post my thoughts here. If this blog has helped you out, even a little bit, vote on the poll below, or let me know by sending me an email. I'm always open to exchanging links with other blogs or websites that share a similar interest.

Tuesday, August 26, 2008

D-Link KVM-121 Woes

I just recently purchased a D-Link KVM-121 [dlink.com] model KVM switch. It supports audio switching, along with keyboard, video and mouse (using PS/2 and VGA ports). No audio adapters or jacks were necessary and everything plugged in easily. That's where the positive features end.

I suppose it would be best to explain my hardware setup before attempting to explain the problems I ran into. My setup would be much more easily explained in image form, so here it is. The dual monitors aren't really positioned the way they are in the diagram, but I'm sure you'll figure it out.



So after I had connected all the cables, I powered up my PC. The second monitor (the one I am switching with) was blurrier than the first monitor (plugged directly into the PC). According to the manual, this can be caused by improper cable setup (which I checked), cables that are too long (I doubt this was the case), and too high of a resolution. I was running both monitors at 1440x900. According to the product data sheet from the D-Link website, the switch supports resolutions up to 2048x1536.

The mouse decided to start going crazy once I started using it. Apparently this can be caused by PS/2 mouses with extra features such as a scroll wheel, and that generic PS/2 drivers should be enabled in the BIOS. I'm not willing to live without a scroll wheel. Not only did it have a scroll wheel, it was a USB laser mouse plugged into a USB-to-PS/2 adapter, so I'm not really surprised that it had problems. I did try a vanilla 3-button PS/2 trackball mouse, and it performed nearly perfect. Left click didn't work sometimes, but that could be the mouse itself. It's pretty old.

I powered up my Xbox 360 connected via VGA cable [xbox.com]. I then pressed the switch button on the KVM. The Xbox Dashboard flashed on screen for a moment, then disappeared, and the KVM switched back to my Linux desktop, notifying me with a beep both times. I thought maybe the resolution was set too high on the 360, even though the KVM claims to support up to 2048x1536. I connected the 360 directly to my monitor, lowered the resolution to 640x480, as low as it gets, and tried switching. Same problem.

There are several additional switching modes, accessible only by keyboard, so I decided to try those. The manual tells me to press the Scroll Lock Key twice, then a specific key for each mode. I'm looking and looking and eventually realize that my keyboard has no Scroll Lock Key. I looked into it and apparently most modern keyboards are being made without Scroll Lock [wikipedia.org]. I'm not surprised, when's the last time anyone used the scroll lock key? I realize that D-Link was trying to choose a key that was not commonly used in everyday keyboarding, as Ctrl, Alt, Shift, etc. are already taken. But instead of choosing a key that's going out of style, could they not have used a function key or something similar? I realize now as I type this that the odds of any PS/2 keyboard having a scroll lock key are actually pretty good, if they use the PS/2 connection.

After all these problems, I decided to try their tech support line. I got the phone number from a slip of paper from the package, waited on hold for ten minutes, only to find I had called the United States number. I was given the number for Canada, and waited another five minutes on hold. I explained my setup, and was informed that the model supports only Windows 2000, Windows XP, and Windows Vista. No other operating systems are supported. I may be wrong, but shouldn't the operating system not matter? The switch receives audio and video signals from either PC, then relays them to the hardware that is plugged in. As far as I can see, it has no reason not to work, regardless what operating system is running. I will look into it further though.

All in all, I had my hopes up for this setup. I can see why it's a little out of the ordinary compared to two plain old Windows PCs. I just wanted to be able to watch DVDs and play games on my Xbox, or switch to a dual-screen Linux setup for programming purposes. Hopefully I will be able to return or exchange the product for something better.

EDIT: I tried plugging the Xbox VGA cable into the switch just by itself, with no other PC. The switch started clicking and the power LED barely lit up. This leads me to believe that the Xbox VGA cable does not supply enough power for the switch through the VGA port. I think this means that I will have to find a KVM switch with its own power supply for this setup to work properly.

EDIT: For those of you wanting more information on a KVM that works in this configuration, I have a newer blog post about it.

Sunday, August 24, 2008

Uncompleted Homemade Anemometer

This is one of my summer projects that never fully reached completion. I intended to build a weather station myself, starting with an anemometer (to measure wind speed) and a thermometer. I obtained a temperature chip, which I intended to mount to a heat sink for an accrate reading. It utilizes serial communication. That portion of the station was never even started. However, I did build a decent setup for the anemometer.

The anemometer is composed of an old bike wheel with no tire, four stainless steel bowls from the dollar store (two for a dollar), and some pieces of aluminum bar. Combined with bolts and screws, I mounted the contraption to my fence outside. Unfortunately, it is mostly shielded from the wind there, and I have no other place to mount it.

In its current state, it cannot measure wind speed. The uncompleted portion is the bike computer, which normally measures the speed of your bike by using a magnet and a reed switch. I have such a device, but never implemented it due to time constraints (as the summer is nearing to a close). I intended to mount the magnet and sensor underneath the bike wheel, and send the pulses to a parallel port and C program on my computer. The computer could then use the radius at which the magnet was mounted to calculate wind speed.

It was a good concept in my opinion, but it was never completed. Perhaps I will have the time to finish it some day, and see if my idea works.



Saturday, August 23, 2008

Thoughts On Geometry Wars: Retro Evolved

Geometry Wars: Retro Evolved is definitely my favourite Xbox Live Arcade game, and one of my favourite games of all time. It's addictive and never gives you the same game twice. I've unlocked all the achievements, but still play it from time to time. I was playing it the other day and this got me thinking. For the purposes of this post, I will assume you have played Geometry Wars: Retro Evolved, as I will make reference to several game elements.

Since I'm always looking for challenges to try and program or code to expand my mind and knowledge of programming concepts, I started to wonder what it would be like to write an AI player for Geometry Wars. I wrote down some thoughts on how I behave in the game, and how I might try to emulate that behaviour with code.

Decision-making for the AI would depend on a number of variables, all of which are constantly changing. There are several simple and obvious variables to consider. The game consists of a two-dimensional playing field, spawning objects that fly at the player. The player may move freely in any direction and fire in any direction, the two being independent of each other. There would exist an X and Y coordinate for each object, as well as a velocity. Some of the more complicated variables would have to be calculated, such as distance to nearest enemy, distance to nearest cluster of enemies, amount of available free space adjacent to the player, enemy spawn rate, number of black holes (and every other type of object) present, and so on. Some complex mathematics could be involved in calculating these variables. Of course, a human player can distinguish all of these things, simply by looking at the screen and analyzing the situation.

Different tactics are applied when facing each different type of enemy. Blue diamonds simply travel in a straight line toward the player and do not try to evade fire, making them relatively simple to defeat. Green boxes follow the player, and dash side to side to avoid fire. These enemies can be defeated by alternating fire on either side of the green box, effectively narrowing in until the box is trapped between lines of fire and is destroyed. Purple boxes, which split into two smaller purple boxes once hit, can also be defeated in a similar manner, by circling around the enemy and destroying its remnants after the first hit. Other types of enemies such as magnets, purple jacks and worms each have their own attack strategy, which I won't go into. These different strategies would necessitate several different attack patterns and targeting methods to be written in code, and the AI would have to successfully decide when to use each strategy. Each attack pattern would make use of positional data and tolerance data. For example, when facing one enemy of one type, the line of fire is relatively confined. When facing a large group of enemies of one type, the same attack pattern is used, only with a larger tolerance or range of fire. When multiple types are present, the AI would either rotate between attack patterns, or use some combination of two or more patterns. Special situations exist, for example when a large number of enemies spawn at the same moment in a circle around the player. Before choosing an attack pattern, a player generally takes other actions first, such as punching a hole through the ring of enemies, then encircling the cluster and implementing an attack pattern. This is why determining the location of clusters of enemies is important. Attack pattern choice can be determined by types of enemies present, and the quantity of each type.

A successful AI would have to have the ability to determine the threat level of a situation and which enemies should have target priority. For example, purple windmill enemies would have a low targeting priority, as they meander aimlessly about the playing field, whereas the blue balls that are emitted from black holes that become too full would be of a higher priority, as they can travel faster than the player. Even higher still in priority would be enemies at a very small distance from the player that are in the direct path of motion of the player. At a high level of difficulty and number of enemies, one usually travels in one direction, while firing in that same direction, effectively clearing a path in which to travel. Threat assessment might be accomplished through analyzing the position, distance and speed of each enemy, and which targets take priority.

Different strategies of play will depend on the current difficulty level, as well as game objectives. A player may be trying to unlock an achievement, playing to gain the most points, lives, or bombs. At the beginning difficulty, a player has little trouble dispatching enemies, as they are few and far between. At a medium difficulty later in the game, a player might seek and destroy black holes, or leave them to grow, then destroy them for a higher point value. At high difficulty, a player generally plays to survive, plowing a path, leaving black holes to partially absorb enemy spawns. These situations might be recognized by the amount of time elapsed, the spawn rates of enemies, and so on.

There are many things to consider when programming a game AI (something I have never done), and I imagine it would take a lot of math and processing power to create an effective AI. I see this discussion as an interesting programming challenge, and only wish I had thought of it at the beginning of this summer, rather than the end, as I am returning to school and most likely won't have time to pursue what I have discussed. In any case, I will look into it at some point and hope to learn from the experience.

Friday, August 22, 2008

TwinView and Linux Mint

Referring to my older post on TwinView, the very same steps will successfully set up TwinView under Linux Mint 5. I imagine this goes for any distribution using the nvidia-glx drivers, or maybe even systems that don't. Just thought I would write and confirm that TwinView and Linux Mint are good friends.

Thursday, August 21, 2008

RCA to Mini-phone/Headphone Adapter

I have just recently purchased the Xbox 360 VGA cable, allowing me to use one of my computer monitors for gaming instead of a TV. This is good, because I didn't want to have to bring my TV with me when I move back to university. Before opening the package, I noticed that the audio connectors are RCA connectors, just like the original Xbox 360 A/V cable. Immediately, I thought of my speakers, which use the standard mini-phone/headphone jack. I had forgotten that the VGA cable comes packaged with an adapter, though the headphone end is male, meaning I would need a female-female adapter on top of that. Before finding this adapter though, I constructed a little potting box that converts from RCA jacks to a mini-phone jack for speakers.

I used spare parts from my Dad's store of junk in the basement, and soldered the connections inside a plastic box. The RCA jacks have two pins, one for common, one for signal. I used white and red wires inside the box for left and right signals, respectively. Black was used for common. I used a 6.3 mm TRS phone jack for output, with an adapter plugin that converts to the 3.5 mm headphone jack. The TRS phone jack has four pins, three for the above mentioned purposes, and a fourth that operates a switch that will disconnect main speakers and re-route audio to headphones when they are plugged in. This pin was not needed for my purposes.

The first actual test run revealed that continuity testing wasn't done properly, and only the left audio channel was working. Of course, this was after the lid was epoxy-ed onto the box. I had to re-open the box and re-do the connections, and finally got it working. Pictures are below. Build your own if you like, the pieces aren't all that hard to find.



Monday, August 11, 2008

Link Exchange

To anyone who is visiting and has a blog or website of their own regarding technology, Linux, etc. I am open to exchanging links. My blog isn't really something you would tune in to every day, so most of my traffic would come from someone Googling for a solution to their problem, or some similar situation. For that reason, I'm trying to improve my page rank and will most likely exchange links with anyone that contacts me with their own technology blog or website. You can contact me at the email address shown to the right.

Sunday, August 10, 2008

D-Link DWA-643 ExpressCard and MadWifi, Aircrack-ng

I have just purchased a D-Link DWA-643 Xtreme N Wireless Notebook ExpressCard, which uses the Atheros AR5418 chipset. It was one of very few ExpressCard wireless cards that support monitor mode and packet injection.

After some work, I successfully installed the card on Linux Mint 5, with the madwifi-trunk 02 Aug 2008 driver. I also installed aircrack-ng-1.0-rc for card testing purposes. The card did not work with madwifi-0.9.4 drivers. The kernel version I am running is 2.6.24-16-generic.

Once the installation instructions from the MadWifi website were followed, I was able to complete a simple WEP crack tutorial from the Aircrack-ng website on my own home wireless router. Master mode has not been tested as of yet.

I have had intermittent problems with the card not being recognized, by Linux or Windows XP. After several reboots, the card has apparently started working again. The internal Intel wireless on my laptop does not play well with the new wireless card, so I must run one while the other is disabled or unplugged. The activity LED on the D-Link card does not blink under Linux, but does blink under Windows XP. The card protrudes 3.5 cm from my particular laptop when it is fully inserted.

If you are looking to purchase an ExpressCard wireless card capable of monitor mode and packet injection, I would recommend this card, though I haven't used it extensively. It is listed under TuxMobil's ExpressCard Hardware Compatibility List.

EDIT: To get the madwifi-trunk drivers I used type the following command at the terminal:

svn co -r3837 http://svn.madwifi-project.org/madwifi/trunk

Saturday, August 9, 2008

Linux Mint 5 Elyssa and ntfsresize Adventures

I've recently purchased a new wireless card for my laptop with the intention of using it in combination with Linux to learn more about wireless technologies. I currently had Windows XP on my laptop, and needed to resize the XP partition to make room for Linux. In the past I have used Windows Vista's partition resizing tool, and assumed there would be one in XP, though I was wrong. I had never tried to resize partitions from XP, so I did not know if there was such a tool.

In the end, I used the Live CD of the distro I intended to install (Linux Mint 5 Elyssa) and its partitioning tools. I would like to say, I've enjoyed my Linux Mint experience so far. Everything worked out-of-the-box, including my laptop's internal wireless, audio, Flash, and so on.

I began my partitioning adevntures with Gparted, only to find it informing me of bad sectors on my hard drive, and there was nothing it could do. I did some more research and found a command-line utility called ntfsresize. I issued the following commands to see what I would be able to do with my drive.

sudo umount /dev/sda5
sudo ntfsresize -v -i -b /dev/sda5

-v and -i were for verbose and information, -b to ignore the bad sectors. I proceeded to do a test run of resizing the file system with this:

sudo ntfsresize -n -b -s 175705M /dev/sda5

-n was for no-write, -b once again for bad sectors, -s to indicate the size of the new file system. The test run was successful, so I ran the same command again without the -n flag. The resize reported successful, then recommended I delete and re-create the NTFS partition with a partitioning tool. The new partition should be made smaller (in my case) than the original size, but not smaller than the new file system size. I used QTParted to accomplish this (which I had to install). When trying to boot back into my new NTFS partition, Windows reports a missing or corrupted DLL. I used the Windows XP disc and repair console and determined that my new partition had zero files on it.

After this, I spent much time fooling around with QTParted and another tool called TestDisk to try and recover my NTFS partition. In the end, I decided the rescue attempt had become futile and I am now reformatting my laptop as I type this. I did not make a backup copy of my original partition table, though I should have. I did back up my essential data, but there were some other things I wanted to keep on there, like episodes of a hard-to-find TV show.

Something completely unrelated to be said for torrent downloads and seeding: Seed torrents that you've finished, especially rare ones! It pays off if you ever decide to try and resize your NTFS partition and end up losing everything and are trying to get your rare torrent back!

Donate to Mikazo Tech Blog