ATMEGA8 Programming

February 12, 2011

As many of you are already aware, I have been doing a fair amount of Arduino programming over the past year. The Arduino platform is built as a very rudimentary introduction to hobbyist electronics. Arduinos come with all of the necessary parts to begin building simple circuits with a very low learning curve. It is the perfect introduction into the world of electronics. Since the Arduino makes circuitry extremely easy and uses a gimped version of C as its programming language, many electronics enthusiasts are reluctant to give it any credit. In my case, the Arduino has proven very useful as an introduction to electronics and circuitry. I thank Limor Fried and Phillip Torre for all of their tutorials, chats, and other guidance from adafruit.com over the past year. Limor and Phillip are large promoters of the Arduino platform, but they too realize that is is only a stepping stone to the much larger world of electronics.

This past week, I have taken my second step into electronics and circuitry (I’m sure there are n steps). I have learned a great deal from the Arduino platform but I feel that I have learned all that I can from it due to its over-simplicity. In order to further my understanding of these integrated chips, I have moved on to programming the ATMEGA8. I am programming it through standard C with the avr-gcc suite. I have yet to delve into its assembly language, but that is something I would consider in the future. For now, programming in C suits me just fine.

Part of the reason I am working with the ATMEGA8 is for the Computer Science Club at Mansfield. I am the current president of the club and we are in desperate need of new members. All of our officers are graduating and moving on at the end of this semester, so it is vital that we find replacements. We are doing a number of things to generate interest in the club and programming ATMEGA8 chips is one of them. Mark Burger, the vice president, and I would like to build some games on these ATMEGA8 chips and sell them for a small profit. This would generate more interest in the club, as we are building our own games and it would also serve as a minor fundraiser for the club. An advantage of using ATMEGA8 chips is that they are vastly cheaper than buying Arduinos and programming them. We plan to use this to our advantage and be able to make an affordable game.

Right now, what I have is fairly basic. It has taken me about a solid week to figure everything out up to this part, including: programming with the programmer, writing code, interfacing a LCD (writing custom characters, turning the cursor on/off, turning advancement of the cursor on/off, etc.), doing register I/O on the ATMEGA8, and a few other minor details. What I have so far may not be impressive, but coming from an Arduino user, it certainly is.

My current project is writing a simple and lightweight LCD interface where the user can use the two buttons on the board to either advance the cursor (and add a space if needed) or cycle through the letters and symbols available in the CGRAM of the LCD screen. I use a standard HD44780 LCD, so this project should work for any similar LCD screen. Below is a picture of my project. Most of what is on the breadboard is residual from past projects and is not in use. All I use once it is programmed is two buttons, an LCD screen (with a contrast potentiometer), and the ATMEGA8.

In the future, I am looking into a number of games including a classic snake game, a maze game, a simplified nethack dungeon game, and a hangman game. If anyone has any good ideas for a game that can be played on a 20×4 character LCD screen (or 16×4), please write a comment or send an e-mail. I would be glad to hear from you.

As it stands my LCD code is posted on GitHub here. I also have a video imbedded below of my project in action. Click here to go to YouTube to view the video in HD.

1

Ice Tube Clock Kit Built!

January 23, 2011

For Christmas this year, I received one of Adafruit‘s Ice Tube Clock kits. It is a really neat project that is basically a PCB that Adafruit designed along with a bunch of parts (resistors, capacitors, etc.) that you must solder onto it in order to build the kit. It is a good introduction to building electronics, as it teaches better soldering skills and has a few hints as to what each part does. I took some extra time while making the kit to understand how voltage boosters work and a number of other parts. It is a great kit for an introduction to DIY electronics.

I started out a little overwhelmed. I laid all the parts on the table and just began reading the instructions. The instructions that Adafruit gives for this kit are very easy to follow and intuitive.

You can see below that I did a poor job of soldering the DC jack onto the PCB. I later went back and re-soldered those three joints.

The only issue I had during the build phase was that I forgot to solder in a resistor, which caused a little bit of chaos as I attempted to figure out my mistake. Luckily, no damage was done to the kit.

About 3-4 hours later, I finished the kit. The finished product turned out quite nicely.

I now have an extra edition to what I like to call my Linux Shrine!

Above, you will see:

Binary clock

Hard drive

Laptop running Gentoo Linux

Router running DD-WRT

Cable modem

Arduino (inactive, waiting for friend to return my breadboard)

Ice tube clock

Tux plushie

Knitted penguin from my sister

Thanks to Adafruit for the great kit and instructions! Thanks to my family for the great Christmas gift.

2

New Photos: Christmas 2010

December 24, 2010

I have uploaded some new photographs from Christmas 2010. You can view them by clicking on our tree below.

Merry Christmas everyone!

0

Mansfield University’s IT Doesn’t Respect Students

November 27, 2010

It all started with an issue in a computer lab in room 216 of Elliot Hall. Over the summer, the IT staff at Mansfield University decided it would be proper to disallow mansfield.edu access from this particular lab, citing “security” issues. This is all fine and dandy, since the people who use the lab are Computer Science majors and know the power of proxies. Proxies are less than ideal, but are necessary if we feel the need to do any school work in a state-funded computer lab. Never mind that the Computer Science Club cannot even access their own server from the lab. Never mind that we cannot check class cancellations, campus news, or even put in our work hours without memorizing an outside URL. Never mind that there are tutors, including me, who need to access the mansfield.edu site from inside of the lab. What kind of twisted rationale would allow the university to block its own network from a location inside of its campus?

Until now, we have dealt with it. We have realized that Mansfield thinking is backwards and the bureaucracy controls the university and there is nothing us lowly students can do about it. We dealt with it until one day I had enough. The internet access in the lab had slowed to a crawl. Our department head cited that it took him 6 minutes to load his slides from inside of the Elliot 216 lab (which he must have hosted outside of his faculty account on mansfield.edu). His students were unable to complete their lab that day because the internet access was unusable.

After this, I decided to write an e-mail to Alan Johnson, Associate Director of Campus Technologies. Alan has helped me in the past when I have had issues with the Mansfield network. This time I decided to not only ask for a fix on the internet speeds, but also for access to mansfield.edu. Alan didn’t get back to me by the next business day, so I sent a reminder e-mail to him. He responded stating he was out of the office and that he would look into it when his vacation was over. Ok, no problem. I understand that entirely and it is right that he should not have to work during vacation time. Less than five minutes later, I received a follow-up e-mail from Connie Beckman, Director of Campus Technologies. This is where things became interesting. Below is the text of her e-mail (unedited):

I don’t know what he is trying to do, but it is likely not the intent that he should do it in that lab.  In addition, he is not Dan McKee – the Chair.  Therefore, he should not be asking you to address anything.  Don’t rush to do anything or feel you need to respond.

I know he is a dorm student who thinks he knows a great deal – except the rules.

Connie Beckman, whom I had never had any contact with before, nor did I even know who she was, had degraded me. I was outraged, and rightfully so. First off, I am not a dorm student. I do not know what she is implying, but I was certainly only asking for rightful and expedient internet access. Connie and I had many further exchanges, as I expressed my disappointment that she could feel such a way about someone who she had never even met or spoken to before. I will include the full text of all e-mail correspondance with Connie Beckman, including my initial inquiry to Alan Johnson, at the bottom of this post.

Connie Beckman should be exhibiting professional behavior towards both the professional staff and towards the students. She is the head of Campus Technologies and she should act as such. Her attitude towards me, other students, and towards the Computer Science department staff is unacceptable. She attempts to force people to adhere to bureaucracy (which is why she mentioned that I am not Dr. Dan McKee, the chair of the Computer Science department) and is generally disrespectful. Unfortunately, little will be done to reprimand her, as she is retiring in a month.

I wrote a letter to the editor to the Flashlight, our campus newspaper. I was told that my story would be published at the next release, but they never published it. I attempted to bring the matter to the president of the university but never received a reply back. Ashley, my fiance, spoke with the president and she claimed that corrective action would be taken against Connie Beckman, but I have not heard of any repercussions for this outburst. I also spoke personally with the provost of the university and he said that he would follow up on the incident, but gave no specifics. Overall the response from the university has been lackluster at best.

I have little to no hope of attaining mansfield.edu access in the Elliot 216 lab and I have very little hope that anything will change internally. The university has failed to hear my complaint and has failed to act on an unjust response from a professional. I have personally made my fair share of mistakes and I have been held accountable for them. All I ask is that Connie Beckman be held accountable for her actions.

The following is all correspondence between Connie Beckman, Alan Johnson, and me:

Connie Beckman E-mails (PDF)

1

New Photos on CleteBlackwellPhoto.com

November 27, 2010

I have finally dusted off my camera and taken some new pictures. I found this kitten at Ashley’s father’s house and I decided to take some pictures of it. See the album by clicking on the picture below (redirect to cleteblackwellphoto.com).

0

Happy Thanksgiving!

November 25, 2010

Happy Thanksgiving to all Americans!

Herei s a picture of a kitten that I took today:

0

IBM 600E Laptop and Gentoo Linux

November 19, 2010

I have recently finished installing Gentoo Linux on an old IBM 600E laptop. At one time I would have called this laptop a powerhorse, but that time is not today nor five years ago even. The laptop contains a Mobile Pentium II processor clocked at a racing 364MHz. It also contains a whopping total of 128MB of RAM. It has a single USB 1.x port and a shoddy DVD drive that doesn’t like DVDs at all. The only NIC it contains is a modem. As such, a few special considerations should be made when installing Linux on this machine. None of these are out of the ordinary for old laptops, and most are general guidelines for installation on old machines.

The most special of the issues with this laptop is its DVD drive. First off, it cannot read DVDs — at all. It says it can, but they will not be recognized. At first, we thought that the laptop could only properly read pressed CDs (as opposed to burned CDs). I have now come to find that this assumption isn’t entirely true. While it may help that a CD is pressed, it is not a guarantee. The problem seems to stem from some driver issues within Linux: The CD will load but will not be able to find itself once the kernel initializes. There are two ways around this:

1) Find another CD that works.

2) “dd if=<ISO image> of=<flash drive> bs=1M” – Create a flash drive with the same image you created the CD with. If the CD has USB flash drive support, which it should, then it can mount your flash drive as the root partition.

The next major problem is the lack of a NIC. This Monoprice USB to Ethernet adapter will do the trick. Use the “asix” and “usbnet” kernel modules for support. This NIC may not work on the Gentoo LiveCD for reasons unknown to me. Try KNOPPIX instead.

Once installed, be sure to set CFLAGS properly. I am using -O2, but -Os may suit you well due to the size of the hard drive. Gentoo warns against this, but the worst that could happen is that you have to recompile some packages with -O2 instead of -Os.

MAKEOPTS=”-j1″ is vital. With limited RAM, you don’t want to compile more than one file at a time.

Other than that, it’s a piece of cake! I have a new server running znc, a great IRC bouncer, and a Tor relay. In a while, I plan to make it a NAS server after getting a USB 2.0 PCMCIA card.

1

Stopping a Thread in Java – Safely and Easily

November 5, 2010

Stopping a thread in Java has proven to be a pain for me. You can’t call a the stop() method anymore even if your thread doesn’t have anything that will fail by abruptly stopping a thread. I found this awesome code that shuts down a thread and I thought I would share it. Simple and it works.

Link

2

CCSC East Conference

October 16, 2010

This Friday and Saturday, I had the pleasure of taking a trip to Juniata College in Huntingdon, Pennsylvania to attend the CCSC East conference and programming competition. Six programmers and one advisor attended as an official trip of the Mansfield University Computer Science Club, of which I am the current president.

The conference itself was short and honestly a little lacking in good content. We listened to a talk from a Microsoft representative on the company’s new Azure cloud hosting service. Without actually trying either of them out, I would have to say that Azure needs some work in order to match what Amazon offers with their EC2 service. Most notably, Amazon’s EC2 allows the customer more configurability in terms of how their services are set up and provisioned. Azure is an easy-to-use way to upload services. All you must do is create a .NET or FastCGI-based project, compile, and upload. It provides for easy uploading of services and short set-up time. Microsoft will take care of the rest. On the other hand, Amazon’s offering requires the customer to create an entire virtual machine, complete with the operating system and the service software installed (although this may have changed since I last evaluated their services). This allows the customer to micro-manage their partitions and get the most out of their usage. Microsoft’s offering does not allow for this, but it is possible for Microsoft to add this functionality in the future as Azure is a very new service. Azure seems to be a good service, but it could use some improvements as well. I will be trying it out in production in the next few weeks and I may have a hands-on review of the service to give.

After Microsoft’s talk on Azure, we heard a keynote from a government employee of Fairfax County in Virginia. Later on in the day, we decided to relax, purchase the game of Risk, and wage war against each other.

The next day was the programming competition, which was the best part of the weekend. The competition was set up in a manner where there were seven medium-sized logic-based problems. These problems ranged in difficulty and most of them were fairly difficult to program in a very short amount of time. If in the future I finish one of the problems that we failed to complete as a team, I will post both the problem and the solution here. The problems we were given were frustrating above all. As usual, one small error would cause the program to fail miserably. My team was frustrated that we had only one computer to use between the three of us. We placed in the 33rd percentile with two out of seven problems complete. There were roughly 8 teams that completed two problems, 3 that completed three problems, and one team that completed 4 problems. Our team was extremely frustrated because we had programmed the majority of five out of the seven programs and we had them extremely close to functioning properly. Although we were frustrated and dissatisfied with our results, I personally had an enjoyable time competing and enjoyed the problem-solving aspect.

The trip was mostly a success and was enjoyable. As most trips do, we had a number of inside jokes that we are still laughing about. In the Spring, we hope to attend PACISE, a local competition, and possibly take a trip to Redmond, Washington to explore Microsoft’s facilities as part of a game programming competition.

I have had four cups of coffee and four Mountain Dews to keep me awake today. I am very sleep deprived and I am looking forward to some rest. I will be following up about Azure and the programming problems in the future.

0

Drudge Report Headlines on Arduino

September 16, 2010

My latest Arduino project is a little bit more complicated than my last. This new project will check the main headline on Drudge Report and it will then display it on the LCD screen of the Arduino. After that, it checks to see if the headline has changed since the last time it checked. If it is, it plays a song on a speaker on the Arduino and sends an email (or text message) notifying me of the change.

Here is how it accomplishes this:

1) Arduino + Ethernet shield to connect to a PHP script (here)

2) Script uses regex to pull only the headline

3) Arduino prints headline on LCD screen

4) Arduino plays song if new

5) Arduino connects to specified SMTP server, plain text authenticates, and sends an email

My code is posted here on Git.

I have a YouTube video uploaded so you can see the project in action:

See it in HD at the original YouTube link.

And here is a preview of the text message that the Arduino sent to me:

text message

2